-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsicob_snap_polyline2polyline.sql
More file actions
33 lines (31 loc) · 1 KB
/
Copy pathsicob_snap_polyline2polyline.sql
File metadata and controls
33 lines (31 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
SET CLIENT_ENCODING TO 'utf8';
CREATE OR REPLACE FUNCTION public.sicob_snap_polyline2polyline(polyline_a geometry, polyline_b geometry)
RETURNS geometry
LANGUAGE plpgsql
AS $function$
DECLARE
new_borde geometry;
BEGIN
WITH
snapzone AS (
SELECT st_union(ST_Buffer(polyline_a, 6::float/111000)) as the_geom
),
line_pol_b AS --Obteniendo las lineas del poligono poly_b dentro de la zona de snapping
(
SELECT row_number() over() as segment, (dp).geom as the_geom, st_startpoint((dp).geom) as pini, st_endpoint((dp).geom) as pfin
FROM(
SELECT st_dump(the_geom) as dp
FROM (
SELECT st_intersection(polyline_b, (SELECT the_geom from snapzone )
) as the_geom
) r
) q
)
SELECT sicob_snap_line2line(polyline_a, (SELECT st_union(the_geom) FROM line_pol_b)) into new_borde;
RETURN new_borde;
EXCEPTION
WHEN others THEN
RAISE EXCEPTION 'geoSICOB (sicob_snap_polyline2polyline): % (%)', SQLERRM, SQLSTATE;
END;
$function$