<p dir="auto">Currently uploaded gpx files are unpacked and parsed each time the <code class="notranslate">points</code> 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 <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2536745303" data-permission-text="Title is private" data-url="https://github.com/openstreetmap/openstreetmap-website/issues/5226" data-hovercard-type="pull_request" data-hovercard-url="/openstreetmap/openstreetmap-website/pull/5226/hovercard" href="https://github.com/openstreetmap/openstreetmap-website/pull/5226">#5226</a> and I want to handle one more error (invalid characters in xml), thus I want parse errors to happen in a predictable place.</p>
<p dir="auto">To avoid parsing files again I store trackpoint coordinates while reading each file. These coordinates are later used to draw images.</p>
<hr>
<h4>You can view, comment on, or merge this pull request online at:</h4>
<p> <a href='https://github.com/openstreetmap/openstreetmap-website/pull/5233'>https://github.com/openstreetmap/openstreetmap-website/pull/5233</a></p>
<h4>Commit Summary</h4>
<ul>
<li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/5233/commits/43e8df5145155df428a997c9295149a052d86eee" class="commit-link">43e8df5</a> Make parse_file a private method of GPX::File</li>
<li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/5233/commits/048f3ce3c5ca9a8d94cee6f18496f99ae98bc2d7" class="commit-link">048f3ce</a> Store latitudes and longitudes during gpx parsing</li>
<li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/5233/commits/9eb86f43e3457408812b60e5b9d73bf00c09dcb5" class="commit-link">9eb86f4</a> Don't pass number of points to gpx picture method</li>
<li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/5233/commits/06c2a8e3d204c922f2dba679cf7af34b9b5eec67" class="commit-link">06c2a8e</a> Use stored lats/lons to draw trace images</li>
<li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/5233/commits/c05002919dba2859ed8d082caa437286dc7013c8" class="commit-link">c050029</a> Initialize all trace file instance variables in constructor</li>
<li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/5233/commits/28ffaf7ce14308210024ab8139e0c9368ea31c64" class="commit-link">28ffaf7</a> Replace points method of trace file with read file method</li>
</ul>
<h4 style="display: inline-block">File Changes </h4> <p style="display: inline-block">(<a href="https://github.com/openstreetmap/openstreetmap-website/pull/5233/files">2 files</a>)</p>
<ul>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/5233/files#diff-49ff8e13eb2bff9ffd834dad7421f568b40186cb58b28e7eac6b3e9168ec8759">app/models/trace.rb</a>
(6)
</li>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/5233/files#diff-2f101bb482816df81f20afe2e8626836bd542158be8744474dcffcc4a113d769">lib/gpx.rb</a>
(96)
</li>
</ul>
<h4>Patch Links:</h4>
<ul>
<li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/5233.patch'>https://github.com/openstreetmap/openstreetmap-website/pull/5233.patch</a></li>
<li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/5233.diff'>https://github.com/openstreetmap/openstreetmap-website/pull/5233.diff</a></li>
</ul>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5233">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLLYBGDEB6GXGFC3FPTZYASMVAVCNFSM6AAAAABOWH7BTOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGU2DEOBYHAZTONY">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLPLY65XVLVVMNU62N3ZYASMVA5CNFSM6AAAAABOWH7BTOWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHJPELFXE.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/5233</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/5233",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/5233",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>