Check whether a CLLocation is based on GPS or cellular - ios

With a 3G GPS device (i.e. iPad 3G) is there a way to know if a reported CLLocation is based on a GPS signal, and not the inaccurate cellular data?

The CLLocation class has a method called -horizontalAccuracy:. This will give you some idea of the radius of accuracy of that measurement. This is probably better than asking just "is it GPS" because GPS readings can also be pretty inaccurate, depending on receiving conditions and satellite visibility.

Related

Exact coordinates from ios app

I'm creating a tracking application and ios application is the front end to gather the coordinates. Issue is my ios application is not giving the exact path followed. Im using this code to gather coordinates
locationMgr.desiredAccuracy = kCLLocationAccuracyBestForNavigation
locationMgr.delegate = self
//locationMgr.allowDeferredLocationUpdatesUntilTraveled(1.0, timeout:100)
locationMgr.requestWhenInUseAuthorization()
locationMgr.pausesLocationUpdatesAutomatically=false
locationMgr.distanceFilter=1
locationMgr.startUpdatingLocation()
I'm using coordinates gathered upto 8th decimal point such as 34.98776555
but Out put is not straight one that I followed. Please help
GPS Positioning typically has an accuracy of 1-5 meters. There are additional factors that can reduce the accuracy further.
As per the excerpt from the following website : How Accurate is the GPS on my Smart Phone?
For any GPS to work the antennae needs a clear view of the sky. Users of smart phones will frequently be in “urban canyons” or indoors. This is where WiFi and cellular network positioning become necessary. Both of these methods are used by smart phones as indoor positioning systems. The phone will use a hybrid approach, using all three methods to locate you. These other two technologies aren’t nearly as accurate as A-GPS, but can still locate you sufficiently to find the closest vanilla latte!
Generally WiFi positioning is more accurate than cellular network
positioning. It uses wireless access points and measures the
intensity of the received signal from one or more networks to find the
position. Interestingly it doesn’t require your device to be WiFi
enabled to work.
Cellular network positioning triangulates your position based off of
nearby cell phone towers. Phone companies have precise locations for
their cell towers, which when combined with signal strength can be
used to approximate your location. Both of these techniques are
dependent on overlapping signals from either access points and
cellular towers. Therefore they’re more accurate in urban settings.
CLLocationManger has an attribute called horizontalAccuracy which you can use to ignore points if they aren't accurate enough as per your requirements.
public func locationManager(manager: CLLocationManager, didUpdateToLocation newLocation: CLLocation, fromLocation oldLocation: CLLocation){
print(newLocation.coordinate.latitude)
print(newLocation.coordinate.longitude)
print(newLocation.horizontalAccuracy)
}
A GPS point which is off by just 1-2 meters will cause that point to get plotted off the road. From my experience getting pinpoint accuracy will be difficult and there is nothing that can be done about it.

How to check user location provided by WIFi or GPS

CLLocationManager Class provide location by GPS, WIFI or cellular, is there any way to check location provided by WIFI.
I know CLLocationManager class used GPS, WIFI on the basis of desiredAccuracy property.
GPS location readings show non negative speed. WiFi and cell tower triangulation locations have speed set to -1.

Indoor location based on iBeacon

I want to locate an object position inside a house( one floor).
The object will have a iBeacon on it.
What are the best approach.
With api, i can get distance from the iBeacon, but this doesn't reflect position.
One idea was to have 4 fixed iBeacon on the floor, but seem's i can't get the distance from the moving iBeacon to a fixed.
Any idea?
iBeacon isn't the right technology for this - at least not with a single receiver.
iBeacon only gives you an approximate distance. If you have multiple beacons in known locations then you can try and triangulate the receiver's position but you can't use this information to determine the location of another transmitter in an unknown location - only estimate its distance from the receiver.
Even using known, fixed transmitters it is difficult to locate the receiver with any accuracy due to the nature of the Bluetooth signals.
If you had multiple iBeacon receivers on the floor at known locations then it might be possible to determine the location of the transmitter.

How to show an iBeacon in a map

