Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 3 Next »

This document describes how download and install a working network available for routing

 Download osm2po

Make sure you have av home directory with full access.

Osm2po webb page is http://osm2po.de/ and the lates releases from http://osm2po.de/releases/

download
#download osm2po (check version)
wget  http://osm2po.de/releases/osm2po-5.1.35.zip

#unzip
mkdir osm2po
unzip osm2po-5.1.35.zip -d  ./osm2po
rm osm2po-5.1.35.zip

Change open2po.config

The default is good but it does not include bike and walk path.

osm2po.config changes
# only convert ways with one of these flags

#.default.wtr.finalMask = car
.default.wtr.finalMask = car|bike
#.default.wtr.finalMask = bike|foot&goodgrade (since v5.0.20) 

# osm2po needs to know the anchor-tag and some default values if not tagged.
# To avoid ambiguities configure a well chosen priority.
# Main-Tag definitions. Params 1-4:
# 1) priority
# 2) clazz identifier (1-127)
# 3) default speed in kmh
# 4) allowed transportation type (optional)

.default.wtr.tag.highway.motorway =       1,  11, 100, car
.default.wtr.tag.highway.motorway_link =  1,  12, 30,  car
.default.wtr.tag.highway.trunk =          1,  13, 90,  car
.default.wtr.tag.highway.trunk_link =     1,  14, 30,  car
.default.wtr.tag.highway.primary =        1,  15, 70,  car
.default.wtr.tag.highway.primary_link =   1,  16, 30,  car
.default.wtr.tag.highway.secondary =      1,  21, 60,  car
.default.wtr.tag.highway.secondary_link = 1,  22, 30,  car
.default.wtr.tag.highway.tertiary =       1,  31, 40,  car|bike
.default.wtr.tag.highway.tertiary =       1,  33, 40,  car|bike
.default.wtr.tag.highway.tertiary_link =  1,  32, 20,  car|bike
.default.wtr.tag.highway.residential =    1,  41, 40,  car|bike
.default.wtr.tag.highway.road =           1,  42, 50,  car|bike
.default.wtr.tag.highway.unclassified =   1,  43, 50,  car|bike
.default.wtr.tag.highway.service =        1,  51, 5,   car|bike
.default.wtr.tag.highway.living_street =  1,  63, 7,   car|bike|foot   
.default.wtr.tag.highway.pedestrian =     1,  62, 5,   bike|foot
.default.wtr.tag.highway.track =          1,  71, 10,  bike|foot
.default.wtr.tag.highway.path =           1,  72, 10,  bike|foot
.default.wtr.tag.highway.cycleway =       1,  81, 15,  bike
#.default.wtr.tag.highway.footway =        2,  91, 5,   foot
#.default.wtr.tag.highway.steps =          2,  92, 5,   foot
.default.wtr.tag.route.ferry =            2,   1, 10,  ferry
#.default.wtr.tag.route.shuttle_train =    2,   2, 50,  rail|car
#.default.wtr.tag.railway.rail =           3,   3, 50,  rail

# Other tags may also overwrite the default transportation type definition.
# Tags without explicit values like wtr.deny.motorcar act like
# an else-part and will be used if no other tag=value matches.

.default.wtr.allow.motor[car|_vehicle].[yes|destination] = car
.default.wtr.allow.[bicycle|cycleway] = bike
.default.wtr.allow.[footway|sidewalk] = foot

#.default.wtr.deny.tracktype.grade[4|5] = car|bike
#.default.wtr.deny.access.no = car|bike|foot|rail|ferry
#.default.wtr.deny.vehicle.no = car|bike
#.default.wtr.deny.motor[_vehicle|car] = car
#.default.wtr.deny.bicycle.no = bike
#.default.wtr.deny.foot.no = foot
#.default.wtr.deny.footway.none = foot

Get data and run osm2po

running osm2po
cd osm2po
java -Xmx1g -jar osm2po-core-5.1.35-signed.jar prefix=sweden tileSize=x http://download.geofabrik.de/europe/sweden-latest.osm.pbf postp.0.class=de.cm.osm2po.plugins.postp.PgRoutingWriter cmd=c

Create database osm2po and load data

Create osm2po database
#be postgres
sudo su postgres
#run psql
psql
create database osm2po;
\q
psql osm2po
create extension postgis; 
\i ./sweden/sweden_2po_4pgr.sql;
\q
exit

Create tables and views

osm2po tables
create extension pgrouting;

alter table public.sweden_2po_4pgr add column bike_cost double precision; 
alter table public.sweden_2po_4pgr add column walk_cost double precision; 
update public.sweden_2po_4pgr set 
bike_cost = CASE WHEN clazz IN (11,12,13,14)  THEN 100000 when kmh < 17 then km/kmh ELSE (km/17)::double precision END , 
walk_cost= CASE WHEN clazz IN (11,12,13,14)  THEN 100000 when kmh < 6 then km/kmh ELSE (km/6)::double precision END;

CREATE TABLE public.sweden_osm2po_nodes (id integer primary key);
SELECT AddGeometryColumn('public','sweden_osm2po_nodes','geom',4326,'point',2);

INSERT INTO public.sweden_osm2po_nodes(id, geom) (
select id, st_centroid(st_collect(pt)) as geom
from (
    (select source as id, st_startpoint(geom_way) as pt
    from public.sweden_2po_4pgr
    ) 
union
    (select target as id, st_endpoint(geom_way) as pt
    from public.sweden_2po_4pgr
    ) 
) as foo
group by id
);

CREATE INDEX idx_sweden_osm2po_nodes_id ON public.sweden_osm2po_nodes(id);
--drop table public.distance_nodes
CREATE TABLE public.distance_nodes (id serial, "name" text, node integer, edge integer, cost double precision );
SELECT AddGeometryColumn('public','distance_nodes','geom',4326,'point',2);

-- isocrones 
CREATE TABLE distance_polygons (id serial, name text, max_cost double precision);
SELECT AddGeometryColumn('distance_polygons','geom',4326,'POLYGON',2);

Find a start and end node for making examples of routing and distances

Longitude (west) and Latitude (north) , place

59,1214893, 18,1033966, Villavägen 1 Västerhaninge

59,2717347, 18,0460712, Kallforsvägen, Bandhagen

find node
 





  • No labels