dawarich/app/services/tracks/build_path.rb

22 lines
397 B
Ruby
Raw Normal View History

2025-01-24 06:01:54 -05:00
# frozen_string_literal: true
class Tracks::BuildPath
def initialize(coordinates)
@coordinates = coordinates
end
def call
factory.line_string(
2025-02-22 16:37:21 -05:00
coordinates.map { |point| factory.point(point.lon.to_f.round(5), point.lat.to_f.round(5)) }
2025-01-24 06:01:54 -05:00
)
end
private
attr_reader :coordinates
def factory
@factory ||= RGeo::Geographic.spherical_factory(srid: 3857)
end
end