Skip to content

Commit

Permalink
Suffixes - adaptation CADASTRE -> BAN (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
vdct committed Mar 28, 2021
1 parent e8a44b5 commit 25a501d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
14 changes: 14 additions & 0 deletions bano/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from . import db
from . import helpers as hp
from .sources import fantoir
from . import core as c


class Adresse:
Expand Down Expand Up @@ -96,6 +97,19 @@ def load_cadastre_hsnr(self):
nd = Node({'id':cle_interop,'lon':lon,'lat':lat},{})
self.add_adresse(Adresse(nd,housenumber,name,'',code_postal), 'CADASTRE')

def load_ban_hsnr(self):
dict_node_relations = {}
data = c.get_data_from_pg_direct('ban_hsnr',self.code_insee)
for id, housenumber, name, lon, lat in data:
if not name or len(name) < 2 or not lon:
continue
self.register(name)
if not id in dict_node_relations:
dict_node_relations[id] = []
dict_node_relations[id].append(hp.normalize(name))
if hp.is_valid_housenumber(housenumber):
self.add_adresse(Adresse(Node({'id':id,'lon':lon,'lat':lat},{}),housenumber,name,'',''), 'BAN')

def save(self, source, code_dept):
with db.bano.cursor() as cur_insert :
for a in ['cumul_adresses','cumul_voies']:
Expand Down
6 changes: 4 additions & 2 deletions bano/pre_process_suffixe.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from . import helpers as hp
from . import db_helpers as dh
from .models import Adresses
from .core import load_ban_hsnr

def collect_adresses_points(selection, adresses):
kres = {}
Expand Down Expand Up @@ -80,7 +81,7 @@ def select_street_names_by_name(freq):
return sel

def process(departements, **kwargs):
source = 'CADASTRE'
source = 'BAN'
for dept in departements:
if hp.is_valid_dept(dept):
for code_insee, nom_commune in dh.get_insee_name_list_by_dept(dept):
Expand All @@ -90,7 +91,8 @@ def process(departements, **kwargs):

batch_id = batch_start_log(source,'detectesuffixe',code_insee)

adresses.load_cadastre_hsnr()
# adresses.load_cadastre_hsnr()
adresses.load_ban_hsnr()
freq = name_frequency(adresses)
selection = select_street_names_by_name(freq)
adds = collect_adresses_points(selection, adresses)
Expand Down

0 comments on commit 25a501d

Please sign in to comment.