[OSM-talk] Update OSM PostGIS DB with .osc files?

Martijn van Oosterhout kleptog at gmail.com
Thu May 29 12:18:15 BST 2008


On Thu, May 29, 2008 at 11:16 AM, Dave Stubbs <osm.list at randomjunk.co.uk> wrote:
> Not actively as far as I'm aware.
>
> Martijn did some work to make the osm2pgsql slim mode work which you'd
> need for this; this results in tables for ways, nodes, and relations,
> as well as the standard feature tables.

Correct, in slim mode it now stores the actual ways and nodes. For
making it parse diffs files you basically need the following steps:

- Parse the actual diff itself, this shouldn't be too hard
- Process the directives in the diff. This shouldn't be too hard
either, you need to extend the out/mid api to have commands for modify
and delete. This is also fairly straightforward, if a lot of typing.
- Correctly update the output tables, this is harder. The basic idea
is as follows:

If a node is inserted, treat like a normal insert when bulk loading
If a node is updated/deleted:
  - delete from points table with osm_id=this_node
  - Run new version through output processing (may not appear in new
output if tags were removed)
  - Find all the ways/relations using this node and mark then processed=false
For ways the system is the same. There is the additional step of
handling processed=false ways, these need to have their output deleted
(with matching osm_id). Relations using these need processed=false.
Finally, to handle relations the same stuff needs to be repeated
again, handling unprocessed relations.

The whole deal about processed is because in general all the nodes of
a way will be changed when a way is changed and the updates will not
appear in order that they can be directly applied.

Database changes are:
- Indexes on the osm_id fields
- Index on the nodes of a way/relations. Needs the intarray contrib module.

It's not exceptionally difficult, it just needs a chunk of dedicated
coding time...

Hope this helps,
-- 
Martijn van Oosterhout <kleptog at gmail.com> http://svana.org/kleptog/




More information about the talk mailing list