[pgrouting-users] very hight costs

Hello,

I'm working with pgrouting and costs. When i want that one road can not be used i give it a very high cost. But my question is, there is a value that makes the pgrouting not consider this alternative? Like '-1'?
Because if this option is the only, does not mattercost, that this road will be selected.

Anyone knows more examples about costs with pgrouting?

Thanks

I remember trying -1 values and having to revert back to using a high cost (such as 99999999). I can’t remember why -1 didn’t work out, but using the high cost has worked well for me.

On Mon, Jun 11, 2012 at 10:32 AM, Pedro Costa <pedrocostaarma@sapo.pt> wrote:

Hello,

I’m working with pgrouting and costs. When i want that one road can not be used i give it a very high cost. But my question is, there is a value that makes the pgrouting not consider this alternative? Like ‘-1’?
Because if this option is the only, does not mattercost, that this road will be selected.

Anyone knows more examples about costs with pgrouting?

Thanks


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


Steve Horn

Em 11-06-2012 15:38, Steve Horn escreveu:

high cost (such as 99999999

Hello Steve,

With me the hight cost is a problem because my network have few roads....

Hi Pedro,

Could you someone temporarily remove the roads from the network
instead? When you do the select statement to query your network, you
could do a WHERE statement which ignores certain roads?

Might not work, just thinking out loud....

James

On 11 June 2012 15:40, Pedro Costa <pedrocostaarma@sapo.pt> wrote:

Em 11-06-2012 15:38, Steve Horn escreveu:

high cost (such as 99999999

Hello Steve,

With me the hight cost is a problem because my network have few roads....

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

Yes, eliminating the segments with a where clause will work best because it reduces the number of segments and means that you can never travel on that edge because it is not there.

I believe the usage of -1 for a cost is algorithm specific and I don't know which ones accept this and eliminate the edges internally. I'm pretty sure TRSP allows -1 for a cost and drops that edge internally.

-Steve W

On 6/11/2012 10:45 AM, James David Smith wrote:

Hi Pedro,

Could you someone temporarily remove the roads from the network
instead? When you do the select statement to query your network, you
could do a WHERE statement which ignores certain roads?

Might not work, just thinking out loud....

James

On 11 June 2012 15:40, Pedro Costa<pedrocostaarma@sapo.pt> wrote:

Em 11-06-2012 15:38, Steve Horn escreveu:

high cost (such as 99999999

Hello Steve,

With me the hight cost is a problem because my network have few roads....

_______________________________________________
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

Hi

On Mon, 11 Jun 2012 11:03:33 -0400
Stephen Woodbridge <woodbri@swoodbridge.com> wrote:

I'm pretty sure TRSP allows -1 for a cost and drops that edge
internally.

Yes
If you look at the code starting at line 361

Edges are only "used" if >=0.0

...
  if(cur_edge.m_dCost >= 0.0)
...
  if(cur_edge.m_dReverseCost >= 0.0)
...

Regards

max

-Steve W

On 6/11/2012 10:45 AM, James David Smith wrote:
> Hi Pedro,
>
> Could you someone temporarily remove the roads from the network
> instead? When you do the select statement to query your network, you
> could do a WHERE statement which ignores certain roads?
>
> Might not work, just thinking out loud....
>
> James
>
>
>
> On 11 June 2012 15:40, Pedro Costa<pedrocostaarma@sapo.pt> wrote:
>> Em 11-06-2012 15:38, Steve Horn escreveu:
>>>
>>> high cost (such as 99999999
>>
>>
>> Hello Steve,
>>
>> With me the hight cost is a problem because my network have few
>> roads....
>>
>>
>>
>> _______________________________________________
>> 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

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

Hi Max,

Thank you for the confirmation on that. For other reads of this, you would need to verify that function other than TRSP do or do not do this. It would be nice if people that check for this would document it in ticket so we can update the documentation to accurately reflect these facts.

Thanks,
   -Steve

On 6/11/2012 1:05 PM, Max Weninger wrote:

Hi

On Mon, 11 Jun 2012 11:03:33 -0400
Stephen Woodbridge<woodbri@swoodbridge.com> wrote:

I'm pretty sure TRSP allows -1 for a cost and drops that edge
internally.

Yes
If you look at the code starting at line 361

Edges are only "used" if>=0.0

...
  if(cur_edge.m_dCost>= 0.0)
...
  if(cur_edge.m_dReverseCost>= 0.0)
...

Regards

max

-Steve W

On 6/11/2012 10:45 AM, James David Smith wrote:

Hi Pedro,

Could you someone temporarily remove the roads from the network
instead? When you do the select statement to query your network, you
could do a WHERE statement which ignores certain roads?

Might not work, just thinking out loud....

James

On 11 June 2012 15:40, Pedro Costa<pedrocostaarma@sapo.pt> wrote:

Em 11-06-2012 15:38, Steve Horn escreveu:

high cost (such as 99999999

Hello Steve,

With me the hight cost is a problem because my network have few
roads....

_______________________________________________
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

_______________________________________________
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

Hi

One thing to mention for TRSP is also that using -1.0
will give you a "small" performance improvement since the
"starting" number of edges used for route calculation
will be less then if you use a large number

regards

max

On Mon, 11 Jun 2012 13:15:08 -0400
Stephen Woodbridge <woodbri@swoodbridge.com> wrote:

Hi Max,

Thank you for the confirmation on that. For other reads of this, you
would need to verify that function other than TRSP do or do not do
this. It would be nice if people that check for this would document
it in ticket so we can update the documentation to accurately reflect
these facts.

Thanks,
   -Steve

On 6/11/2012 1:05 PM, Max Weninger wrote:
> Hi
>
> On Mon, 11 Jun 2012 11:03:33 -0400
> Stephen Woodbridge<woodbri@swoodbridge.com> wrote:
>> I'm pretty sure TRSP allows -1 for a cost and drops that edge
>> internally.
>
> Yes
> If you look at the code starting at line 361
>
> Edges are only "used" if>=0.0
>
> ...
> if(cur_edge.m_dCost>= 0.0)
> ...
> if(cur_edge.m_dReverseCost>= 0.0)
> ...
>
> Regards
>
> max
>
>> -Steve W
>>
>> On 6/11/2012 10:45 AM, James David Smith wrote:
>>> Hi Pedro,
>>>
>>> Could you someone temporarily remove the roads from the network
>>> instead? When you do the select statement to query your network,
>>> you could do a WHERE statement which ignores certain roads?
>>>
>>> Might not work, just thinking out loud....
>>>
>>> James
>>>
>>>
>>>
>>> On 11 June 2012 15:40, Pedro Costa<pedrocostaarma@sapo.pt>
>>> wrote:
>>>> Em 11-06-2012 15:38, Steve Horn escreveu:
>>>>>
>>>>> high cost (such as 99999999
>>>>
>>>>
>>>> Hello Steve,
>>>>
>>>> With me the hight cost is a problem because my network have few
>>>> roads....
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> 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
>>
>> _______________________________________________
>> 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

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

Thank you to all.
I resolved with a where statement but i also will try using '-1'.
I have another question, anybody know examples of using pgrouting with mapserver?
Or know information about that....

Thanks

On 06/11/2012 06:05 PM, Max Weninger wrote:

Hi

On Mon, 11 Jun 2012 11:03:33 -0400
Stephen Woodbridge<woodbri@swoodbridge.com> wrote:

I'm pretty sure TRSP allows -1 for a cost and drops that edge
internally.

Yes
If you look at the code starting at line 361

Edges are only "used" if>=0.0

...
  if(cur_edge.m_dCost>= 0.0)
...
  if(cur_edge.m_dReverseCost>= 0.0)
...

Regards

max

-Steve W

On 6/11/2012 10:45 AM, James David Smith wrote:

Hi Pedro,

Could you someone temporarily remove the roads from the network
instead? When you do the select statement to query your network, you
could do a WHERE statement which ignores certain roads?

Might not work, just thinking out loud....

James

On 11 June 2012 15:40, Pedro Costa<pedrocostaarma@sapo.pt> wrote:

Em 11-06-2012 15:38, Steve Horn escreveu:

high cost (such as 99999999

Hello Steve,

With me the hight cost is a problem because my network have few
roads....

_______________________________________________
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

_______________________________________________
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

This page is in error:

http://www.pgrouting.org/docs/howto/mapserver.html

The result of the dijkstra_sp() function returns a record set like:
    vertex_id | edge_id | cost
which does not contain a geometry column.

To get the geometry column which is in your dourol table you need to join the results back to that table, change you DATA statement to something like:

DATA "the_geom from (
select b.the_geom, a.* from
   (SELECT * FROM shortest_path('SELECT gid AS id, source::int4,
              target::int4, length::double precision AS cost,
         FROM dourol',3, 7, false, false)) as a
   dourol b where a.edge_id=b.gid) AS
               foo using unique gid using srid=-1"

Also for what it is worth, if you are also using OpenLayers, I typically write a simple PHP ajax handler to interact with postgresql and format the results as XML or JSON then use an OpenLayers geometry feature to display the route. This way I compute the route once and can pan an zoom on the result in OpenLayers without having to requext a new route until I want to change the route. Look at this page to get some ideas:

http://gis.imaptools.com/routing/leaddog/?zoom=11&lat=33.86651&lon=35.51184&layers=B0TTTF&start=35.493583%2033.826664&stop=35.565174%2033.864285&method=STS&lang=eng

-Steve W

On 6/11/2012 1:59 PM, Pedro Costa wrote:

Thank you to all.
I resolved with a where statement but i also will try using '-1'.
I have another question, anybody know examples of using pgrouting with
mapserver?
Or know information about that....

Thanks

On 06/11/2012 06:05 PM, Max Weninger wrote:

Hi

On Mon, 11 Jun 2012 11:03:33 -0400
Stephen Woodbridge<woodbri@swoodbridge.com> wrote:

I'm pretty sure TRSP allows -1 for a cost and drops that edge
internally.

Yes
If you look at the code starting at line 361

Edges are only "used" if>=0.0

...
if(cur_edge.m_dCost>= 0.0)
...
if(cur_edge.m_dReverseCost>= 0.0)
...

Regards

max

-Steve W

On 6/11/2012 10:45 AM, James David Smith wrote:

Hi Pedro,

Could you someone temporarily remove the roads from the network
instead? When you do the select statement to query your network, you
could do a WHERE statement which ignores certain roads?

Might not work, just thinking out loud....

James

On 11 June 2012 15:40, Pedro Costa<pedrocostaarma@sapo.pt> wrote:

Em 11-06-2012 15:38, Steve Horn escreveu:

high cost (such as 99999999

Hello Steve,

With me the hight cost is a problem because my network have few
roads....

_______________________________________________
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

_______________________________________________
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

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

Thank you Steve.

But for now, i'm not using openlayers and so I'm searching examples with mapserver...

But it is a good example. I want implement one with more options....

On 06/11/2012 07:08 PM, Stephen Woodbridge wrote:

This page is in error:

http://www.pgrouting.org/docs/howto/mapserver.html

The result of the dijkstra_sp() function returns a record set like:
   vertex_id | edge_id | cost
which does not contain a geometry column.

To get the geometry column which is in your dourol table you need to join the results back to that table, change you DATA statement to something like:

DATA "the_geom from (
select b.the_geom, a.* from
  (SELECT * FROM shortest_path('SELECT gid AS id, source::int4,
             target::int4, length::double precision AS cost,
        FROM dourol',3, 7, false, false)) as a
  dourol b where a.edge_id=b.gid) AS
              foo using unique gid using srid=-1"

Also for what it is worth, if you are also using OpenLayers, I typically write a simple PHP ajax handler to interact with postgresql and format the results as XML or JSON then use an OpenLayers geometry feature to display the route. This way I compute the route once and can pan an zoom on the result in OpenLayers without having to requext a new route until I want to change the route. Look at this page to get some ideas:

http://gis.imaptools.com/routing/leaddog/?zoom=11&lat=33.86651&lon=35.51184&layers=B0TTTF&start=35.493583%2033.826664&stop=35.565174%2033.864285&method=STS&lang=eng

-Steve W

On 6/11/2012 1:59 PM, Pedro Costa wrote:

Thank you to all.
I resolved with a where statement but i also will try using '-1'.
I have another question, anybody know examples of using pgrouting with
mapserver?
Or know information about that....

Thanks

On 06/11/2012 06:05 PM, Max Weninger wrote:

Hi

On Mon, 11 Jun 2012 11:03:33 -0400
Stephen Woodbridge<woodbri@swoodbridge.com> wrote:

I'm pretty sure TRSP allows -1 for a cost and drops that edge
internally.

Yes
If you look at the code starting at line 361

Edges are only "used" if>=0.0

...
if(cur_edge.m_dCost>= 0.0)
...
if(cur_edge.m_dReverseCost>= 0.0)
...

Regards

max

-Steve W

On 6/11/2012 10:45 AM, James David Smith wrote:

Hi Pedro,

Could you someone temporarily remove the roads from the network
instead? When you do the select statement to query your network, you
could do a WHERE statement which ignores certain roads?

Might not work, just thinking out loud....

James

On 11 June 2012 15:40, Pedro Costa<pedrocostaarma@sapo.pt> wrote:

Em 11-06-2012 15:38, Steve Horn escreveu:

high cost (such as 99999999

Hello Steve,

With me the hight cost is a problem because my network have few
roads....

_______________________________________________
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

_______________________________________________
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

_______________________________________________
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

I'm trying to add a route layer to mapserver but can solve a problem.

If I do in my database works:

SELECT *
    FROM arcos
    JOIN
    (
SELECT * FROM shortest_path('
       SELECT id,
           source::int4 AS source,
           target::int4 AS target,
           length*estado_actual.custo AS cost
       FROM arcos, estado_actual
       where arcos.estado_a = estado_actual.id_ea',
       438,439,false,false)) AS rota
    ON
    arcos.id = rota.edge_id

So, in mapfile I add this:

select the_geom from

(SELECT *
    FROM arcos
    JOIN
    (
SELECT * FROM shortest_path('
       SELECT id,
           source::int4 AS source,
           target::int4 AS target,
           length*estado_actual.custo AS cost
       FROM arcos, estado_actual
       where arcos.estado_a = estado_actual.id_ea',
       438,439,false,false)) AS rota
    ON
    arcos.id = rota.edge_id) using unique id2

ANd I got this error:

ERROR: subquery in FROM must have an alias
LINE 6: (SELECT *

And I try again like this:

select the_geom from

(SELECT *
    FROM arcos
    JOIN
    (
SELECT * FROM shortest_path('
       SELECT id,
           source::int4 AS source,
           target::int4 AS target,
           length*estado_actual.custo AS cost
       FROM arcos, estado_actual
       where arcos.estado_a = estado_actual.id_ea',
       438,439,false,false)) AS rota
    ON
    arcos.id = rota.edge_id) as foo using unique id2

And give me this error:

ERROR: syntax error at or near "using"
LINE 19: arcos.id = rota.edge_id) as foo using unique id2

Can anyone tell me how to solve this problem in the query?

Thanks

On 11-06-2012 19:08, Stephen Woodbridge wrote:

This page is in error:

http://www.pgrouting.org/docs/howto/mapserver.html

The result of the dijkstra_sp() function returns a record set like:
   vertex_id | edge_id | cost
which does not contain a geometry column.

To get the geometry column which is in your dourol table you need to join the results back to that table, change you DATA statement to something like:

DATA "the_geom from (
select b.the_geom, a.* from
  (SELECT * FROM shortest_path('SELECT gid AS id, source::int4,
             target::int4, length::double precision AS cost,
        FROM dourol',3, 7, false, false)) as a
  dourol b where a.edge_id=b.gid) AS
              foo using unique gid using srid=-1"

Also for what it is worth, if you are also using OpenLayers, I typically write a simple PHP ajax handler to interact with postgresql and format the results as XML or JSON then use an OpenLayers geometry feature to display the route. This way I compute the route once and can pan an zoom on the result in OpenLayers without having to requext a new route until I want to change the route. Look at this page to get some ideas:

http://gis.imaptools.com/routing/leaddog/?zoom=11&lat=33.86651&lon=35.51184&layers=B0TTTF&start=35.493583%2033.826664&stop=35.565174%2033.864285&method=STS&lang=eng

-Steve W

On 6/11/2012 1:59 PM, Pedro Costa wrote:

Thank you to all.
I resolved with a where statement but i also will try using '-1'.
I have another question, anybody know examples of using pgrouting with
mapserver?
Or know information about that....

Thanks

On 06/11/2012 06:05 PM, Max Weninger wrote:

Hi

On Mon, 11 Jun 2012 11:03:33 -0400
Stephen Woodbridge<woodbri@swoodbridge.com> wrote:

I'm pretty sure TRSP allows -1 for a cost and drops that edge
internally.

Yes
If you look at the code starting at line 361

Edges are only "used" if>=0.0

...
if(cur_edge.m_dCost>= 0.0)
...
if(cur_edge.m_dReverseCost>= 0.0)
...

Regards

max

-Steve W

On 6/11/2012 10:45 AM, James David Smith wrote:

Hi Pedro,

Could you someone temporarily remove the roads from the network
instead? When you do the select statement to query your network, you
could do a WHERE statement which ignores certain roads?

Might not work, just thinking out loud....

James

On 11 June 2012 15:40, Pedro Costa<pedrocostaarma@sapo.pt> wrote:

Em 11-06-2012 15:38, Steve Horn escreveu:

high cost (such as 99999999

Hello Steve,

With me the hight cost is a problem because my network have few
roads....

_______________________________________________
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

_______________________________________________
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

_______________________________________________
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

I'm trying to add a route layer to mapserver but I can't solve a problem.

This works in my database:

SELECT *
    FROM arcos
    JOIN
    (
SELECT * FROM shortest_path('
       SELECT id,
           source::int4 AS source,
           target::int4 AS target,
           length*estado_actual.custo AS cost
       FROM arcos, estado_actual
       where arcos.estado_a = estado_actual.id_ea',
       438,439,false,false)) AS rota
    ON
    arcos.id = rota.edge_id

So, in mapfile I add this:

DATA the_geom from

(SELECT *
    FROM arcos
    JOIN
    (
SELECT * FROM shortest_path('
       SELECT id,
           source::int4 AS source,
           target::int4 AS target,
           length*estado_actual.custo AS cost
       FROM arcos, estado_actual
       where arcos.estado_a = estado_actual.id_ea',
       438,439,false,false)) AS rota
    ON
    arcos.id = rota.edge_id) using unique id2

But don't work. I simulate the query in my database replacing DATA for SELECT and I got this error:

ERROR: subquery in FROM must have an alias
LINE 6: (SELECT *

And I try again like this:

select the_geom from

(SELECT *
    FROM arcos
    JOIN
    (
SELECT * FROM shortest_path('
       SELECT id,
           source::int4 AS source,
           target::int4 AS target,
           length*estado_actual.custo AS cost
       FROM arcos, estado_actual
       where arcos.estado_a = estado_actual.id_ea',
       438,439,false,false)) AS rota
    ON
    arcos.id = rota.edge_id) as foo using unique id2

And give me this error:

ERROR: syntax error at or near "using"
LINE 19: arcos.id = rota.edge_id) as foo using unique id2

Can anyone tell me how to solve this problem in the query?

Thanks

On 11-06-2012 19:08, Stephen Woodbridge wrote:

This page is in error:

http://www.pgrouting.org/docs/howto/mapserver.html

The result of the dijkstra_sp() function returns a record set like:
   vertex_id | edge_id | cost
which does not contain a geometry column.

To get the geometry column which is in your dourol table you need to
join the results back to that table, change you DATA statement to
something like:

DATA "the_geom from (
select b.the_geom, a.* from
  (SELECT * FROM shortest_path('SELECT gid AS id, source::int4,
             target::int4, length::double precision AS cost,
        FROM dourol',3, 7, false, false)) as a
  dourol b where a.edge_id=b.gid) AS
              foo using unique gid using srid=-1"

Also for what it is worth, if you are also using OpenLayers, I
typically write a simple PHP ajax handler to interact with postgresql
and format the results as XML or JSON then use an OpenLayers geometry
feature to display the route. This way I compute the route once and
can pan an zoom on the result in OpenLayers without having to requext
a new route until I want to change the route. Look at this page to get
some ideas:

http://gis.imaptools.com/routing/leaddog/?zoom=11&lat=33.86651&lon=35.51184&layers=B0TTTF&start=35.493583%2033.826664&stop=35.565174%2033.864285&method=STS&lang=eng

-Steve W

On 6/11/2012 1:59 PM, Pedro Costa wrote:

Thank you to all.
I resolved with a where statement but i also will try using '-1'.
I have another question, anybody know examples of using pgrouting with
mapserver?
Or know information about that....

Thanks

On 06/11/2012 06:05 PM, Max Weninger wrote:

Hi

On Mon, 11 Jun 2012 11:03:33 -0400
Stephen Woodbridge<woodbri@swoodbridge.com> wrote:

I'm pretty sure TRSP allows -1 for a cost and drops that edge
internally.

Yes
If you look at the code starting at line 361

Edges are only "used" if>=0.0

...
if(cur_edge.m_dCost>= 0.0)
...
if(cur_edge.m_dReverseCost>= 0.0)
...

Regards

max

-Steve W

On 6/11/2012 10:45 AM, James David Smith wrote:

Hi Pedro,

Could you someone temporarily remove the roads from the network
instead? When you do the select statement to query your network, you
could do a WHERE statement which ignores certain roads?

Might not work, just thinking out loud....

James

On 11 June 2012 15:40, Pedro Costa<pedrocostaarma@sapo.pt> wrote:

Em 11-06-2012 15:38, Steve Horn escreveu:

high cost (such as 99999999

Hello Steve,

With me the hight cost is a problem because my network have few
roads....

_______________________________________________
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

_______________________________________________
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

_______________________________________________
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

Hi

Another thing that I just noticed looking in the TRSP code
IMHO you must not set the cost of a turn restriction to -1!

So this only applies to cost and reverseCost of the "edges"
e.g. for oneways

Regards

max

On Mon, 11 Jun 2012 19:27:20 +0200
Max Weninger <max.weninger@gmail.com> wrote:

Hi

One thing to mention for TRSP is also that using -1.0
will give you a "small" performance improvement since the
"starting" number of edges used for route calculation
will be less then if you use a large number

regards

max

On Mon, 11 Jun 2012 13:15:08 -0400
Stephen Woodbridge <woodbri@swoodbridge.com> wrote:

> Hi Max,
>
> Thank you for the confirmation on that. For other reads of this,
> you would need to verify that function other than TRSP do or do not
> do this. It would be nice if people that check for this would
> document it in ticket so we can update the documentation to
> accurately reflect these facts.
>
> Thanks,
> -Steve
>
> On 6/11/2012 1:05 PM, Max Weninger wrote:
> > Hi
> >
> > On Mon, 11 Jun 2012 11:03:33 -0400
> > Stephen Woodbridge<woodbri@swoodbridge.com> wrote:
> >> I'm pretty sure TRSP allows -1 for a cost and drops that edge
> >> internally.
> >
> > Yes
> > If you look at the code starting at line 361
> >
> > Edges are only "used" if>=0.0
> >
> > ...
> > if(cur_edge.m_dCost>= 0.0)
> > ...
> > if(cur_edge.m_dReverseCost>= 0.0)
> > ...
> >
> > Regards
> >
> > max
> >
> >> -Steve W
> >>
> >> On 6/11/2012 10:45 AM, James David Smith wrote:
> >>> Hi Pedro,
> >>>
> >>> Could you someone temporarily remove the roads from the network
> >>> instead? When you do the select statement to query your network,
> >>> you could do a WHERE statement which ignores certain roads?
> >>>
> >>> Might not work, just thinking out loud....
> >>>
> >>> James
> >>>
> >>>
> >>>
> >>> On 11 June 2012 15:40, Pedro Costa<pedrocostaarma@sapo.pt>
> >>> wrote:
> >>>> Em 11-06-2012 15:38, Steve Horn escreveu:
> >>>>>
> >>>>> high cost (such as 99999999
> >>>>
> >>>>
> >>>> Hello Steve,
> >>>>
> >>>> With me the hight cost is a problem because my network have few
> >>>> roads....
> >>>>
> >>>>
> >>>>
> >>>> _______________________________________________
> >>>> 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
> >>
> >> _______________________________________________
> >> 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
>
> _______________________________________________
> Pgrouting-users mailing list
> Pgrouting-users@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/pgrouting-users