Once an app finds a beacon is possible to show both in a map (the device that found the beacon and the beacon itself)? If so how can i do that? I tried work with the distance bit with no success so far.
Unfortunately, you can't just find the exact location of an iBeacon once it's detected. You can only estimate its distance away from the device.
The proximity property tells you the relative distance (far, immediate, or close) that the beacon is away from the device while the accuracy property tells you how accurate that value is; so you can use proximity in combination with accuracy to get a general approximation of the distance. You could also potentially use these properties in combination with the RSSI, i.e. the received signal strength of the beacon, to further approximate the relative distance.
The device on the other hand can be mapped easily by turning on the map's showsUserLocation property.
I suppose your map is a MKMapView. If you know the precise location of the beacon (by having use a GPS to get the coordinates of the beacon when you have installed it) you can add an annotation on your MKMapView.
Take a look at MKMapView - (void)addAnnotation:(id < MKAnnotation >)annotation method for that.
If you don't have a database where to fetch the GPS coordinates of your beacons, there is no way to display them on a map as a beacon knows nothing about its surroundings.
By the way the accuracy property of a CLBeacon object isn't reliable enough for positioning.

Estimating distance to iBeacon on iOS

I'm trying to estimate the distance from an iOS device to an iBeacon. I am aware that distance estimation is not super accurate, and I am also aware of this formula:
https://electronics.stackexchange.com/questions/83354/calculate-distance-from-rssi
I have found, through some research, that an iBeacon's BLE advertisement in fact contains data that represents the calibration value. That is to say, the RSSI determined at 1 meter away is actually broadcast by the beacon for all to see.
Now, I think the iOS must internally use this information to determine the Near, Far, Immediate, and Unknown categorizations of distance but I am not aware of any way to access this 1-meter RSSI directly.
My question is simply: Is there a way to get the distance estimate between an iOS device and a beacon WITHOUT having the 1-meter calibration value saved on the iOS device beforehand?
Some people say that the 'accuracy' field of the CLBeacon class is, in fact, the distance measurement to the beacon. The documentation does not support this statement, here's what it says:
accuracy The accuracy of the proximity value, measured in meters from
the beacon. (read-only)
#property (readonly, nonatomic) CLLocationAccuracy accuracy;
Discussion Indicates the one sigma horizontal accuracy in meters. Use
this property to differentiate between beacons with the same proximity
value. Do not use it to identify a precise location for the beacon.
Accuracy values may fluctuate due to RF interference.
A negative value in this property signifies that the actual accuracy
could not be determined.
There is a new iBeacon Document released by Apple on June 2, 2014 that states:
When building an application that uses either GPS or
beacon, it is important to consider this accuracy. The values
reported by the Core Location objects (the
horizontalAccuracy property in the CLLocation class, or
the accuracy property in the CLBeacon class) indicate this
level of uncertainty, or the margin of error. Both are
measured in meters. The higher the value, the lower the
certainty of the position of the device or beacon. Keep in
mind that depending on the physical surroundings a low
accuracy may not be possible.
I suspect that's Apple's 'confidence' metric when reading their CLProximity values. I interpret that as obtaining something like:
CLProximityNear with an accuracy value of 5; Apple pinpoints your position within a 5m margin of error.
The general sentiment I'm getting from my general analysis of sources is that using beacon technology for distance approximation is probably not the strength of the technology.
EDIT: Chaise Hocking from Shine Technologies in Melbourne has an insightful blog post that has some experiments and results regarding the accuracy property.
Is there a way to get the distance estimate between an iOS device and a beacon WITHOUT having the 1-meter calibration value saved on the iOS device beforehand?
YES, you simply read the CLBeacon accuracy field as you suspected. This is an estimate of the distance to the beacon in meters.
This estimate uses an undocumented calculation that is based on the RSSI measurements (likely a 30 second running average, perhaps discarding outliers) combined with the 1-meter RSSI calibration value embedded in the iBeacon advertisement. A port of this calculation to Android is shown here.
And, no, there is no way to read the calibration value from an app. It is obscured by iOS, which disallows seeing the details of iBeacon Bluetooth LE advertisements. See here for a detailed explanation.

Resources