0

I have a question about GPS alarm.

I have some points (latitude and longitude). I need a way to check if the user location is near to some of these points (approximately are 1800 points).

If I remember correctly there is a best practice to do this: to be notified when GPS position is in a certain region. This allows for optimizations regarding the battery.

Can you give me any suggestions?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Safari
  • 11,437
  • 24
  • 91
  • 191
  • If my answer is exactly what you are looking for, please upvote and mark as answer. Thanks. – Ricky May 18 '14 at 08:49

2 Answers2

3

1800 points as per 1800 different regions to be monitored?

It is not possible. See here:

For this reason, Core Location limits to 20 the number of regions that may be simultaneously monitored by a single app.

If you have more than 20 regions to be monitored, this is what you can do:-

  1. When the user launches your app, get the user's location and send the location to your server
  2. After the server gets the user location, gathers all the points within N Kilometres (KM) radius.
  3. If the points within N KM are less than 20, then send all the points to your user to be monitored.
  4. If the points within N KM are more than 20, your server has to reduce the points based on the smaller radius (eg: N-1 KM)

I have developed a region monitoring app myself and this is what we do.

Jagat Dave
  • 1,643
  • 3
  • 23
  • 30
Ricky
  • 10,485
  • 6
  • 36
  • 49
  • do you think that are there some different ways to obtain same result? – Safari May 08 '14 at 15:01
  • How big are your points in terms of radius? And What are the distance between 1 point to another (roughly)? – Ricky May 08 '14 at 15:02
  • Updated my answer above. – Ricky May 08 '14 at 15:14
  • there are not regions, but they are not really regions are just positions. We can consider these as a POI (eg restaurants). Some of these points can be very close to each other (few meters) other very lontandi (for example 1000 km) – Safari May 08 '14 at 15:15
  • I think you need more than 1 solution. For places that are some distance from each other, you can use Region monitoring. For places that are closed by, I think you should look at iBeacon (which I am not too familiar with yet) – Ricky May 08 '14 at 15:21
0

Define what you mean by near to some of these points.

You could use the haversine formula to calculate the distance between your current location and each of the set of test points. The calculation involves a fair number of trig functions so could work out computationally intensive but depending upon your application it may not be necessary to recalculate more than once a minute or so.

uɐɪ
  • 2,540
  • 1
  • 20
  • 23