[pgrouting-users] Error in "dijkstra_sp_delta_directed" line 83

Hello,

I get the following error using the dijkstra_sp_delta function :

type of parameter 33 (integer) does not match that when preparing the plan (numeric)
Où : PL/pgSQL function “dijkstra_sp_delta_directed” line 83 at assignment
PL/pgSQL function “dijkstra_sp_delta” line 19 at FOR over EXECUTE statement

I didn’t find anything about that.
I’m using postgis with a java application. Calls are done with Hibernate’s named queries, but I don’t think that the use of Hibernate is the cause of this error.
The error occurs randomly : A failing request can work at its next call.

Versions :
Postgres 9.1
Postgis 1.5
Pgrouting 1.0.5

Any idea about this?

Regards,

Mathias.

Hi Mathias,

Could you post the query?
The pgRouting function you’re using is this one:
https://github.com/pgRouting/pgrouting/blob/master/core/sql/routing_core_wrappers.sql#L594

Can you check if the expected parameters have the right data types?
If the data type is not correct it sometimes is enough to type cast.

Daniel

On Thu, Jun 21, 2012 at 9:57 AM, Mathias Villeger <mathias.villeger@gmail.com> wrote:

Hello,

I get the following error using the dijkstra_sp_delta function :

type of parameter 33 (integer) does not match that when preparing the plan (numeric)
Où : PL/pgSQL function “dijkstra_sp_delta_directed” line 83 at assignment
PL/pgSQL function “dijkstra_sp_delta” line 19 at FOR over EXECUTE statement

I didn’t find anything about that.
I’m using postgis with a java application. Calls are done with Hibernate’s named queries, but I don’t think that the use of Hibernate is the cause of this error.
The error occurs randomly : A failing request can work at its next call.

Versions :
Postgres 9.1
Postgis 1.5
Pgrouting 1.0.5

Any idea about this?

Regards,

Mathias.


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users


Georepublic UG & Georepublic Japan
eMail: daniel.kastl@georepublic.de
Web: http://georepublic.de

Hi Daniel,

I added type casts to request parameters but the error persists :
SELECT gid, the_geom FROM dijkstra_sp_delta( CAST( ‘routes’ AS varchar ), CAST( :source AS int4 ), CAST( :target AS int4 ), CAST( :delta AS float8 ) );

I solved it changing this bloc of function dijkstra_sp_delta_directed :

FOR rec IN EXECUTE ‘SELECT CASE WHEN ‘||source_x||’<’||target_x||
’ THEN ‘||source_x||’ ELSE '||target_x||
’ END as ll_x, CASE WHEN ‘||source_x||’>'||target_x||
’ THEN ‘||source_x||’ ELSE ‘||target_x||’ END as ur_x’
LOOP
END LOOP;

ll_x := rec.ll_x;
ur_x := rec.ur_x;

FOR rec IN EXECUTE ‘SELECT CASE WHEN ‘||source_y||’<’||
target_y||’ THEN ‘||source_y||’ ELSE '||
target_y||’ END as ll_y, CASE WHEN '||
source_y||‘>’||target_y||’ THEN '||
source_y||’ ELSE ‘||target_y||’ END as ur_y’
LOOP
END LOOP;

with bloc :

# Cast in Float to prevent plan error in PostgreSQL
FOR rec IN EXECUTE ‘SELECT CASE WHEN CAST(’||source_x||’ as float8)< CAST('||target_x||
’ as float8) THEN CAST(‘||source_x||’ as float8) ELSE CAST('||target_x||
’ as float8) END as ll_x, CASE WHEN CAST(‘||source_x||’ as float8)>CAST('||target_x||
’ as float8) THEN CAST(‘||source_x||’ as float8) ELSE CAST(‘||target_x||’ as float8) END as ur_x’
LOOP
END LOOP;

ll_x := rec.ll_x;
ur_x := rec.ur_x;

# Cast in Float to prevent plan error in PostgreSQL
FOR rec IN EXECUTE ‘SELECT CASE WHEN CAST(’||source_y||’ as float8)<CAST('||
target_y||’ as float8) THEN CAST(‘||source_y||’ as float8) ELSE CAST('||
target_y||’ as float8) END as ll_y, CASE WHEN CAST('||
source_y||’ as float8)>CAST(‘||target_y||’ as float8) THEN CAST('||
source_y||’ as float8) ELSE CAST(‘||target_y||’ as float8) END as ur_y’
LOOP
END LOOP;

The error occured when source_x has not any decimal.
Should I create an issue on issue tracker?

Mathias.

2012/6/21 Daniel Kastl <daniel@georepublic.de>

