2

In my IOS app I worked on the functionality of detect the regions and its working fine whenever user enters in those regions, means didEnterARegion, didExitRegion methods getting called. Now I am facing a problem while enhancing this functionality with one more feature. Lets assume there are two roads i.e Road A and Road B with their lanes direction opposite to each other. When I am plotting the regions for both roads at different different locations on the roads, the condition can arise when the vehicles moving on Road A can detect the plotted region on Road B and vice versa.But I want to prevent the detection of regions plotted on Road A by Road B moving vehicles and vice versa.

It will work fine if my app will detect the regions based on the moving direction of vehicle or device (app knows that regions associated with which direction). I tried lot of solutions for it. But still not able to find the direction of angle of moving vehicle. Please suggest some solutions or algorithms to resolve this problem. Thanks.

iDevAmit
  • 1,550
  • 2
  • 21
  • 33

2 Answers2

0

There is no simple solution. The solution needs a collaboration between the server end and the front end (App.)

Simple algorithm:-

  1. When the user launches the app, the app sends the device current location to the server.
  2. Based on the location, the server will select a list of regions (eg: within 20 km radius) and sends to the app.
  3. If the list of sending regions is more than 20, the server has to reduce the radius until there are only 20 regions maximum.
  4. When the app receives the regions, it will start to monitor the region.

With the above algorithm, Road A and Road B will have different monitored regions. iOS has the limitation to monitor maximum 20 regions at the same time. So, you will need to remove the old regions before start to monitor the new regions return from the server.

Other Region monitoring topics that you might want to check out:-

Community
  • 1
  • 1
Ricky
  • 10,485
  • 6
  • 36
  • 49
  • Thanks very much for this nice explanatory answer. But my app is much enough intelligent to overcome all the conditions like 20 regions limitation, radius etc. I need solution when its mandatory to detect the region based on the direction of road, then how the algorithm will be? – iDevAmit Jul 02 '14 at 06:33
  • What is the possible distance between Road A and Road B? Could the server use a small radius so that the returned regions will not overlap. Getting the regions from the server based on radius is easy. Get the regions based on the direction of the user would be tough and the algorithm might be complex. As I don't think a road will be straight all the time. – Ricky Jul 02 '14 at 06:40
  • Both roads may connected with each other with 1 meter separator or may be there will be just 1 foot separator between them. Radius of regions managed by server. And minimum it can be 5 meter. What happened if regions getting overlap ?? I have to rid out from all the conditions, like overlapping of regions, curved roads etc. What the possible solutions, please suggest if anyone have idea. – iDevAmit Jul 02 '14 at 06:50
  • I think what you are trying to achieve is a bit hard based on our current technology. Even if you use kCLLocationAccuracyBestForNavigation, the accuracy could be 10-50 meters away depends on where you are. You should check http://stackoverflow.com/questions/23866097/ios-geofence-clcircularregion-monitoring-locationmanagerdidexitregion-does-not for more details. – Ricky Jul 02 '14 at 06:58
  • Yes it is bit hard. But I believe it may possible with the combination of technologies of Compass,Geo-fencing,direction etc. So trying to resolve it. – iDevAmit Jul 02 '14 at 07:21
  • All the best to you and hope that you can solve it. I don't have enough knowledge to contribute further. – Ricky Jul 02 '14 at 07:29
0

Region monitoring won't help you in determine.

If you have geo points of Roads then u can detect in which road your car is currently moving. nevertheless roads are 1 meter far apart.

If u can have two geo points on each road then its possible to determine

sajjeel
  • 29
  • 3
  • My regions can also be near to the square of roads. So we don't know, in which direction the vehicle can move immediately. So just after move, our region can come and need to detect for my selected road only. I hope you can understand. – iDevAmit Jul 07 '14 at 03:57
  • Although not the 100% correct but one quick solution is try to find the distance between your current location and the centre of each Region. Check which distance is less to identify the region . – sajjeel Jul 08 '14 at 11:47
  • Yes @sajjeel I did this also. It is fail in the case, where only Road A has Region but not on Road B, still road B vehicles getting detect the Region of A (in this case, the nearest distance is always the distance from the region A). – iDevAmit Jul 09 '14 at 06:01