[pgrouting-users] problem with pgrouting.

Daniel Kastl kastl at orkney.co.jp
Thu Feb 5 18:35:46 EST 2009


Hi Valeria,

It returns the length in the unit of your projection if you take the
length of your geometry.
Often data has an attribute length, which is probably meter then, but
your number looks like length in degrees.

You can transform your geometry in a meter projection first  and then
get the length, like

SELECT length(transform(setsrid(the_geom,<your current projection>),<a
meter projection>);

If you have a lot of data and your routing becomes slow, I recommend you
to precalculate those attributes.

Daniel

Valeria Muñoz schrieb:
> Daniel
>  
> what type of measure returns the function length()?, my result
> was:0.00208418695629
>  
> I have the SPEED field, you know how I can give instructions such as
> turn right or left?
>  
> RG
>
> 2009/2/5 Daniel Kastl <kastl at orkney.co.jp <mailto:kastl at orkney.co.jp>>
>
>     Valeria,
>
>     This depends on your data. Distance might be your current cost
>     already.
>     You can get the total distance with SELECT
>     sum(length(rt.the_geom)) ... .
>
>     If you want to have time you might need a "speed" attribute for your
>     road link table.
>
>     Daniel
>
>
>     Valeria Muñoz schrieb:
>     >
>     >   how can i get the distance,time, if you have to turn right o
>     to turn
>     > left??
>     >
>     > RG
>     >
>     >
>     > 2009/2/4 Valeria Muñoz <valemunoz at gmail.com
>     <mailto:valemunoz at gmail.com> <mailto:valemunoz at gmail.com
>     <mailto:valemunoz at gmail.com>>>
>     >
>     >     Stephen you are right i change to :
>     >
>     >
>     >     SELECT assign_vertex_id('edges', 0.000001, 'the_geom', 'gid');
>     >      and works!!! thanks!!
>     >
>     >
>     >
>     >     2009/2/4 Stephen Woodbridge <woodbri at swoodbridge.com
>     <mailto:woodbri at swoodbridge.com>
>     >     <mailto:woodbri at swoodbridge.com
>     <mailto:woodbri at swoodbridge.com>>>
>     >
>     >         Valeria,
>     >
>     >         What projection is your shapefile in? it looks like WGS84 or
>     >         NAD83 from your coordinates below. So when you did:
>     >
>     >         SELECT assign_vertex_id('edges', 0.001, 'the_geom', 'gid');
>     >
>     >         you should probably have done:
>     >
>     >         SELECT assign_vertex_id('edges', 0.000001, 'the_geom',
>     'gid');
>     >
>     >         The tolerance needs to be in the units of your data.
>     This will
>     >         probably give better results.
>     >
>     >         You should probably drop the database and start over with a
>     >         new load and use the statement above when you get to
>     that step.
>     >
>     >         -Steve
>     >
>     >
>     >         Valeria Muñoz wrote:
>     >
>     >             Hi
>     >              I followed a little tutorial works perfectly with the
>     >             shapefile from the example, but to use mine the
>     result is
>     >             not expected, generating lines are not continuous, I
>     think
>     >             I missing some coordinates or something to work with my
>     >             shapefile.
>     >              tutorial url
>     >             http://www.utdallas.edu/~ama054000/rt_tutorial.html
>     <http://www.utdallas.edu/%7Eama054000/rt_tutorial.html>
>     >             <http://www.utdallas.edu/%7Eama054000/rt_tutorial.html>
>     >              query:
>     >              the query is optimal path between 887 y 852. :
>     >             SELECT rt.gid, AsText(rt.the_geom) AS wkt,
>     >                               length(rt.the_geom) AS length,
>     calle.gid
>     >                            FROM calle,
>     >                                (SELECT gid, the_geom
>     >                                    FROM dijkstra_sp_delta(
>     >                                        'calle',
>     >                                        887,
>     >                                        852,
>     >                                        3000)
>     >                                 ) as rt
>     >                            WHERE calle.gid=rt.gid;
>     >             result:
>     >              "gid";"wkt";"length";"gid"
>     >             4389;"MULTILINESTRING((-71.1951327440651
>     >             -30.5911350429583,-71.1957462426904
>     >             -30.5912128948402,-71.1957861853043
>     >             -30.591219747929,-71.1958400125164
>     >             -30.591211719682))";0.000713367403530106;4389
>     >             4603;"MULTILINESTRING((-71.1939954028678
>     >             -30.5921681162637,-71.1939834234752
>     >             -30.5922241673576,-71.1938231446269
>     >             -30.5925509466888))";0.000421286769021393;4603
>     >             4331;"MULTILINESTRING((-71.1950174992082
>     >             -30.5919506007811,-71.1950526139385
>     >             -30.5916919152203))";0.000261057969957178;4331
>     >             4608;"MULTILINESTRING((-71.1938231446269
>     >             -30.5925509466888,-71.1937648360013
>     >             -30.5926358138883))";0.00010296765211197;4608
>     >             RG
>     >             attached image.
>     >              please help!!..
>     >
>     >            
>     ------------------------------------------------------------------------
>     >
>     >
>     >            
>     ------------------------------------------------------------------------
>     >
>     >             _______________________________________________
>     >             Pgrouting-users mailing list
>     >             Pgrouting-users at lists.postlbs.org
>     <mailto:Pgrouting-users at lists.postlbs.org>
>     >             <mailto:Pgrouting-users at lists.postlbs.org
>     <mailto:Pgrouting-users at lists.postlbs.org>>
>     >            
>     http://lists.postlbs.org/mailman/listinfo/pgrouting-users
>     >
>     >
>     >
>     >
>     >
>     ------------------------------------------------------------------------
>     >
>     > _______________________________________________
>     > Pgrouting-users mailing list
>     > Pgrouting-users at lists.postlbs.org
>     <mailto:Pgrouting-users at lists.postlbs.org>
>     > http://lists.postlbs.org/mailman/listinfo/pgrouting-users
>     >
>
>     _______________________________________________
>     Pgrouting-users mailing list
>     Pgrouting-users at lists.postlbs.org
>     <mailto:Pgrouting-users at lists.postlbs.org>
>     http://lists.postlbs.org/mailman/listinfo/pgrouting-users
>
>




More information about the Pgrouting-users mailing list