Hi Mathias,

Could you post the query?
The pgRouting function you’re using is this one:
https://github.com/pgRouting/pgrouting/blob/master/core/sql/routing_core_wrappers.sql#L594

Can you check if the expected parameters have the right data types?
If the data type is not correct it sometimes is enough to type cast.

Daniel

On Thu, Jun 21, 2012 at 9:57 AM, Mathias Villeger <mathias.villeger@gmail.com> wrote:

Hello,

I get the following error using the dijkstra_sp_delta function :

type of parameter 33 (integer) does not match that when preparing the plan (numeric)
Où : PL/pgSQL function “dijkstra_sp_delta_directed” line 83 at assignment
PL/pgSQL function “dijkstra_sp_delta” line 19 at FOR over EXECUTE statement

I didn’t find anything about that.
I’m using postgis with a java application. Calls are done with Hibernate’s named queries, but I don’t think that the use of Hibernate is the cause of this error.
The error occurs randomly : A failing request can work at its next call.

Versions :
Postgres 9.1
Postgis 1.5
Pgrouting 1.0.5

Any idea about this?

Regards,

Mathias.


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users


Georepublic UG & Georepublic Japan
eMail: daniel.kastl@georepublic.de
Web: http://georepublic.de


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users

Hi Mathias,

Thanks for reporting this!
It’s weird that source/target should be a decimal number.
If you could create a ticket, that would be nice. Otherwise issues easily get lost in the mailing list archive.

Daniel

On Thu, Jun 21, 2012 at 11:25 AM, Mathias Villeger <mathias.villeger@gmail.com> wrote:

Hi Daniel,

I added type casts to request parameters but the error persists :
SELECT gid, the_geom FROM dijkstra_sp_delta( CAST( ‘routes’ AS varchar ), CAST( :source AS int4 ), CAST( :target AS int4 ), CAST( :delta AS float8 ) );

I solved it changing this bloc of function dijkstra_sp_delta_directed :

FOR rec IN EXECUTE ‘SELECT CASE WHEN ‘||source_x||’<’||target_x||
’ THEN ‘||source_x||’ ELSE '||target_x||
’ END as ll_x, CASE WHEN ‘||source_x||’>'||target_x||
’ THEN ‘||source_x||’ ELSE ‘||target_x||’ END as ur_x’
LOOP
END LOOP;

ll_x := rec.ll_x;
ur_x := rec.ur_x;

FOR rec IN EXECUTE ‘SELECT CASE WHEN ‘||source_y||’<’||
target_y||’ THEN ‘||source_y||’ ELSE '||
target_y||’ END as ll_y, CASE WHEN '||
source_y||‘>’||target_y||’ THEN '||
source_y||’ ELSE ‘||target_y||’ END as ur_y’
LOOP
END LOOP;

with bloc :

# Cast in Float to prevent plan error in PostgreSQL
FOR rec IN EXECUTE ‘SELECT CASE WHEN CAST(’||source_x||’ as float8)< CAST('||target_x||
’ as float8) THEN CAST(‘||source_x||’ as float8) ELSE CAST('||target_x||
’ as float8) END as ll_x, CASE WHEN CAST(‘||source_x||’ as float8)>CAST('||target_x||
’ as float8) THEN CAST(‘||source_x||’ as float8) ELSE CAST(‘||target_x||’ as float8) END as ur_x’
LOOP
END LOOP;

ll_x := rec.ll_x;
ur_x := rec.ur_x;

# Cast in Float to prevent plan error in PostgreSQL
FOR rec IN EXECUTE ‘SELECT CASE WHEN CAST(’||source_y||’ as float8)<CAST('||
target_y||’ as float8) THEN CAST(‘||source_y||’ as float8) ELSE CAST('||
target_y||’ as float8) END as ll_y, CASE WHEN CAST('||
source_y||’ as float8)>CAST(‘||target_y||’ as float8) THEN CAST('||
source_y||’ as float8) ELSE CAST(‘||target_y||’ as float8) END as ur_y’
LOOP
END LOOP;

The error occured when source_x has not any decimal.
Should I create an issue on issue tracker?

Mathias.

2012/6/21 Daniel Kastl <daniel@georepublic.de>

Hi Mathias,

Could you post the query?
The pgRouting function you’re using is this one:
https://github.com/pgRouting/pgrouting/blob/master/core/sql/routing_core_wrappers.sql#L594

Can you check if the expected parameters have the right data types?
If the data type is not correct it sometimes is enough to type cast.

Daniel

On Thu, Jun 21, 2012 at 9:57 AM, Mathias Villeger <mathias.villeger@gmail.com> wrote:

