banniere

Le portail francophone de la géomatique


Toujours pas inscrit ? Mot de passe oublié ?
Nom d'utilisateur    Mot de passe              Toujours pas inscrit ?   Mot de passe oublié ?

Annonce

Pour sécuriser votre compte sur les forums du GeoRezo, nous demandons de changer votre mot de passe.

Vous allez recevoir un message pour effectuer ce changement de mot de passe.

Merci de bien respecter les règles préconisées.

#1 Mon 05 September 2011 16:54

icadedt
Participant assidu
Lieu: ici et là
Date d'inscription: 21 Jul 2006
Messages: 478

[pgrouting] fonction driving_distance et voies à sens unique

Bonjour,

la fonction driving_distance de pgrouting permet de determiner des zones isochrones.
Comment fait on comprendre à cette fonction qu'on doit tenir compte des restriction dues au sens
unique de certaines voies?


http://www.pgrouting.org/docs/1.x/dd.html


Merci d'avance

Hors ligne

 

#2 Mon 05 September 2011 19:21

Nicolas Ribot
Membre
Lieu: Toulouse
Date d'inscription: 9 Sep 2005
Messages: 1538

Re: [pgrouting] fonction driving_distance et voies à sens unique

icadedt a écrit:

Bonjour,

la fonction driving_distance de pgrouting permet de determiner des zones isochrones.
Comment fait on comprendre à cette fonction qu'on doit tenir compte des restriction dues au sens
unique de certaines voies?


http://www.pgrouting.org/docs/1.x/dd.html


Merci d'avance


Bonsoir,

En regardant rapidos, les parametres cost de la requete SQL recupérant les données de routing et reverse_cost permettent de prendre en compte les sens interdits:
Mettre has_reverse_cost a vrai et ajouter une colonne reverse_cost dans son jeu de données, en mettant une valeur négative pour les troncons a sens unique. Ces troncons ne pourront alors etre parcouru que dans un seul sens lors du calcul avec driving_distance.

Nicolas

Hors ligne

 

#3 Wed 07 September 2011 10:07

icadedt
Participant assidu
Lieu: ici et là
Date d'inscription: 21 Jul 2006
Messages: 478

Re: [pgrouting] fonction driving_distance et voies à sens unique

quand j'essaie d'utiliser la fonction driving_distance, le systeme me dit que c'est une fonction inconnue, alors je vais voir dans le fichier routing_core.sql et je n'ai pas de définition pour la fonction en question:

--
-- Copyright (c) 2005 Sylvain Pasche,
--               2006-2007 Anton A. Patrushev, Orkney, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
--


CREATE TYPE path_result AS (vertex_id integer, edge_id integer, cost float8);
CREATE TYPE vertex_result AS (x float8, y float8);

-----------------------------------------------------------------------
-- Core function for shortest_path computation
-- See README for description
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION shortest_path(sql text, source_id integer,
        target_id integer, directed boolean, has_reverse_cost boolean)
        RETURNS SETOF path_result
        AS '$libdir/librouting'
        LANGUAGE 'C' IMMUTABLE STRICT;

-----------------------------------------------------------------------
-- Core function for shortest_path_astar computation
-- Simillar to shortest_path in usage but uses the A* algorithm
-- instead of Dijkstra's.
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION shortest_path_astar(sql text, source_id integer,
        target_id integer,directed boolean, has_reverse_cost boolean)
         RETURNS SETOF path_result
         AS '$libdir/librouting'
         LANGUAGE 'C' IMMUTABLE STRICT;

-----------------------------------------------------------------------
-- Core function for shortest_path_astar computation
-- Simillar to shortest_path in usage but uses the Shooting* algorithm
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION shortest_path_shooting_star(sql text, source_id integer,
        target_id integer,directed boolean, has_reverse_cost boolean)
         RETURNS SETOF path_result
         AS '$libdir/librouting'
         LANGUAGE 'C' IMMUTABLE STRICT;

-----------------------------------------------------------------------
-- This function should not be used directly. Use create_graph_tables instead
--
-- Insert a vertex into the vertices table if not already there, and
--  return the id of the newly inserted or already existing element
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION insert_vertex(vertices_table varchar,
       geom_id anyelement)
       RETURNS int AS
$$
DECLARE
        vertex_id int;
        myrec record;
BEGIN
        LOOP
          FOR myrec IN EXECUTE 'SELECT id FROM ' ||
                     quote_ident(vertices_table) ||
                     ' WHERE geom_id = ' || quote_literal(geom_id)  LOOP

                        IF myrec.id IS NOT NULL THEN
                                RETURN myrec.id;
                        END IF;
          END LOOP;
          EXECUTE 'INSERT INTO ' || quote_ident(vertices_table) ||
                  ' (geom_id) VALUES (' || quote_literal(geom_id) || ')';
        END LOOP;
