On Sat, Feb 19, 2011 at 2:13 AM, Mike Toews <[email protected]> wrote: > I'll assume this feature doesn't exist, so I've added an enhancement ticket: > http://trac.gispython.org/lab/ticket/247 > > -Mike > > On 18 February 2011 13:09, Mike Toews <[email protected]> wrote: >> Hi, >> >> I'm using Shapely to compare linestrings (e.g., contains) from >> different sources. Unfortunately, as they are from different sources, >> my comparisons are not as they expected due to precision loss. >> >> Is it possible to modify the GEOS precision model[1] in Shapely? I've >> tested my work in JTS TestBuilder using a fixed scale of 100000.0, >> which works perfectly. >> >> I'll provide an example for context. To see if A contains B, using >> default double precision model: >> A : LINESTRING (2804546.853088379 6342201.814086914, 2804586.597930257 >> 6342227.426515108, 2804626.342772136 6342253.038943302, >> 2804666.0876140143 6342278.651371496, 2804705.8324558926 >> 6342304.26379969, 2804745.577297771 6342329.876227884, >> 2804765.623917896 6342368.096008201, 2804789.0318718576 >> 6342403.585924613, 2804826.622362667 6342430.003267048, >> 2804841.9301757812 6342474.739379883) >> B : LINESTRING (2804586.597930198 6342227.426515403, >> 2804546.8530881978 6342201.814087403) >> >> A contains B = False >> >> Changing precision model to 100000.0: >> >> A : LINESTRING (2804546.85309 6342201.81409, 2804586.59793 >> 6342227.42652, 2804626.34277 6342253.03894, 2804666.08761 >> 6342278.65137, 2804705.83246 6342304.2638, 2804745.5773 6342329.87623, >> 2804765.62392 6342368.09601, 2804789.03187 6342403.58592, >> 2804826.62236 6342430.00327, 2804841.93018 6342474.73938) >> B : LINESTRING (2804586.59793 6342227.42652, 2804546.85309 6342201.81409) >> >> A contains B = True >> >> Thanks! >> -Mike
Hi Mike, I'm trying to steer Shapely development to Github, and have moved your issue to https://github.com/sgillies/shapely/issues/7 Implementing this feature will be complicated, requiring changes to Shapely and also to the GEOS codebase. Shapely uses GEOS via its C API, which does not currently expose the C++ PrecisionModel class. The C API would need enhancement, and a new GEOS release would need to be wrangled. After that, we'd need to come up with a good precision model API for Shapely. Would it be enough to expose the precision model as a variable in shapely.geos? The experience would be much like the one of modifying sys.path, the same pros and cons, and working best if you set the precision model once a session. Unfortunately, I'm completely committed on other projects and do not have the time to enhance the GEOS C API. Others might. Interest in modifying the precision model for use with OGR (another C API user) seems to come and go over time. Oliver Tonhofer has been finding new ways to extend Shapely using Cython, but I don't know if that will be a good way to access the C++ precision model. Maybe he can tell us. Cheers, -- Sean _______________________________________________ Community mailing list [email protected] http://lists.gispython.org/mailman/listinfo/community
