1

I have 2 polylines, A and B. My objective is to

  1. Find closest point on B from a given node on A
  2. Find tangent on that point

So I use function nearestPointOnLine to find point on B closest to a node on A.

I am not sure how to achieve 2nd objective. I would probably need the node on B which comes immediately after the point I found for 1st objective, so that I have 2 points to determine the bearing.

Does Turf offer an API which can give me that node?

4
  • If you find a point on a segment of B (a segment defined by two vertexes) the tangent of that point equals that segment? A polyline, in (spatial) vector geometry, is no curve.
    – geozelot
    Oct 2, 2020 at 6:58
  • I agree, but how to find the segment?
    – Mandroid
    Oct 2, 2020 at 6:59
  • Ah, well that more likely needs to be your actual question then.
    – geozelot
    Oct 2, 2020 at 7:01
  • Coding question on GIS SE site require existing code of what has be done/tried so far to be included in the question, otherwise question is most likely to be closed as not compliant with the site policy. Please edit your question and add relevant existing code.
    – TomazicM
    Oct 2, 2020 at 7:41

1 Answer 1

0

We can do it as follows:

Feature feature = TurfMisc.nearestPointOnLine(node, points);
feature.getNumberProperty("index");

getNumberProperty returns the index of node preceding the nearest point. For argument "dist",it returns the distance to closest point.

1
  • 1
    General turf.js library has no getNumberProperty method, this exists only in Mapbox Android API implementation of Turf. There is no mention of Mapbox or Android in the question.
    – TomazicM
    Oct 2, 2020 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.