UChangeset

From OpenStreetMap Wiki
Jump to navigation Jump to search

The UChangeset aims to provide an easy way to "see" where changes have occurred on the map. This is all done in a simple XML document ready to be parsed.

General

It is important to understand the OSM datastructures. Nodes are the fundamental building blocks. Ways are just a collection of nodes and relations are just a collection of ways and nodes.

Only nodes can move. This is since nodes are the building blocks. A way can't move. Just the nodes that make up the way. Same goes for relations.

In order to update everything related to an update we need to do a full search trough the database. This means that if a node is moved we must also check for all ways and relations containing that node.

DTD

Right now only a simple DTD is available. However XML-Schema would be a better solution since this would allow us to specify cardinality.

<!ELEMENT OSMCHANGES (Node*, Area*)>
<!ELEMENT Node EMPTY>
<!ELEMENT WaySegment (Node+)>
<!ELEMENT Area (Node+)>

<!ATTLIST Node lat CDATA #REQUIRED>
<!ATTLIST Node lon CDATA #REQUIRED>

Nodes

As you can see in the DTD nodes are simple. They are just latitude and longitude coordinates which anyone can convert to tiles on any zoom level.

Now what to do/how to handle node stuff:

Create

If a node is newly created we just need to delete the tiles containing lat/lon (of the new node)

Delete

If a node is deleted we only need to delete all the tile containing lat/lon (of the deleted node)

Modify

When a node is modified we need to check if the node has been moved. If not (so only tags are updated) we just need to update lat/lon (of the node) if the node is moved both all the tiles containing the old lat/lon and the tiles containing the new lat/lon should be updated.

Recursion

Since nodes are the fundamental building block they can be contained in relations and ways. Later we can choose to update parts of a way/relation but for now update the whole way.

Ways

Find all the ways containing the node with their (own) minimum bounding box. Delete all the tiles in that bounding box. This way can be part of an relation so this emerges up.

Relations

Find all the relations containing that node with the minimum bounding box of that relation. Delete all those tiles. Also a relation can be part of an other relation. So this also emerges up.

Ways

Ways consist of an ordered list of nodes. In time we would like to use way segments but for now we will use a minimum bounding box of the whole way.

Create

A new way is created we need to find all the nodes that make up the way (both in the database and in the diff). Calculate the minimum bounding box and remove all the tiles in that bounding box.

Delete

Find all the nodes that make up the way to find the minimum bounding box. Delete all the tiles in that bounding box.

Modify

Find the "old" way and its minimum bounding box. Delete all the tiles within that bounding box. Calculate the new bounding box of the way and also delete all the tiles whit in that bounding box.

Recursion

When a way is deleted this can affect a relation.

Relation

Find all the relations containing the way with their minimum bounding box. Delete all the tiles in that bounding box. This relation can of course (again) be part of another relation.

Relations

Relations can consist of nodes,ways or other relations.

Relations are tricky since the bounding box can be HUGE! Lets say we want a relation of all the EU countries. We can't update the bounding box. Since that would include rerendering almost the whole EU.

TODO: Think about this

Improvements

Deleting everything in the bounding box of the way is not optimal. We can better delete segments of the way. All ideas about improvements go here until they are implemented

Way Segment

A way segment has exactly two nodes. It is (like it says) a segment of a way, or a whole way if it only consist only of two nodes. This allows us to find all the tiles touched by this way segment.

File:UChangeset waysegment.svg

The above images shows that we need to not only clear the tiles that contain the nodes. But also the tiles that are touched by the way segment. Since well if we change a segment of the way or the tags of the way we need to update all the tiles touched by the way.

Areas

And area is anything that is not a node or a way segment. Areas consist of at least 3 nodes. These nodes create a bounding box. That allow us to delete all the tiles (partially) in the bounding box on any zoom level.

File:UChangeset area.svg

The above picture shows that it is necessary to update all the tiles whit in the bounding box. Since no part of the area touches the center tile. However it is part of the area so should be updated.

TO DO

  • Relations