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/5...@github.com>
_______________________________________________ rails-dev mailing list rails-dev@openstreetmap.org https://lists.openstreetmap.org/listinfo/rails-dev