Opened 8 years ago

Closed 6 years ago

#3490 closed enhancement (fixed)

osm2pgsql: import relations

Reported by: stanton Owned by: jburgess777@…
Priority: minor Milestone:
Component: osm2pgsql Version:
Keywords: Cc:


At present, osm2pgsql largely ignores relations. The only processing of relations that happens is that ways which are members are concatenated (if consecutive) and added to planet_osm_line as a separate entry, with the tags of the relation. The link between points and relations, as well as roles, are lost entirely.

Having "raw" relation and membership data in the database and thus available to Mapnik would open up new possibilities. (What I have in mind is a public transport map with the lines superimposed. Each way would be labeled with the lines that use it as a list, e.g. 1, 2, 5; ways used in only one direction could be rendered with arrows.)

This would involve creating two new tables:

  • planet_osm_relation, which would contain an osm_id column (with its OSM ID) and one more column for each tag of the relation - in a fashion similar to planet_osm_line and planet_osm_point
  • planet_osm_member, which would contain the relation membership information as follows:
    • osm_id - ID of the relation
    • type - OSM primitive type of the member (node, way, relation)
    • member - ID of the member
    • seq - Sequential number of the member in the relation (1-based)
    • role - Role of the member

As for processing cost, I'd guesstimate a relation with a certain number of members to have a similar cost to a way with the same number of nodes:

  • A row in the corresponding table, one column per tag, needs to be created in either case.
  • Instead of collecting all nodes of a way, we'd be collecting all members of a relation - roughly equivalent.
  • No spatial calculation for relations; instead we would add another table row per member. Given that spatial calculations are expensive, I'd expect relations to be even slightly faster on this one.

Change History (3)

comment:1 Changed 8 years ago by Tom Hughes

Owner: changed from Tom Hughes to jburgess777@…
Status: newassigned

comment:2 Changed 8 years ago by Tom Hughes

Component: utilsosm2pgsql

comment:3 Changed 6 years ago by amm

Resolution: fixed
Status: assignedclosed

This information should be available in the slim table planet_osm_rels, even if it isn't in the most convenient form.

Note: See TracTickets for help on using tickets.