[OSM-dev] Simplifying ways

Paul Norman penorman at mac.com
Tue May 8 08:14:46 BST 2012


> From: Paul Norman [mailto:penorman at mac.com]
> Subject: [OSM-dev] Simplifying ways
> 
> I'm working with a process where I generate a .osm file and need to
> simplify the ways in output on the command line. JOSM's simplify way
> command isn't an option as it requires interaction and it is also fairly
> slow on large files.
> Using ogr2ogr to simplify the source files is not an option as it could
> cause the different layers to no longer agree with each other.
> 
> I'd rather not re-implement Douglas-Peucker if someone has already done
> it.

To summarize the options given to me through email and IRC there are

1. JTS[1]. This is not OSM-specific and written in Java. I would need to
write code to convert OSM data to the Geometries.

2. gdal Simplify[2]. This would be the easiest to integrate into ogr2osm
except that I need to simplify after conversion to OSM objects and duplicate
node removal or two ways that share nodes for part of their length. There
are also cases where an optimal solution would not be arrived at since
points that were removed could be re-added by another object.

3. osmosis-simplifyways[3]. This is based on JTS and uses osmosis.
Unfortunately osmosis rejects .osm files with negative IDs so I would need
to either multiply all IDs by -1 before and after or patch osmosis.

4. Schuyler Erle's PD implementation[4] of DP in python. This is a
non-recursive implementation of DP. I would have to write code to read the
.osm file, identify points that would be kept anyways, reproject to a
projection where distance can be measured and them simplify.

5. scanaerial's GPL implementation[5] of DP in python. This is a recursive
implementation. The same issues apply as with option 4.

Given the choices, I think I'm going to end up implementing something based
on 4 or 5. I want something that will preserve any points in a relation or
where another way meets the way being simplified but does simplify when two
ways share nodes for a stretch.


[1]: http://tsusiatsoftware.net/jts/main.html

[2]: http://gdal.org/python/osgeo.ogr.Geometry-class.html#Simplify

[3]: https://github.com/podolsir/osmosis-simplifyways

[4]: http://mappinghacks.com/code/dp.py.txt

[5]:
https://github.com/jonasstein/scanaerial/blob/master/scanaerial_functions.py
#L29





More information about the dev mailing list