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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
|
/*PGR-GNU*****************************************************************
Copyright (c) 2015 ~ pgRouting developers
Mail: project@pgrouting.org
Copyright (c) 2015 Celia Virginia Vergara Castillo
mail: vicky_vergara@hotmail.com
------
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
********************************************************************PGR-GNU*/
CREATE TYPE pgr_costResult AS
(
seq integer,
id1 integer,
id2 integer,
cost float8
);
CREATE TYPE pgr_costResult3 AS
(
seq integer,
id1 integer,
id2 integer,
id3 integer,
cost float8
);
CREATE TYPE pgr_geomResult AS
(
seq integer,
id1 integer,
id2 integer,
geom geometry
);
----------------------------------------------------------------------------
-- Routing function: pgr_dijkstra
-- Developer: Vicky Vergara
--
--
-- Availability:
-- - Created on v2.0.0
-- - Deprecated signature on v2.1.0
-- - Moved to legacy on v3.0
--
-- Use the new signatures of pgr_dijkstra instead
----------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION pgr_dijkstra(
edges_sql TEXT,
start_vid INTEGER,
end_vid INTEGER,
directed BOOLEAN,
has_rcost BOOLEAN)
RETURNS SETOF pgr_costresult AS
$BODY$
DECLARE
has_reverse BOOLEAN;
sql TEXT;
BEGIN
RETURN query SELECT seq-1 AS seq, node::integer AS id1, edge::integer AS id2, cost
FROM _pgr_dijkstra(sql, ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], directed, false);
END
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100
ROWS 1000;
-----------------------------------------------------------------------------
--- Routing function: pgr_drivingDistance
--- Developer: Vicky Vergara
---
---
--- Availability:
--- - Created on v2.0.0
--- - Deprecated on v2.1.0
--- - moved to legacy on v3.0.0
---
--- Use the new signatures of pgr_drivingDistance instead
-----------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION pgr_drivingDistance(edges_sql text, source INTEGER, distance FLOAT8, directed BOOLEAN, has_rcost BOOLEAN)
RETURNS SETOF pgr_costresult AS
$BODY$
SELECT seq - 1, node::INTEGER, edge::INTEGER, agg_cost
FROM pgr_drivingDistance($1, ARRAY[$2]::BIGINT[], $3, $4);
$BODY$
LANGUAGE sql VOLATILE
COST 100
ROWS 1000;
----------------------------------------------------------------------------
-- Routing function: pgr_ksp
-- Developer: Vicky Vergara
--
--
-- Availability:
-- - Created on v2.0.0
-- - Deprecated on v2.1.0
-- - moved to legacy on v3.0
--
-- Use the new signature of pgr_KSP instead
----------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION pgr_ksp(edges_sql text, start_vid integer, end_vid integer, k integer, has_rcost boolean)
RETURNS SETOF pgr_costresult3 AS
$BODY$
SELECT ((row_number() over()) -1)::integer, (path_id - 1)::integer, node::integer, edge::integer, cost
FROM pgr_ksp($1::text, $2::BIGINT, $3::BIGINT, $4, TRUE, FALSE) WHERE path_id <= k;
$BODY$
LANGUAGE sql VOLATILE
COST 100
ROWS 1000;
----------------------------------------------------------------------------
-- Routing function: pgr_kdijkstraPath
-- Developer: Steve Woodbridge
--
-- Availability:
-- - Created on v2.0.0
-- - Deprecated signature on v2.2.0
-- - Moved to legacy on v3.0
--
-- Use the new signatures of pgr_dijkstra instead
----------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION pgr_kdijkstraPath(
sql text,
source INTEGER,
targets INTEGER ARRAY,
directed BOOLEAN,
has_rcost BOOLEAN)
RETURNS SETOF pgr_costResult3 AS
$BODY$
SELECT (row_number() over () -1)::integer, end_vid::INTEGER, node::INTEGER, edge::INTEGER, cost
FROM pgr_dijkstra($1, $2, $3, $4);
$BODY$
LANGUAGE sql VOLATILE
COST 100
ROWS 1000;
----------------------------------------------------------------------------
-- Routing function: pgr_kdijkstraCost
-- Developer: Steve Woodbridge
--
-- Availability:
-- - Created on v2.0.0
-- - Deprecated signature on v2.2.0
-- - Moved to legacy on v3.0
--
-- Use the new signatures of pgr_dijkstraCost instead
----------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION pgr_kdijkstracost(
sql text,
source INTEGER,
targets INTEGER array,
directed BOOLEAN,
has_rcost BOOLEAN)
RETURNS SETOF pgr_costResult AS
$BODY$
SELECT (row_number() over () -1)::integer, start_vid::integer, end_vid::INTEGER, agg_cost
FROM pgr_dijkstraCost($1, $2, $3, $4);
$BODY$
LANGUAGE sql VOLATILE
COST 100
ROWS 1000;
----------------------------------------------------------------------------
-- Routing function: pgr_apspJohnson
-- Developer: Vicky Vergara
--
--
-- Availability:
-- - Created on v2.0.0
-- - Deprecated on v2.2.0
-- - Moved to legacy on v3.0
--
-- Use the new signatures of pgr_johnson instead
----------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION pgr_apspJohnson(edges_sql text)
RETURNS SETOF pgr_costResult AS
$BODY$
SELECT (row_number() over () - 1)::INTEGER, start_vid::INTEGER, end_vid::INTEGER, agg_cost
FROM pgr_johnson($1, TRUE);
$BODY$
LANGUAGE sql VOLATILE
COST 100
ROWS 1000;
----------------------------------------------------------------------------
-- Routing function: pgr_apspWarshall
-- Developer: Vicky Vergara
--
--
-- Availability:
-- - Created on v2.0.0
-- - Deprecated on v2.2.0
-- - Moved to legacy on v3.0
--
-- Use the new signatures of pgr_floydWarshall instead
----------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION pgr_apspWarshall(edges_sql text, directed BOOLEAN, has_rcost BOOLEAN)
RETURNS SETOF pgr_costResult AS
$BODY$
SELECT (row_number() over () -1)::INTEGER, start_vid::INTEGER, end_vid::INTEGER, agg_cost
FROM pgr_floydWarshall($1, $2);
$BODY$
LANGUAGE sql VOLATILE
COST 100
ROWS 1000;
----------------------------------------------------------------------------
-- Routing function: pgr_astar
-- Developer: Vicky Vergara
--
--
-- Availability:
-- - Created on v2.0.0
-- - Deprecated on v2.3.0
-- - Moved to legacy on v3.0
--
-- Use the new signatures of pgr_aStar instead
----------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION pgr_astar(edges_sql TEXT, source_id INTEGER, target_id INTEGER, directed BOOLEAN, has_rcost BOOLEAN)
RETURNS SETOF pgr_costresult AS
$BODY$
DECLARE
has_reverse BOOLEAN;
sql TEXT;
BEGIN
RETURN query SELECT seq - 1 AS seq, node::INTEGER AS id1, edge::INTEGER AS id2, cost
FROM pgr_astar(sql, ARRAY[$2], ARRAY[$3], directed);
END
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100
ROWS 1000;
----------------------------------------------------------------------------
-- Routing function: pgr_bdDijkstra
-- Developer: Vicky Vergara
--
--
-- Availability:
-- - Created on v2.0.0
-- - Deprecated on v2.4.0
-- - Moved to legacy on v3.0
--
-- Use the new signatures of pgr_bdDijkstra instead
----------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION pgr_bdDijkstra(edges_sql TEXT, start_vid INTEGER, end_vid INTEGER, directed BOOLEAN, has_rcost BOOLEAN)
RETURNS SETOF pgr_costresult AS
$BODY$
DECLARE
has_reverse BOOLEAN;
sql TEXT;
BEGIN
SELECT seq - 1 AS seq, node::integer AS id1, edge::integer AS id2, cost
FROM pgr_bdDijkstra($1, ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], $4);
END
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100
ROWS 1000;
----------------------------------------------------------------------------
-- Routing function: pgr_bdAstar
-- Developer: Vicky Vergara
--
--
-- Availability:
-- - Created on v2.0.0
-- - Deprecated on v2.5.0
-- - Moved to legacy on v3.0
--
-- Use the new signatures of pgr_bdAstar instead
----------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION pgr_bdAstar(
edges_sql TEXT,
start_vid INTEGER,
end_vid INTEGER,
directed BOOLEAN,
has_rcost BOOLEAN)
RETURNS SETOF pgr_costresult AS
$BODY$
SELECT seq - 1 AS seq, node::integer AS id1, edge::integer AS id2, cost
FROM pgr_bdAstar($1, ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], $4);
$BODY$
LANGUAGE sql VOLATILE
COST 100
ROWS 1000;
|