How to find if two google map routes are being intersected in an IOS project
google-maps, ios
Solution
There is no direct method to check for that intersection.
You can turn the problem into a geometry problem by converting the lat/long positions into map positions (applying the transform to flatten onto a normalised grid). This can be done with `MKMapPointForCoordinate`.
One thing to consider is the inaccuracy of the GPS reported positions. In a number of cases you will find that the reported track from the GPS isn't actually on the road but running beside the road. Particularly when turning (tight) corners you will often get a large curve in the track. As such you may want to extend the width of the 'finishing line' to compensate for this.
If you just care about whether the user is within a certain distance of a set point then you can create a `CLRegion` to represent the target location and then call `containsCoordinate:` with the current user location. This removes any projection and uses the lat/long directly. You can also get the system to monitor this for you and give you a callback when the user enters or exits the region with `startMonitoringForRegion:desiredAccuracy:`. Again, you need to consider GPS accuracy when setting the radius.
Problem
I want to achieve the following and I am unaware whether it is possible or not. I am having two points on a road (imagine like a finishing line - they are the two edges of the pavements - they are in a straight line) and I want to check whether a user's route has passed between these points. So I thought, I can do something like this: - get the route between these two points (they are quite near - the road is 20 m wide at most) - get the users route - check if these routes are interecting, if there is any crossing between them. If it was pure geometry, it would be easy. I am having two lines and I want to know if there is any intersection between them. I want to use the following in an IOS project, if it makes any difference. For example, I thought that maybe there is a programmatically way of drawing the MKPolylines and see if there is intersection. I do not want to see it visually, I just need it programmatically. Is it possible? Can you suggest me anything else?