[openstreetmap/openstreetmap-website] Integrate the high-performance GPX importer (#1852)
mmd
notifications at github.com
Thu Oct 4 17:49:10 UTC 2018
After a bit more testing... Once gem "activerecord-import" gets added to the Gemfile,` trace.rb` `import` method could be enhanced to use bulk inserts via the following code. I also added the `tile` field, which wasn't included in the original source yet. If I'm not missing anything, this should really be all. SELECT for validation purposes also won't show up in the trace.
```ruby
# If there are any existing points for this trace then delete them
Tracepoint.where(:gpx_id => id).delete_all
tps = []
gpx.points do |point|
if first
f_lat = point.latitude
f_lon = point.longitude
first = false
end
tp = Tracepoint.new
tp.lat = point.latitude
tp.lon = point.longitude
tp.altitude = point.altitude
tp.timestamp = point.timestamp
tp.gpx_id = id
tp.tile = QuadTile.tile_for_point(point.latitude, point.longitude)
tp.trackid = point.segment
tps << tp
end
Tracepoint.import tps, :validate => false
```
--
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/issues/1852#issuecomment-427110022
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20181004/b19c49b0/attachment.html>
More information about the rails-dev
mailing list