Demo pgRouting

Actions

Récupérer le sommet le plus proche correspondant à une coordonée

SELECT
  id,
  x(the_geom),
  y(the_geom)
FROM vertices_tmp
WHERE id = (
  SELECT id(foo.x) as id
  FROM (
    SELECT find_node_by_nearest_link_within_distance( 'POINT(longitude_value latitude_value)',  0.5, 'ways')::link_point as x
  ) AS foo
) 

Recherche d'un itinéraire entre deux sommet

SELECT st_asgeojson(st_transform(st_union(the_geom), 900913)) as geometry
FROM ways
WHERE gid in (
  SELECT edge_id
  FROM shortest_path('
    SELECT gid as id,
      source::integer,
      target::integer,
      to_cost as cost,
      reverse_cost
      FROM ways',
      start_vertice_id,
      end_vertice_id,
      false,
      false)
    );