dawarich/app/serializers/points/geojson_serializer.rb

30 lines
564 B
Ruby
Raw Normal View History

2024-09-02 14:51:34 -04:00
# 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',
2025-05-22 13:09:43 -04:00
coordinates: [point.lon, point.lat]
2024-09-02 14:51:34 -04:00
},
properties: PointSerializer.new(point).call
}
end
}.to_json
end
# rubocop:enable Metrics/MethodLength
private
attr_reader :points
end