Skip to content

Commit d82f1c3

Browse files
committed
(sql) removing pgrouting dependency
1 parent 006d713 commit d82f1c3

File tree

7 files changed

+61
-16
lines changed

7 files changed

+61
-16
lines changed

sql/optimize/optimizeRaw.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*PGR-GNU*****************************************************************
2-
File: optimize.sql
2+
File: optimizeRaw.sql
33
44
Copyright (c) 2021 pgRouting developers
55
@@ -48,10 +48,10 @@ $BODY$
4848

4949
SELECT *
5050
FROM _vrp_optimize(
51-
_pgr_get_statement($1),
52-
_pgr_get_statement($2),
53-
_pgr_get_statement($3),
54-
_pgr_get_statement($4),
51+
_vrp_get_statement($1),
52+
_vrp_get_statement($2),
53+
_vrp_get_statement($3),
54+
_vrp_get_statement($4),
5555
factor, max_cycles, execution_date,
5656
check_triangle_inequality, subdivision_kind,
5757
false);

sql/optimize/optimizeUpdateRaw.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ BEGIN
6666
SET %11$I = n.stops
6767
FROM new_stops AS n WHERE v.%12$I = n.vehicle_id
6868
$$,
69-
_pgr_get_statement($1),
70-
_pgr_get_statement($2),
71-
_pgr_get_statement($3),
72-
_pgr_get_statement($4),
69+
_vrp_get_statement($1),
70+
_vrp_get_statement($2),
71+
_vrp_get_statement($3),
72+
_vrp_get_statement($4),
7373
factor, max_cycles, execution_date,
7474
check_triangle_inequality, subdivision_kind,
7575
vehicles_tbl, stops_column, id_column);

sql/pgr_pickDeliver/pgr_pickDeliver.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ CREATE FUNCTION vrp_pgr_pickDeliver(
5151
RETURNS SETOF RECORD AS
5252
$BODY$
5353
SELECT *
54-
FROM _vrp_pgr_pickDeliver(_pgr_get_statement($1), _pgr_get_statement($2), $3, $4, $5);
54+
FROM _vrp_pgr_pickDeliver(_vrp_get_statement($1), _pgr_get_statement($2), $3, $4, $5);
5555
$BODY$
5656
LANGUAGE SQL VOLATILE STRICT;
5757

sql/pgr_pickDeliver/pgr_pickDeliverEuclidean.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ CREATE FUNCTION vrp_pgr_pickDeliverEuclidean(
5050
RETURNS SETOF RECORD AS
5151
$BODY$
5252
SELECT *
53-
FROM _vrp_pgr_pickDeliverEuclidean(_pgr_get_statement($1), _pgr_get_statement($2), $3, $4, $5);
53+
FROM _vrp_pgr_pickDeliverEuclidean(_vrp_get_statement($1), _pgr_get_statement($2), $3, $4, $5);
5454
$BODY$
5555
LANGUAGE SQL VOLATILE STRICT;
5656

sql/pickDeliver/pickDeliverRaw.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ RETURNS SETOF RECORD AS
6060
$BODY$
6161

6262
SELECT * FROM _vrp_pickDeliverRaw(
63-
_pgr_get_statement($1),
64-
_pgr_get_statement($2),
65-
_pgr_get_statement($3),
66-
_pgr_get_statement($4),
63+
_vrp_get_statement($1),
64+
_vrp_get_statement($2),
65+
_vrp_get_statement($3),
66+
_vrp_get_statement($4),
6767
optimize, factor,
6868
max_cycles, stop_on_all_served, execution_date);
6969

sql/utilities/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
SET(LOCAL_FILES
22
vehiclesAtTime.sql
3-
)
3+
_get_statement.sql
4+
)
45

56
foreach (f ${LOCAL_FILES})
67
configure_file(${f} ${f})

sql/utilities/_get_statement.sql

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*PGR-GNU*****************************************************************
2+
3+
_get_statement.sql
4+
5+
Copyright (c) 2025 Celia Virginia Vergara Castillo
6+
mail: vicky at erosion.dev
7+
8+
------
9+
10+
This program is free software; you can redistribute it and/or modify
11+
it under the terms of the GNU General Public License as published by
12+
the Free Software Foundation; either version 2 of the License, or
13+
(at your option) any later version.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU General Public License for more details.
19+
20+
You should have received a copy of the GNU General Public License
21+
along with this program; if not, write to the Free Software
22+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23+
24+
********************************************************************PGR-GNU*/
25+
26+
--v0.5
27+
CREATE FUNCTION _vrp_get_statement(o_sql text)
28+
RETURNS text AS
29+
$BODY$
30+
DECLARE
31+
sql TEXT;
32+
BEGIN
33+
EXECUTE 'SELECT statement FROM pg_prepared_statements WHERE name =' || quote_literal(o_sql) || ' limit 1 ' INTO sql;
34+
IF (sql IS NULL) THEN
35+
RETURN o_sql;
36+
ELSE
37+
RETURN regexp_replace(regexp_replace(regexp_replace(sql, '\s(as)\s', '___foo___', 'i'), '^.*___foo___', '','i'), ';$', '');
38+
END IF;
39+
END
40+
$BODY$
41+
LANGUAGE plpgsql STABLE STRICT;
42+
43+
COMMENT ON FUNCTION _vrp_get_statement(TEXT)
44+
IS 'vrprouting internal function';

0 commit comments

Comments
 (0)