views: use FeatureCollection for geojson format (#51163)
This commit is contained in:
parent
7b6a854c58
commit
cac1bc1534
|
@ -284,14 +284,14 @@ class VisualizationGeoJSONView(generics.GenericAPIView):
|
|||
instance = self.get_object()
|
||||
visualization = Visualization.from_json(instance.parameters)
|
||||
visualization.measure = visualization.cube.measures['geolocation']
|
||||
geojson = []
|
||||
geojson = {'type': 'FeatureCollection', 'features': []}
|
||||
|
||||
for row in visualization.data():
|
||||
properties = {}
|
||||
for cell in row.dimensions:
|
||||
properties[cell.dimension.label] = '%s' % (cell,)
|
||||
points = row.measures[0].value or []
|
||||
geojson.append({
|
||||
geojson['features'].append({
|
||||
'type': 'Feature',
|
||||
'geometry': {
|
||||
'type': 'MultiPoint',
|
||||
|
|
|
@ -260,8 +260,9 @@ def test_geoloc(schema1, app, admin):
|
|||
'drilldown_x': 'date__year',
|
||||
})
|
||||
response = app.get('/visualization/%d/geojson/' % visu.pk)
|
||||
assert response.json == [
|
||||
{
|
||||
assert response.json == {
|
||||
'type': 'FeatureCollection',
|
||||
'features': [{
|
||||
u'geometry': {
|
||||
u'coordinates': [
|
||||
[1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0],
|
||||
|
@ -320,7 +321,7 @@ def test_geoloc(schema1, app, admin):
|
|||
},
|
||||
u'type': u'Feature'
|
||||
}
|
||||
]
|
||||
]}
|
||||
|
||||
|
||||
def test_filter_type_mismatch(schema1, app, admin):
|
||||
|
|
|
@ -278,7 +278,8 @@ def test_geojson_view(schema1, app, admin, visualization, settings):
|
|||
login(app, admin)
|
||||
resp = app.get('/visualization/%s/geojson/' % visualization.id)
|
||||
assert resp.content_type == 'application/json'
|
||||
assert len(resp.json) == 8
|
||||
assert resp.json['type'] == 'FeatureCollection'
|
||||
assert len(resp.json['features']) == 8
|
||||
|
||||
|
||||
@mock.patch('bijoe.views.get_idps', return_value=[{'METADATA': '...'}])
|
||||
|
|
Loading…
Reference in New Issue