Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/drivers/yen/withPoints_ksp_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ extern "C" {

Path_rt**, size_t*,
char**, char**, char**);

/*TODO remove on v4*/
int do_pgr_withPointsKsp(
Edge_t *edges, size_t total_edges,
Expand Down
5 changes: 3 additions & 2 deletions include/yen/pgr_ksp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#include <algorithm>
#include <set>
#include <limits>
#include <map>

#include "dijkstra/dijkstra.hpp"
#include "cpp_common/pgr_assert.h"
Expand Down Expand Up @@ -246,7 +247,7 @@ namespace algorithms {
G &graph,
const std::map<int64_t, std::set<int64_t>> &combinations,
size_t k,
bool heap_paths){
bool heap_paths) {
std::deque<Path> paths;
pgrouting::yen::Pgr_ksp<G> fn_yen;

Expand All @@ -267,7 +268,7 @@ namespace algorithms {
return paths;
}

} // namespace algorithms
} // namespace algorithms

} // namespace pgrouting

Expand Down
6 changes: 5 additions & 1 deletion pgtap/ksp/withPointsKSP/inner_query.pg
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
BEGIN;

UPDATE edge_table SET cost = sign(cost), reverse_cost = sign(reverse_cost);
SELECT plan(84);
SELECT plan(168);

SELECT style_dijkstra('pgr_withPointsKSP(', ', $$SELECT * from pointsOfInterest$$, 2, 3, 2, $$l$$, true)');
SELECT innerquery_points('pgr_withPointsKSP($$SELECT * FROM edge_table$$,', ', 2, 3, 2, $$r$$, true)');

/* TODO Remove on v4*/
-- ONE TO ONE
SELECT style_dijkstra('pgr_withPointsKSP(', ', $$SELECT * from pointsOfInterest$$, 2, 3, 2, true)');
SELECT innerquery_points('pgr_withPointsKSP($$SELECT * FROM edge_table$$,', ', 2, 3, 2, true)');
Expand Down
57 changes: 46 additions & 11 deletions pgtap/ksp/withPointsKSP/types_check.pg
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,56 @@ 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*/
BEGIN;
SELECT plan(5);
SELECT plan(15);

SELECT has_function('pgr_withpointsksp');
SELECT has_function('pgr_withpointsksp',ARRAY['text','text','bigint','bigint','integer','boolean','boolean','character','boolean']);
SELECT function_returns('pgr_withpointsksp',ARRAY['text','text','bigint','bigint','integer','boolean','boolean','character','boolean'],'setof record');
SELECT has_function('pgr_withpointsksp',ARRAY['text','text','bigint','bigint','integer','character','boolean','boolean','boolean']);
SELECT has_function('pgr_withpointsksp',ARRAY['text','text','bigint','anyarray','integer','character','boolean','boolean','boolean']);
SELECT has_function('pgr_withpointsksp',ARRAY['text','text','anyarray','bigint','integer','character','boolean','boolean','boolean']);
SELECT has_function('pgr_withpointsksp',ARRAY['text','text','anyarray','anyarray','integer','character','boolean','boolean','boolean']);
SELECT has_function('pgr_withpointsksp',ARRAY['text','text','text','integer','character','boolean','boolean','boolean']);

SELECT function_returns('pgr_withpointsksp',ARRAY['text','text','bigint','bigint','integer','character','boolean','boolean','boolean'],'setof record');
SELECT function_returns('pgr_withpointsksp',ARRAY['text','text','bigint','anyarray','integer','character','boolean','boolean','boolean'],'setof record');
SELECT function_returns('pgr_withpointsksp',ARRAY['text','text','anyarray','bigint','integer','character','boolean','boolean','boolean'],'setof record');
SELECT function_returns('pgr_withpointsksp',ARRAY['text','text','anyarray','anyarray','integer','character','boolean','boolean','boolean'],'setof record');
SELECT function_returns('pgr_withpointsksp',ARRAY['text','text','text','integer','character','boolean','boolean','boolean'],'setof record');

