Correct use of setPrecision

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Correct use of setPrecision

Nyall Dawson
Hi list,

As part of refactoring some QGIS code I was looking at replacing some
custom Python code [1] with the GEOS GEOSGeom_setPrecision function,
which appears to perform the same logic but much more efficiently.

However, after looking into this in more depth I think the original
python code is incorrectly used. It's being used by QGIS in order to
set a "tolerance" on a spatial join operation - i.e. to consider that
two geometries which are 100m distant actually do intersect.

My understanding is that the original code is badly broken, and that
using GEOS precision won't help here either, since there's no
guarantee that two vertices which are < 100 units distant will round
to the same result.

If this is correct, is there any other way in GEOS to handle this situation?

Cheers,
Nyall



[1] https://github.com/qgis/QGIS/blob/master/python/plugins/processing/tools/vector.py#L219
_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel
Reply | Threaded
Open this post in threaded view
|

Re: Correct use of setPrecision

Sandro Santilli-4
On Mon, Sep 04, 2017 at 04:28:32PM +1000, Nyall Dawson wrote:

> However, after looking into this in more depth I think the original
> python code is incorrectly used. It's being used by QGIS in order to
> set a "tolerance" on a spatial join operation - i.e. to consider that
> two geometries which are 100m distant actually do intersect.

[...]

> If this is correct, is there any other way in GEOS to handle this situation?

How about using GEOSDistance ?

--strk;
_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel
Reply | Threaded
Open this post in threaded view
|

Re: Correct use of setPrecision

Nyall Dawson
On 4 September 2017 at 17:29, Sandro Santilli <[hidden email]> wrote:

> On Mon, Sep 04, 2017 at 04:28:32PM +1000, Nyall Dawson wrote:
>
>> However, after looking into this in more depth I think the original
>> python code is incorrectly used. It's being used by QGIS in order to
>> set a "tolerance" on a spatial join operation - i.e. to consider that
>> two geometries which are 100m distant actually do intersect.
>
> [...]
>
>> If this is correct, is there any other way in GEOS to handle this situation?
>
> How about using GEOSDistance ?

Thanks - that's a good option for intersects tests. I'm not sure
offhand if it would be translatable to the other geometry predicates,
but then I'd say trying to do a 'touches' or 'contains' test with a
tolerance would be quite an edge case anyway.

Nyall
_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel
Reply | Threaded
Open this post in threaded view
|

Re: Correct use of setPrecision

Daniel Baston
My understanding is that precision models are considered only in the overlay options (and not in the geometry predicates).

Dan

On Mon, Sep 4, 2017 at 5:13 AM, Nyall Dawson <[hidden email]> wrote:
On 4 September 2017 at 17:29, Sandro Santilli <[hidden email]> wrote:
> On Mon, Sep 04, 2017 at 04:28:32PM +1000, Nyall Dawson wrote:
>
>> However, after looking into this in more depth I think the original
>> python code is incorrectly used. It's being used by QGIS in order to
>> set a "tolerance" on a spatial join operation - i.e. to consider that
>> two geometries which are 100m distant actually do intersect.
>
> [...]
>
>> If this is correct, is there any other way in GEOS to handle this situation?
>
> How about using GEOSDistance ?

Thanks - that's a good option for intersects tests. I'm not sure
offhand if it would be translatable to the other geometry predicates,
but then I'd say trying to do a 'touches' or 'contains' test with a
tolerance would be quite an edge case anyway.

Nyall
_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel


_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel
Reply | Threaded
Open this post in threaded view
|

Re: Correct use of setPrecision

Martin Davis-3
That is correct - the precision model is not used in relate and spatial predicate evaluation.  (It's used in a few more places than the overlay functions, but that is its primary usage)

It is feasible to introduce a precision model into the spatial predicate computation, but not easily in the current implementation.  I have plans for a better implementation which will make it straightforward to use the precision model.  No timeline on that, however.

On Wed, Sep 6, 2017 at 6:03 AM, Daniel Baston <[hidden email]> wrote:
My understanding is that precision models are considered only in the overlay options (and not in the geometry predicates).

Dan

On Mon, Sep 4, 2017 at 5:13 AM, Nyall Dawson <[hidden email]> wrote:
On 4 September 2017 at 17:29, Sandro Santilli <[hidden email]> wrote:
> On Mon, Sep 04, 2017 at 04:28:32PM +1000, Nyall Dawson wrote:
>
>> However, after looking into this in more depth I think the original
>> python code is incorrectly used. It's being used by QGIS in order to
>> set a "tolerance" on a spatial join operation - i.e. to consider that
>> two geometries which are 100m distant actually do intersect.
>
> [...]
>
>> If this is correct, is there any other way in GEOS to handle this situation?
>
> How about using GEOSDistance ?

Thanks - that's a good option for intersects tests. I'm not sure
offhand if it would be translatable to the other geometry predicates,
but then I'd say trying to do a 'touches' or 'contains' test with a
tolerance would be quite an edge case anyway.

Nyall
_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel


_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel


_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel
Reply | Threaded
Open this post in threaded view
|

Re: Correct use of setPrecision

Mateusz Loskot
On 6 September 2017 at 18:12, Martin Davis <[hidden email]> wrote:
> That is correct - the precision model is not used in relate and spatial
> predicate evaluation.

Directly, not.
Indirectly, it might be, depending on how input geometries are created
(eg. via WKB I/O).
In such case, one may consider precision model does affect the predicates.

> (It's used in a few more places than the overlay
> functions, but that is its primary usage)

For the record, intersection calculation in GEOS does use precision model,
perhaps other places too.


Please, consider my comments above as complementary documentation,
and w/o any purpose of argument.

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
_______________________________________________
geos-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geos-devel