demarches-normaliennes/app/lib/api_geo/rpg_adapter.rb

25 lines
551 B
Ruby
Raw Normal View History

2018-10-23 15:37:13 +02:00
class ApiGeo::RPGAdapter
def initialize(coordinates)
@coordinates = GeojsonService.to_json_polygon_for_rpg(coordinates)
end
def data_source
@data_source ||= ApiGeo::API.search_rpg(@coordinates)
end
def results
data_source[:features].map do |feature|
feature[:properties]
.stringify_keys
.transform_keys(&:underscore)
.symbolize_keys
.slice(
:culture,
:code_culture,
:surface,
:bio
).merge({ geometry: feature[:geometry] })
end
end
end