How to get exact user sitting position latitude and longitude values in a room? - swift

I want get exact user sitting position latitude and longitude values in a room or building. I am getting user location latitude and longitude values through CLLocationManager but not exactly showing. Is any possibility through get user exact building latitude and longitude values.
Thanks
Laxman

GPS precision is usually at best 10m, so you cannot expect to obtain positions with better precision than that, which is not usually enough for positioning within a building. Besides, if your user is not using GPS, you will get network-based positioning data which has yet lower precision.
I don't think you can use CLLocationManager or any other out-of-the-box positioning service for that.
Technologies exist that can be used to locate a phone within a building based on other sensor data (eg. https://en.situm.es/solutions.php), that perhaps you could apply.
There are also ways to improve GPS precision outdoors (eg. https://es.wikipedia.org/wiki/Wide_Area_Augmentation_System) depending on where you live. It all depends on your application.

Related

How to notify user when he enters a specific type of place in flutter?

I want to build a flutter app in which I want to trigger a notification when a user enters a place of a specific type.
places of specific type means (saloon, restaurants, hospital, etc) these all are types of places.
Requirments
I want the system to work offline. (like if the user dosn't have
mobile data & user enters the specified type of place he should
recive a notification).
I want the system to work in background.
(when the app is terminated(killed) & user enters the specified type
of place he should recive a notification).
My approach
when the user installs the app and opens it for the first time, the
app will cal google places API and save latitude, longitude of all
places of specified type near him.
and then use the background_locator link plugin to monitor users
current latitude, longitude.
on every change of latitude, longitude find distance between users
latitude, longitude, and all places latitude, longitude that we
stored.
if the distance is below 50 meters between users current latitude,
longitude, and certain place latitude, longitude then trigger a
notification.
problems with my approach
Background service will be running all the time in background(also
when the app is killed) witch will consume battery alot.
As the background service will be running all the time the whole
distance calculation will happen every 5 to 10 secs or you can say
every the background service fetch users current location which is
also not a good thing.
If the user goes to any other city How will I update latitudes,
longiudes of the nearby places ?
As we know some places have areas(size) and some have small, and
distance of 50 meters will not be accurate for all places.
What I want from you
If you have a better approach for solving the above problem, share it
with me.
if you can improve the solution that is also appreciated.
do provide me names and links of plugins in your approach.

store latitude and longitude in ios address book

Can latitude and longitude be added to a record in an iOS address book?
My app wants to display nearby contacts on a map. I know how to get the latitude/longitude from an address. I do not know how to save them so I can avoid repeated lookups
Yes, you can add a latitude-and-longitude address to a contact in your iOS address book. It takes one extra step to view the map pin from that address, but it works.
Open an existing or new Contact, and create a new address. Under Street, put in the latitude and longitude, with a comma between but no blank space.
Leave everything else empty: city, state, and so on. It will force you to pick a country, so either just leave the default, or if you want, you can select the country that corresponds to the coordinates, though it really doesn't matter.
For example, you could enter:
• Street: 48.8582,2.2945
• Country: France (or any country)
(For locations South of the equator or East of the Greenwich meridian, add a minus sign: e.g., -17.53655,-149.56832).
Save the address.
To go to the location in Apple maps, open the Contact and click the latitude/longitude address. This will take you to Apple maps. Don't wait for the map to come up, because if you wait the pin will be dead center in whatever country is listed. Instead, while it's thinking, just go to the address bar at the top and edit out the country so that only the lat/long is left and hit Search. This time, the pin will go directly to the correct latitude/longitude location. If you want Google maps, just copy/paste the lat/long into Google maps.
The example shown above should put you right at the Eiffel Tower. Bon voyage!
In iPhone native address book it's not possible to store. But you can do one thing, you can store info of the user in SQLite database in your app along with lat lon and if you want some synchronization functionality then you can create web-service which will update your SQLite database as per your logic.
Hope this will help you.
All the best !!!
I am not sure but this may be not possible to add latitude and longitude value to ABPeoplePickerNavigationController. but if you want to find distance between two Contact then you can find it from contacts's address or add your latitude and longitude value into database and use 2 option of mine .
There are two way for find location by address
1) How to get street address from ABPeoplePickerNavigationController
2) use reverseGeocodeLocation and also check this my answer CLLocationManager not getting City name this is helpful for you.

