[OSM-dev] Extracting polygons from planet.osm - take 2

Keith Sharp kms at passback.co.uk
Fri Mar 16 10:27:14 GMT 2007

On Fri, 2007-03-16 at 10:11 +0000, Robert Hart wrote:
> > I would appreciate it if people could try this out and let me know if
> it
> > works, and is accurate!  If people think this is valuable I would like
> > to create directory in SVN for both the script and a collection of
> > polygon files, I am happy to oversee this.  I would also like to
> create
> > a Wiki page describing the script usage and polygon files.
> Keith, 
> Not had time to run this yet, but I read the code, so here's some things
> I thought of along the way:
> Line 106:
> if ($compress > 99) {
> Shouldn't that be ($compress < 99)?

Thanks for pointing this out, actually it was completely wrong, it
should be:

	if (($compress > 0 && $compress < 100) && $pol->nrPoints > 99)

Only accept percentage values of 1-99 and only reduce if the number of
points in the polygon is 100 or more.

> Line 171:
> if ($used_nodes->{$2} || $used_nodes->{$3})
> Wouldn't it be better to only output segments with both nodes defined?
> i.e. && instead of ||

I have to admit this part is a copy and paste from Frederiks original so
I'll have to leave to him to comment :-)

> Of course, you are making all the usual assumptions about the structure
> of the OSM file, but I think that's an acceptable compromise for users
> of your script.

Sure, it might be worth adding a OSM file version check to the script in
the hope that if the structure changes the version will be bumped.

Thanks for the feedback,


More information about the dev mailing list