Hello,

I get the following error using the dijkstra_sp_delta function :

type of parameter 33 (integer) does not match that when preparing the plan (numeric)
Où : PL/pgSQL function “dijkstra_sp_delta_directed” line 83 at assignment
PL/pgSQL function “dijkstra_sp_delta” line 19 at FOR over EXECUTE statement

I didn’t find anything about that.
I’m using postgis with a java application. Calls are done with Hibernate’s named queries, but I don’t think that the use of Hibernate is the cause of this error.
The error occurs randomly : A failing request can work at its next call.

Versions :
Postgres 9.1
Postgis 1.5
Pgrouting 1.0.5

Any idea about this?

Regards,

Mathias.


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users


Georepublic UG & Georepublic Japan
eMail: daniel.kastl@georepublic.de
Web: http://georepublic.de


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users


Georepublic UG & Georepublic Japan
eMail: daniel.kastl@georepublic.de
Web: http://georepublic.de

See https://github.com/pgRouting/pgrouting/issues/60

Thanks
Bye

Mathias.

2012/6/21 Daniel Kastl <daniel@georepublic.de>

Hi Mathias,

Thanks for reporting this!
It’s weird that source/target should be a decimal number.
If you could create a ticket, that would be nice. Otherwise issues easily get lost in the mailing list archive.

Daniel

On Thu, Jun 21, 2012 at 11:25 AM, Mathias Villeger <mathias.villeger@gmail.com> wrote:

Hi Daniel,

I added type casts to request parameters but the error persists :
SELECT gid, the_geom FROM dijkstra_sp_delta( CAST( ‘routes’ AS varchar ), CAST( :source AS int4 ), CAST( :target AS int4 ), CAST( :delta AS float8 ) );

I solved it changing this bloc of function dijkstra_sp_delta_directed :

FOR rec IN EXECUTE ‘SELECT CASE WHEN ‘||source_x||’<’||target_x||
’ THEN ‘||source_x||’ ELSE '||target_x||
’ END as ll_x, CASE WHEN ‘||source_x||’>'||target_x||
’ THEN ‘||source_x||’ ELSE ‘||target_x||’ END as ur_x’
LOOP
END LOOP;

ll_x := rec.ll_x;
ur_x := rec.ur_x;

FOR rec IN EXECUTE ‘SELECT CASE WHEN ‘||source_y||’<’||
target_y||’ THEN ‘||source_y||’ ELSE '||
target_y||’ END as ll_y, CASE WHEN '||
source_y||‘>’||target_y||’ THEN '||
source_y||’ ELSE ‘||target_y||’ END as ur_y’
LOOP
END LOOP;

with bloc :

# Cast in Float to prevent plan error in PostgreSQL
FOR rec IN EXECUTE ‘SELECT CASE WHEN CAST(’||source_x||’ as float8)< CAST('||target_x||
’ as float8) THEN CAST(‘||source_x||’ as float8) ELSE CAST('||target_x||
’ as float8) END as ll_x, CASE WHEN CAST(‘||source_x||’ as float8)>CAST('||target_x||
’ as float8) THEN CAST(‘||source_x||’ as float8) ELSE CAST(‘||target_x||’ as float8) END as ur_x’
LOOP
END LOOP;

ll_x := rec.ll_x;
ur_x := rec.ur_x;

# Cast in Float to prevent plan error in PostgreSQL
FOR rec IN EXECUTE ‘SELECT CASE WHEN CAST(’||source_y||’ as float8)<CAST('||
target_y||’ as float8) THEN CAST(‘||source_y||’ as float8) ELSE CAST('||
target_y||’ as float8) END as ll_y, CASE WHEN CAST('||
source_y||’ as float8)>CAST(‘||target_y||’ as float8) THEN CAST('||
source_y||’ as float8) ELSE CAST(‘||target_y||’ as float8) END as ur_y’
LOOP
END LOOP;

The error occured when source_x has not any decimal.
Should I create an issue on issue tracker?

Mathias.

2012/6/21 Daniel Kastl <daniel@georepublic.de>

Hi Mathias,

Could you post the query?
The pgRouting function you’re using is this one:
https://github.com/pgRouting/pgrouting/blob/master/core/sql/routing_core_wrappers.sql#L594

Can you check if the expected parameters have the right data types?
If the data type is not correct it sometimes is enough to type cast.

Daniel

On Thu, Jun 21, 2012 at 9:57 AM, Mathias Villeger <mathias.villeger@gmail.com> wrote:

Hello,

I get the following error using the dijkstra_sp_delta function :

