Sign in to follow this  

Coordinate systems, real world to XYZ

Recommended Posts

Hi guys, I am looking at writing an app to display real world terrain data relative to a gps position. The idea would be to combine DEM or similar imaging data to generate a height map for the terrain then overlay sattellite imagery as the texture. Using the gps position you could then see in the app what you see outside ( in terms of topography ) My confusion comes with how to deal with the coordinates. I am used to treating worlds as flat planes with xyz offsets. However I will need to convert from GPS position, which I am presuming is in lat long, to an XYZ position. I initially thought I could just come up with a scale to convert from XY to lat long, and height map data to offset y however presumably as the earth isnt a flat surface this will give me some errors? Are there any papers on this kind of stuff, or open source examples? Any advice appreciated. Ultimately would like to get this running on the iphone. Edit - should add I am not hoping to represent the whole world with this, just the UK if that makes any difference. Cheers!

Share this post

Link to post
Share on other sites
First, I don't know of any papers or open source for you.

An approach I took (using geological survey data, USA, lat/long/altitude), was to create an array[rows][cols] of height vs. XZ position. I chose a "corner" lat/long for the "lower right-hand corner," array[0][0]. Pick a delta-longitude and delta-latitude (I used something like 2 arc-seconds, I think, about 200 feet/~51 meters). Normalize your gps positions (assuming you can derive lat/long/altitude) to that "corner" lat/long, and divide by the delta-lat and delta-long to get indices into the array. Set the altitude.

Work your way left and up in the array, setting altitudes, for as many rows and columns as might be appropriate for limited memory.

Is that the sort of info you're seeking?

Also, you don't have to worry about curvature for a limited field-of-view ( a couple of kilometers to the horizon ).

EDIT: You may have to pay close attention to longitudes along the prime meridian (since that's in the territory) as you'll either switch from east-to-west or 360-to-0 on that line.

Share this post

Link to post
Share on other sites
Thanks Buckeye, I managed to dig up some info on both the GoogleEarth and FlightGear implementations. Both of which seem to do something very similar to what you have mentioned, essentially breaking it up into 'plates' and working from there. Sounds pretty straight forward! Relieved that I dont have to worry about curvature.

Just need to come up with a good scale between the lat/long deltas in terms of X,Z do you remember what 1.0f represented to you?

Share this post

Link to post
Share on other sites
Because it was the precision of the survey data, I used 1800 elev points per degree. Of course, a degree of longitude changes length from north to south, but, if you don't need to be too rigorous, draw a box around Britain and use the size of a degree at the center.

From my helicopter app (I think NED is our National Elevation Database):

// refining the display of NED data
// for compatibility with the NED database, use cells 71 quads on a side, a quad being ~202 feet or 1/30th of a nautical mile, or
// 1/30th of an arc-minute or 1/1800 of a degree. Each database record (1 degree on a side) has 1800x1800 data points.

(We Yanks still use the British foot)

EDIT: a "quad" was what I used to draw 2 triangles for the terrain. It's a little "blocky," with changes of elevation only every 200 feet (~62m).

That's about 1.3Mb (using (4 byte) floats) per 1-degree-square-array, maybe too big for iPhone. Either use smaller arrays, or larger deltas.

If you want to muck about with conversions, store the altitude in 2 bytes (0-65535) and cut the array size in quarter. The UK doesn't have a lot of high altitudes (Scotland, maybe) so that precision may suffice.

This calculator can help you decide.

EDIT: By the way, the bookkeeping for which rectangle(s) need to be displayed when you're near an array boundary will drive you nuts. But you asked.

EDIT2: FYI, using 1-degree records, my database for about 1/2 of Pennsylvania plus most of Arizona (the Grand Canyon is spectacular!) runs about 355Mb. Don't know how that compares in size to portions of the UK you want to cover.

[Edited by - Buckeye on February 23, 2010 11:32:45 AM]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this