[OSM-dev] Using NULL values in mapnik / postgres DB

Artem Pavlenko artem at pavlenko.uklinux.net
Wed Feb 21 21:53:48 GMT 2007


Hello,

Attached is console app that takes list of geometries ( in WKT format) and 
cleans them. It works quite well and I can correct all not simple ways from 
latest osm. It requires GEOS lib from geos.refractions.net (I'm using 
geos-3.0.0rc3). 

It should fit nicely into osm2pgsql as in essence it takes bunch of 
segments, 'node' them , merge them and spits out 'clean' geometries.

As a side effect it is possible to output geometries in HEX WKB format which 
will speed up loading into postgresql.

Shall I try to merge this into osm2pgsql? 
 
Cheers,
Artem 

On Tuesday 20 February 2007 23:56, Jon Burgess wrote:
> On Tue, 2007-02-20 at 23:20 +0000, Artem Pavlenko wrote:
> > > I'll have to take a look. Would linemerge fix up the ways looping back
> > > on themselves that you reported before?
> >
> > That's the plan
> >
> > > What node function are you
> > > thinking of and what would it do?
> >
> > Here are some examples of invalid ways (geometrically) :
> >
> > 1.  http://artem.dev.openstreetmap.org/files/notsimple_way.png
> >    osm2pgsql actually outputs three LINESTRINGS from this way but one is
> > self-tangent (see example 3)
> >
> > 2.  http://artem.dev.openstreetmap.org/files/notsimple_way-2.png  -
> > self-intersecting way.
> >
> > 3. http://artem.dev.openstreetmap.org/files/notsimple_way-3.png -
> > self-tangent. Only start and end points can match!!!
> >
> >
> > 'Noding' is an operation that given collection of LineStrings will
> > produce a new one where none of LineStrings are crossing each other  ( in
> > example [2] it will insert extra node at intesection).
> >
> > 'LineMerge' will join segments into simple geometries (the current
> > segment join algorithm produces cases like [2])
> >
> > I can code all this in C++  and see if it works and then we can try to
> > merge it into osm2pgsql?  Let me know!
>
> Handling 1 & 3 should be fairly easy to add to the WKT function. It
> already locates segments which attach to a given node, it should be
> possible to make it split the way if it finds more that 1 matching
> segment.
>
> Handling intersecting lines (example 2) is more tricky. I could work out
> the math for detecting this if I thought about it for a bit but my old
> vector math is a little rusty at the moment. If someone has a link to
> some neat algorithm then it would be handy :-)
>
> If you wanted to port osm2pgsql to C++ it should be fairly straight
> forward. Some of the code could be simplified by making use of the more
> advanced libraries and data constructs.
>
> 	Jon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cpp
Type: text/x-c++src
Size: 2545 bytes
Desc: not available
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20070221/0c07e15c/attachment.cpp>


More information about the dev mailing list