Accuracy Openweathermap or is it the Apple Watch? - swift

I'm building a weather app for Apple Watch only and the app is working. The strange thing is that I think that the coordinates that Openweathermap is using are not accurate.
I live in a small town in The Netherlands and that is recognised when I type it in on the website of Openweathermap. It returns also the coordinates on this website with 4 decimal places for the latitude and three decimal places for the longitude.
I generate the URL with coordinates, this results in a long number (I've printed this to the console) and the return is much shorter.
These coordinates are the real coordinates of my city, when I compare it to the coordinates from this website: https://www.where-am-i.net are those the same that my app is showing. The code I'm using is:
locationManager.desiredAccuracy = kCLLocationAccuracyBest
Changing to:
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
(this is not recommended unless device is plugged in)
With other words, does anyone know why the coordinates of openweathermap are different from the real coordinates and is there a solution for this. Because the app is now giving an other name back for the city that I'm located in.
The only thing I can think of is is dat my city is not recognised by open weather, but based on the location it will get de weather for the location with their coordinates, but will keep the city name in place. The outcome is the same.

Related

Hey are coordinates from Apple Maps incorrect when used as a CLLocation in mapkit?

I’m working on an app that shows various places on a map (SwiftUI using mkmapkit in a uiViewRepresentable) and have found that coordinates are being placed off target for some reason.
I have the data listed in Firebase as a map - Latitude value and Longitude value that is then transferred into a CLLocation in app.
Example of the problem is that Big Ben in London should be (according to Apple Maps) be at 51.50070N and 0.12455W doesn’t appear there in app (see image) but the app reports coordinates of 51.500702, 0.124610 - when tapped just below the annotation.reported coordinates
The sign on the longitude is incorrect. According to my MKLocalSearch (and confirmed by dropping an annotation there), Big Ben is at a latitude of 51.5006854 and a longitude of -0.1245698. Note, that's -0.1245698 (aka, 0.1245698W) and not 0.1245698 (aka 0.1245698E).
A longitude is defined “relative to the zero meridian, with positive values extending east of the meridian and negative values extending west of the meridian.”
But your map is showing the coordinate east of the meridian, not the one west of the meridian. Here are the two coordinates:
And zooming in on that incorrect coordinate to the east, that's obviously where your map is pointing:
But Big Ben is to the west of the meridian:

How to detect the accuracy margin of error using Core Location

I have an app that tracks user location using the following:
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
According to Apple's documentation, Core Location will try to obtain the best possible reading until I tell it to stop. However, I realize the reading can be impaired by many uncontrollable things i.e. weather, device in a building, etc.
For the purposes of my app, I would like to store how accurate the reading actually was. For example, if I am in a field, I may get a reading that is accurate up to 10 meters, but if I were in that same field during a thunderstorm, I may get a reading that is accurate up to 100 meters.
Is there a way to detect how accurate my reading actually is?
CLLocation (the object that gets returned from the CLLocationManager) contains two properties, horizontalAccuracy and verticalAccuracy.
This is a value measured in metres that tells you how many metres radius around the given location you could be.
You can read more about CLLocation here... CLLocation Class Reference
I believe this is what Apple uses in its maps app to place the circle around the location to represent the area you could possibly be in.

How to get number of random points around one point in iphone maps?

I am developing one iphone application which contains maps. Starting screen is navigation screen where user can select location, lets say florida. Now when User selects florida i want to pick up at least six random points (latitude and longitude of points so that I can put annotation) from florida only.
I do not have DB so that I can not fetch 5 points from DB for florida and place them.
Any ideas?
Thanks,
This is going to be quite hard if you don't have anything to tell you the shape and size of the area you are trying to produce random points within. Harikrishnan had given you a good start, though increasing the lat and long by 0.0001 each time is hardly random. At Florida's coordintes (28.0908° N, 81.9604° W according to Google) moving 0.0001 in both directions is only 14m away, so you're unlikely to leave Florida at that speed.
You could adjust Harikirshnan's method by using a random number instead of 0.0001, but you still need to know how big the area is that your user is looking at. Having 5 points all 14m when you're looking at a state, or even a city, is not much good.
Maybe you need to look more closely at what you are trying to achieve. If the points don't represent geographical data then why are you putting them on a map. If they do and they represent the entire area and not a single point then the best I can think of is to generate random points based on the maprect that Apple returns for the location the user has chosen. (roughly speaking that would be mapX = random*maprect.size.width + maprect.origin.x). And then incase you have an area like Florida that is not perfectly shaped like your MKMapView you'd need to reverse geocode to see if the point you picked really is within Florida (i.e. send the coords to Apple and check the address).
Or, you could consider now showing the data on the map
Try this
NSInteger i;
double offset=0.0001;
for(i=1;i<=5;i++){
double newlatitude=location.coordinate.longitude+offset;
double newlongitude=location.coordinate.longitude+offset;
NSLog(#"%f ,%f",newlatitude,newlongitude );
offset+=0.0001;
}

Converting an address to geolocation and adding a range

I have city address and state on my server.
I need to fetch data in my iPhone application as per distance range (i.e in miles).
Please give some proper suggestions.
You can use Google Geocoding to get Lat-Long form address.
For example :
http://maps.google.com/maps/api/geocode/json?sensor=false&address=newyork,us
address — The address that you want to geocode.
You can use the google geolocation service, where it will get the Lat long from the address or vice-a-versa.
Please read the FAQ for the same.
Another is Foursquare which also nice to use and provides good data.
This will solve your issue.
You can travel to each of your cities and measure the highest position of some stars.
Through the altitude relation you can calculate then you current latitude.
The longitude is a bit more complicated. You need an accurate clock and a table/chart of star positions/times. Then you take measure the time of the highest position of some stars and compare it to your table. with the difference of this two values you can calculate the longitude of the city.
But there are already people who did that and share their results.

Translate GPS coordinates to location on PDF Map

I'd like to know (from a high level view) what would be required to take a pdf floor plan of a building and determine where exactly you are on that floor plan using GPS coordinates? In addition to location, the user would be presented with a "turn by turn" directions to another point on the map, navigating down hallways, between cubicles, etc.
Use case: an iPhone app that determined a user's location and guided them to a conference room or person's office in the building.
I realize that this is by no means trivial, but any help is appreciated. Thanks!
It's an interesting problem. When you're using Core Location, you're not necessarily using GPS. Using WiFi and cell tower triangulation, you can get pretty good location results. So from Core Location you get a latitude and longitude fix. (You might also get altitude info, since GPS data is 3-dimensional. You also will get an accuracy value.)
So you have lat and lon. You need to map these coordinates to the PDF plan's coordinates. Assuming that the plan is aligned with the latitude and longitude lines, and that you have a lat-long fix for one of the points on the plan, you need to calculate the x-axis scale and y-axis scale. Then it's some calculations to map the lat-long to x-y coordinates on the PDF plan.
GPS may not be accurate enough for this purpose, especially indoors. Assuming errors on
the order of 10 meters, you'll have difficulty determining which floor the user is on.
Here's a neat (?) idea that might work: can you post some "You are here" placards
at various locations around the building? You could label each one with a unique,
machine-readable location code (maybe a QR code or something similar), then take an
image using the camera, have your app read that image and interpret the location code,
and use that instead of GPS to determine the start location.
GPS inside? That's your first -- and biggest -- hurdle.
Next hurdle is knowing the GPS coordinates of at least three points on that PDF to define the plane of of your map in the real world. (The PDF will need to be to scale, of course.)
So that gives you where you are on the PDF. Now you'll need to figure out some way to determine where you can walk (or where you can't) to get directions.