Translate GPS coordinates to location on PDF Map - iphone

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.

Related

Finding the next intersection on the current street by using OpenStreetMap

I'm new to OSM and would like to know if my approach for finding the next intersection ahead is possible when doing it offline.
The goal is to get the coordinates (latitude/longitude) of the next intersection on the street I'm currently driving on. For that I have my actual position (lat/lon coordinates) and heading (w.r.t. the north-pole) at disposition.
My current approach right now is to first use my coordinates for getting the name of the street/way/trace in which I am driving; then use that name for knowing which are the next intersections on that street (to both sides); and then use the heading for knowing which direction is the one I should pay attention to.
Once I have the intersection, I would get its coordinates and continue with the program.
My questions are then, is it possible to do all of that offline, i.e. with a .osm file (or similar)?
And, do you know a better approach for getting the coordinates of the next intersection ahead?
Thanks a lot in advance!
PS. I was able to get the name of the street by using nominatim and to get all the intersections of a street by using Overpass turbo, but this solutions would need internet; or is there a way of using them offline?

Highest Altitude with best terrain data

I have a program that uses the API to get altitude data of the screen by running through hundreds of thousands of latitude and longitude points. However, Google Earth's data refines itself as one zooms in. So I need to know the minimum altitude I can use to get the best data Google has to offer. I am at a loss to figure out how to do this.
Furthermore, I assume that this depends on the part of the world. I'm going to assume the best part of the world, always.
Thanks for any feedback.
There is no API for determining the quality of the underlying imagery. While this question is not an exact duplicate of Get ground altitude in a reliable way, the same general algorithm can be applied:
Zoom to the required lat/lon at altitude Z
Wait for the imagery to come in (as described in the linked question)
Zoom in "closer" (Z - [delta])
If Google has better imagery, the loaded percentage should drop, wait for it load
Repeat steps 3-4 until the progress is always ~100% (e.g., until no loading is required)
Even with this hack, I'm not sure it will yield reliable results. Your question is flawed for several reasons:
What does "the best data Google has to offer" mean?
You have a lat/lon coordinate. That's a single, infinitely small, point on the Earth
Raw satellite imagery typically covers large sections (many lat/lon points), so the "best" height would be to set the GE camera so that your view convers exactly one satellite image tile
Why do you need the "best" data?
Satellite imagery is expressed in terms of "area covered by a single pixel" (e.g., 1m = 1 pixel in the image covers 1sq m)
Knowing this, the camera height will vary image by image, even for tiles within the same satellite imagery data set (it shouldn't vary much -- but it could slightly.)
Are you trying to cache the imagery off the globe? If so, you should carefully review the TOS to make sure you're not in violation.
Note that if you are just looking to obtain satellite imagery -- there are many good (free) sources. USGS National Map Viewer should be able to get you pretty good imagery for the US (including territories).

Calculate nearest point of KML polygon for iPhone app

I have a series of nature reserves that need to be plotted, as polygon overlays, on a map using the coordinates contained within KML data. I’ve found a tutorial on the Apple website for displaying KML overlays on map instances.
The problem is that the reserves vary in size greatly - from a small pond right up to several hundred kilometers in size. As a result I can’t use the coordinates of the center point to find the nearest reserves. Instead I need to calculate the nearest point of the reserves polygon to find the nearest one. With the data in KML - how would I go about trying to achieve this?
I've only managed to find one other person ask this and no one had replied :(
Well, there are a couple different solutions depending on your needs. The higher the accuracy required, the more work required. I like Phil's meanRadius parameter idea. That would give you a rough idea of which polygon is closest and would be pretty easy to calculate. This idea works best if the polygons are "circlish". If the polygon are very irregular in shape, this idea loses it's accuracy.
From a math standpoint, here is what you want to do. Loop through all points of all polygons. Calculate the distance from those points to your current coordinate. Then just keep track of which one is closest. There is one final wrinkle. Imagine a two points making a line segment that is very long. You are located one meter away from the midpoint of the line. Well, the distance to these two points is very large, while, in fact you are very close to the polygon. You will need to calculate the distance from your coordinate to every possible line segment which you can do in a variety of manners which are outlined here:
http://www.worsleyschool.net/science/files/linepoint/distance.html
Finally, you need to ask yourself, am I in any polygons? If you're 10 meters away from a point on a polygon, but are, in fact, inside the polygon, obviously, you need to consider that. The best way to do that is to use a ray casting algorithm:
http://en.wikipedia.org/wiki/Point_in_polygon#Ray_casting_algorithm

What is the best way to detecting distance between two iphone/ipod/ipad?

I only can think to use GPS location to calculate the distance ...
What if the two device is in the same building,but different floor
How to get the vertical distance ?
or any better ideas ???
GPS is probably going to be your best bet, although it only tends to be accurate within a few meters.
Fortunately, you can deal with vertical distance if you have a 3D lock with the GPS. This will provide you with latitude, longitude, and altitude. Enough to allow you to calculate 3D vector between any two points.
Here's a quick demo utilizing altitude in Core Location:
http://www.vellios.com/2010/08/18/ios-core-location-gps-tutorial-pt-2/
It does not sound possible to do what you want. That said...
GPS sounds like your only option to get the location that is as accurate as you want.
If you need to make sure that they are close enough for Bluetooth, use GameKit and it will search automatically for devices in range.
For vertical difference, you can try using the Gyro in iPhone 4, but I'm not sure that would work either.
As a last ditch effort, perhaps the proximity sensor may work for close range checking.

Visualizing/plotting location based on accelerometer/gyro readings over time

What's the easiest way to plot location track based on series of reading of accelerometer/gyro/compass sensors taken over time? Let's say I have following data taken every second:
ElapsedTime(s) xMag(uT) yMag(uT) zMag(uT) xAccel(g) yAccel(g) zAccel(g) xRate(rad/sec) yRate(rad/sec) zRate(rad/sec) roll(rad) pitch(rad) yaw(rad)
...
Is there an easy way to draw a location plot for any given time? I'm using iPhone 4 with xSensor app to capture data, but can't just use GPS. I would appreciate any hints. Both standalone applications and Java libraries would be good.
Double integration of the acceleration vector (after gyro & compass direction correction) will give you a location from some initial or arbitrary offset. The problem is that any small offset or errors in the acceleration data, which there will be, will result in a rapidly diverging position.
What might be more possible is to get frequent and precise GPS position data, and use the acceleration data to estimate the route in between two very nearby GPS fixes.