Reputation: 113
So,I'm trying to create an applications, where the user sets his destination on a map - let's say from Home to work-, then (with the help of google maps)a direction line shows on the map to guide the user to his destination, or to work in our example . What I'm trying to achieve here is that I want the app to show any coffee house that is going to be on the user's way to work,or slightly around it, but I'm not sure how to tackle this head scratcher .
Is there a way to know if a point (C) , falls within a straight line between A and b ? or falls close by factor(x) to the line between A and B ?
Upvotes: 0
Views: 99
Reputation: 2197
I created a gist which is a Swift translation of locationIndexOnEdgeOrPath
function and all the other required functions present in PolyUtil.java.
The parameters you need to pass are the co-ordinates of the point you want to check and the array of points that represent the path. (Your case only includes start and end point, so just pass those two)
The other parameters needed are closed
which represents whether a line should be drawn from the last point to first point in order to close the loop; geodesic
which means if the earth's curvature should be taken into consideration.
Finally, toleranceEarth
is the last parameter where you need to specify how close to the path is considered being on the path.
Upvotes: 1