2016-01-12 17:24:42 +01:00
|
|
|
class CARTO::SGMAP::Cadastre::Adapter
|
|
|
|
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
|
|
|
|
@data_source ||= JSON.parse(CARTO::SGMAP::API.search_cadastre(@coordinates), symbolize_names: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_params
|
2018-01-15 21:33:29 +01:00
|
|
|
data_source[:features].map do |feature|
|
2016-01-18 12:03:18 +01:00
|
|
|
tmp = filter_properties feature[:properties]
|
2016-01-12 17:24:42 +01:00
|
|
|
tmp[:geometry] = feature[:geometry]
|
|
|
|
|
2018-01-15 21:33:29 +01:00
|
|
|
tmp
|
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
|
|
|
|
2016-01-18 12:03:18 +01:00
|
|
|
def filter_properties properties
|
|
|
|
{
|
2018-01-15 19:02:12 +01:00
|
|
|
surface_intersection: properties[:surface_intersection],
|
|
|
|
surface_parcelle: properties[:surface_parcelle],
|
|
|
|
numero: properties[:numero],
|
|
|
|
feuille: properties[:feuille],
|
|
|
|
section: properties[:section],
|
|
|
|
code_dep: properties[:code_dep],
|
|
|
|
nom_com: properties[:nom_com],
|
|
|
|
code_com: properties[:code_com],
|
|
|
|
code_arr: properties[:code_arr]
|
2016-01-18 12:03:18 +01:00
|
|
|
}
|
2016-01-12 17:24:42 +01:00
|
|
|
end
|
|
|
|
end
|