|
2 | 2 | """
|
3 | 3 | Test TimestampedGeoJson
|
4 | 4 | -----------------------
|
5 |
| -
|
6 | 5 | """
|
| 6 | +from jinja2 import Template |
| 7 | +import numpy as np |
7 | 8 |
|
8 | 9 | import folium
|
9 | 10 | from folium import plugins
|
10 |
| -import numpy as np |
11 | 11 |
|
12 | 12 | def test_timestamped_geo_json():
|
13 | 13 | coordinates = [[[[lon-8*np.sin(theta), -47+6*np.cos(theta)] for
|
@@ -81,7 +81,50 @@ def test_timestamped_geo_json():
|
81 | 81 | ],
|
82 | 82 | }
|
83 | 83 |
|
84 |
| - mape = folium.Map([47, 3], zoom_start=1) |
85 |
| - mape.add_children(plugins.TimestampedGeoJson(data)) |
86 |
| - mape._repr_html_() |
| 84 | + m = folium.Map([47, 3], zoom_start=1) |
| 85 | + tgj = plugins.TimestampedGeoJson(data) |
| 86 | + m.add_children(tgj) |
| 87 | + m._repr_html_() |
| 88 | + |
| 89 | + out = m._parent.render() |
| 90 | + |
| 91 | + # Verify the imports. |
| 92 | + assert ('<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/' |
| 93 | + 'jquery.min.js"></script>' |
| 94 | + ) in out |
| 95 | + assert ('<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/' |
| 96 | + '1.10.2/jquery-ui.min.js"></script>' |
| 97 | + ) in out |
| 98 | + assert ('<script src="https://raw.githubusercontent.com/nezasa/' |
| 99 | + 'iso8601-js-period/master/iso8601.min.js"></script>' |
| 100 | + ) in out |
| 101 | + assert ('<script src="https://raw.githubusercontent.com/socib/Leaflet.' |
| 102 | + 'TimeDimension/master/dist/leaflet.timedimension.min.js">' |
| 103 | + '</script>' |
| 104 | + ) in out |
| 105 | + assert ('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/' |
| 106 | + 'libs/highlight.js/8.4/styles/default.min.css" />' |
| 107 | + ) in out |
| 108 | + assert ('<link rel="stylesheet" href="http://apps.socib.es/Leaflet.' |
| 109 | + 'TimeDimension/dist/leaflet.timedimension.control.min.css" />' |
| 110 | + ) in out |
| 111 | + |
| 112 | + # Verify that the script is okay. |
| 113 | + tmpl = Template(""" |
| 114 | + {{this._parent.get_name()}}.timeDimension = L.timeDimension(); |
| 115 | + {{this._parent.get_name()}}.timeDimensionControl = L.control.timeDimension({ |
| 116 | + position: 'bottomleft', |
| 117 | + autoPlay: {{'true' if this.auto_play else 'false'}}, |
| 118 | + playerOptions: { |
| 119 | + transitionTime: {{this.transition_time}}, |
| 120 | + loop: {{'true' if this.loop else 'false'}}} |
| 121 | + }); |
| 122 | + {{this._parent.get_name()}}.addControl({{this._parent.get_name()}}.timeDimensionControl); |
| 123 | +
|
| 124 | + var {{this.get_name()}} = L.timeDimension.layer.geoJson( |
| 125 | + L.geoJson({{this.data}}), |
| 126 | + {updateTimeDimension: true,addlastPoint: true} |
| 127 | + ).addTo({{this._parent.get_name()}}); |
| 128 | + """) |
87 | 129 |
|
| 130 | + assert ''.join(tmpl.render(this=tgj).split()) in ''.join(out.split()) |
0 commit comments