Change place lib repository
This commit is contained in:
parent
27cc62ea1e
commit
1a3e23c6ef
21 changed files with 0 additions and 0 deletions
32
app/lib/carto/sgmap/cadastre/adapter.rb
Normal file
32
app/lib/carto/sgmap/cadastre/adapter.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
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
|
||||
|
||||
def to_params
|
||||
data_source[:features].inject([]) do |acc, feature|
|
||||
tmp = filter_properties feature[:properties]
|
||||
tmp[:geometry] = feature[:geometry]
|
||||
|
||||
acc << tmp
|
||||
end
|
||||
end
|
||||
|
||||
def filter_properties properties
|
||||
{
|
||||
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]
|
||||
}
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue