Plan for this solution

This time I had a plan.

The plan assumed that I'll create initial solution for GPX reading information.

Reading basic information like points and just create initial test-cases for this.

I've even created a sub-class of GPXReader for Endomondo Specific format data, but thus far endomondo's format data is almost identical with my example data.

Initial Solution - ideas behind the curtain

Solution is simple - reading points from what-ever data is in gpx file i.e. routepoints, trackpoints, waypoints.

Solution is far from perfect, but this time I made it in my timeframe I've given to myself - YEAH!!

Check this source code which is the core for gathering points: (for today - it may vary at the end)

    def get_track_points(self, item_nb=0):
        Returns only first track points
        points = []
        if len(self.__tracks) > 0 and len(self.__tracks) >= item_nb:
            for point in self.__tracks[item_nb].walk():
        return points

    def get_route_points(self, item_nb=0):
        Returns route points
        points = []
        if len(self.__routes) > 0 and len(self.__routes) >= item_nb:
            for point in self.__routes:
        return points

    def get_way_points(self, item_nb=0):
        Returns way points
        points = []
        if len(self.__waypoints) > 0 and len(self.__waypoints) >= item_nb:
            for point in self.__waypoints:
        return points

    def get_points(self, item_nb=0):
        Returns Points from either route/track or waypoints.
        If there is more then one type then uses Track's as a default.

        Make assumption that there will be only one of each data_type
        i.e. only one track/route/waypoint.
        if len(self.__tracks) > 0 and self.__tracks[item_nb].get_points_no() > 0:
            return self.get_track_points()
        elif len(self.__routes) > 0 and self.__routes[item_nb].get_points_no() > 0:
            return self.get_route_points()
        elif len(self.__waypoints) > 0 and self.__waypoints[item_nb].get_points_no() > 0:
            return self.get_way_points()
            return []

Code commits done for this post:

Commits in PR for GPX Reader, and it will not yet be pulled.

Adds initial Utils.pY

Adds more information on gpx reader at utils

Initial GPXReader with Test-Cases

Adds fix for unused import of gpx

Tools and applications used:

  • vIM

  • pylint/django tests

  • make

  • Docker

  • Github pull-request

LL (Lessons Learned)

1. I've created test-cases before checking if code even works :)

You may find yourself creating tests for code, before you even run it manually, as I did.

Then unfortunatelly debugging inside of test-cases is not ideal.

For now with limited time, I didn't find solution that could use django tests with code and debugging code within tests.


First test if your solution works - manually, then create test-case. When creating test-case source-code may or may not be changed, but you can check it with your manual testbed.


GPS Waypoints, Routes, and Tracks – the difference

Pull Request I've created today for GPX Reader

What's next

1. I'll continue working on GPX Reader to improve code for better maintainance and test-coverage.

2. Probably move again to travis builds to make pyreverse builds per commit visible at github gh-pages #12.

3. As always - check my Issues for the project


comments powered by Disqus