[OSM-dev] Determining if two linestrings are "similar"

Tom MacWright tom at macwright.org
Fri Jan 4 18:44:49 GMT 2013


How about rendering the lines at z16 in black with no antialiasing and
comparing the results? After that, you can cache the hash of the image and
compare it to additional lines. If you want to get really fancy, you could
even pack them into bits and compare the hamming weight of the difference.

On Fri, Jan 4, 2013 at 1:37 PM, Michal Migurski <mike at teczno.com> wrote:

> I believe Muki Haklay's comparison of OSM and OS used this method: buffer
> two lines into polygons, compare the ratio of their intersection and union.
> The buffering is done in mercator coordinates so it's conformal. I use a
> technique like this in Skeletron to find simple centerlines for single and
> dual carriageways, works great.
>
> -mike.
>
> On Jan 4, 2013, at 6:47 AM, David Prime wrote:
>
> > Construct a polygon from the two lines and calculate the area inside?
> Have some magic number denoting an acceptable length/area ratio that scales
> the limit appropriately. There's a few nasty edge cases, though.
> >
> >
> > On Fri, Jan 4, 2013 at 2:44 PM, Paweł Paprota <ppawel at fastmail.fm>
> wrote:
> > Hi Andrzej
> >
> > On 01/04/2013 03:37 PM, andrzej zaborowski wrote:
> >
> > If the number of nodes in a way didn't change you could optimize by just
> > comparing them coordinate by coordinate.
> >
> > I was thinking you could take the maximum of every node's distance
> > from the other way.  It should yield the same metric as ST_Buffer
> > would.
> >
> >
> > I tried that by using ST_MaxDistance but it fails for some cases where
> the maximum distance is actually quite large even though the linestrings
> are near each other.
> >
> > Paweł
> >
> >
> > _______________________________________________
> > dev mailing list
> > dev at openstreetmap.org
> > http://lists.openstreetmap.org/listinfo/dev
> >
> > _______________________________________________
> > dev mailing list
> > dev at openstreetmap.org
> > http://lists.openstreetmap.org/listinfo/dev
>
> ----------------------------------------------------------------
> michal migurski- contact info and pgp key:
> sf/ca            http://mike.teczno.com/contact.html
>
>
>
>
>
> _______________________________________________
> dev mailing list
> dev at openstreetmap.org
> http://lists.openstreetmap.org/listinfo/dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20130104/bd53bda7/attachment.html>


More information about the dev mailing list