Skip to content
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

Nearest point functions now supports POINT Z #1006

Closed
wants to merge 1 commit into from

Conversation

jlucidar
Copy link

No description provided.

@coveralls
Copy link

coveralls commented Oct 20, 2020

Coverage Status

Coverage increased (+0.02%) to 83.396% when pulling 46f5c84 on jlucidar:patch-1 into eae4dcb on Toblerity:master.

@sgillies
Copy link
Contributor

sgillies commented Nov 9, 2020

@jlucidar can you point me to something in the GEOS change log or a GEOS PR or ticket discussing this?

@mwtoews
Copy link
Member

mwtoews commented Nov 11, 2020

Testing with GEOS master, it seems that GEOSNearestPoints_r only returns 2D geometries, regardless if the inputs are 3D. This change would need to happen in GEOS before any magic happens here.

@mwtoews
Copy link
Member

mwtoews commented Feb 28, 2021

I was about to close this, but checking again using:

from shapely import geos
from shapely.geometry import Point, LineString
from shapely.ops import nearest_points

print(geos.geos_version_string)

pt = Point(1, 2, 3)
ls = LineString([(0, 0, 20), (5, 0, 30)])
print([g.wkt for g in nearest_points(ls, pt)])
print([g.wkt for g in nearest_points(pt, ls)])

there appears to be some changes, e.g. with GEOS 3.9.1 these are strictly 2D:

3.9.1dev-CAPI-1.14.1
['POINT (1 0)', 'POINT (1 2)']
['POINT (1 2)', 'POINT (1 0)']

and with a development GEOS:

3.10.0dev-CAPI-1.15.0
['POINT (1 0)', 'POINT Z (1 2 3)']
['POINT Z (1 2 3)', 'POINT (1 0)']

I know GEOS is be capable of interpolating the Z coord for the other nearest point, because of this:

print(ls.interpolate(1.0).wkt)  # POINT Z (1 0 22)

xref https://trac.osgeo.org/geos/ticket/1102

@mwtoews
Copy link
Member

mwtoews commented Feb 28, 2021

But, also I've come to my senses that we should probably keep 2D geometry behaviour for Shapely 1.8 and earlier. Any future work on this end will not be via ctypes (as implemented in this PR).

@mwtoews mwtoews closed this Feb 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants