Skip to content

Commit

Permalink
Caractères parasites dans les noms OSM (#307)
Browse files Browse the repository at this point in the history
* Rebase (#300)

* Update load_fantoir.sh

Update Fantoir T2 2022

* Ajout dans le dico type_voie (#285)

* typo sur le nom de fichier des communes pour batch nocturne

Co-authored-by: deuzeffe <[email protected]>

* Caractères parasites dans les noms BAN (#301)

* Caractères parasites dans les noms du Cadastre (#301)

* Caractères parasites dans les noms OSM (#301)

Co-authored-by: deuzeffe <[email protected]>
  • Loading branch information
vdct and deuzeffe authored Nov 21, 2022
1 parent b66d3f0 commit 4ccfd23
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions bano/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ def remove_quotes_on_null(s):
def replace_single_quotes_with_double(s):
return s.replace('\'','"')

def replace_double_quotes_with_single(s):
return s.replace('"',"'")

def format_toponyme(s):
a_s = s.replace('\'',' ').split(' ')

Expand Down
13 changes: 7 additions & 6 deletions bano/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ def save(self, source, code_dept):
for v in self:
code_postal = ''
cle_fantoir = self.get_best_fantoir(v)
street_name_osm = self[v]['voies'].get('OSM') or fantoir.mapping.get_fantoir_name(cle_fantoir,'OSM') or ''
street_name_fantoir = self[v]['voies'].get('FANTOIR') or ''
street_name_cadastre = self[v]['voies'].get('CADASTRE') or ''
street_name_bal = self[v]['voies'].get('BAL') or ''
street_name_osm = hp.replace_double_quotes_with_single(self[v]['voies'].get('OSM') or fantoir.mapping.get_fantoir_name(cle_fantoir,'OSM') or '')
street_name_fantoir = hp.replace_double_quotes_with_single(self[v]['voies'].get('FANTOIR') or '')
street_name_cadastre = hp.replace_double_quotes_with_single(self[v]['voies'].get('CADASTRE') or '')
street_name_bal = hp.replace_double_quotes_with_single(self[v]['voies'].get('BAL') or '')
if source == 'CADASTRE':
street_name_autre = self[v]['voies'].get('CADASTRE') or ''
elif source == 'BAL':
Expand All @@ -136,6 +136,7 @@ def save(self, source, code_dept):
street_name_autre = self[v]['voies'].get('BAN') or ''
else:
street_name_autre = ''
street_name_autre = hp.replace_double_quotes_with_single(street_name_autre)
lat_point_par_rue = None
lon_point_par_rue = None

Expand Down Expand Up @@ -248,9 +249,9 @@ def as_string(self):
return f"ID {self.id} \n FANTOIR {self.fantoir.name} - FANTOIR {self.fantoir.fantoir} \nOSM {self.osm.lon} - {self.osm.lat} - {self.osm.place} - {self.osm.name} \nCADASTRE {self.cadastre.lon} - {self.cadastre.lat} - {self.cadastre.name}"
def as_SQL_cadastre_row(self):
if self.has_cadastre:
return hp.remove_quotes_on_null(f"(ST_PointFromText('POINT({self.cadastre.lon} {self.cadastre.lat})',4326),'{hp.escape_quotes(hp.format_toponyme(self.cadastre.name)) or 'null'}','{hp.escape_quotes(self.osm.name) or 'null'}','{hp.escape_quotes(self.fantoir.name) or 'null'}','{self.fantoir.fantoir or 'null'}','{self.code_insee}','{self.code_dept}','null','CADASTRE',{self.fantoir.bati or 'null'},'')")
return hp.remove_quotes_on_null(f"(ST_PointFromText('POINT({self.cadastre.lon} {self.cadastre.lat})',4326),'{hp.escape_quotes(hp.format_toponyme(self.cadastre.name)) or 'null'}','{hp.escape_quotes(hp.replace_double_quotes_with_single(self.osm.name)) or 'null'}','{hp.escape_quotes(self.fantoir.name) or 'null'}','{self.fantoir.fantoir or 'null'}','{self.code_insee}','{self.code_dept}','null','CADASTRE',{self.fantoir.bati or 'null'},'')")
def as_SQL_osm_row(self):
return hp.remove_quotes_on_null(f"(ST_PointFromText('POINT({self.osm.lon} {self.osm.lat})',4326),null,'{hp.escape_quotes(self.osm.name) or 'null'}','{hp.escape_quotes(self.fantoir.name) or 'null'}','{self.fantoir.fantoir or 'null'}','{self.code_insee}','{self.code_dept}',null,'OSM',{self.fantoir.bati or 'null'},'{self.osm.place}')")
return hp.remove_quotes_on_null(f"(ST_PointFromText('POINT({self.osm.lon} {self.osm.lat})',4326),null,'{hp.escape_quotes(hp.replace_double_quotes_with_single(self.osm.name)) or 'null'}','{hp.escape_quotes(self.fantoir.name) or 'null'}','{self.fantoir.fantoir or 'null'}','{self.code_insee}','{self.code_dept}',null,'OSM',{self.fantoir.bati or 'null'},'{self.osm.place}')")

class Places:
def __init__(self):
Expand Down

0 comments on commit 4ccfd23

Please sign in to comment.