2015-12-08 16:02:35 +01:00
|
|
|
class CARTO::SGMAP::QuartiersPrioritaires::Adapter
|
2015-11-23 18:43:07 +01:00
|
|
|
def initialize(coordinates)
|
2015-11-25 10:26:55 +01:00
|
|
|
@coordinates = GeojsonService.to_json_polygon(coordinates)
|
2015-11-23 18:43:07 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def data_source
|
2016-01-12 17:24:42 +01:00
|
|
|
@data_source ||= JSON.parse(CARTO::SGMAP::API.search_qp(@coordinates), symbolize_names: true)
|
2015-11-23 18:43:07 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def to_params
|
|
|
|
params = {}
|
|
|
|
|
2015-11-30 17:03:36 +01:00
|
|
|
data_source[:features].each do |feature|
|
2015-11-25 10:26:55 +01:00
|
|
|
qp_code = feature[:properties][:code]
|
|
|
|
|
|
|
|
params[qp_code] = feature[:properties]
|
|
|
|
params[qp_code][:geometry] = feature[:geometry]
|
2015-11-23 18:43:07 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
params
|
|
|
|
end
|
|
|
|
end
|