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 always returns first feature in collection? #96

Closed
devleaks opened this issue Jun 1, 2021 · 1 comment
Closed

nearest_point always returns first feature in collection? #96

devleaks opened this issue Jun 1, 2021 · 1 comment
Assignees

Comments

@devleaks
Copy link

devleaks commented Jun 1, 2021

Hello,

Could you please explain this behavior?
To me, it seems that nearest_point always returns the first feature in the supplied collection, not the closest one.

P.

`
from geojson import Point, Feature, FeatureCollection
from turfpy.measurement import distance, nearest_point

p0 = Point((25.0, 51.0))

p1 = Point((25.2, 51.2))
f1 = Feature(geometry=p1)
p2 = Point((25.4, 51.6))
f2 = Feature(geometry=p2)

print("to p1", distance(p0, p1))
#to p1 26.260267785645777

print("to p2", distance(p0, p2))
#to p2 72.28066331033915

fc1 = FeatureCollection(features=[f1, f2])
print("to p1", nearest_point(p0, fc1))
#to p1 {"geometry": {"coordinates": [25.2, 51.2], "type": "Point"}, "properties": {"distanceToPoint": 26.260267785645777, "featureIndex": 0}, "type": "Feature"}

fc2 = FeatureCollection(features=[f2, f1])
print("to p2", nearest_point(p0, fc2))
#to p2 {"geometry": {"coordinates": [25.4, 51.6], "type": "Point"}, "properties": {"distanceToPoint": 72.28066331033915, "featureIndex": 0}, "type": "Feature"}
`

@omanges omanges assigned omanges and unassigned omanges Jun 17, 2021
@omanges omanges self-assigned this Jul 24, 2021
@omanges
Copy link
Owner

omanges commented Jul 24, 2021

@devleaks Fixed in release v0.0.7

@omanges omanges closed this as completed Jul 24, 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

No branches or pull requests

2 participants