Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to import an Italian osm file into PostGIS with osm2pgrouting. I launched the script and it worked until it encountered an error. This is the output of osm2pgr:

.....
Nodes table created
2create ways failed: 
Types table created
Way_tag table created
Relations table created
Relation_ways table created
Classes table created
Adding tag types and classes to database...
Adding relations to database...
Adding nodes to database...
Adding ways to database...
ERROR:  extra data after last expected column
CONTEXT:  COPY ways, line 681382: "934378       117     0.15808824934990467    11.1369311       45.8187991      11.1388487      45.818314100000002      37264295srid=432..."
Creating topology...
NOTICE:  CREATE TABLE will create implicit sequence "vertices_tmp_id_seq" for serial column "vertices_tmp.id"
CONTEXT:  SQL statement "CREATE TABLE vertices_tmp (id serial)"
PL/pgSQL function "assign_vertex_id" line 14 at EXECUTE statement
#########################
size of streets: 1072190
size of splitted ways : 2281124
finished

I used the italy.osm.bz2 file decompressed finded here:
http://download.geofabrik.de/osm/europe/
but have also tried with the one here:
http://download.gfoss.it/osm/osm/

I have tried different times, with different files -- in fact, I have been trying from almost a month, but nothing has changed: I always get the same error. Any suggestions?

Thanks
Luca

share|improve this question
add comment

1 Answer

Some of the road/way names in the OSM data seem to contain a backslash ("\") which they should not. This case is not tested and fixed by the "osm2pgrouting" tool so far and this most probably causes the error you get. What you could do is inserting the following line in the in the "exportWays" method in the "Export2DB.cpp" file (in the "src" folder of your "osm2pgrouting" folder) and after that build the tool again ("make"):

    if(!way->name.empty())
    {
        std::string escaped_name = way->name;
        boost::replace_all(escaped_name, "\t", "\\\t");

        // This line needs to be added to remove backslashes from way names:
        boost::replace_all(escaped_name, "\\", "");
        //

        boost::replace_all(escaped_name, "\n", "");
        boost::replace_all(escaped_name, "\r", "");
        row_data += escaped_name.substr(0,199);
    }

Cheers,

Michael

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.