demarches-normaliennes/app/lib/carto/sgmap/cadastre/adapter.rb

30 lines
680 B
Ruby
Raw Normal View History

class CARTO::SGMAP::Cadastre::Adapter
def initialize(coordinates)
@coordinates = GeojsonService.to_json_polygon_for_cadastre(coordinates)
end
def data_source
@data_source ||= JSON.parse(CARTO::SGMAP::API.search_cadastre(@coordinates), symbolize_names: true)
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|
filter_properties(feature[:properties]).merge({ geometry: feature[:geometry] })
end
2016-01-18 12:03:18 +01:00
end
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
)
end
end