My application uses a MapView which will display multiple places.
I have the latitude and longitude of these places stored in a database in degrees.
The latitudes, longitudes have a precision of 14 digits after the decimal.
If I have to determine if two geo locations are the same, how much precision should I consider
or rather how much precision I can overlook so that I do not have pins very close to each
other in the map view ?
If two positions are same then I plan to position a single pin on the map and then when the pin is clicked, it will display a list of places located at that location
There is a function in the Location class called distance between:
Location.distanceBetween(double startLatitude, double startLongitude, double endLatitude, double endLongitude, float[] results)
you can use this to calculate a distance between the points and mark a minimum.
The calculation for distance is not just about calculating distance between 2 points on a straight line, but rather takes the earths eliptical shape into account so its as accurate as it can be.
for the use case, there is the float array which you need to provide at the end of the method where the results will actually be written.
That depends is the boring answer:
For 1) you could have a certain number of decimals or (or distance in feeet/meters), per zoom level.
For 2 you could either vary the decimals depending on latitude or have a fixed number of meters/feet, but you need to convert it to meters/feet then. Still depending on zoom level though.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.