SELECT set_eq(
$$SELECT proargnames from pg_proc WHERE proname = 'pgr_withpointsksp'$$,
$$SELECT '{"","","","","","directed","heap_paths","driving_side","details","seq","path_id","path_seq","node","edge","cost","agg_cost"}'::TEXT[] $$
);
/*Remove last 1 row on v4*/
SELECT CASE WHEN min_version('3.6.0')
THEN collect_tap(
set_eq(
$$SELECT proargnames from pg_proc WHERE proname = 'pgr_withpointsksp'$$,
$$VALUES
('{"","","","","","","directed","heap_paths","details","seq","path_id","path_seq","start_vid","end_vid","node","edge","cost","agg_cost"}'::TEXT[]),
('{"","","","","","directed","heap_paths","details","seq","path_id","path_seq","start_vid","end_vid","node","edge","cost","agg_cost"}'::TEXT[]),
('{"","","","","","directed","heap_paths","driving_side","details","seq","path_id","path_seq","node","edge","cost","agg_cost"}'::TEXT[])
$$),
set_eq(
$$SELECT proallargtypes FROM pg_proc WHERE proname = 'pgr_withpointsksp'$$,
$$VALUES
('{25,25,20,20,23,1042,16,16,16,23,23,23,20,20,20,20,701,701}'::OID[]),
('{25,25,20,2277,23,1042,16,16,16,23,23,23,20,20,20,20,701,701}'::OID[]),
('{25,25,2277,20,23,1042,16,16,16,23,23,23,20,20,20,20,701,701}'::OID[]),
('{25,25,2277,2277,23,1042,16,16,16,23,23,23,20,20,20,20,701,701}'::OID[]),
('{25,25,25,23,1042,16,16,16,23,23,23,20,20,20,20,701,701}'::OID[]),
('{25,25,20,20,23,16,16,1042,16,23,23,23,20,20,701,701}'::OID[])
$$)
)
ELSE collect_tap(
set_eq(
$$SELECT proargnames from pg_proc WHERE proname = 'pgr_withpointsksp'$$,
$$SELECT '{"","","","","","directed","heap_paths","driving_side","details","seq","path_id","path_seq","node","edge","cost","agg_cost"}'::TEXT[] $$
),
set_eq(
$$SELECT proallargtypes FROM pg_proc WHERE proname = 'pgr_withpointsksp'$$,
$$SELECT '{25,25,20,20,23,16,16,1042,16,23,23,23,20,20,701,701}'::OID[] $$
)
)END;

SELECT set_eq(
$$SELECT proallargtypes FROM pg_proc WHERE proname = 'pgr_withpointsksp'$$,
$$SELECT '{25,25,20,20,23,16,16,1042,16,23,23,23,20,20,701,701}'::OID[] $$
);
/* TODO remove on v4*/
SELECT has_function('pgr_withpointsksp',ARRAY['text','text','bigint','bigint','integer','boolean','boolean','character','boolean']);
SELECT function_returns('pgr_withpointsksp',ARRAY['text','text','bigint','bigint','integer','boolean','boolean','character','boolean'],'setof record');

