New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
precision model or setPrecision #64
Comments
Hmm I'm not sure how this is supposed to work. Is there an example somewhere using the C API that we can learn from? Unfortunately https://geos.osgeo.org/doxygen/geos__c_8h_source.html is not very helpful here. With your example: using LibGEOS
p1 = LibGEOS.Polygon([[[75.9, 30.7], [79.9, 30.7], [77.9, 28.7], [75.9, 30.7]]])
p2 = LibGEOS.Polygon([[[81.0, 26.8], [76.0, 26.8], [81.0, 31.8], [81.0, 26.8]]])
LibGEOS.GEOSGeom_setPrecision(p2.ptr, 0.1, 0) # returns C_NULL, so something went wrong I tried to use this method (is the other one deprecated already?), and this did give a valid pointer, but did not change the results: p1_grid = Polygon(LibGEOS.GEOSGeom_setPrecision_r(LibGEOS._context.ptr, p1.ptr, 0.1, 0))
p2_grid = Polygon(LibGEOS.GEOSGeom_setPrecision_r(LibGEOS._context.ptr, p2.ptr, 0.1, 0))
intersects(p1_grid, p2_grid)
touches(p1_grid, p2_grid) Looking at https://shapely.readthedocs.io/en/stable/manual.html#object.touches it says:
So is false not the correct answer here? What does shapely return here? That should be the same. |
Compare with a bit more fortunate geometry using LibGEOS
p1m = LibGEOS.Polygon([[[76.0, 30.0], [80.0, 30.0], [78.0, 28.0], [76.0, 30.0]]]);
p2m = LibGEOS.Polygon([[[81.0, 26.0], [76.0, 26.0], [81.0, 31.0], [81.0, 26.0]]]);
intersects(p1m, p2m) # true
touches(p1m, p2m) # **true**
is12m = intersection(p1m, p2m)
area(is12m) # 0.0 Here the intersection is a In the grid-example, To compare with shapely from shapely.geometry import Polygon
p1 = Polygon([(75.9, 30.7), (79.9, 30.7), (77.9, 28.7), (75.9, 30.7)])
p2 = Polygon([(81.0, 26.8), (76.0, 26.8), (81.0, 31.8), (81.0, 26.8)])
p1.intersects(p2) # True
p1.touches(p2) # False
is12 = p1.intersection(p2)
is12.area So shapely is saying There is discussion about GEOS precision models for shapely shapely/shapely#110 but maybe best not to hold one's breath. |
Ok then at least we are not doing something wrong in this package. Of course it would be nice to create an easier interface for this functionality, right now it's still hard to use with passing the pointers directly. Also we should probably make the Btw it might be nice to know there is currently also work going on to set up this library: https://github.com/pygeos/pygeos |
This example is problematic with float precision
I cannot figure out usage of
setPrecision
that does not seem to do anything, this is what I triedThere seems to be a precision model in GEOS
https://github.com/libgeos/geos/blob/master/src/geom/PrecisionModel.cpp
but is this exposed in LibGEOS.jl ?
The text was updated successfully, but these errors were encountered: