[openstreetmap/openstreetmap-website] Use a view to render tracepoints (#3332)
Andy Allan
notifications at github.com
Wed Sep 29 14:49:32 UTC 2021
This PR moves the rendering of the tracepoints#index call to use a builder view, rather than creating the xml within the controller method. It then allows us to remove the `to_xml_node` method from the model.
I've had to refactor the code slightly, since the original involved going back to previously added XML nodes and adding more details to them (e.g. adding more points to the anon_trackseg). I couldn't find a way to do this "revisiting" approach with the xml builder, so instead I sort all the tracepoints into the tracksegs using hashes and arrays, and then iterate over those structures when writing out the end result as xml. The decisions on what goes where should (hopefully) be the same though, since that logic hasn't been changed.
You can view, comment on, or merge this pull request online at:
https://github.com/openstreetmap/openstreetmap-website/pull/3332
-- Commit Summary --
* <a href="https://github.com/openstreetmap/openstreetmap-website/pull/3332/commits/95e5178bfbb2a37bf26b57e4f5dfcb329dd3333c">Refactor tracepoint index to use an xml builder view</a>
* <a href="https://github.com/openstreetmap/openstreetmap-website/pull/3332/commits/9ab15f38ea72ccd0a6b6715a9b8014c1f4ce1ad8">Move the tracepoint coordinate format test to the controller test</a>
-- File Changes --
M app/controllers/api/tracepoints_controller.rb (68)
M app/models/tracepoint.rb (8)
A app/views/api/tracepoints/index.gpx.builder (79)
M test/controllers/api/tracepoints_controller_test.rb (9)
M test/models/tracepoint_test.rb (8)
-- Patch Links --
https://github.com/openstreetmap/openstreetmap-website/pull/3332.patch
https://github.com/openstreetmap/openstreetmap-website/pull/3332.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/3332
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20210929/a9431321/attachment.htm>
More information about the rails-dev
mailing list