Skip to content

Commit 94ec4de

Browse files
committed
#1 #3 Work in progress:
-Update documentation -Add first test for GPX.folium_plot method (not working) [ci skip]
1 parent dff6cb2 commit 94ec4de

File tree

5 files changed

+142
-9
lines changed

5 files changed

+142
-9
lines changed

doc/ezgpx.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Subpackages
1111
ezgpx.gpx_elements
1212
ezgpx.gpx_parser
1313
ezgpx.gpx_writer
14+
ezgpx.kml_parser
15+
ezgpx.kml_writer
16+
ezgpx.parser
17+
ezgpx.writer
1418
ezgpx.utils
1519

1620
Module contents

doc/tutorials/parsing.rst

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Parsing
22
-------
33

4+
GPX Files
5+
^^^^^^^^^
6+
47
In order to parse a GPX file, simply create a new :py:class:`~ezgpx.gpx.GPX` object with the path to the file.
58

69
.. note::
@@ -12,4 +15,21 @@ In order to parse a GPX file, simply create a new :py:class:`~ezgpx.gpx.GPX` obj
1215
from ezGPX import GPX
1316

1417
# Parse GPX file
15-
gpx = GPX("file.gpx")
18+
gpx = GPX("file.gpx")
19+
20+
21+
KML Files
22+
^^^^^^^^^
23+
24+
In order to parse a KML file, simply create a new :py:class:`~ezgpx.gpx.GPX` object with the path to the file.
25+
26+
.. note::
27+
28+
This method is mainly designed to perform a simple conversion from KML to GPX. To that extent, only GPS data from the KML files will be processed.
29+
30+
::
31+
32+
from ezGPX import GPX
33+
34+
# Parse KML file
35+
gpx = GPX("file.kml")

ezgpx/gpx/gpx.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ def folium_plot(
11451145
# Plot track points
11461146
gpx_df = self.to_dataframe()
11471147
gpx_df["coordinates"] = list(
1148-
zip(gpx_df.latitude, gpx_df.longitude))
1148+
zip(gpx_df.lat, gpx_df.lon))
11491149
folium.PolyLine(gpx_df["coordinates"],
11501150
tooltip=self.name(), color=color).add_to(m)
11511151

@@ -1183,6 +1183,8 @@ def folium_plot(
11831183
).add_to(m)
11841184

11851185
# Save map
1186+
if file_path is None:
1187+
file_path = "unnamed.html"
11861188
m.save(file_path)
11871189

11881190
# Open map in web browser

tests/test_GPX.py

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,7 @@ def _test_matplotlib_plot_4(self):
304304
return np.array_equal(test_img, ref_img)
305305

306306
@pytest.mark.skip(reason="not ready")
307-
def test_matplotlib_plot(self, remove_tmp: bool = True):
308-
"""
309-
Test matplotlib_plot method.
310-
311-
Args:
312-
remove_tmp (bool, optional): Remove temporary folder. Defaults to True.
313-
"""
307+
def test_matplotlib_plot(self):
314308
# Parse GPX file
315309
self.gpx = GPX(os.path.join(FILES_DIRECTORY, "strava_run_1.gpx"))
316310
# Tests
@@ -323,6 +317,36 @@ def test_matplotlib_plot(self, remove_tmp: bool = True):
323317
# self._test_matplotlib_plot_3()
324318
# self._test_matplotlib_plot_4()
325319

320+
def _test_folium_plot_1(self):
321+
# Plot
322+
self.gpx.folium_plot(tiles="openStreetMap",
323+
color="#110000",
324+
start_stop_colors=None,
325+
way_points_color=None,
326+
minimap=False,
327+
coord_popup=False,
328+
title=None,
329+
zoom=12,
330+
file_path="tmp/folium_strava_run_1.html",
331+
open=False)
332+
# Compare files
333+
return filecmp.cmp("tmp/folium_strava_run_1.html", os.path.join(REFERENCE_FILES_DIRECTORY, "folium_strava_run_1.html"), False)
334+
335+
@pytest.mark.skip(reason="not ready")
336+
def test_folium_plot(self):
337+
self.test_init() # For developping purpose only (using: pytest test_GPX.py::TestGPX::test_folium_plot)
338+
# Parse GPX file
339+
self.gpx = GPX(os.path.join(FILES_DIRECTORY, "strava_run_1.gpx"))
340+
# Tests
341+
assert(self._test_folium_plot_1())
342+
# assert(self._test_folium_plot_2())
343+
# assert(self._test_folium_plot_3())
344+
# assert(self._test_folium_plot_4())
345+
# self._test_folium_plot_1()
346+
# self._test_folium_plot_2()à
347+
# self._test_folium_plot_3()
348+
# self._test_folium_plot_4()
349+
326350
#==== Destroy ============================================================#
327351

328352
def test_destroy(self, remove_tmp: bool = True):

tests/test_files/reference_files/folium_strava_run_1.html

Lines changed: 83 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)