type of parameter 33 (integer) does not match that when preparing the plan (numeric)
Où : PL/pgSQL function “dijkstra_sp_delta_directed” line 83 at assignment
PL/pgSQL function “dijkstra_sp_delta” line 19 at FOR over EXECUTE statement

I didn’t find anything about that.
I’m using postgis with a java application. Calls are done with Hibernate’s named queries, but I don’t think that the use of Hibernate is the cause of this error.
The error occurs randomly : A failing request can work at its next call.

Versions :
Postgres 9.1
Postgis 1.5
Pgrouting 1.0.5

Any idea about this?

Regards,

Mathias.


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users


Georepublic UG & Georepublic Japan
eMail: daniel.kastl@georepublic.de
Web: http://georepublic.de


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users


Georepublic UG & Georepublic Japan
eMail: daniel.kastl@georepublic.de
Web: http://georepublic.de


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users

Hi,

I am trying to add a function: 1-to-many dijkstra shortest path.
Thus I downloaded the last git and added a folder named 1toNsp in “extra”, which contains tomanysp.h, tomanysp.c and boost_wrapper_tomany.cpp.

These files are highly inspired from the dijkstra.h, dijkstra.c and boost_wrapper.cpp files that are in the “core” directory.
-actually for now it’s mainly a copy/paste of them-

I also created a .sql in extra/1toNsp/sql to define the function onetomany_dijkstra_shortest_path(text, int, int array, boolean ,boolean).
I checked if this function exists by returning the distance between source and the first target only, using boost_dijkstra; this works well \o/.

Now I want the (static int compute_tomany_shortest_path(char* sql, int start_vertex,
int *end_vertices, int nb_targets, bool directed,
bool has_reverse_cost,
path_element_t **path, int *path_count)) function to call a function defined in boost_dijkstra_tomany.cpp (named boost_dijkstra_tomany(…)).

Problem is that when I call
routing=> SELECT * FROM onetomany_dijkstra_sp(‘SELECT gid AS id, source::int4,
target::int4, length::double precision AS cost,length::double precision
AS reverse_cost FROM ways’, 3, ‘{7,18,179}’, true, true);
I get
ERROR: could not load library “/usr/lib/postgresql/9.1/lib/librouting_tomanysp.so”: /usr/lib/postgresql/9.1/lib/librouting_tomanysp.so: undefined symbol: boost_dijkstra_tomany

