scrapper / postrunner

Application to manage FIT files such as those produced by Garmin fitness devices
GNU General Public License v2.0
62 stars 14 forks source link

Map not included in browser view #33

Open edigiacomo opened 2 years ago

edigiacomo commented 2 years ago

First of all, thank you for postrunner!

Unfortunately, I can't see the map in the browser. Am I doing something wrong?

$ gem install --user-install postrunner
Fetching postrunner-1.0.5.gem
Successfully installed postrunner-1.0.5
Parsing documentation for postrunner-1.0.5
Installing ri documentation for postrunner-1.0.5
Done installing documentation for postrunner after 1 seconds
1 gem installed
$ postrunner import /mnt/GARMIN/GARMIN/ACTIVITY/
...
$ postrunner show

Screenshot from 2022-04-05 10-34-13

Thanks!

scrapper commented 2 years ago

Looks like your web browser can't load the javascript files. These should be in the same directory as the generated HTML files. Look for the directories jquery and openlayers and make sure your web server can access them. You can use the debugger in your browser (press F12) to debug the issue.

edigiacomo commented 2 years ago

Thank you for the suggestion!

After some debug, I found out that TrackView.has_geo_data is false and then openlayers in not included in the HTML file (https://github.com/scrapper/postrunner/blob/master/lib/postrunner/TrackView.rb#L34=). My FIT files have geographical data, so I suspect that fit4ruby is not compatible with the FIT files generated by my Forerunner 25 watch: I have tested them with another tool and they contains the coordinates of my activity.

I'll further investigate my issue and eventually I'll open a new issue/PR in fit4ruby repository, thank you for your help and for postrunner!

edigiacomo commented 2 years ago

If I understand correctly, Activity.aggregate should be called in order to include the map in the HTML page: Activity.aggregate invokes Session.aggregate which calculates the extent of the activity and sets its attributes @swc_lat, @swc_long, @nec_lat, @nec_long. Session.has_geo_data is true if these attributes are non-null (https://github.com/scrapper/fit4ruby/blob/master/lib/fit4ruby/Session.rb#L73-L75=) and Session.has_geo_data must be true in order to include openlayers in the HTML.

This patch fixes my issue:

diff --git a/lib/postrunner/FFS_Device.rb b/lib/postrunner/FFS_Device.rb
index d1d0e7f..75fa5a9 100644
--- a/lib/postrunner/FFS_Device.rb
+++ b/lib/postrunner/FFS_Device.rb
@@ -53,6 +53,7 @@ module PostRunner
     #         FitFileStore or nil if file could not be added.
     def add_fit_file(fit_file_name, fit_entity, overwrite)
       if fit_entity.is_a?(Fit4Ruby::Activity)
+        fit_entity.aggregate
         entity = activity_by_file_name(File.basename(fit_file_name))
         entities = @activities
         type = 'activity'

Thank you!

mrjones-plip commented 1 year ago

@edigiacomo - Thanks very much for your patch! It worked great for me.