pgRouting / osm2pgrouting

Import tool for OpenStreetMap data to pgRouting database
https://pgrouting.org
GNU General Public License v2.0
288 stars 112 forks source link

End Of File encountered before ways and relations are imported #228

Closed veniversum closed 6 years ago

veniversum commented 6 years ago

Here's the osm file that I'm importing. The config file is just the default mapconfig.xml provided. osm2pgrouting is built from most recent commit e937efd on master branch.

I'm running with command line options --addnodes --attributes --tags

Only osm_nodes gets populated and osm_ways and osm_relations remain empty even though there are relevant entries in the osm file.

Connecting to the database
connection success

.... <bunch of dropping/creating of tables> ....

Opening configuration file: /usr/share/osm2pgrouting/mapconfig.xml
    Parsing configuration

Exporting configuration ...
  - Done
Counting lines ...
  - Done
Opening data file: osm/example.osm      total lines: 23458
    Parsing data

Current osm_nodes:      0
Final osm_nodes:        6223
Current osm_ways:       0
End Of file

    Finish Parsing data

Adding auxiliary tables to database...
... <bunch of other output>

Any idea why this is happening?

veniversum commented 6 years ago

I seem to have narrowed down the problem. None of the relations matched tags in the config (at least OSMDocument::AddRelation was never called), and in combination with the default chunk size of 20000, meant that none of the way data was exported to the database.

I think adding a check for m_waysPending in OSMDocument::endOfFile() similar to how it's already done in OSMDocument::AddRelation suffices as a fix for this bug.

cayetanobv commented 6 years ago

Thanks! @veniversum, with this PR #229 the import of osm_ways is fixed. I tested with 4 different datasets and it is working now (below new output with your dataset). The problem occurs when we try to import datasets (usually small) without any importable relation (osm2pgrouting does not import all the relations in the current version due to memory problems; in the near future we will solve this issue).

***************************************************
           COMMAND LINE CONFIGURATION             *
***************************************************
Filename = /home/cayetano/Descargas/test_osm2pgrouting/example.osm
Configuration file = /home/cayetano/dev/osm2pgrouting/mapconfig.xml
host = localhost
port = 5439
dbname = pruebas
username = postgres
password = postgres
schema= error_relations
prefix = 
suffix = 
Drop tables
Don't create indexes
Add OSM nodes
***************************************************
Testing database connection: pruebas
database connection successful: pruebas
Connecting to the database
connection success

Dropping tables...
TABLE: error_relations.ways dropped ... OK.
TABLE: error_relations.ways_vertices_pgr dropped ... OK.
TABLE: error_relations.pointsofinterest dropped ... OK.
TABLE: error_relations.configuration dropped ... OK.
TABLE: error_relations.osm_nodes dropped ... OK.
TABLE: error_relations.osm_ways dropped ... OK.
TABLE: error_relations.osm_relations dropped ... OK.

Creating tables...
TABLE: error_relations.ways_vertices_pgr created ... OK.
TABLE: error_relations.ways created ... OK.
TABLE: error_relations.pointsofinterest created ... OK.
TABLE: error_relations.configuration created ... OK.
TABLE: error_relations.osm_nodes created ... OK.
TABLE: error_relations.osm_ways created ... OK.
TABLE: error_relations.osm_relations created ... OK.
Opening configuration file: /home/cayetano/dev/osm2pgrouting/mapconfig.xml
    Parsing configuration

Exporting configuration ...
  - Done 
Counting lines ...
  - Done 
Opening data file: /home/cayetano/Descargas/test_osm2pgrouting/example.osm  total lines: 23458
    Parsing data

Current osm_nodes:  0
Final osm_nodes:    6223
Current osm_ways:   0
Final osm_ways:     1091

End Of file

    Finish Parsing data

Adding auxiliary tables to database...

Export Ways ...
    Processing 1091 ways:
[**************************************************|] (100%) Total processed: 1091   Vertices inserted: 474 Split ways inserted 620

Creating indexes ...

Processing Points of Interest ...

Adding functions for processing Points of Interest ...

To process pointsOfInterest table:
osm2pgr_pois_update(radius default 200, within default 50)

  - Using areas of (radius)mts on POIS
  - Using edges that are at least (within) mts of each POI
POIS that do not have a closest edge is considered as too far
#########################
size of streets: 1091
#########################
cvvergara commented 6 years ago

@cayetanobv can we close this issue?

cayetanobv commented 6 years ago

Ok, it was fixed.