visualization: handle empty geolocation measure (#39180)
This commit is contained in:
parent
65f023086a
commit
3b5dd98ad6
|
@ -268,11 +268,12 @@ class VisualizationGeoJSONView(generics.GenericAPIView):
|
|||
properties = {}
|
||||
for cell in row.dimensions:
|
||||
properties[cell.dimension.label] = '%s' % (cell,)
|
||||
points = row.measures[0].value or []
|
||||
geojson.append({
|
||||
'type': 'Feature',
|
||||
'geometry': {
|
||||
'type': 'MultiPoint',
|
||||
'coordinates': [[coord for coord in point] for point in row.measures[0].value],
|
||||
'coordinates': [[coord for coord in point] for point in points],
|
||||
},
|
||||
'properties': properties,
|
||||
})
|
||||
|
|
|
@ -235,39 +235,69 @@ def test_geoloc(schema1, app, admin):
|
|||
'cube': 'facts1',
|
||||
'representation': 'graphical',
|
||||
'measure': 'percent',
|
||||
'drilldown_y': 'leftcategory',
|
||||
'drilldown_y': 'outercategory',
|
||||
'drilldown_x': 'date__year',
|
||||
})
|
||||
response = app.get('/visualization/%d/geojson/' % visu.pk)
|
||||
assert response.json == [
|
||||
{
|
||||
u'geometry':
|
||||
{
|
||||
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], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0],
|
||||
[1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0],
|
||||
[1.0, 1.0]
|
||||
[1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0],
|
||||
[1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0],
|
||||
[1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0]
|
||||
],
|
||||
u'type': u'MultiPoint'
|
||||
},
|
||||
u'properties': {
|
||||
u'Left Category': u'cat\xe91',
|
||||
u'Outer Category': u'cat\xe91',
|
||||
u'ann\xe9e (Date)': u'2017'
|
||||
},
|
||||
u'type': u'Feature',
|
||||
u'type': u'Feature'
|
||||
},
|
||||
{
|
||||
u'geometry': {
|
||||
u'coordinates': [
|
||||
[1.0, 1.0]
|
||||
],
|
||||
u'coordinates': [[1.0, 1.0]],
|
||||
u'type': u'MultiPoint'
|
||||
},
|
||||
u'properties': {
|
||||
u'Left Category': u'Aucun(e)',
|
||||
u'Outer Category': u'Aucun(e)',
|
||||
u'ann\xe9e (Date)': u'2017'
|
||||
},
|
||||
u'type': u'Feature'
|
||||
},
|
||||
{
|
||||
u'geometry': {
|
||||
u'coordinates': [],
|
||||
u'type': u'MultiPoint'
|
||||
},
|
||||
u'properties': {
|
||||
u'Outer Category': u'cat\xe92',
|
||||
u'ann\xe9e (Date)': u'Aucun(e)'
|
||||
},
|
||||
u'type': u'Feature'
|
||||
},
|
||||
{
|
||||
u'geometry': {
|
||||
u'coordinates': [],
|
||||
u'type': u'MultiPoint'
|
||||
},
|
||||
u'properties': {
|
||||
u'Outer Category': u'cat\xe93',
|
||||
u'ann\xe9e (Date)': u'Aucun(e)'
|
||||
},
|
||||
u'type': u'Feature'
|
||||
},
|
||||
{
|
||||
u'geometry': {
|
||||
u'coordinates': [],
|
||||
u'type': u'MultiPoint'
|
||||
},
|
||||
u'properties': {
|
||||
u'Outer Category': u'cat\xe91',
|
||||
u'ann\xe9e (Date)': u'Aucun(e)'
|
||||
},
|
||||
u'type': u'Feature'
|
||||
}
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in New Issue