[openstreetmap/openstreetmap-website] Process trace files once (PR #5233)

Anton Khorev notifications at github.com
Mon Sep 23 14:44:26 UTC 2024


Currently uploaded gpx files are unpacked and parsed each time the `points` method is called. This happens a dozen of times: once for storing the trackpoints in the db, once for generating a thumbnail and once for each frame of an animated trace image. Even if we don't mind reparsing the files over and over, there's another problem. I started adding parse error handling in #5226 and I want to handle one more error (invalid characters in xml), thus I want parse errors to happen in a predictable place.

To avoid parsing files again I store trackpoint coordinates while reading each file. These coordinates are later used to draw images.
You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/5233

-- Commit Summary --

  * Make parse_file a private method of GPX::File
  * Store latitudes and longitudes during gpx parsing
  * Don't pass number of points to gpx picture method
  * Use stored lats/lons to draw trace images
  * Initialize all trace file instance variables in constructor
  * Replace points method of trace file with read file method

-- File Changes --

    M app/models/trace.rb (6)
    M lib/gpx.rb (96)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/5233.patch
https://github.com/openstreetmap/openstreetmap-website/pull/5233.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5233
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/5233 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20240923/432fa764/attachment.htm>


More information about the rails-dev mailing list