Projet

Général

Profil

0001-visualization-handle-empty-geolocation-measure-39180.patch

Benjamin Dauvergne, 22 janvier 2020 19:53

Télécharger (4,13 ko)

Voir les différences:

Subject: [PATCH] visualization: handle empty geolocation measure (#39180)

 bijoe/visualization/views.py |  3 +-
 tests/test_schema1.py        | 56 +++++++++++++++++++++++++++---------
 2 files changed, 45 insertions(+), 14 deletions(-)
bijoe/visualization/views.py
268 268
            properties = {}
269 269
            for cell in row.dimensions:
270 270
                properties[cell.dimension.label] = '%s' % (cell,)
271
            points = row.measures[0].value or []
271 272
            geojson.append({
272 273
                'type': 'Feature',
273 274
                'geometry': {
274 275
                    'type': 'MultiPoint',
275
                    'coordinates': [[coord for coord in point] for point in row.measures[0].value],
276
                    'coordinates': [[coord for coord in point] for point in points],
276 277
                },
277 278
                'properties': properties,
278 279
            })
tests/test_schema1.py
235 235
            'cube': 'facts1',
236 236
            'representation': 'graphical',
237 237
            'measure': 'percent',
238
            'drilldown_y': 'leftcategory',
238
            'drilldown_y': 'outercategory',
239 239
            'drilldown_x': 'date__year',
240 240
        })
241 241
    response = app.get('/visualization/%d/geojson/' % visu.pk)
242 242
    assert response.json == [
243 243
        {
244
            u'geometry':
245
            {
244
            u'geometry': {
246 245
                u'coordinates': [
247
                    [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0],
248
                    [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0],
249
                    [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0],
250
                    [1.0, 1.0]
246
                    [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0],
247
                    [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0],
248
                    [1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0]
251 249
                ],
252 250
                u'type': u'MultiPoint'
253 251
            },
254 252
            u'properties': {
255
                u'Left Category': u'cat\xe91',
253
                u'Outer Category': u'cat\xe91',
256 254
                u'ann\xe9e (Date)': u'2017'
257 255
            },
258
            u'type': u'Feature',
256
            u'type': u'Feature'
259 257
        },
260 258
        {
261 259
            u'geometry': {
262
                u'coordinates': [
263
                    [1.0, 1.0]
264
                ],
260
                u'coordinates': [[1.0, 1.0]],
265 261
                u'type': u'MultiPoint'
266 262
            },
267 263
            u'properties': {
268
                u'Left Category': u'Aucun(e)',
264
                u'Outer Category': u'Aucun(e)',
269 265
                u'ann\xe9e (Date)': u'2017'
270 266
            },
271 267
            u'type': u'Feature'
268
        },
269
        {
270
            u'geometry': {
271
                u'coordinates': [],
272
                u'type': u'MultiPoint'
273
            },
274
            u'properties': {
275
                u'Outer Category': u'cat\xe92',
276
                u'ann\xe9e (Date)': u'Aucun(e)'
277
            },
278
            u'type': u'Feature'
279
        },
280
        {
281
            u'geometry': {
282
                u'coordinates': [],
283
                u'type': u'MultiPoint'
284
            },
285
            u'properties': {
286
                u'Outer Category': u'cat\xe93',
287
                u'ann\xe9e (Date)': u'Aucun(e)'
288
            },
289
            u'type': u'Feature'
290
        },
291
        {
292
            u'geometry': {
293
                u'coordinates': [],
294
                u'type': u'MultiPoint'
295
            },
296
            u'properties': {
297
                u'Outer Category': u'cat\xe91',
298
                u'ann\xe9e (Date)': u'Aucun(e)'
299
            },
300
            u'type': u'Feature'
272 301
        }
273 302
    ]
303

  
274
-