Exemple #1
0
 def doFileConversion(self, name):
     ''' Test conversion results for named file.
     '''
     file = FakeUpload(join(dirname(__file__), name))
     geojson = transformers.transform_shapefile(file)
 
     #
     # Is it GeoJSON?
     #
     self.assertEqual(geojson['type'], 'FeatureCollection')
     self.assertEqual(len(geojson['features']), 6)
     self.assertEqual(set([f['geometry']['type'] for f in geojson['features']]), set(['LineString']))
 
     #
     # Does it cover the expected geographic area?
     #
     lons, lats = [], []
 
     for f in geojson['features']:
         lons.extend([y for (x, y) in f['geometry']['coordinates']])
         lats.extend([x for (x, y) in f['geometry']['coordinates']])
 
     self.assertTrue(37.80071 < min(lons) and max(lons) < 37.80436)
     self.assertTrue(-122.25925 < min(lats) and max(lats) < -122.25671)
Exemple #2
0
def map():
    # import pdb; pdb.set_trace()
    # Show an uplaod form or process an uploaded shapefile
    data = transformers.transform_shapefile(request.files["file"])
    return render_template("map.html", data=data)