def data(): """Returns all data as a GoeJSON list. """ routes = Route.all(app.db) features = [] for route in routes: geojson = json.loads(db.session.scalar(func.ST_AsGeoJSON(route.geom))) features.append( {'geometry': geojson, 'properties': {'guid': route.guid, 'user_id': route.user_id} } ) dd = {"type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, 'features': features, } return jsonify(dd)
def routes_geojson(): """ :return: Returns a dict containing the bundaries of the table and a list of guids of the routes. { "bounds": [ 10.26912689208984, 63.38337070759972, 10.45074462890625, 63.4445238395574 ], "guids": [ "75ab78e8-63a5-459a-b580-61f67c45db94", "f82d1581-2649-4fbb-8716-270da989538c", "01407688-2237-4f87-ba66-697097517cbc", "d25184ca-a76a-4e52-b474-aadc80d26626" ] } """ return jsonify( { 'bounds': Route.get_bounds(app.db), 'guids': [r.guid for r in Route.all(app.db)] })