diff --git a/.gitignore b/.gitignore index 399b4c0..08f548e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ tests/dev_tests/* *_test.gpx +*.old +*.private +*.unused # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/ezgpx/utils/distance.py b/ezgpx/utils/distance.py index fe787bf..cefe1a7 100644 --- a/ezgpx/utils/distance.py +++ b/ezgpx/utils/distance.py @@ -12,8 +12,8 @@ def haversine_distance(point_1, point_2) -> float: https://en.wikipedia.org/wiki/Haversine_formula Args: - point_1 (TrackPoint): First point. - point_2 (TrackPoint): Second point. + point_1 (WayPoint): First point. + point_2 (WayPoint): Second point. Returns: float: Haversine distance between the points. @@ -34,8 +34,8 @@ def distance(point_1, point_2) -> float: Euclidian distance between two points. Args: - point_1 (TrackPoint): First point. - point_2 (TrackPoint): Second point. + point_1 (WayPoint): First point. + point_2 (WayPoint): Second point. Returns: float: Distance between the points. @@ -50,9 +50,9 @@ def perpendicular_distance(start_point, end_point, point) -> float: Distance between a point and a line. Args: - start_point (TrackPoint): A point on the line. - end_point (TrackPoint): A point on the line. - point (TrackPoint): A point to measure the distance from. + start_point (WayPoint): A point on the line. + end_point (WayPoint): A point on the line. + point (WayPoint): A point to measure the distance from. Returns: float: Perpendicular distance between the point *point* and the line defined by *start_point* and *end_point*. @@ -63,8 +63,8 @@ def line_coefficients(point_1, point_2): Compute the coefficients of a line equation of the form: ax+by+c=0. Args: - point_1 (TrackPoint): A point on the line. - point_2 (TrackPoint): A point on the line. + point_1 (WayPoint): A point on the line. + point_2 (WayPoint): A point on the line. Returns: tuple: Coefficients of the line equation. diff --git a/setup.py b/setup.py index 70e4afb..394cdb5 100644 --- a/setup.py +++ b/setup.py @@ -10,18 +10,24 @@ long_description = f.read() setup( - name='ezGPX', - version='0.1.0', + name='ezgpx', + version='0.1.1', description='Easy to use Python GPX library', long_description=long_description, long_description_content_type='text/markdown', + keywords=['gpx', 'gpx-files', 'gpx-parser', 'gpx-reader', 'gpx-writer', 'gpx-data'], # url='https://medium-multiply.readthedocs.io/', + download_url='https://github.com/FABallemand/ezGPX', + project_urls={ + "Bug Tracker": "https://github.com/FABallemand/ezGPX/issues", + # "Documentation": "", + "Source Code": "https://github.com/FABallemand/ezGPX", + }, author='Fabien ALLEMAND', author_email='allemand.fabien@orange.fr', license='GNU GPLv3', classifiers=[ 'Intended Audience :: Developers', - 'License :: OSI Approved :: GNU License', 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.6', @@ -30,24 +36,11 @@ 'Programming Language :: Python :: 3.9', 'Operating System :: OS Independent' ], - packages=find_packages(include=['ezgpx']), + # packages=find_packages(include=['ezgpx']), + packages=['ezgpx'], include_package_data=True, - install_requires=["gmap", "folium"], + install_requires=['gmap', 'folium'], setup_requires=['pytest-runner'], tests_require=['pytest'], test_suite='tests' -) - -# setup( -# name='ezGPX', -# # packages=find_packages(include=['mypythonlib']), -# packages=find_packages(), -# version='0.1.0', -# description='Easy to use Python GPX library', -# author='Fabien ALLEMAND', -# license='GNU GPLv3', -# install_requires=[], -# setup_requires=['pytest-runner'], -# tests_require=['pytest'], -# test_suite='tests', -# ) \ No newline at end of file +) \ No newline at end of file diff --git a/tests/test_GPX.py b/tests/test_GPX.py index 104c480..4c923fe 100644 --- a/tests/test_GPX.py +++ b/tests/test_GPX.py @@ -16,63 +16,68 @@ class TestGPX(): - def _test_plot_1(self): + def _test_matplotlib_plot_1(self): # Plot - self.test_gpx.plot(start_stop=False, elevation_color=False, file_path="tmp/strava_run_1.png") + self.test_gpx.matplotlib_plot(start_stop_colors=None, elevation_color=False, title="Track", file_path="tmp/matplotlib_strava_run_1.png") # Load images - test_img = plt.imread("tmp/strava_run_1.png") - ref_img = plt.imread("../test_files/reference_files/strava_run_1.png") + test_img = plt.imread("tmp/matplotlib_strava_run_1.png") + ref_img = plt.imread("../tests/test_files/reference_files/matplotlib_strava_run_1.png") # Compare images return np.array_equal(test_img, ref_img) - def _test_plot_2(self): + def _test_matplotlib_plot_2(self): # Plot - self.test_gpx.plot(start_stop=True, elevation_color=False, file_path="tmp/strava_run_1_start_stop.png") + self.test_gpx.matplotlib_plot(start_stop_colors=("#00FF00", "#FF0000"), elevation_color=False, title="Track", file_path="tmp/matplotlib_strava_run_1_start_stop.png") # Load images - test_img = plt.imread("tmp/strava_run_1_start_stop.png") - ref_img = plt.imread("../test_files/reference_files/strava_run_1_start_stop.png") + test_img = plt.imread("tmp/matplotlib_strava_run_1_start_stop.png") + ref_img = plt.imread("../tests/test_files/reference_files/matplotlib_strava_run_1_start_stop.png") # Compare images return np.array_equal(test_img, ref_img) - def _test_plot_3(self): + def _test_matplotlib_plot_3(self): # Plot - self.test_gpx.plot(start_stop=False, elevation_color=False, file_path="tmp/strava_run_1_elevation.png") + self.test_gpx.matplotlib_plot(start_stop_colors=None, elevation_color=True, title="Track", file_path="tmp/matplotlib_strava_run_1_elevation.png") # Load images - test_img = plt.imread("tmp/strava_run_1_elevation.png") - ref_img = plt.imread("../test_files/reference_files/strava_run_1_elevation.png") + test_img = plt.imread("tmp/matplotlib_strava_run_1_elevation.png") + ref_img = plt.imread("../tests/test_files/reference_files/matplotlib_strava_run_1_elevation.png") # Compare images return np.array_equal(test_img, ref_img) - def _test_plot_4(self): + def _test_matplotlib_plot_4(self): # Plot - self.test_gpx.plot(start_stop=True, elevation_color=True, file_path="tmp/strava_run_1_start_stop_elevation.png") + self.test_gpx.matplotlib_plot(start_stop_colors=("#00FF00", "#FF0000"), elevation_color=True, title="Track", file_path="tmp/matplotlib_strava_run_1_start_stop_elevation.png") # Load images - test_img = plt.imread("tmp/strava_run_1_start_stop_elevation.png") - ref_img = plt.imread("../test_files/reference_files/strava_run_1_start_stop_elevation.png") + test_img = plt.imread("tmp/matplotlib_strava_run_1_start_stop_elevation.png") + ref_img = plt.imread("../tests/test_files/reference_files/matplotlib_strava_run_1_start_stop_elevation.png") # Compare images return np.array_equal(test_img, ref_img) - def test_plot(self, remove_tmp: bool = True): + def test_matplotlib_plot(self, remove_tmp: bool = True): + """ + Test matplotlib_plot method. - self.test_gpx = GPX("../test_files/files/strava_run_1.gpx") + Args: + remove_tmp (bool, optional): Remove temporary folder. Defaults to True. + """ + self.test_gpx = GPX("../tests/test_files/files/strava_run_1.gpx") # Create temporary folder rmtree("tmp", True) os.makedirs(os.path.dirname(__file__) + "/tmp") # Tests - assert(self._test_plot_1()) - assert(self._test_plot_2()) - assert(self._test_plot_3()) - assert(self._test_plot_4()) + assert(self._test_matplotlib_plot_1()) + assert(self._test_matplotlib_plot_2()) + assert(self._test_matplotlib_plot_3()) + assert(self._test_matplotlib_plot_4()) # Remove temporary folder if remove_tmp: diff --git a/tests/test_files/reference_files/strava_run_1.png b/tests/test_files/reference_files/matplotlib_strava_run_1.png similarity index 100% rename from tests/test_files/reference_files/strava_run_1.png rename to tests/test_files/reference_files/matplotlib_strava_run_1.png diff --git a/tests/test_files/reference_files/matplotlib_strava_run_1_elevation.png b/tests/test_files/reference_files/matplotlib_strava_run_1_elevation.png new file mode 100644 index 0000000..a369346 Binary files /dev/null and b/tests/test_files/reference_files/matplotlib_strava_run_1_elevation.png differ diff --git a/tests/test_files/reference_files/matplotlib_strava_run_1_start_stop.png b/tests/test_files/reference_files/matplotlib_strava_run_1_start_stop.png new file mode 100644 index 0000000..b9dd540 Binary files /dev/null and b/tests/test_files/reference_files/matplotlib_strava_run_1_start_stop.png differ diff --git a/tests/test_files/reference_files/matplotlib_strava_run_1_start_stop_elevation.png b/tests/test_files/reference_files/matplotlib_strava_run_1_start_stop_elevation.png new file mode 100644 index 0000000..873f047 Binary files /dev/null and b/tests/test_files/reference_files/matplotlib_strava_run_1_start_stop_elevation.png differ diff --git a/tests/test_files/reference_files/strava_run_1_elevation.png b/tests/test_files/reference_files/strava_run_1_elevation.png deleted file mode 100644 index 7990d96..0000000 Binary files a/tests/test_files/reference_files/strava_run_1_elevation.png and /dev/null differ diff --git a/tests/test_files/reference_files/strava_run_1_start_stop.png b/tests/test_files/reference_files/strava_run_1_start_stop.png deleted file mode 100644 index fe20df7..0000000 Binary files a/tests/test_files/reference_files/strava_run_1_start_stop.png and /dev/null differ diff --git a/tests/test_files/reference_files/strava_run_1_start_stop_elevation.png b/tests/test_files/reference_files/strava_run_1_start_stop_elevation.png deleted file mode 100644 index af59c7c..0000000 Binary files a/tests/test_files/reference_files/strava_run_1_start_stop_elevation.png and /dev/null differ diff --git a/tests/test_utils.py b/tests/test_utils.py index 5660958..199af16 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -13,7 +13,7 @@ os.chdir(file_folder) sys.path.append(parent_folder + "/ezgpx") -from ezgpx import utils, TrackPoint +from ezgpx import utils, WayPoint class TestUtils(): @@ -21,27 +21,27 @@ def test_haversine_distance(self): pass def _test_perpendicular_distance_horizontal_line(self): - start = TrackPoint(0, 0) - end = TrackPoint(0, 2) - point = TrackPoint(1, 1) + start = WayPoint("wpt", 0, 0) + end = WayPoint("wpt", 0, 2) + point = WayPoint("wpt", 1, 1) return math.isclose(utils.perpendicular_distance(start, end, point), 1) def _test_perpendicular_distance_vertical_line(self): - start = TrackPoint(0, 0) - end = TrackPoint(2, 0) - point = TrackPoint(1, 1) + start = WayPoint("wpt", 0, 0) + end = WayPoint("wpt", 2, 0) + point = WayPoint("wpt", 1, 1) return math.isclose(utils.perpendicular_distance(start, end, point), 1) def _test_perpendicular_distance_random_line(self): - start = TrackPoint(0, 0) - end = TrackPoint(1, 1) - point = TrackPoint(1, 0) + start = WayPoint("wpt", 0, 0) + end = WayPoint("wpt", 1, 1) + point = WayPoint("wpt", 1, 0) return math.isclose(utils.perpendicular_distance(start, end, point), math.sqrt(2)/2) def _test_perpendicular_distance_point_on_line(self): - start = TrackPoint(0, 0) - end = TrackPoint(1, 1) - point = TrackPoint(2, 2) + start = WayPoint("wpt", 0, 0) + end = WayPoint("wpt", 1, 1) + point = WayPoint("wpt", 2, 2) return math.isclose(utils.perpendicular_distance(start, end, point), 0) def test_perpendicular_distance(self):