def generate_geojson(): yield '{"cloneUrl": ' + json.dumps( QueryService.get_clone_url(dataset.get('id'), query)) + ',' if table_type is 'ft': f_len = len(features) yield '"data": [{ "type": "FeatureCollection", "features": [' for idx, feature in enumerate(features): geo_feature = { "type": "Feature", "properties": {}, "geometry": {} } for prop in feature: if prop == 'the_geom': geo_feature['geometry'] = feature['the_geom'] else: geo_feature['properties'][prop] = feature[prop] if idx != f_len - 1: yield json.dumps(geo_feature) + ',' else: yield json.dumps(geo_feature) yield ']}]}' elif table_type is 'raster': yield '"data": [' yield json.dumps(response) yield ']}'
def generate_json(): yield '{"cloneUrl": ' + json.dumps( QueryService.get_clone_url(dataset.get('id'), query)) + ',' if table_type is 'ft': f_len = len(features) yield '"data": [' for idx, feature in enumerate(features): if idx != f_len - 1: yield json.dumps(feature) + ', ' else: yield json.dumps(feature) yield ']}' elif table_type is 'raster': yield '"data": [' yield json.dumps(response) yield ']}'