Code Monkey home page Code Monkey logo

trackeditor's Introduction

License: MIT Build Status

TrackEditor

This is a small tool to edit GPX files. There are a number of tools that I periodically need to create my own GPS Tracks and export them in a single GPX file, such as: cut, split, reverse, add time, correct elevation... and always need more than one single tool to do this!

The single goal of this application is to load, visualize and edit your GPX files to create your custom track.

There are amazing tools to create tracks from scratch: komoot, strava... But no GPX editor matches my necessities at 100%.

Current status

This project is being improved or maintained. A web version is being developed as an alternative: TrackEditorWeb

Repository organization

  • bin: executable files
  • docs: design documents
  • src: source code
  • test: test cases for src modules
  • Dockerfile
  • docker_compose.yml
  • requirements.txt: list of python packages dependencies

Getting started

Option 1 Download your executable from bin/

Note: windows users will need to be uncompress using 7z and execute track_editor.exe file

Option 2 Clone full code and launch it with python

python3 -m pip install -r requirements.txt
python3 track_editor.py

Option 3 Use the docker image

Usage

A window in which you can load GPX files will be open, like this:

โ†“ it is a video, click it! Watch the video

Docker

A Dockerfile is provided to execute the application in a controlled environment. It is suggested to be used in a Linux environment, since x-server must be configured to get the GUI. In order to have visibility of your file system a volume from /home/${USER}/Desktop (host) to /home/Desktop (guest) is created. Procedure:

docker build -t track_editor_im:1.0 .
xhost +
docker-compose up -d

Note: if docker-compose is launched with sudo the docker-compose.yml should be modified. The ${USER} variable would be set to root which may be confusing when using the volumes. This can be debug by using docker-compose config

โ†“ it is a video, click it! Watch the video

License

MIT

trackeditor's People

Contributors

alguerre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

alguerre

trackeditor's Issues

Matplotlib button6 and button7 produces KeyError in Linux

alguerre@alguerre-VirtualBox:~/Desktop/TrackEditor$ python3 src/track_editor.py
Traceback (most recent call last):
File "src/track_editor.py", line 112, in
MainApplication(root).pack(side='top', fill='both', expand=True)
File "src/track_editor.py", line 57, in init
toolbar.children['!button6'].pack_forget() # configure subplots
KeyError: '!button6'

The script issue_14_16.sh has a workaround for Linux launch.

PerformanceWarning when saving session

When the option "save session" is used the next warning is displayed, besides this warning the created .h5 file can be properly loaded:

C:\Users\Alonso\AppData\Local\Programs\Python\Python38\lib\tkinter_init_.py:1420: PerformanceWarning:
your performance may suffer as PyTables will pickle object types that it cannot
map directly to c-types [inferred_type->integer,key->block1_values] [items->Index(['segment'], dtype='object')]

self.tk.mainloop(n)

Exception is raised when reversing a segment

A TypeError is rised. This may be affected by the 'time' column, which has a time type.