This function (int boost_dijkstra_tomany(…)) is declared in tomanysp.h and called from tomanysp.c; while it is defined in boost_wrapper_tomany.cpp (which #includes “tomanysp.h”); once again it looks the same as what is done with dijkstra.h, dijkstra.c and boost_wrapper.cpp.

my /extra/1toNsp/src/CMakeLists.txt is :
SET(LIBRARY_OUTPUT_PATH …/…/…/lib/)
ADD_LIBRARY(routing_tomany SHARED boost_wrapper_tomany.cpp tomanysp.c tomanysp.h)
INSTALL(TARGETS routing_tomany DESTINATION ${LIBRARY_INSTALL_PATH})

Could someone tell me what I am missing?


Using postgresql 9.1 with ubuntu 11.10.

Sylvain Housseman wrote:

Hi,

I am trying to add a function: 1-to-many dijkstra shortest path.
Thus I downloaded the last git and added a folder named 1toNsp in
"extra", which contains tomanysp.h, tomanysp.c and
boost_wrapper_tomany.cpp.

These files are highly inspired from the dijkstra.h, dijkstra.c and
boost_wrapper.cpp files that are in the "core" directory.
-actually for now it's mainly a copy/paste of them-

I also created a .sql in extra/1toNsp/sql to define the function
onetomany_dijkstra_shortest_path(text, int, int array, boolean ,boolean).
I checked if this function exists by returning the distance between
source and the first target only, using boost_dijkstra; this works well
\o/.

Now I want the (static int compute_tomany_shortest_path(char* sql, int
start_vertex,
                                  int *end_vertices, int nb_targets,
bool directed,
                                  bool has_reverse_cost,
                                  path_element_t **path, int
*path_count)) function to call a function defined in
boost_dijkstra_tomany.cpp (named boost_dijkstra_tomany(...)).

Problem is that when I call
     routing=> SELECT * FROM onetomany_dijkstra_sp('SELECT gid AS id,
source::int4,
              target::int4, length::double precision AS
cost,length::double precision
         AS reverse_cost FROM ways', 3, '{7,18,179}', true, true);
I get
     ERROR: could not load library
"/usr/lib/postgresql/9.1/lib/librouting_tomanysp.so":
/usr/lib/postgresql/9.1/lib/librouting_tomanysp.so: undefined symbol:
                 boost_dijkstra_tomany

This function (int boost_dijkstra_tomany(......)) is declared in
tomanysp.h and called from tomanysp.c; while it is defined in
boost_wrapper_tomany.cpp (which #includes "tomanysp.h"); once again it
looks the same as what is done with dijkstra.h, dijkstra.c and
boost_wrapper.cpp.

my /extra/1toNsp/src/CMakeLists.txt is :
     SET(LIBRARY_OUTPUT_PATH ../../../lib/)*
* ADD_LIBRARY(routing_tomany SHARED boost_wrapper_tomany.cpp
tomanysp.c tomanysp.h)
     INSTALL(TARGETS routing_tomany DESTINATION ${LIBRARY_INSTALL_PATH})*

*Could someone tell me what I am missing?

How have you declared this function?

In your header file you need to tell the compiler that this function is go
to be declared as c function.

So you need something like

#ifdef __cplusplus
extern "C"
{
#endif
int compute_kshortest_path(char* sql, int start_vertex,
                                 int end_vertex, int no_paths,
                                 bool has_reverse_cost,
                                 ksp_path_element_t **path, int
*ksp_path_count) ;

#ifdef __cplusplus
}
#endif

--------------
Using postgresql 9.1 with ubuntu 11.10.
_______________________________________________
Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users

--

Dear Dave,

thank you for your answer, I think you were right pointing the C vs C++ fuinctions.
I actually made my function work by putting within a class initialized through an interface function... Maybe the

#ifdef __cplusplus
extern "C"
{
#endif

would have been enough!

All this is not really clear to me yet but I will make a few tests and upload the sources of a "clean" 1_to_many dijkstra by the end of the week.

Thanks again;
Sylvain.

Le 29/06/2012 21:08, Dave Potts a écrit :

Sylvain Housseman wrote:

Hi,

I am trying to add a function: 1-to-many dijkstra shortest path.
Thus I downloaded the last git and added a folder named 1toNsp in
"extra", which contains tomanysp.h, tomanysp.c and
boost_wrapper_tomany.cpp.

These files are highly inspired from the dijkstra.h, dijkstra.c and
boost_wrapper.cpp files that are in the "core" directory.
-actually for now it's mainly a copy/paste of them-

I also created a .sql in extra/1toNsp/sql to define the function
onetomany_dijkstra_shortest_path(text, int, int array, boolean ,boolean).
I checked if this function exists by returning the distance between
source and the first target only, using boost_dijkstra; this works well
\o/.

Now I want the (static int compute_tomany_shortest_path(char* sql, int
start_vertex,
                                   int *end_vertices, int nb_targets,
bool directed,
                                   bool has_reverse_cost,
                                   path_element_t **path, int
*path_count)) function to call a function defined in
boost_dijkstra_tomany.cpp (named boost_dijkstra_tomany(...)).

Problem is that when I call
      routing=> SELECT * FROM onetomany_dijkstra_sp('SELECT gid AS id,
source::int4,
               target::int4, length::double precision AS
cost,length::double precision
          AS reverse_cost FROM ways', 3, '{7,18,179}', true, true);
I get
      ERROR: could not load library
"/usr/lib/postgresql/9.1/lib/librouting_tomanysp.so":
/usr/lib/postgresql/9.1/lib/librouting_tomanysp.so: undefined symbol:
                  boost_dijkstra_tomany

This function (int boost_dijkstra_tomany(......)) is declared in
tomanysp.h and called from tomanysp.c; while it is defined in
boost_wrapper_tomany.cpp (which #includes "tomanysp.h"); once again it
looks the same as what is done with dijkstra.h, dijkstra.c and
boost_wrapper.cpp.

my /extra/1toNsp/src/CMakeLists.txt is :
      SET(LIBRARY_OUTPUT_PATH ../../../lib/)*
* ADD_LIBRARY(routing_tomany SHARED boost_wrapper_tomany.cpp
tomanysp.c tomanysp.h)
      INSTALL(TARGETS routing_tomany DESTINATION ${LIBRARY_INSTALL_PATH})*

*Could someone tell me what I am missing?

How have you declared this function?

In your header file you need to tell the compiler that this function is go
to be declared as c function.

So you need something like

#ifdef __cplusplus
extern "C"
{
#endif
int compute_kshortest_path(char* sql, int start_vertex,
                                  int end_vertex, int no_paths,
                                  bool has_reverse_cost,
                                  ksp_path_element_t **path, int
*ksp_path_count) ;

#ifdef __cplusplus
}
#endif

--------------
Using postgresql 9.1 with ubuntu 11.10.
_______________________________________________
Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users