2018-10-15 16:54:38 +02:00
|
|
|
class ApiCarto::Cadastre::Adapter
|
2016-01-12 17:24:42 +01:00
|
|
|
def initialize(coordinates)
|
2016-01-15 11:53:00 +01:00
|
|
|
@coordinates = GeojsonService.to_json_polygon_for_cadastre(coordinates)
|
2016-01-12 17:24:42 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def data_source
|
2018-10-15 16:54:38 +02:00
|
|
|
@data_source ||= JSON.parse(ApiCarto::API.search_cadastre(@coordinates), symbolize_names: true)
|
2016-01-12 17:24:42 +01:00
|
|
|
end
|
|
|
|
|
2018-10-15 16:25:16 +02:00
|
|
|
def results
|
2018-01-15 21:33:29 +01:00
|
|
|
data_source[:features].map do |feature|
|
2018-10-15 16:11:46 +02:00
|
|
|
filter_properties(feature[:properties]).merge({ geometry: feature[:geometry] })
|
2016-01-12 17:24:42 +01:00
|
|
|
end
|
2016-01-18 12:03:18 +01:00
|
|
|
end
|
2016-01-12 17:24:42 +01:00
|
|
|
|
2018-03-20 17:47:37 +01:00
|
|
|
def filter_properties(properties)
|
2018-10-15 16:12:51 +02:00
|
|
|
properties.slice(
|
|
|
|
:surface_intersection,
|
|
|
|
:surface_parcelle,
|
|
|
|
:numero,
|
|
|
|
:feuille,
|
|
|
|
:section,
|
|
|
|
:code_dep,
|
|
|
|
:nom_com,
|
|
|
|
:code_com,
|
|
|
|
:code_arr
|
|
|
|
)
|
2016-01-12 17:24:42 +01:00
|
|
|
end
|
|
|
|
end
|