shortest path search with pgrouting

55
Shortest Path Search with pgRouting Daniel Kastl

Upload: foss4g-2011

Post on 18-Nov-2014

1.268 views

Category:

Technology


2 download

DESCRIPTION

Shortest Path Search with pgRouting by Daniel Kastl of GeoRepublic

TRANSCRIPT

Page 1: Shortest Path Search with pgRouting

Shortest Path Search with pgRouting

Daniel Kastl

Page 2: Shortest Path Search with pgRouting

What is pgRouting?

Page 3: Shortest Path Search with pgRouting

An Extension for

PostgreSQL / PostGIS, ...

Page 4: Shortest Path Search with pgRouting

An Open Source project, ...

Page 5: Shortest Path Search with pgRouting

A Library providing, ...

Page 6: Shortest Path Search with pgRouting

Shortest Path

Page 7: Shortest Path Search with pgRouting

DD and TSP

Page 8: Shortest Path Search with pgRouting

DARP

Page 9: Shortest Path Search with pgRouting

@justjkk

@jay_mahadeokar

Page 10: Shortest Path Search with pgRouting

APSP and TDSP

Page 11: Shortest Path Search with pgRouting

Multi-Modal

Page 12: Shortest Path Search with pgRouting

https://github.com/pgRouting/pgrouting

Page 13: Shortest Path Search with pgRouting

SQL Function

SELECT * FROM shortest_path('

SELECT gid as id,

source::integer,

target::integer,

length::float8 as cost

FROM ways',

605, 359, false, false);

Page 14: Shortest Path Search with pgRouting

Query Result

vertex_id | edge_id | cost

-----------+---------+--------------------

605 | 599 | 0.19925085940845

604 | 598 | 0.100258103875674

603 | 597 | 0.201123583387407

602 | 596 | 0.204847680679676

601 | 595 | 0.158334540345002

4293 | 9602 | 0.0183273901669081

... | ... | ...

Page 15: Shortest Path Search with pgRouting

Most users need pgRouting for

Road Networks

How do they look like?

Page 16: Shortest Path Search with pgRouting

Like this ...

Page 17: Shortest Path Search with pgRouting

… or like this ...

Page 18: Shortest Path Search with pgRouting

… or sometimes like this.

Page 19: Shortest Path Search with pgRouting

What makes them real?

Traffic lights Signs Road marking

Page 20: Shortest Path Search with pgRouting

How can pgRouting help here?

Page 21: Shortest Path Search with pgRouting

gid,source,target,cost,reverse_cost,x1, y1,x2, y2,rule,to_cost

source

target

Page 22: Shortest Path Search with pgRouting

Traffic lights slow down

… so costs must increase.

Page 23: Shortest Path Search with pgRouting

A

BC

D

cost(A)=cost(A)+30seccost(B)=cost(B)+30seccost(C)=cost(C)+30seccost(D)=cost(D)+30sec

1min

Page 24: Shortest Path Search with pgRouting

Signs inform about

restrictions and rules

Page 25: Shortest Path Search with pgRouting
Page 26: Shortest Path Search with pgRouting

cost(A) = length(A)reverse_cost(A) = ∞

A

Page 27: Shortest Path Search with pgRouting

Sometimes

the costs

have different

meaning.

Page 28: Shortest Path Search with pgRouting

cost(A)=length(A)/2reverse_cost(A)=length(A)*2

cost(B)=length(B)*3reverse_cost(B)=length(B)/3

A

B

Page 29: Shortest Path Search with pgRouting

Turn restrictions

obviously

restrict turns.

Page 30: Shortest Path Search with pgRouting

A

BC

D

cost(A)=cost(A)+1mincost(B)=cost(B)+1mincost(C)=cost(C)+1mincost(D)=cost(D)+1min

1min

A

BC

D

rule(A) = "D"to_cost(A, D) = ∞

Page 31: Shortest Path Search with pgRouting

Road type

can be used

for cost

calculation.

Page 32: Shortest Path Search with pgRouting

Not only road types

but also conditions

Page 33: Shortest Path Search with pgRouting

http://upload.wikimedia.org/wikipedia/commons/e/e4/Jughandle_signage.jpg

Jughandle intersection

Page 34: Shortest Path Search with pgRouting

@ckrahe

Page 35: Shortest Path Search with pgRouting

And you know

what is great about pgRouting?

Page 36: Shortest Path Search with pgRouting

All costs are dynamic!… which is the opposite to pre-calculated

Page 37: Shortest Path Search with pgRouting

If the road is closed ...

Page 38: Shortest Path Search with pgRouting

… or there is an accident, ...

Page 39: Shortest Path Search with pgRouting

… there is a sign with

restrictions limited

to a certain time, ...

Page 40: Shortest Path Search with pgRouting

… bad weather conditions ...

Page 41: Shortest Path Search with pgRouting

… or any other obstacle, ...

Page 42: Shortest Path Search with pgRouting

You don't need to

rebuild and reload

your network

Page 43: Shortest Path Search with pgRouting

… and wait forever.

Page 44: Shortest Path Search with pgRouting

You only need to adjust the cost

for this particular road,

and the next search will go another way.

Page 45: Shortest Path Search with pgRouting

Cost can be virtually anything

Page 46: Shortest Path Search with pgRouting

OpenStreetMap data

Page 47: Shortest Path Search with pgRouting

pgRouting can be used for

different kinds of networks

Page 48: Shortest Path Search with pgRouting

Canals and

Rivers

Page 49: Shortest Path Search with pgRouting

Hiking trails

Page 50: Shortest Path Search with pgRouting

… or any other

kind of networks.

Page 51: Shortest Path Search with pgRouting

pgRouting Demo

http://websi.openvrp.com

http://map.veloland.ch

http://www.ridethecity.com

http://www.pgrouting.org/gallery.html

Page 52: Shortest Path Search with pgRouting

Plans until FOSS4G 2012

● Integrate new functions

● All-Pair-Shortest-Path

● Time-Dependent-Shortest-Path

● Multi-Modal

● Two-way A-Star, ...

● Drop CGAL dependency

● PostgreSQL 9.x & PostGIS 2.0 support

● Source cleanup

Page 53: Shortest Path Search with pgRouting

www.pgrouting.org

workshop.pgrouting.org

[email protected]

Page 54: Shortest Path Search with pgRouting
Page 55: Shortest Path Search with pgRouting

Photos from sxc.hu and flickr under Creative Commons Licence.