def makeareamap(area, locations): b = Bounds() mapbase="https://maps.googleapis.com/maps/api/staticmap?key=" + parms.staticmapsapikey + "&" mapparts = [] clubinfo = [] marker = 'A' for (clubname, latitude, longitude) in locations: b.extend(latitude, longitude) mapparts.append('markers=label:%s%%7C%s,%s' % (marker, latitude, longitude)) marker = chr(ord(marker)+1) # mapparts.append("center=%s" % (b.centercoords())) mapparts.append("size=640x640&scale=2") # As large as possible, at least for now return '%s%s' % (mapbase, '&'.join(mapparts))
def computeDistances(clubs): """ For a group of clubs, compute the distance of each club from their center and from each other. """ # Now, compute bounds and center bounds = Bounds() for c in list(clubs.values()): bounds.extend(c.latitude, c.longitude) bounds.clat = (bounds.north + bounds.south) / 2.0 bounds.clong = (bounds.east + bounds.west) / 2.0 for c in clubs: clubs[c].centraldistance = distance_on_unit_sphere(clubs[c].latitude, clubs[c].longitude, bounds.clat, bounds.clong) for d in clubs: if c > d: dist = distance_on_unit_sphere(clubs[c].latitude, clubs[c].longitude, clubs[d].latitude, clubs[d].longitude) clubs[c].distances.append((d, dist)) clubs[d].distances.append((c, dist))
outfile.write(div.html()) outfile.write('\n') outfile.write("""[/et_pb_tabs] """) # Create map pages if mapdir was specified. if parms.mapdir: for d in sorted(Division.divisions): if d.lower() != 'new': div = Division.divisions[d] for a in sorted(div.areas): with open(os.path.join(parms.mapdir, '%s.html' % a), 'w') as mapfile: b = Bounds() mapbase = "https://maps.googleapis.com/maps/api/staticmap?" mapparts = [] clubinfo = [] marker = 'A' for c in sorted(div.areas[a].clubs, key=lambda x: x.clubnumber.zfill(8)): b.extend(float(c.latitude), float(c.longitude)) mapparts.append('markers=label:%s%%7C%s,%s' % (marker, c.latitude, c.longitude)) clubinfo.append('<tr><td class="marker">%s</td>' % marker) clubinfo.append('<td class="clubnum">%s</td>' % c.clubnumber)