Update phase 5
test 2
This commit is contained in:
parent
e1c14f84a6
commit
062bd6b16d
|
@ -144,7 +144,7 @@ try:
|
||||||
|
|
||||||
print(" Vidage de la table d'import")
|
print(" Vidage de la table d'import")
|
||||||
sql_truncate = "TRUNCATE TABLE phase_5_pk_umap_4326 ;"
|
sql_truncate = "TRUNCATE TABLE phase_5_pk_umap_4326 ;"
|
||||||
#db_redadeg_cursor.execute(sql_truncate)
|
db_redadeg_cursor.execute(sql_truncate)
|
||||||
print(" fait")
|
print(" fait")
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ try:
|
||||||
"-nln", "phase_5_pk_umap_4326",
|
"-nln", "phase_5_pk_umap_4326",
|
||||||
"-lco", "GEOMETRY_NAME=the_geom"]
|
"-lco", "GEOMETRY_NAME=the_geom"]
|
||||||
#print(cmd)
|
#print(cmd)
|
||||||
#subprocess.call(cmd)
|
subprocess.call(cmd)
|
||||||
|
|
||||||
# on efface le fichier aussitôt
|
# on efface le fichier aussitôt
|
||||||
os.remove(layer_file)
|
os.remove(layer_file)
|
||||||
|
@ -219,8 +219,48 @@ ORDER BY pk_id ;"""
|
||||||
print(" ARRÊT : corriger puis relancer")
|
print(" ARRÊT : corriger puis relancer")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
print("")
|
||||||
|
|
||||||
|
|
||||||
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
print(" Test : nb de pk déplacés par secteur")
|
||||||
|
|
||||||
|
sql_tdb_mouvements = """
|
||||||
|
WITH secteurs AS (
|
||||||
|
SELECT id FROM secteur
|
||||||
|
WHERE id > 0 AND id < 999
|
||||||
|
ORDER BY id
|
||||||
|
),
|
||||||
|
test AS (
|
||||||
|
SELECT r.secteur_id, COUNT(*)
|
||||||
|
FROM phase_5_pk_ref r FULL OUTER JOIN phase_5_pk_umap u ON r.pk_id = u.pk_id
|
||||||
|
WHERE TRUNC(ST_Distance(r.the_geom, u.the_geom)::numeric,2) > 1
|
||||||
|
GROUP BY r.secteur_id
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
secteurs.id,
|
||||||
|
test.count
|
||||||
|
FROM secteurs FULL OUTER JOIN test ON secteurs.id = test.secteur_id
|
||||||
|
"""
|
||||||
|
|
||||||
|
db_redadeg_cursor.execute(sql_tdb_mouvements)
|
||||||
|
controle_table = db_redadeg_cursor.fetchall()
|
||||||
|
total_pk_deplaces = 0
|
||||||
|
|
||||||
|
for record in controle_table:
|
||||||
|
secteur_id = record[0]
|
||||||
|
nb_pk_deplaces = record[1]
|
||||||
|
|
||||||
|
if nb_pk_deplaces is None :
|
||||||
|
nb_pk_deplaces = 0
|
||||||
|
print(f" aucun PK déplacé pour le secteur {secteur_id}")
|
||||||
|
else:
|
||||||
|
print(f" {nb_pk_deplaces} PK déplacés pour le secteur {secteur_id}")
|
||||||
|
|
||||||
|
total_pk_deplaces += nb_pk_deplaces
|
||||||
|
|
||||||
|
print(f" {total_pk_deplaces} PK déplacés au total")
|
||||||
|
|
||||||
|
|
||||||
print("")
|
print("")
|
||||||
print("")
|
print("")
|
||||||
|
|
|
@ -760,6 +760,34 @@ CREATE INDEX phase_5_pk_umap_geom_idx ON phase_5_pk_umap USING gist(the_geom);
|
||||||
ALTER TABLE phase_5_pk_umap OWNER TO redadeg;
|
ALTER TABLE phase_5_pk_umap OWNER TO redadeg;
|
||||||
|
|
||||||
|
|
||||||
|
-- une vue de contrôle
|
||||||
|
DROP VIEW IF EXISTS phase_5_pk_diff ;
|
||||||
|
CREATE VIEW phase_5_pk_diff AS
|
||||||
|
WITH ref AS (
|
||||||
|
SELECT secteur_id, COUNT(pk_id) as ref
|
||||||
|
FROM phase_5_pk_ref
|
||||||
|
GROUP BY secteur_id
|
||||||
|
),
|
||||||
|
umap AS (
|
||||||
|
SELECT secteur_id, COUNT(pk_id) as umap
|
||||||
|
FROM phase_5_pk_umap
|
||||||
|
GROUP BY secteur_id
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
r.secteur_id,
|
||||||
|
r.ref,
|
||||||
|
u.umap,
|
||||||
|
r.ref - u.umap AS diff,
|
||||||
|
CASE
|
||||||
|
WHEN r.ref < u.umap THEN 'plus'
|
||||||
|
WHEN r.ref > u.umap THEN 'moins'
|
||||||
|
WHEN r.ref = u.umap THEN 'pareil'
|
||||||
|
ELSE 'problème'
|
||||||
|
END AS test
|
||||||
|
FROM "ref" r JOIN umap u ON r.secteur_id = u.secteur_id
|
||||||
|
ORDER BY r.secteur_id ;
|
||||||
|
|
||||||
|
|
||||||
-- la table finale
|
-- la table finale
|
||||||
DROP TABLE IF EXISTS phase_5_pk CASCADE ;
|
DROP TABLE IF EXISTS phase_5_pk CASCADE ;
|
||||||
CREATE TABLE phase_5_pk
|
CREATE TABLE phase_5_pk
|
||||||
|
|
Loading…
Reference in a new issue