How to Find Which Ocean a Coordinate is on - ios

I have some coordinates, which will always be somewhere in an ocean. I need a way to convert the coordinates into a string telling which ocean/sea the coordinate falls. Is there any convenient way to do this?
Thanks

If you're using MapKit, you can use the CLGeocoder method – reverseGeocodeLocation:completionHandler: to perform a reverse geocoding request. The completion handler returns an array of CLPlacemark objects. If you take a look at the CLPlacemark Class Reference, you'll see that there is an ocean property that contains the name of the ocean associated with the placemark. I'm assuming this will also apply to seas; if not, try the inlandWater property instead.

You can use reverse geocoding API: https://developers.google.com/maps/documentation/geocoding/#ReverseGeocoding https://developers.google.com/maps/documentation/javascript/examples/geocoding-reverse

Related

Creating CLPlacemark with custom values for testing

I have an application that moves CLPlacemark objects around and uses them, and I would like to unit-test several components that interact with them. To do this, I would like to be able to stub out calls to real reverse-geolocation from MapKit with methods that produce mock CLPlacemarks with known values.
CLPlacemark only has one initializer (copy initializer). But in the documentation, it says:
Placemark objects are typically generated by a CLGeocoder object, although you can also create them explicitly yourself.
However, most of the members are read-only, so I'm not sure how to create one with custom values. Is it possible to set internal properties in this way in Swift? If not, any ideas as to what they mean in the above citation?
I would use OCMock (http://ocmock.org) to stub out calls to create stub CLPlacemark objects, and stub out their getter methods with your own values.
id userDefaultsMock = OCMClassMock([CLPlacemark class]);
// set it up to return a specific value when stringForKey: is called
OCMStub([userDefaultsMock property]).andReturn(customValue);

XCode Debugger viewing variables

I'm attempting to step through some code where I have a variable:
view.annotation.coordinate.latitude
Looking at the variable in XCode I see:
Since this is an instance of a UIView there are structures that I'm unfamiliar with (e.g subViewCache). Is there some document explaining what these other structures are for? Where can I drill down to to find the annotation object (view.annotation) that I want to view?
By convention, anything start with underscore means it is private variable, which (normally) won't be documented and subject to change. The best you can do is guess the meaning from the name and hope there is something called _annotation.
However, you can use lldb command po view.annotation to ask debugger to print that property for you
Or you could create a temporary variable where you are trying to debug:
CLLocationCoordinate2D tempCoord = annotation.coordinate;
You should be able to see the long and lat from tempCoord if you hover over it while debugging.

Getting user's current location before doing next event in single method?

My requirement here is to get the user's current location and pass to map.google.com. And the most imp condition is : these two events must happen in a single method.
And my problem here is , I have to pass the user's location, but it is only obtained through the delegate of CLlocationManager.Basically i need user's location before calling for map.google.com.
(imp: i can't call for CLLocationManager in my viewwillappear or anywhere else in the code)
So, can we solve this issue using block handler?
Any help,links would be appreciated.
One of several solutions could be to use a third party library. Here one I used for geolocation, very light, simple, and blockbased : https://gist.github.com/steakknife/6972228
EDIT :
Here's an example to easily find the current location in one-line way using the synchronous method currentLocationByWaitingUpToMilliseconds:success: of the little library quoted above :
CLLocation *location = [LocationManager currentLocationByWaitingUpToMilliseconds:1000 success:nil];

CLGeocoder delay until completion handler

I have an app that requires Geocoding from a string to lat/long values, I use the geocoder from the iOS class reference:
http://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CLGeocoder_class/Reference/Reference.html#//apple_ref/occ/cl/CLGeocoder
but the completion handler gets called after I need it to be (namely I have code that uses those lat/long values, but is getting called before they are available)
any thoughts?
Put the code that uses the lat-long into the geocoder's completion handler. That's what it's for.

iOS CLLocationManager - How to call a method when the location is determined

I am using CLLocation manager to get my lat & long, and it seems to work rather well. However, the first reading of accuracy no matter what, is always 10. From here it seems to home-in correctly starting at about 1500m. The reason that this is a problem is because to determine whether the method is called, I am checking if the accuracy is below 15, which this false reading is, and therefore calling the method at the wrong time. How do I get around this?
CoreLocation may cache some old location values to "speed up" first location update. You can see if your location is a new one by checking CLLocation's timeStamp property.
you can check using horizontal accuracy there are many posts in stackoverflow regarding cllocationmanager. And for calling a method you can use NSNotificationCenter,Deleagate & protocol mechanism and IBAction of course. It depends on your requirement.

Resources