-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathworkshop7.sql
33 lines (29 loc) · 852 Bytes
/
workshop7.sql
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
CREATE TYPE route_intersect_type_v1 AS
(distance double precision,
istouching boolean
);
--idleri tanımlı iki yolun bboxları arasındaki uzaklığı döndüren fonksiyon
--uzaklık 0 ise istouching değerini true set eder
CREATE OR REPLACE FUNCTION route_intersect_v1(
int1 integer,
int2 integer)
RETURNS route_intersect_type_v1 AS
$BODY$
DECLARE
route1 text;
route2 text;
returnVal route_intersect_type_v1;
BEGIN
select geom from roads where ogc_fid = int1 into route1;
select geom from roads where ogc_fid = int2 into route2;
select route1 <#> route2 into returnVal.distance;
returnVal.istouching = false;
if returnVal.distance = 0 then
returnVal.istouching = true;
end if;
return returnVal;
END;
$BODY$
LANGUAGE plpgsql VOLATILE STRICT
COST 100;
select route_intersect_v1(1806,13621);