phase 2 : recalage des points de nettoyage
la couche est hardcodée
This commit is contained in:
parent
48d315e1b2
commit
275f1d8b1b
|
@ -17,14 +17,15 @@ fi
|
||||||
|
|
||||||
|
|
||||||
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||||
echo " Récupération des fichiers geojson depuis umap"
|
echo " PK secteurs"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
# on commence par supprimer la table
|
# on commence par supprimer la table
|
||||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME -c "DROP TABLE IF EXISTS phase_2_pk_secteur_3857 CASCADE;"
|
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME -c "DROP TABLE IF EXISTS phase_2_pk_secteur_3857 CASCADE;"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
echo " récupération des fichiers geojson depuis les cartes umap"
|
||||||
|
echo ""
|
||||||
|
|
||||||
# on va lire le fichier de config des couches umap pour boucler
|
# on va lire le fichier de config des couches umap pour boucler
|
||||||
IFS="="
|
IFS="="
|
||||||
|
@ -45,15 +46,9 @@ do
|
||||||
echo " fait"
|
echo " fait"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
# fin de la boucle de lecture des layers umap
|
# fin de la boucle de lecture des layers umap
|
||||||
done < $rep_data/umap_phase_2_layers.txt
|
done < $rep_data/umap_phase_2_layers.txt
|
||||||
|
|
||||||
|
|
||||||
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
|
||||||
echo " Application des traitements SQL"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
echo " recalage des PK secteurs sur un nœud du réseau routable"
|
echo " recalage des PK secteurs sur un nœud du réseau routable"
|
||||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME < sql/phase_2.1_recalage_pk_secteurs.sql
|
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME < sql/phase_2.1_recalage_pk_secteurs.sql
|
||||||
echo " fait"
|
echo " fait"
|
||||||
|
@ -61,6 +56,32 @@ echo ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||||
|
echo " Points de nettoyage"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# on commence par supprimer la table
|
||||||
|
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME -c "DROP TABLE IF EXISTS phase_2_point_nettoyage_3857 CASCADE;"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
echo " récupération des fichiers geojson depuis la carte umap"
|
||||||
|
echo ""
|
||||||
|
curl -sS http://umap.openstreetmap.fr/fr/datalayer/1899462/ > $rep_data/phase_2_umap_points_nettoyage.geojson
|
||||||
|
echo " fait"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
echo " chargement dans la couche d'import"
|
||||||
|
ogr2ogr -f "PostgreSQL" PG:"host=$DB_HOST port=$DB_PORT user=$DB_USER password=$DB_PASSWD dbname=$DB_NAME" \
|
||||||
|
$rep_data/phase_2_umap_points_nettoyage.geojson -nln phase_2_point_nettoyage_3857 -lco GEOMETRY_NAME=the_geom -explodecollections
|
||||||
|
echo " fait"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
echo " recalage des points de nettoyage sur un nœud du réseau routable"
|
||||||
|
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME < sql/phase_2.2_recalage_points_nettoyage.sql
|
||||||
|
echo " TODO"
|
||||||
|
echo ""
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo ""
|
echo ""
|
||||||
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||||
|
|
34
scripts_v2/sql/phase_2.2_recalage_points_nettoyage.sql
Normal file
34
scripts_v2/sql/phase_2.2_recalage_points_nettoyage.sql
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
|
||||||
|
-- on recale également les points de nettoyage sur le tracé
|
||||||
|
TRUNCATE TABLE phase_2_point_nettoyage ;
|
||||||
|
|
||||||
|
WITH candidates AS
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
pt_org.ogc_fid AS pt_id,
|
||||||
|
edge.id AS edge_id,
|
||||||
|
ST_Distance(pt_org.the_geom, ST_ClosestPoint(edge.the_geom, pt_org.the_geom)) AS distance,
|
||||||
|
ST_Snap(
|
||||||
|
pt_org.the_geom, -- le point d'origine à recaler
|
||||||
|
ST_ClosestPoint(edge.the_geom, pt_org.the_geom), -- le point le plus près dans la couche de nœuds
|
||||||
|
ST_Distance(pt_org.the_geom, ST_ClosestPoint(edge.the_geom, pt_org.the_geom))* 1.01 -- dans la distance de ce plus proche point
|
||||||
|
) AS the_geom
|
||||||
|
FROM
|
||||||
|
(SELECT ogc_fid::integer, ST_Transform(the_geom,2154) AS the_geom FROM phase_2_point_nettoyage_3857) AS pt_org,
|
||||||
|
(SELECT id, the_geom FROM osm_roads_pgr) AS edge
|
||||||
|
WHERE
|
||||||
|
ST_INTERSECTS(edge.the_geom, ST_BUFFER(ST_Transform(pt_org.the_geom,2154) ,2) )
|
||||||
|
ORDER BY pt_org.ogc_fid, ST_Distance(pt_org.the_geom, ST_ClosestPoint(edge.the_geom, pt_org.the_geom))
|
||||||
|
)
|
||||||
|
INSERT INTO phase_2_point_nettoyage
|
||||||
|
SELECT
|
||||||
|
nextval('phase_2_point_nettoyage_id_seq'::regclass),
|
||||||
|
pt_id,
|
||||||
|
edge_id,
|
||||||
|
distance,
|
||||||
|
the_geom
|
||||||
|
FROM candidates ;
|
||||||
|
|
||||||
|
-- un peu de ménage
|
||||||
|
VACUUM FULL phase_2_point_nettoyage ;
|
||||||
|
|
Loading…
Reference in a new issue