Use lonlat in maps controller

This commit is contained in:
Eugene Burmakin 2025-02-23 22:59:14 +01:00
parent 383b88ab04
commit 217d6249e2
6 changed files with 4 additions and 6 deletions

View file

@ -9,7 +9,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## TODO:
- Realtime broadcast for importing progress
- Frontend update to use `lonlat` column.
## Fixed
@ -25,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Points are now using `lonlat` column for storing longitude and latitude.
- Semantic history points are now being imported much faster.
- GPX files are now being imported much faster.
- Distance calculation are now using Postgis functions and expected to be more accurate.
# 0.24.1 - 2025-02-13

View file

@ -7,8 +7,8 @@ class MapController < ApplicationController
@points = points.where('timestamp >= ? AND timestamp <= ?', start_at, end_at)
@coordinates =
@points.pluck(:latitude, :longitude, :battery, :altitude, :timestamp, :velocity, :id, :country)
.map { [_1.to_f, _2.to_f, _3.to_s, _4.to_s, _5.to_s, _6.to_s, _7.to_s, _8.to_s] }
@points.pluck(:lonlat, :battery, :altitude, :timestamp, :velocity, :id, :country)
.map { |lonlat, *rest| [lonlat.y.to_f, lonlat.x.to_f, *rest.map(&:to_s)] }
@distance = distance
@start_at = Time.zone.at(start_at)
@end_at = Time.zone.at(end_at)

View file

@ -105,8 +105,6 @@ module Distanceable
RGeo::Geographic.spherical_factory(srid: 4326).point(point[1], point[0])
when self.class
point.lonlat
else
nil
end
end
end

2
db/schema.rb generated
View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2025_02_21_151930) do
ActiveRecord::Schema[8.0].define(version: 2025_02_21_194509) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_catalog.plpgsql"
enable_extension "postgis"