END;
$$
LANGUAGE 'plpgsql' VOLATILE STRICT;


Où peut on bien trouver la définition de la fonction driving_distance?


je travaille avec pgrouting 1.03 pour postgresql 8.4.2

Dernière modification par icadedt (Wed 07 September 2011 10:22)

Hors ligne

 

#4 Wed 07 September 2011 11:04

Nicolas Ribot
Membre
Lieu: Toulouse
Date d'inscription: 9 Sep 2005
Messages: 1538

Re: [pgrouting] fonction driving_distance et voies à sens unique

icadedt a écrit:

quand j'essaie d'utiliser la fonction driving_distance, le systeme me dit que c'est une fonction inconnue, alors je vais voir dans le fichier routing_core.sql et je n'ai pas de définition pour la fonction en question:

--
-- Copyright (c) 2005 Sylvain Pasche,
--               2006-2007 Anton A. Patrushev, Orkney, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
--


CREATE TYPE path_result AS (vertex_id integer, edge_id integer, cost float8);
CREATE TYPE vertex_result AS (x float8, y float8);

-----------------------------------------------------------------------
-- Core function for shortest_path computation
-- See README for description
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION shortest_path(sql text, source_id integer,
        target_id integer, directed boolean, has_reverse_cost boolean)
        RETURNS SETOF path_result
        AS '$libdir/librouting'
        LANGUAGE 'C' IMMUTABLE STRICT;

-----------------------------------------------------------------------
-- Core function for shortest_path_astar computation
-- Simillar to shortest_path in usage but uses the A* algorithm
-- instead of Dijkstra's.
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION shortest_path_astar(sql text, source_id integer,
        target_id integer,directed boolean, has_reverse_cost boolean)
         RETURNS SETOF path_result
         AS '$libdir/librouting'
         LANGUAGE 'C' IMMUTABLE STRICT;

-----------------------------------------------------------------------
-- Core function for shortest_path_astar computation
-- Simillar to shortest_path in usage but uses the Shooting* algorithm
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION shortest_path_shooting_star(sql text, source_id integer,
        target_id integer,directed boolean, has_reverse_cost boolean)
         RETURNS SETOF path_result
         AS '$libdir/librouting'
         LANGUAGE 'C' IMMUTABLE STRICT;

-----------------------------------------------------------------------
-- This function should not be used directly. Use create_graph_tables instead
--
-- Insert a vertex into the vertices table if not already there, and
--  return the id of the newly inserted or already existing element
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION insert_vertex(vertices_table varchar,
       geom_id anyelement)
       RETURNS int AS
$$
DECLARE
        vertex_id int;
        myrec record;
BEGIN
        LOOP
          FOR myrec IN EXECUTE 'SELECT id FROM ' ||
                     quote_ident(vertices_table) ||
                     ' WHERE geom_id = ' || quote_literal(geom_id)  LOOP

                        IF myrec.id IS NOT NULL THEN
                                RETURN myrec.id;
                        END IF;
          END LOOP;
          EXECUTE 'INSERT INTO ' || quote_ident(vertices_table) ||
                  ' (geom_id) VALUES (' || quote_literal(geom_id) || ')';
        END LOOP;
END;
$$
LANGUAGE 'plpgsql' VOLATILE STRICT;


Où peut on bien trouver la définition de la fonction driving_distance?


je travaille avec pgrouting 1.03 pour postgresql 8.4.2


Bonjour,

Effectivement, le fichier routing_core.sql ne contient que les fonctions de base de pgRouting et DD n'en fait pas partie.
Il faut installer les autres fonctions de pgRouting, comme indiqué ici: http://www.pgrouting.org/docs/1.x/install.html, chapitre "step 3":


Code:

3. Add pgRouting extra functions (optional)
# With TSP
psql -U postgres -f /usr/share/postlbs/routing_tsp.sql routing
psql -U postgres -f /usr/share/postlbs/routing_tsp_wrappers.sql routing

# With Driving Distance
psql -U postgres -f /usr/share/postlbs/routing_dd.sql routing
psql -U postgres -f /usr/share/postlbs/routing_dd_wrappers.sql routing

Nicolas

Hors ligne

 

#5 Wed 07 September 2011 16:58

icadedt
Participant assidu
Lieu: ici et là
Date d'inscription: 21 Jul 2006
Messages: 478

Re: [pgrouting] fonction driving_distance et voies à sens unique

Que veut dire plus précisément le paramètre "directed"?

CREATE OR REPLACE FUNCTION driving_distance(
                        sql text,
                        source_id integer,
                        distance float8,
                        directed boolean,
                        has_reverse_cost boolean)
        RETURNS SETOF path_result


Quand on met reverse_cost à true , faut-il mettre aussi obligatoirement directed à true?

Dernière modification par icadedt (Wed 07 September 2011 16:59)

Hors ligne

 

Pied de page des forums

Powered by FluxBB