I have a line object made up of two CLLocation's (startPoint and endPoint). I am adding a tolerance set in metres (say 3000 metres) around an MBR (Minimum Bounding Rectangle) derived from these two points.
The question I have is how would I add say 3000 metres to a CLLocation and arrive at a new CLLocation, especially given that there's no function like this?
Thought it might be easier to work with two CLLocations (topLeft and bottomRight). Still can't see how to add distances to these and arrive at a new set of points.
Thanks for helping me with a starting point. I'm building a bounding box, and trying to determine the maximum latitude north. This is the exact calculation that I need, however given the following:
offsetLocation: latitude 37.331688999999997, longitude -122.030731
offsetMeters: 1000
bearing: 0
lat2 returns -0.36726592610659514
Any suggestions? I've coded around this particular formula until now and this one has me stumped.
You can't modify CLLocations - create another one instead.
Quote:
Originally Posted by coulls
Hi all,
I have a line object made up of two CLLocation's (startPoint and endPoint). I am adding a tolerance set in metres (say 3000 metres) around an MBR (Minimum Bounding Rectangle) derived from these two points.
The question I have is how would I add say 3000 metres to a CLLocation and arrive at a new CLLocation, especially given that there's no function like this?
Thought it might be easier to work with two CLLocations (topLeft and bottomRight). Still can't see how to add distances to these and arrive at a new set of points.
Thanks,
Jason
I wrestled with this too. You can't change the values in a CLLocation. What you have to do is calculate the new coordinate you want, and then initialize a new one with the parameters from the old one.
You use the call initWithCoordinate:altitude:horizontalAccuracy:ver ticalAccuracy:timestamp: to create a new location using the values from the old location.
That lets you copy most, but not all, of the settings from the old location.
Thanks for helping me with a starting point. I'm building a bounding box, and trying to determine the maximum latitude north. This is the exact calculation that I need, however given the following:
offsetLocation: latitude 37.331688999999997, longitude -122.030731
offsetMeters: 1000
bearing: 0
lat2 returns -0.36726592610659514
Any suggestions? I've coded around this particular formula until now and this one has me stumped.
b.dot
I've not had a chance to come back to this one yet. I hope to attack it fairly soon though! :-)
I wrestled with this too. You can't change the values in a CLLocation. What you have to do is calculate the new coordinate you want, and then initialize a new one with the parameters from the old one.
Thanks - I sort of arrived at that conclusion. The bigger problem for me next was the accuracy of the offset in metres when dealing with longitude. Still haven't quite had the time to sit down and figure that one out.
OK - Had to fix that bug, and it's looking good now... although much different to the first implementation. Much head scratching got me ready to throw the Mac out the window....
Add this at the top of your .m file. (Note the ArcCos hack I had to make as couldn't get the quiet_nan to work).