demarches-normaliennes/app/lib/carto/sgmap/quartiers_prioritaires/adapter.rb
gregoirenovel 34ac68b27f
2018-10-15 17:12:34 +02:00

15 lines
424 B
Ruby

class CARTO::SGMAP::QuartiersPrioritaires::Adapter
def initialize(coordinates)
@coordinates = GeojsonService.to_json_polygon_for_qp(coordinates)
end
def data_source
@data_source ||= JSON.parse(CARTO::SGMAP::API.search_qp(@coordinates), symbolize_names: true)
end
def results
data_source[:features].map do |feature|
feature[:properties].merge({ geometry: feature[:geometry] })
end
end
end