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
|
2018-10-30 11:05:08 +01:00
|
|
|
).merge({
|
|
|
|
geometry: feature[:geometry],
|
|
|
|
geo_reference_id: feature[:properties][:id]
|
|
|
|
})
|
2018-10-23 15:37:13 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|