Traceback (most recent call last):
File "C:\Users\Alonso\AppData\Local\Programs\Python\Python38\lib\tkinter_init_.py", line 1883, in call
return self.func(*args)
File "C:\Users\Alonso\Desktop\proyectos\TrackEditor\src\edit_menu.py", line 54, in reverse_segment
self.controller.shared_data.obj_track.reverse_segment(segment_idx)
File "C:\Users\Alonso\Desktop\proyectos\TrackEditor\src\track.py", line 64, in reverse_segment
rev_segment = pd.DataFrame(segment.values[::-1].astype('float32'),
TypeError: float() argument must be a string or a number, not 'NaTType'

Run application in containers

It is possible to create a customized docker container to run the application. This way we can be sure to run it using, exactly, the same environment every time. No python package problem would be generated.

Possible Steps:

  1. Create an image. This should contain all the instalation process.
  2. Configure x-server to process the GUI.
  3. Create a folder which can be common for host and docker, as input/output directory.
  4. Run application on a docker which is auto-deleted after its use.

Split segment several times

When trying a second split the result is not shown.
Test description:

  1. Load Innacessible_Island_part1.gpx -> segment 1
  2. Load Innacessible_Island_part2.gpx -> segment 2
  3. Load Innacessible_Island_part3.gpx -> segment 3
  4. Split segment 2 -> into 2a and 2b
  5. Split segment 3 -> nothing happens

UserWarning in label axis management

A new warning is raised when updating matplotlib:
UserWarning: FixedFormatter should only be used together with FixedLocator

C:\Users\Alonso\Desktop\proyectos\TrackEditor\src\plots.py:469: UserWarning: FixedFormatter should only be used together with FixedLocator
ax.set_xticklabels(dist_label)
C:\Users\Alonso\Desktop\proyectos\TrackEditor\src\plots.py:470: UserWarning: FixedFormatter should only be used together with FixedLocator
ax.set_yticklabels(ele_label)

Improve unit tests for: gpx, iosm and db_handler

test_gpx.py

  • There are some skipped test cases

test_db_handler.py

  • remove mark.dependency, it does not work

test_iosm.py

  • download_tiles_by_num is not tested but used in the code
  • test_download_tiles_nominal should be renamed
  • test_deg2num and test_num2deg are set to True and do not contribute to coverage metric, should we do anything?

Coverage Analysis
Name Stmts Miss Cover
src/db_handler.py 97 16 84%
src/gpx.py 49 3 94%
src/iosm.py 75 16 79%

Create thread with 'loading' window

A loading message can be useful in time consuming operation such as:

  • fix elevation
  • load gpx
  • load session

This may can be shown after waiting more than 0.5seconds and using a decorator.

Color management

A good color management policy must be defined.

  • What color must be assigned when re-ordering segments?
  • New colors after split
  • Colors after segment removal
  • ...

Line to join segments

It would be great if a line join different segments. Therefore, it would be more clear the order of the segments.

Split & Remove action is failing

Two errors emerge when the first segment is removed:

  • 'Last segment has been removed.' warning box is raised
  • ValueError: Axis limits cannot be NaN or Inf
    image

save_gpx functionality to include a model with altimeter

Using a gps device with altimeter is a good decission if the gpx file will be uploaded to strava. Since:

"For devices without recognized barometric altimeters, Strava calculates your activity's elevation gain by comparing the GPS data to a known basemap of absolute elevation measurements."

It has been observed that, actually, when uploading an activity with fixed elevation the final result is a kind of mean value between strava data base and your gpx file.

Suggested model to use: Garmin Edge 830

Code cleaning for V0.11

General

  • Include file header

track.py

  • Organize public and private classes in track.py
  • Include a small comment to describe methods, when not fully clear: fix_elevation, change_order
  • Review methods which may be short but bulky: reverse_segment

plots.py

  • can be this somehow refactor?

db_handler.py

  • remove TODO and create issue if needed

constants.py

  • remove TODO and create issue if needed

gpx.py

  • remove TODO and create issue if needed

FLAKE8

  • Review all the output of flake8 from github actions

Misterious needed exception

split_segment.py produces an exception which is, apparently, needed to have a proper behaviour of split segment functionality. Interactivity is broken without this exception.
It is the print of non-existing variable:

  File "C:\Users\Alonso\Desktop\proyectos\TrackEditor\src\split_segment.py", line 80, in connect
    print(f'cidpress: {cidpress}')
NameError: name 'cidpress' is not defined

Implications:

  • An exception causing a final expected behaviour is smelly.
  • In edit_menu.py the split_segment does not uses the exception_handler decorator. So, other exceptions from split_segment.py module can reach the final user without control.
  • Flake8 task in CI process excludes this file.

Try lighter linux distribution for docker

The docker image creation takes too long (5min aprox), can it be reduced by using a lighter distribution?
Proposal:

  • Alpine Linux: not debian, so apt get is not used and Dockerfile must be modified

Create icon

Look for a free compass icon on the web and use it.

Create a new window for split segment functionality

Right now, the split segment operation is done in the main plot. The creation of a new window can drive to a more friendly user experience since:

  • The 'special' DONE button is not needed in main GUI
  • No clicking segment operations will be available

This could also fix #34 bug

Unable to locate src package

The src.[module] notation is used in import when launching from pycharm. Launching configuration must be reviewed, since it is being problematic when launching in a Linux environment.

Ambiguous log directory location

Different log locations are established in track_editor.py, main function.
It is not clear whether log files must be created at "log/" or "../log/", which causes an exception when using a new environment.

ValueError when click on elevation plot

When clicking in the elevation plot, instead of map, a ValueError is reported.

Traceback (most recent call last):
File "C:\Users\Alonso\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\cbook_init_.py", line 196, in process
func(*args, **kwargs)
File "C:\Users\Alonso\Desktop\proyectos\TrackEditor\plots.py", line 276, in on_click
get_closest_segment(ob_track.track, (event.ydata, event.xdata))
File "C:\Users\Alonso\Desktop\proyectos\TrackEditor\plots.py", line 220, in get_closest_segment
df_track['point_distance'] = df_track.apply(
File "C:\Users\Alonso\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\frame.py", line 6878, in apply
return op.get_result()
File "C:\Users\Alonso\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\apply.py", line 186, in get_result
return self.apply_standard()
File "C:\Users\Alonso\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\apply.py", line 295, in apply_standard
result = libreduction.compute_reduction(
File "pandas_libs\reduction.pyx", line 620, in pandas._libs.reduction.compute_reduction
File "pandas_libs\reduction.pyx", line 128, in pandas._libs.reduction.Reducer.get_result
File "C:\Users\Alonso\Desktop\proyectos\TrackEditor\plots.py", line 221, in
lambda row: geopy.distance.geodesic((row.lat, row.lon), point).km,
File "C:\Users\Alonso\AppData\Local\Programs\Python\Python38\lib\site-packages\geopy\distance.py", line 389, in init
super(geodesic, self).init(*args, **kwargs)
File "C:\Users\Alonso\AppData\Local\Programs\Python\Python38\lib\site-packages\geopy\distance.py", line 164, in init
kilometers += self.measure(a, b)
File "C:\Users\Alonso\AppData\Local\Programs\Python\Python38\lib\site-packages\geopy\distance.py", line 410, in measure
a, b = Point(a), Point(b)
File "C:\Users\Alonso\AppData\Local\Programs\Python\Python38\lib\site-packages\geopy\point.py", line 165, in new
return cls.from_sequence(seq)
File "C:\Users\Alonso\AppData\Local\Programs\Python\Python38\lib\site-packages\geopy\point.py", line 405, in from_sequence
return cls(*args)
File "C:\Users\Alonso\AppData\Local\Programs\Python\Python38\lib\site-packages\geopy\point.py", line 178, in new
_normalize_coordinates(latitude, longitude, altitude)
File "C:\Users\Alonso\AppData\Local\Programs\Python\Python38\lib\site-packages\geopy\point.py", line 76, in _normalize_coordinates
raise ValueError('Latitude must be in the [-90; 90] range.')
ValueError: Latitude must be in the [-90; 90] range.

Process finished with exit code 0

Remove md5 check in add_gpx method

This check does not include any extra value to the project. This can be problematic with the following sequence:

  1. Load file test.gpx
  2. Split segment
  3. Remove one of the segments
  4. Reload test.gpx to get some removed information

Step 4 would not load any gpx file.

Force version in requirements.txt

Changes in matplotlib package has been shown to change some plots. Versions will be hardcoded in requirements.txt.
They will be updated periodically in a controlled approach

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.