2
I am developing an app where I would need to return points (Lat, Long) in a radius of size X (Km) from the user’s location (Lat, Long). I’ve devised the following logic:
- Get current user location
Insert the user’s location as the point A of the radius, and the distance of that radius as the point B, in latitude and longitude.
But I’m having a hard time determining how to calculate and convert that distance to meters or kilometers.
The points that will be searched are stored in the app, not requiring requests from a web service.
At the end I will list in an array the points that are within the radius.
Does anyone know an API or methods that can help you craft this function.
NOTE: I am using the API google maps iOS to show the map, I am storing the points of the places that will be searched within the radius in the App itself. I’m using Google Maps coordinates.
Image to illustrate:
When you say you have the points stored in the app you are referring to a comic book?
– ramaral
Yes, the locations are stored using coredata and include name and coordinates (latitude, longetude).
– Tiago Amaral
I had an idea to solve this problem, but it returned another question. Possible answer: Send the coordinates to Cclocation, and pick the distance, and make the following comparison:
if(distancia < X){ // Dentro do Raio, slavo no array}
But this concept will force the app to go through ALL stored points. To solve this problem then I thought of implementing something using a binary search tree (Correct me if I’m wrong with the name), but never implemented one before.– Tiago Amaral
I suppose you can filter these data by latitude/longitude or not? Excuse the question my knowledge rises IOS/Objectivec is almost null.
– ramaral
Tranquil! : I believe you have heard of Binary Tree. If yes it would help a lot.
– Tiago Amaral
I’ll give you an answer see if it fits.
– ramaral
@ramaral thanks "brother"! By name we already have some degree of kinship kkkk Thank you.
– Tiago Amaral