tillnagel / unfolding

A library to create interactive maps and geovisualizations in Processing and Java
http://unfoldingmaps.org
Other
477 stars 245 forks source link

How to calculate distance between a Location and SimpleLinesMarker #144

Closed izibizi666 closed 4 years ago

izibizi666 commented 7 years ago

I have created a map with a Simple Lines Marker. The Lines Marker contains e.g. 10 Locations. When I move the mouse I can allocate the actual mouse location (Lat,Lon) in the map. Now I want to calculate the distance between the acutal Mouse position to the line of the Lines Marker (not to the Marker Point itself). Is this possible?

I want to implement a parallel driving system. So first I drive a line from Point A to Point B and then I turn around and want to drive parallel to the AB line with a distance from 15 meters. And I want to check the distance to the AB line from the current position.

Thank you for your answers and best regards

tillnagel commented 7 years ago

Currently not supported in Unfolding. You might want to search for nearest colinear points on lines algorithms, and implement it yourself. If you want to apply this in large scale maps (you mention 15 meters), a coplanar assumption should be sufficient. For correct calculations (WGS84 or even a spheroid) you should be able to find solutions, too.