diff --git a/cadastre/dialogs/search_dialog.py b/cadastre/dialogs/search_dialog.py index e2f90d49..8e1b0bc2 100644 --- a/cadastre/dialogs/search_dialog.py +++ b/cadastre/dialogs/search_dialog.py @@ -744,7 +744,7 @@ def refreshAutocomplete(self, key): def getFeaturesFromSqlQuery(self, layer, filterExpression=None, attributes='*', orderBy=None): """ Get data from a db table, - optionnally filtered by given expression + optionally filtered by given expression and get corresponding QgsFeature objects """ QApplication.setOverrideCursor(Qt.WaitCursor) @@ -855,10 +855,10 @@ def onSearchItemChoose(self, key, label, value): QApplication.restoreOverrideCursor() return None - # Set filter expression for parcell child data + # Set filter expression for parcelle child data ckey = self.searchComboBoxes[key]['search']['parcelle_child'] if key == 'adresse': - filterExpression = "voie = '%s'" % value['voie'] + filterExpression = "SUBSTR(voie, 1, 6) || SUBSTR(voie, 12, 4) = '%s%s'" % (value['voie'][0:6], value['voie'][11:]) if key == 'proprietaire': filterExpression = "comptecommunal IN (%s)" % ', '.join(value['cc']) diff --git a/cadastre/scripts/plugin/edigeo_create_indexes.sql b/cadastre/scripts/plugin/edigeo_create_indexes.sql index 99150506..c4a76a51 100644 --- a/cadastre/scripts/plugin/edigeo_create_indexes.sql +++ b/cadastre/scripts/plugin/edigeo_create_indexes.sql @@ -59,6 +59,8 @@ DROP INDEX IF EXISTS idx_local00_parcelle; CREATE INDEX idx_local00_parcelle ON local00 (parcelle); DROP INDEX IF EXISTS idx_local00_voie; CREATE INDEX idx_local00_voie ON local00 (voie); +DROP INDEX IF EXISTS idx_local00_voie_substr; +CREATE INDEX idx_local00_voie_substr ON local00 ((substr(voie, 1, 6) || substr(voie, 12, 4))); DROP INDEX IF EXISTS idx_local10_local00; CREATE INDEX idx_local10_local00 ON local10 (local00); DROP INDEX IF EXISTS idx_local10_comptecommunal; @@ -69,5 +71,7 @@ DROP INDEX IF EXISTS idx_pevtaxation_pev; CREATE INDEX idx_pevtaxation_pev ON pevtaxation (pev); DROP INDEX IF EXISTS idx_parcelle_voie; CREATE INDEX idx_parcelle_voie ON parcelle (voie); +DROP INDEX IF EXISTS idx_parcelle_voie_substr; +CREATE INDEX idx_parcelle_voie_substr ON parcelle ((substr(voie, 1, 6) || substr(voie, 12, 4))); DROP INDEX IF EXISTS idx_parcelle_comptecommunal; CREATE INDEX idx_parcelle_comptecommunal ON parcelle (comptecommunal); diff --git a/cadastre/scripts/plugin/edigeo_create_table_parcelle_info_majic.sql b/cadastre/scripts/plugin/edigeo_create_table_parcelle_info_majic.sql index 122a1d4e..ebe01270 100644 --- a/cadastre/scripts/plugin/edigeo_create_table_parcelle_info_majic.sql +++ b/cadastre/scripts/plugin/edigeo_create_table_parcelle_info_majic.sql @@ -30,12 +30,12 @@ CREATE INDEX aa ON [PREFIXE]parcelle (parcelle ); CREATE INDEX bb ON [PREFIXE]parcelle (comptecommunal ); CREATE INDEX cc ON [PREFIXE]parcelle (ccocom ); CREATE INDEX dd ON [PREFIXE]parcelle (ccodep ); -CREATE INDEX ee ON [PREFIXE]parcelle (voie ); +CREATE INDEX ee ON [PREFIXE]parcelle ((SUBSTR(voie, 1, 6) || SUBSTR(voie, 12, 4))); CREATE INDEX ff ON [PREFIXE]proprietaire (comptecommunal ); CREATE INDEX gg ON [PREFIXE]geo_parcelle (geo_parcelle ); CREATE INDEX hh ON [PREFIXE]commune (ccocom ); CREATE INDEX ii ON [PREFIXE]commune (ccodep ); -CREATE INDEX jj ON [PREFIXE]voie (voie ); +CREATE INDEX jj ON [PREFIXE]voie ((SUBSTR(voie, 1, 6) || SUBSTR(voie, 12, 4))); INSERT INTO [PREFIXE]parcelle_info SELECT gp.ogc_fid AS ogc_fid, gp.geo_parcelle, gp.idu AS idu, gp.tex AS tex, gp.geo_section AS geo_section, @@ -89,7 +89,7 @@ LEFT OUTER JOIN [PREFIXE]parcelle p ON gp.geo_parcelle = p.parcelle LEFT OUTER JOIN [PREFIXE]proprietaire pr ON p.comptecommunal = pr.comptecommunal LEFT OUTER JOIN [PREFIXE]ccodro ON ccodro.ccodro = pr.ccodro LEFT OUTER JOIN [PREFIXE]commune c ON p.ccocom = c.ccocom AND c.ccodep = p.ccodep -LEFT OUTER JOIN [PREFIXE]voie v ON v.voie = p.voie +LEFT OUTER JOIN [PREFIXE]voie v ON SUBSTR(p.voie, 1, 6) || SUBSTR(p.voie, 12, 4) = SUBSTR(v.voie, 1, 6) || SUBSTR(v.voie, 12, 4) GROUP BY gp.geo_parcelle, gp.ogc_fid, gp.idu, gp.tex, gp.geo_section, gp.lot, c.libcom, p.ccocom, gp.geom, p.dcntpa, v.libvoi, p.dnvoiri, v.natvoi, p.comptecommunal, p.cconvo, p.voie, p.dvoilib, p.gurbpa, p.gparbat, @@ -111,7 +111,7 @@ DROP INDEX jj; ALTER TABLE [PREFIXE]parcelle_info ADD CONSTRAINT parcelle_info_pk PRIMARY KEY (ogc_fid); CREATE INDEX parcelle_info_geom_idx ON [PREFIXE]parcelle_info USING gist (geom); CREATE INDEX parcelle_info_geo_section_idx ON [PREFIXE]parcelle_info (geo_section); -CREATE INDEX parcelle_info_voie_idx ON [PREFIXE]parcelle_info (voie); +CREATE INDEX parcelle_info_voie_substr_idx ON [PREFIXE]parcelle_info ((substr(voie, 1, 6) || substr(voie, 12, 4))); CREATE INDEX parcelle_info_comptecommunal_idx ON [PREFIXE]parcelle_info (comptecommunal); CREATE INDEX parcelle_info_codecommune_idx ON [PREFIXE]parcelle_info (codecommune ); CREATE INDEX parcelle_info_geo_parcelle_idx ON [PREFIXE]parcelle_info (geo_parcelle ); diff --git a/cadastre/scripts/plugin/edigeo_drop_indexes.sql b/cadastre/scripts/plugin/edigeo_drop_indexes.sql index 6ca751be..38deccd3 100644 --- a/cadastre/scripts/plugin/edigeo_drop_indexes.sql +++ b/cadastre/scripts/plugin/edigeo_drop_indexes.sql @@ -114,10 +114,12 @@ DROP INDEX IF EXISTS idx_proprietaire_proprietaire; DROP INDEX IF EXISTS idx_proprietaire_comptecommunal; DROP INDEX IF EXISTS idx_local00_parcelle; DROP INDEX IF EXISTS idx_local00_voie; +DROP INDEX IF EXISTS idx_local00_voie_substr; DROP INDEX IF EXISTS idx_local10_local00; DROP INDEX IF EXISTS idx_local10_comptecommunal; DROP INDEX IF EXISTS idx_pevexoneration_pev; DROP INDEX IF EXISTS idx_pevtaxation_pev; DROP INDEX IF EXISTS idx_parcelle_voie; +DROP INDEX IF EXISTS idx_parcelle_voie_substr; DROP INDEX IF EXISTS idx_parcelle_comptecommunal; DROP INDEX IF EXISTS idx_geo_unite_fonciere_id; diff --git a/cadastre/scripts/plugin/majic_recuperation_locaux_par_parcelle.sql b/cadastre/scripts/plugin/majic_recuperation_locaux_par_parcelle.sql index 8028a089..9037bb6e 100644 --- a/cadastre/scripts/plugin/majic_recuperation_locaux_par_parcelle.sql +++ b/cadastre/scripts/plugin/majic_recuperation_locaux_par_parcelle.sql @@ -61,7 +61,7 @@ WITH infos AS ( INNER JOIN local00 l ON l.parcelle = p.parcelle INNER JOIN local10 l10 ON l10.local00 = l.local00 INNER JOIN pev ON pev.local10 = l10.local10 - LEFT JOIN voie v ON v.voie = l.voie + LEFT JOIN voie v ON SUBSTR(l.voie, 1, 6) || SUBSTR(l.voie, 12, 4) = SUBSTR(v.voie, 1, 6) || SUBSTR(v.voie, 12, 4) LEFT JOIN pevtaxation pt ON pt.pev = pev.pev LEFT JOIN pevexoneration px ON px.pev = pev.pev LEFT JOIN "dteloc" ON l10.dteloc = dteloc.dteloc diff --git a/cadastre/templates/parcelle_info_locaux_detail.sql b/cadastre/templates/parcelle_info_locaux_detail.sql index 44d439cf..0c6f6622 100644 --- a/cadastre/templates/parcelle_info_locaux_detail.sql +++ b/cadastre/templates/parcelle_info_locaux_detail.sql @@ -9,7 +9,7 @@ WITH infos AS ( -- adresse ltrim(l.dnvoiri, '0') || l.dindic AS l_numero_voirie, - CASE WHEN v.libvoi IS NOT NULL THEN v.natvoi || v.libvoi ELSE p.cconvo || p.dvoilib END AS l_adresse, + CASE WHEN v.libvoi IS NOT NULL THEN v.natvoi || ' ' || v.libvoi ELSE p.cconvo || ' ' || p.dvoilib END AS l_adresse, -- proprio et acte string_agg((l10.ccodep || l10.ccocom || '-' ||l10.dnupro), '|') AS l10_compte_proprietaire, @@ -66,7 +66,8 @@ WITH infos AS ( INNER JOIN local00 l ON l.parcelle = p.parcelle INNER JOIN local10 l10 ON l10.local00 = l.local00 INNER JOIN pev ON pev.local10 = l10.local10 - LEFT JOIN voie v ON v.voie = l.voie + LEFT JOIN voie v + ON SUBSTR(l.voie, 1, 6) || SUBSTR(l.voie, 12, 4) = SUBSTR(v.voie, 1, 6) || SUBSTR(v.voie, 12, 4) LEFT JOIN pevtaxation pt ON pt.pev = pev.pev LEFT JOIN pevexoneration px ON px.pev = pev.pev LEFT JOIN "dteloc" ON l10.dteloc = dteloc.dteloc diff --git a/cadastre/templates/parcelle_info_parcelle_majic.sql b/cadastre/templates/parcelle_info_parcelle_majic.sql index 2833fd95..55141c49 100644 --- a/cadastre/templates/parcelle_info_parcelle_majic.sql +++ b/cadastre/templates/parcelle_info_parcelle_majic.sql @@ -21,7 +21,7 @@ SELECT coalesce( CASE WHEN v.libvoi IS NOT NULL THEN trim(ltrim(p.dnvoiri, '0') || ' ' || trim(coalesce(v.natvoi, '')) || ' ' || v.libvoi) - ELSE ltrim(p.cconvo, '0') || p.dvoilib + ELSE trim(ltrim(p.cconvo, '0') || ' ' || p.dvoilib) END, '') || '' || '