def get(self): trackings = models.Tracking.all() results = [] for tracking in trackings: if tracking.active: if tracking.dataType == "kmls": kmls = tracking.kmls for link in kmls: res = extract_pos(link) if res: results.append(res) if tracking.dataType == "yellowbrick": results = extract_yb(tracking.url) template = jinja_environment.get_template('templates/all.html') verticalAdjust = 0 #prepare for svg ''' if len(results) > 0: latmin = results[0]["latitude"] latmax = results[0]["latitude"] longmin = results[0]["longitude"] longmax = results[0]["longitude"] for result in results: latmin = min(latmin, result["latitude"]) latmax = max(latmax, result["latitude"]) longmin = min(longmin, result["longitude"]) longmax = max(longmax, result["longitude"]) latmin = latmin - (latmax - latmin) / 10 latmax = latmax + (latmax - latmin) / 10 deltalat = latmax - latmin longmin = longmin - (longmax - longmin) / 10 longmax = longmax + (longmax - longmin) / 10 deltalong = longmax - longmin latmiddle = (latmax + latmin) / 2 longmiddle = (longmax + longmin) / 2 verticalAdjust = geo.distance(geo.xyz(latmiddle, longmin), geo.xyz(latmiddle, longmax)) / geo.distance(geo.xyz(latmin, longmiddle), geo.xyz(latmax, longmiddle)) * 800 for result in results: result["posX"] = (latmax - result["latitude"]) / deltalat * 800 result["posY"] = (result["longitude"] - longmin) / deltalong * verticalAdjust ''' self.response.out.write(template.render({ 'extracts' : sorted(results, key=lambda extract: extract["dtf"]), 'verticalAdjust' : verticalAdjust }))
def test_extract_yb(): teams = extract_yb("http://yb.tl/Flash/t2p2013") for team in teams: print team