prise en compte du secteur pour les points de forçage

This commit is contained in:
MaelREBOUX 2021-10-06 22:56:09 +02:00
parent 5ea3089fd4
commit ca31ae5cd6
2 changed files with 4 additions and 1 deletions

View file

@ -184,6 +184,7 @@ CREATE TABLE phase_2_point_nettoyage
id serial, id serial,
pt_id bigint, pt_id bigint,
edge_id bigint, edge_id bigint,
secteur_id integer,
distance numeric, distance numeric,
the_geom geometry, the_geom geometry,
CONSTRAINT phase_2_point_nettoyage_pkey PRIMARY KEY (id), CONSTRAINT phase_2_point_nettoyage_pkey PRIMARY KEY (id),

View file

@ -7,6 +7,7 @@ WITH candidates AS
SELECT SELECT
pt_org.ogc_fid AS pt_id, pt_org.ogc_fid AS pt_id,
edge.id AS edge_id, edge.id AS edge_id,
edge.secteur_id,
ST_Distance(pt_org.the_geom, ST_ClosestPoint(edge.the_geom, pt_org.the_geom)) AS distance, ST_Distance(pt_org.the_geom, ST_ClosestPoint(edge.the_geom, pt_org.the_geom)) AS distance,
ST_Snap( ST_Snap(
pt_org.the_geom, -- le point d'origine à recaler pt_org.the_geom, -- le point d'origine à recaler
@ -15,7 +16,7 @@ SELECT
) AS the_geom ) AS the_geom
FROM FROM
(SELECT ogc_fid::integer, ST_Transform(the_geom,2154) AS the_geom FROM phase_2_point_nettoyage_3857) AS pt_org, (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 (SELECT id, secteur_id, the_geom FROM osm_roads_pgr) AS edge
WHERE WHERE
ST_INTERSECTS(edge.the_geom, ST_BUFFER(ST_Transform(pt_org.the_geom,2154) ,2) ) 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)) ORDER BY pt_org.ogc_fid, ST_Distance(pt_org.the_geom, ST_ClosestPoint(edge.the_geom, pt_org.the_geom))
@ -25,6 +26,7 @@ INSERT INTO phase_2_point_nettoyage
nextval('phase_2_point_nettoyage_id_seq'::regclass), nextval('phase_2_point_nettoyage_id_seq'::regclass),
pt_id, pt_id,
edge_id, edge_id,
(LEFT(secteur_id::text,1)||'00')::integer AS secteur_id,
distance, distance,
the_geom the_geom
FROM candidates ; FROM candidates ;