This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

osm2pgsql: Import splits ways in table planet_osm_line

0

I'm building up working process for analysing addresses in the database. So I use osm2pgsql for import the data from pbf and append osc-files. In the following steps I take this data for generete my own optimized dataset.

For getting all ways I need, I used the planet_osm_line table where I have all non closed ways (excluding roundabouts). The documentation of the table in the schema says the following:


Additional rows are created for ways which are members of type=route relations:

  • For each relation of type=route, its ways are concatenated into "chunks" of consecutive ways
  • One row is created for each of these chunks (one or more for each relation which has members of type way)
  • The osm_id is the negative ID of the relation
  • The tag columns are filled with the tags of the relation

Since there may be multiple chunks per relation, negative IDs are not necessarily unique.


I only need ways which meens: I only need elements with osm_id>0. If I filter the data, I've found some osm_ids of twice. The documentation only says, that relations can be contained twice. But sometimes, osm2pgsql splits some ways into different chunks.


To reproduce this you can take an extract e.g. bremen: http://download.geofabrik.de/europe/germany/bremen-150207.osm.pbf

Now I import it with default style settings:

osm2pgsql --create -s --number-processes 4 -C 3500 -H 192.168.0.21 -d osm3 -U osm bremen-150207.osm.pbf

Now you can query the table:

SELECT osm_id, count(*) FROM planet_osm_line
WHERE osm_id>0
GROUP BY osm_id
HAVING count(*)>0;

You can found this element: https://www.openstreetmap.org/way/166985155 this is a simple way, it is defined twice, in 2 chunks. Why does osm2pgsql split this way in two chunks? How can I avoid this behavior?

If I use ST_UNION() a complete way is shown without any gap.

asked 09 Feb '15, 17:12

Christopher's gravatar image

Christopher
126153
accept rate: 100%

The reason why I don't use planet_osm_roads is, that this table don't contain all needed ways: see that answer

(09 Feb '15, 17:14) Christopher

One Answer:

0

osm2pgsql has code to split up long lines. The limit is set here:

https://github.com/openstreetmap/osm2pgsql/blob/ed86d635cb0e54252881c766ede90a532e63dca0/output-pgsql.cpp#L125-L128

to about 100.000 Google Mercator units (roughly meters) which your ferry line might well be above.

Change the source code and recompile.

answered 09 Feb '15, 20:17

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Hi, this bugs was fixed? There are an option to say "not split"?

(31 Oct '18, 12:27) ppKrauss

Source code available on GitHub .