Skip to content

Commit c3fb06b

Browse files
committed
(basic/sql_function) script for the documentation
1 parent 10add9b commit c3fb06b

File tree

1 file changed

+0
-57
lines changed

1 file changed

+0
-57
lines changed

docs/scripts/basic/sql_function/images.sql

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,3 @@
1-
DROP FUNCTION IF EXISTS wrk_image;
2-
DROP VIEW IF EXISTS using_vehicle;
3-
4-
CREATE OR REPLACE FUNCTION wrk_image(
5-
IN edges_subset REGCLASS,
6-
IN source BIGINT, -- in terms of osm_id
7-
IN target BIGINT, -- in terms of osm_id
8-
OUT seq INTEGER,
9-
OUT id BIGINT,
10-
OUT node BIGINT,
11-
OUT source BIGINT,
12-
OUT seconds FLOAT,
13-
OUT name TEXT,
14-
OUT length_m FLOAT,
15-
OUT geom geometry,
16-
OUT geom_readable TEXT,
17-
OUT azimuth_geom FLOAT,
18-
OUT route_readable TEXT,
19-
OUT route_geom geometry,
20-
OUT azimuth FLOAT
21-
)
22-
RETURNS SETOF record AS
23-
$BODY$
24-
WITH
25-
results AS (
26-
SELECT seq, edge AS id, cost AS seconds,
27-
node
28-
FROM pgr_dijkstra(
29-
'SELECT * FROM ' || edges_subset,
30-
source, target)
31-
),
32-
additional AS (
33-
SELECT
34-
seq, id, node, source_osm, seconds,
35-
name, length_m,
36-
the_geom,
37-
ST_AsText(the_geom),
38-
degrees(ST_azimuth(ST_StartPoint(the_geom), ST_EndPoint(the_geom))) AS azimuth_geom,
39-
CASE
40-
WHEN node = source_osm THEN ST_AsText(the_geom)
41-
ELSE ST_AsText(ST_Reverse(the_geom))
42-
END AS route_readable,
43-
44-
CASE
45-
WHEN node = source_osm THEN the_geom
46-
ELSE ST_Reverse(the_geom)
47-
END AS route_geom
48-
49-
FROM results
50-
LEFT JOIN ways ON (gid = id)
51-
)
52-
SELECT *,
53-
degrees(ST_azimuth(ST_StartPoint(route_geom), ST_EndPoint(route_geom))) AS azimuth
54-
FROM additional
55-
ORDER BY seq;
56-
$BODY$
57-
LANGUAGE 'sql';
581

592
CREATE OR REPLACE VIEW using_vehicle AS
603
SELECT *

0 commit comments

Comments
 (0)