Trajectory section fails if a line string only has one coordinate
Description
If you publish a line string with only one coordinate in a trajectory section, then there will be a Javascript error and no map widget is rendered in its tab.
Expected behavior
The map should be displayed. Also, a Marv warning/ error would be nice.
How to reproduce
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
import marv
from marv.types import Section, Widget
from marv_detail import make_map_dict
from marv.types import GeoJson
@marv.node(GeoJson)
def foobar():
yield marv.set_header()
feature = {
"geometry": {
"line_string": {
"coordinates": [
[
12.1,
52.1
],
# comment this out to make the Trajectory tab work again
# [
# 12.2,
# 52.2
# ]
],
}
},
"properties": {
"color": [
0.5600000023841858,
0.8100000023841858,
0.15000000596046448,
0.7799999713897705
],
"colors": [],
"coordinatesystem": "WGS84",
"fillcolor": [],
"fillcolors": [],
"markervertices": [],
"width": 4.0
},
}
yield marv.push({'feature_collection': {'features': [feature]}})
@marv.node(Section)
@marv.input('title', default='Trajectory')
@marv.input('foobar', default=foobar)
@marv.input('minzoom', default=-30)
@marv.input('maxzoom', default=40)
@marv.input('tile_server_protocol', default='')
def autonomos_trajectory_section(foobar, title, minzoom, maxzoom, tile_server_protocol):
foobar = yield marv.pull(foobar)
if foobar is None:
raise marv.Abort()
layers = [
{
'title': 'Background',
'tiles': [
{
'title': 'Roadmap',
'url': '%s//[abc].osm.ternaris.com/styles/osm-bright/rendered/{z}/{x}/{y}.png' % tile_server_protocol,
'attribution': '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
'retina': 3,
'zoom': {'min': 0, 'max': 20}
},
]
}
]
if foobar:
layers.append({
'title': 'Foobar trajectory',
'color': (0, 118, 207, 255),
'geojson': foobar
}le': title,
'widgets': [{'map_partial': 'marv-partial:{}'.format(jsonfile.relpath)}]
})
)
dct = make_map_dict({
'layers': layers,
'zoom': {'min': minzoom, 'max': maxzoom},
})
jsonfile = yield marv.make_file('data.json')
with open(jsonfile.path, 'w') as f:
json.dump(dct, f, sort_keys=True)
yield marv.push({
'title': title,
'widgets': [{'map_partial': 'marv-partial:{}'.format(jsonfile.relpath)}]
})