SELECT finish();
ROLLBACK;
24 changes: 12 additions & 12 deletions sql/ksp/withPointsKSP.sql
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ CREATE FUNCTION pgr_withPointsKSP(
OUT seq INTEGER,
OUT path_id INTEGER,
OUT path_seq INTEGER,
OUT start_vid INTEGER,
OUT end_vid INTEGER,
OUT start_vid BIGINT,
OUT end_vid BIGINT,
OUT node BIGINT,
OUT edge BIGINT,
OUT cost FLOAT,
Expand Down Expand Up @@ -74,8 +74,8 @@ CREATE FUNCTION pgr_withPointsKSP(
OUT seq INTEGER,
OUT path_id INTEGER,
OUT path_seq INTEGER,
OUT start_vid INTEGER,
OUT end_vid INTEGER,
OUT start_vid BIGINT,
OUT end_vid BIGINT,
OUT node BIGINT,
OUT edge BIGINT,
OUT cost FLOAT,
Expand Down Expand Up @@ -106,8 +106,8 @@ CREATE FUNCTION pgr_withPointsKSP(
OUT seq INTEGER,
OUT path_id INTEGER,
OUT path_seq INTEGER,
OUT start_vid INTEGER,
OUT end_vid INTEGER,
OUT start_vid BIGINT,
OUT end_vid BIGINT,
OUT node BIGINT,
OUT edge BIGINT,
OUT cost FLOAT,
Expand Down Expand Up @@ -138,8 +138,8 @@ CREATE FUNCTION pgr_withPointsKSP(
OUT seq INTEGER,
OUT path_id INTEGER,
OUT path_seq INTEGER,
OUT start_vid INTEGER,
OUT end_vid INTEGER,
OUT start_vid BIGINT,
OUT end_vid BIGINT,
OUT node BIGINT,
OUT edge BIGINT,
OUT cost FLOAT,
Expand Down Expand Up @@ -169,8 +169,8 @@ CREATE FUNCTION pgr_withPointsKSP(
OUT seq INTEGER,
OUT path_id INTEGER,
OUT path_seq INTEGER,
OUT start_vid INTEGER,
OUT end_vid INTEGER,
OUT start_vid BIGINT,
OUT end_vid BIGINT,
OUT node BIGINT,
OUT edge BIGINT,
OUT cost FLOAT,
Expand Down Expand Up @@ -290,8 +290,8 @@ RETURNS SETOF RECORD AS
$BODY$
BEGIN
RAISE WARNING 'pgr_withPointsKSP(text,text,bigint,bigint,integer,boolean,boolean,char,boolean) deprecated on v3.6.0';
SELECT *
FROM _pgr_withPointsKSP(_pgr_get_statement($1), _pgr_get_statement($2), $3, $4, $5, $6, $7, $8, $9);
RETURN QUERY
SELECT * FROM _pgr_withPointsKSP(_pgr_get_statement($1), _pgr_get_statement($2), $3, $4, $5, $6, $7, $8, $9);
END
$BODY$
LANGUAGE plpgsql VOLATILE STRICT
Expand Down
7 changes: 7 additions & 0 deletions sql/sigs/pgrouting--3.6.sig
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ _pgr_tsp(text,bigint,bigint,double precision,integer,integer,integer,double prec
pgr_tsp(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean)
_pgr_turnrestrictedpath(text,text,bigint,bigint,integer,boolean,boolean,boolean,boolean)
pgr_turnrestrictedpath(text,text,bigint,bigint,integer,boolean,boolean,boolean,boolean)
_pgr_v4withpointsksp(text,text,anyarray,anyarray,integer,character,boolean,boolean,boolean)
_pgr_v4withpointsksp(text,text,text,integer,character,boolean,boolean,boolean)
pgr_version()
_pgr_versionless(text,text)
_pgr_vrponedepot(text,text,text,integer)
Expand All @@ -304,8 +306,13 @@ pgr_withpointscost(text,text,text,boolean,character)
_pgr_withpointsdd(text,text,anyarray,double precision,boolean,character,boolean,boolean)
pgr_withpointsdd(text,text,anyarray,double precision,boolean,character,boolean,boolean)
pgr_withpointsdd(text,text,bigint,double precision,boolean,character,boolean)
pgr_withpointsksp(text,text,anyarray,anyarray,integer,character,boolean,boolean,boolean)
pgr_withpointsksp(text,text,anyarray,bigint,integer,character,boolean,boolean,boolean)
pgr_withpointsksp(text,text,bigint,anyarray,integer,character,boolean,boolean,boolean)
_pgr_withpointsksp(text,text,bigint,bigint,integer,boolean,boolean,character,boolean)
pgr_withpointsksp(text,text,bigint,bigint,integer,boolean,boolean,character,boolean)
pgr_withpointsksp(text,text,bigint,bigint,integer,character,boolean,boolean,boolean)
pgr_withpointsksp(text,text,text,integer,character,boolean,boolean,boolean)
pgr_withpoints(text,text,anyarray,anyarray,boolean,character,boolean)
_pgr_withpoints(text,text,anyarray,anyarray,boolean,character,boolean,boolean,boolean)
pgr_withpoints(text,text,anyarray,bigint,boolean,character,boolean)
Expand Down
14 changes: 7 additions & 7 deletions src/ksp/withPoints_ksp.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ processv4(
size_t k = (size_t)p_k;

driving_side[0] = (char) tolower(driving_side[0]);
if(!((driving_side[0] == 'r')
|| (driving_side[0] == 'l') || (driving_side[0] == 'b'))){
if (!((driving_side[0] == 'r')
|| (driving_side[0] == 'l') || (driving_side[0] == 'b'))) {
elog(ERROR, "Driving side is not selected or Invalid Values");
return;
}
Expand Down Expand Up @@ -207,7 +207,7 @@ PGDLLEXPORT Datum _pgr_v4withpointsksp(PG_FUNCTION_ARGS) {
funcctx = SRF_FIRSTCALL_INIT();
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);

if(PG_NARGS() == 9){
if (PG_NARGS() == 9) {
processv4(
text_to_cstring(PG_GETARG_TEXT_P(0)),
text_to_cstring(PG_GETARG_TEXT_P(1)),
Expand All @@ -221,7 +221,7 @@ PGDLLEXPORT Datum _pgr_v4withpointsksp(PG_FUNCTION_ARGS) {
PG_GETARG_BOOL(8),
&result_tuples,
&result_count);
} else/* (PG_NARGS() == 8) */{
} else /* (PG_NARGS() == 8) */ {
processv4(
text_to_cstring(PG_GETARG_TEXT_P(0)),
text_to_cstring(PG_GETARG_TEXT_P(1)),
Expand Down Expand Up @@ -281,8 +281,8 @@ PGDLLEXPORT Datum _pgr_v4withpointsksp(PG_FUNCTION_ARGS) {
values[0] = Int32GetDatum(funcctx->call_cntr + 1);
values[1] = Int32GetDatum(path_id);
values[2] = Int32GetDatum(result_tuples[funcctx->call_cntr].seq);
values[3] = Int32GetDatum(result_tuples[funcctx->call_cntr].start_id);
values[4] = Int32GetDatum(result_tuples[funcctx->call_cntr].end_id);
values[3] = Int64GetDatum(result_tuples[funcctx->call_cntr].start_id);
values[4] = Int64GetDatum(result_tuples[funcctx->call_cntr].end_id);
values[5] = Int64GetDatum(result_tuples[funcctx->call_cntr].node);
values[6] = Int64GetDatum(result_tuples[funcctx->call_cntr].edge);
values[7] = Float8GetDatum(result_tuples[funcctx->call_cntr].cost);
Expand Down Expand Up @@ -516,4 +516,4 @@ PGDLLEXPORT Datum _pgr_withpointsksp(PG_FUNCTION_ARGS) {
} else {
SRF_RETURN_DONE(funcctx);
}
}
}
2 changes: 1 addition & 1 deletion src/ksp/withPoints_ksp_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,4 +348,4 @@ do_pgr_withPointsKsp(
*log_msg = pgr_msg(log.str().c_str());
}
return 1000;
}
}