Пример #1
0
def zoning_dict2map(zones,translated_geoms):
    threshold = .00000005  #choose this by trial and error, or inspecting VWSimplifier.ordered_thresholds of an example polygon
    mymap = Map()
    n = len(zoning.keys())
    n = 3 if n<3 else n
    colors = get_map('Dark2','Qualitative',n).hex_colors.__iter__()
    print("building datasets")
    for appname,datasets in zoning.items():
       appcolor = colors.next()
       thisapp = App(sanitize_id(appname),title=appname)
       mymap.apps.append(thisapp)
       num_datasets = len(datasets)+3 #don't go to gradient.end
       datacoloriter = gradient(num_datasets,
                                 start=hex2rgb(appcolor))
       for dataname,zone_fields in sorted(datasets.items()):
          color = datacoloriter.next()
          dset = DataSet(sanitize_id(dataname),title=dataname,
                   latlon=False,key_color=color,precision=9)
          thisapp.datasets.append(dset)
          for i,z in enumerate(zones):
            for target in zone_fields:
              if target in z:
               geom = translated_geoms[i]
               if geom.geom_name == 'POLYGON':
                 dset.add_polygon([geom.tuple],
                           threshold=threshold,fillColor=color,
                           strokeColor=color)
               elif geom.geom_name == 'MULTIPOLYGON':
                 dset.add_polygon(geom.tuple,
                           threshold=threshold,fillColor=color,
                           strokeColor=color)
    print("building map")
    mymap.build_page(zoom=13)
Пример #2
0
#
# An example of building data from an app
#
#
###

WhereWeMeet_data = {
    'id': 'WhereWeMeet',  #used for tag names
    'title': 'Average Drive Time',  #used for display
}

app_id = 'wherewemeet'
contour_app = App(app_id, title="Composite Drive Time")

for i, d in enumerate(App3.data()):
    this = DataSet('%s%s' % (app_id, i), title=d['keyValue'])
    this.add_polygon(d['polygon'],
                     fillColor=d['fillColor'],
                     strokeColor=d['strokeColor'],
                     fillOpacity=d['fillOpacity'])
    this.key_color = d['fillColor']
    print d['fillColor']
    contour_app.datasets.append(this)

if __name__ == '__main__':
    Austin = [30.320000, -97.770000]
    mymap = map_from_csvs(data_dir='./example_data')
    mymap.build_page(center=Austin, zoom=5, outfile='from_csv_example.html')
    mymap.apps.append(contour_app)
    mymap.build_page(center=Austin, zoom=9, outfile='two_apps.html')