From 4ccfd23ee38c46986fe3dbdc4fa11474f58c7fea Mon Sep 17 00:00:00 2001 From: vdct Date: Tue, 22 Nov 2022 00:39:25 +0100 Subject: [PATCH] =?UTF-8?q?Caract=C3=A8res=20parasites=20dans=20les=20noms?= =?UTF-8?q?=20OSM=20(#307)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 <36087963+deuzeffe@users.noreply.github.com> * 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 <36087963+deuzeffe@users.noreply.github.com> --- bano/helpers.py | 3 +++ bano/models.py | 13 +++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/bano/helpers.py b/bano/helpers.py index 53231e9..88224b3 100644 --- a/bano/helpers.py +++ b/bano/helpers.py @@ -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(' ') diff --git a/bano/models.py b/bano/models.py index ca51b6c..d997c88 100644 --- a/bano/models.py +++ b/bano/models.py @@ -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': @@ -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 @@ -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):