Remove API GEO legacy adapter

This commit is contained in:
Paul Chavard 2021-05-06 18:47:58 +02:00
parent 6bb9c5fc20
commit 01c558953b
6 changed files with 0 additions and 180 deletions

View file

@ -1,23 +0,0 @@
class APICarto::API
class ResourceNotFound < StandardError
end
def self.search_cadastre(geojson)
url = [API_CARTO_URL, "cadastre", "geometrie"].join("/")
call(url, geojson)
end
private
def self.call(url, geojson)
response = Typhoeus.post(url, body: geojson.to_s, headers: { 'content-type' => 'application/json' })
if response.success?
response.body
else
message = response.code == 0 ? response.return_message : response.code.to_s
Rails.logger.error "[APICarto] Error on #{url}: #{message}"
raise ResourceNotFound
end
end
end

View file

@ -1,29 +0,0 @@
class APICarto::CadastreAdapter
def initialize(coordinates)
@coordinates = GeojsonService.to_json_polygon_for_cadastre(coordinates)
end
def data_source
@data_source ||= JSON.parse(APICarto::API.search_cadastre(@coordinates), symbolize_names: true)
end
def results
data_source[:features].map do |feature|
filter_properties(feature[:properties]).merge({ geometry: feature[:geometry] })
end
end
def filter_properties(properties)
properties.slice(
:surface_intersection,
:surface_parcelle,
:numero,
:feuille,
:section,
:code_dep,
:nom_com,
:code_com,
:code_arr
)
end
end