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

andrzej zaborowski balrogg at gmail.com
Fri Jan 4 14:37:58 GMT 2013


On 4 January 2013 14:50, Jochen Topf <jochen at remote.org> wrote:
> On Fri, Jan 04, 2013 at 01:49:44PM +0100, Paweł Paprota wrote:
>> Here's an interesting problem I'm trying to tackle now in OWL...
>>
>> You have two linestrings and the task is to determine if they are
>> "similar" or not. Similar means spatially "the same" as looked at by
>> human eye at zoom level 18 on a slippy map :-)
>>
>> Note that the two geometries are not equal in ST_Equals sense. They
>> don't have to intersect but can intersect or even be almost the same
>> save for one node slightly moved.
>>
>> OWL right now shows some changes that in fact are non-changes - e.g.
>> using simplify way feature of JOSM changes way nodes but preserves
>> (or only very slightly changes) way geometry. It is not a change
>> worth processing and showing to the user.
>
> You can create a buffer (with ST_Buffer) around one geometry and then see
> whether the other geometry is inside this buffer or not. Unfortunately that
> is a rather expensive operation, so it might be too slow for your use.
>
> 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.

Cheers



More information about the dev mailing list