mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
29 lines
575 B
Ruby
29 lines
575 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Points::GeojsonSerializer
|
|
def initialize(points)
|
|
@points = points
|
|
end
|
|
|
|
# rubocop:disable Metrics/MethodLength
|
|
def call
|
|
{
|
|
type: 'FeatureCollection',
|
|
features: points.map do |point|
|
|
{
|
|
type: 'Feature',
|
|
geometry: {
|
|
type: 'Point',
|
|
coordinates: [point.longitude, point.latitude]
|
|
},
|
|
properties: PointSerializer.new(point).call
|
|
}
|
|
end
|
|
}.to_json
|
|
end
|
|
# rubocop:enable Metrics/MethodLength
|
|
|
|
private
|
|
|
|
attr_reader :points
|
|
end
|