我们在OpenStreetMap上进行路由(路由)。介绍

我想分享在OpenStreetMap上创建PostgreSQL / PgRouting路由系统的经验。这将涉及开发具有复杂需求的[商业]解决方案,对于更简单的项目,可能足以查阅文档。据我所知,诸如全面支持单向道路和行车路线,快速路由到数千个地址(在常规笔记本电脑上为数秒之内,例如Macbook Pro 13“ 2013),创建具有指定属性的路线图,对路径进行元优化它不会在任何地方被考虑,并且像往常一样,所有数据和结果都在我的OSM Routing Tricks的GitHub存储库中提供,我将在发布时添加它。





330 OpenStreetMap ( 5 ). , , 5000 ? , , ( ).





, , , . : , , , , , ( )! PgRouting PostgreSQL OpenStreetMap.



, . , , - . , PgRouting . , , , .



, .





PgRouting 3.0 PostgreSQL 12, PgRouting 2.6 PostgreSQL 9 . , MacOS ( ) Debian/Ubuntu ( ) PgRouting pgr_TSP() , , , , "" MacOS , , , , . MacOS Debian/Ubuntu.



OpenStreetMap PostgreSQL



, GDAL, , . , , OpenStreetMap PostgreSQL SQL , . GDAL: PostgreSQL SQL Dump. , . GDAL. OSM (germany-latest.osm.pbf) PostgreSQL (osmrouting):



ogr2ogr \
    -f PGDUMP \
    /vsistdout/ "germany-latest.osm.pbf" \
    -nln "osm_lines" \
    -nlt LINESTRING \
    -progress \
    --config PG_USE_COPY YES \
    --config GEOMETRY_NAME the_geom \
    --config OSM_COMPRESS_NODES YES \
    --config OSM_CONFIG_FILE "osmconf.ini" \
    -sql "select * from lines where highway is not null" \
    -lco FID=id \
    | psql osmrouting


OpenStreetMap OpenStreetMap Data Extracts.



OpenStreetMap



. (), — . , , (). , ? , — , , , , . , , . PgRouting.



( ) , (, , ) . , . , . , .





. , , . , () , .



( ) , , . , . , 10 100 .



, , «» ? — () , (, , ) . . , 10 100 , , — ! , — . , , () , . .



PostgreSQL



"osmrouting", , PostgreSQL SQL , . load.sh ( PgRouting PostGIS).



, , ( start_id end_id , , , length):



--      (  )
-- id -   
-- the_geom -     
-- oneway -   
-- highway -    (      )
-- pedestrian -    (   )
-- start_id -      
-- end_id -      
-- length -   (        .)
osmrouting=# \d osm_network
                       Table "public.osm_network"
   Column   |           Type            | Collation | Nullable | Default 
------------+---------------------------+-----------+----------+---------
 id         | integer                   |           |          | 
 the_geom   | geometry(LineString,4326) |           |          | 
 type       | text                      |           |          | 
 oneway     | boolean                   |           |          | 
 highway    | boolean                   |           |          | 
 pedestrian | boolean                   |           |          | 
 start_id   | bigint                    |           |          | 
 end_id     | bigint                    |           |          | 
 length     | double precision          |           |          | 


:



--     
-- id -   
-- the_geom -     
osmrouting=# \d osm_nodes
                     Table "public.osm_nodes"
  Column  |         Type         | Collation | Nullable | Default 
----------+----------------------+-----------+----------+---------
 id       | bigint               |           |          | 
 the_geom | geometry(Point,4326) |           |          | 


, :



osmrouting=# \d osm_buildings
                   Table "public.osm_buildings"
  Column  |         Type         | Collation | Nullable | Default 
----------+----------------------+-----------+----------+---------
 id       | character varying    |           |          | 
 the_geom | geometry(Point,4326) |           |          | 
...


.





route.sql 330 PgRouting pgr_TSP(). , , ( , . PgRouting). pgr_dijkstraCostMatrix(). , directed=false, pgr_TSP() (, , ). pgr_dijkstraSymmetrizeCostMatrix() pgr_dijkstraValidateCostMatrix() , . , ( — ) pgr_dijkstraVia() .



randomize=false , randomize=true, . SQL "route" , QGIS. QGIS , . route.qgs .



:





, — , 245,246,247 . «» — , , . ( ), , .





— , PgRouting. , ( , ), , . .




All Articles