Geolocation in Iphone Application

I am a newbee to Iphone App Development and struggling with my first application.
I have a database with few address in it. All I have to do is get the current location and pick the closest three address from the database and of-course have to show the current location and the selected three nearest address on a map with directions on them.
I had a look at the Xcode frameworks LocateMe, CurrentAddress and MKReverseGeocoder Class Reference.
But then not sure how to co-ordinate this all together in an orderly manner.
Any suggestions/assistance would be greatly appreciated.
Thanks
You should provide lat/lon with your addresses in your database, so do the geocoding of the addresses before.
You have a location manager (CLLocationManager) which takes care of your current position, and with each location (CLLocation) you can calculate the distance (distanceFormLocation:). Now you only need to sort your database with this and pick the first three items.
Hmm?

Getting nearby locations

I want to get nearby cities from current location depending upon distance, e.g, cities in radius of 100km,200km etc using the gps of iphone. How can i determine these cties as gps only gives the details of the current location.
Thanks in advance
You need to have a database of the cities in your program, with their coordinates.
You'll read the coordinates of the iphone from the GPS, and then find the x closest cities to you by simple math (see this answer for an example)
You will have to have a custom list of cities and their respective locations and work it out yourself, or potentially use something like google local api, but I don't know if you could reliably return cities through it.

Core Location - fallback, location caching and alternatives

I have a few questions about Core Location.
1) Should the user refuse permission for my app to use core location, or core location is unavailable for some reason, is there a fallback? (Device Locale, for example?)
2)Can I cache a device's location for next time? Does Core Location do this itself?
3)I really need the sunset time in the user's area during the mid-spring season and I have a function to do that, once I have the Latitude and Longitude of the device. Perhaps I can just make an assumption about the time based on Locale? (Example: In the US, assume approximately 7:00pm.)
EDIT:
I really am trying to calculate sunset in the users area for an app. Nothing to do with the map. I am considering the following sequence of events:
Check for Core Location availability. If yes, use it and store it in NSUserPreferences. If Core Location is unavailable, go on to the fallbacks.
Check for a stored Location. If it's stored, use it. If not, go on...
Check for the user's chosen time.
1) Strictly speaking, if the user does not allow using CoreLocation or, if permission were given but CoreLocation is not available, there is no other fallback to get the user's location as a latitude, longitude pair. Using the locale may not work in all of the cases. First, it will just give you an approximation which may be way too far from reality. However, it's up to you to judge whether this approximation is ok for your app. Moreover, there are some users using a locale different from the one related to their country. And, you have no guarantee that people travelling abroad will adjust the date/time every time.
2) Core Location caches by default the last location retrieved from the GPS unit. However, for people travelling abroad this cached location will be certainly wrong (even for people travelling just a few miles away), and in general, you should discard the cached value and localize again the user each time. I understand that for people travelling within their country this will not (usually) create huge problems. But it just depends on the country: travelling within Italy will not change the time, but travelling across the US may change the time up to 3 hours.
3) I would suggest to try using Core Location and, in case of problems, simply ask the user to input his/her local time or location (the city should be enough for your purpose). If you choose to ask for the user's location, then you can get the corresponding latitude/longitude pair but this will require a working network connection.
2) From the online docs for CLLocationManager:
The location service returns an initial location as quickly as possible, returning cached information when available.
You can check the CLLocation timestamp to see if it is a cached value or not.
3) If you do decide to use locale for an initial TZ approximation, remember that users travel, and may not reset their locale promptly. You can get the current TZ object with:
[NSTimeZone localTimeZone]