Get ground elevation (altitude) at arbitrary coordinates

Discuss on the SimConnect SDK can be used by programmers to write add-on components for Prepar3D
Locked
kwb
Posts: 10
Joined: Tue Aug 28, 2012 9:16 pm

Get ground elevation (altitude) at arbitrary coordinates

Post by kwb »

I need to obtain the scenery's ground elevation at a given position (latitude/longitude). I found the following thread here: https://www.fsdeveloper.com/forum/threa ... ost-127891 Obviously the only way is to create a dummy AI object and obtain the ground elevation at its location.

This example here shows how to get it for the own aircraft: http://www.prepar3d.com/forum/viewtopic.php?t=107154 but I need to get it at an ARBITRARY position specified by lat/lng.

  • Is there any better way, maybe something newer which does not require a bogus AI aircraft?
  • What would be the an appropriate AI aircraft, which does not require an AI to be installed (like an invisible AI aircraft)
  • Getting the ground value from an AI aircraft is possible, the question is how to make that AI object invisible to it is not shown among the other AI.
User avatar
ronh991
Posts: 724
Joined: Sat Jan 19, 2013 1:46 am
Location: Ontario, Canada

Re: Get ground elevation (altitude) at arbitrary coordinates

Post by ronh991 »

Try looking at the SDK. There is a SimConnect_RequestGroundInfo - would that work? Looks new. May or may not work for less than v4.

edit: looks like it's in v3 and v2 too
Ron
kwb
Posts: 10
Joined: Tue Aug 28, 2012 9:16 pm

Re: Get ground elevation (altitude) at arbitrary coordinates

Post by kwb »

I give that a trial (SimConnect_RequestGroundInfo) . What I find a bit confusing is that there are alt min/max values, so a define an area for which I want to get the ground info, but why does that definition need altitude min/max values.
User avatar
ronh991
Posts: 724
Joined: Sat Jan 19, 2013 1:46 am
Location: Ontario, Canada

Re: Get ground elevation (altitude) at arbitrary coordinates

Post by ronh991 »

I have not used or played with this API, but I assume you request a bounding box (ie a 3D box) with Lat/Lon and min/max alt - so try with min = 0 max = 10000 or maybe your aircraft height. (assume feet). Then you need to examine the response structure.

SIMCONNECT_RECV_GROUND_INFO and SIMCONNECT_DATA_GROUND_INFO

and then examine the ALT for the LAT/LON point you are interested in.

HTH

LM - Seems the hyperlinking in the API table is all screwed up - links to API don't work - don't go to API, only return to some random previous position.

edit: Specifically the SIMCONNECT API then References section(s). see General function, SimObject functions, View, World, Structures and enums

Anyone else??
Ron
kwb
Posts: 10
Joined: Tue Aug 28, 2012 9:16 pm

Re: Get ground elevation (altitude) at arbitrary coordinates

Post by kwb »

The elevation fetching works fine, only a few detail questions remain. I just post them here just in case somebody knows

  • Can the elevations be negative? Some place have "below MSL" elevations, so I would expect this.
  • Is there any performance penalty if I use a wider range for the alt min/max values when calling "SimConnect_RequestGroundInfo". So I wonder if it would be wise just to use something like 100000/-100000 for alt min max.
SJT
Posts: 16
Joined: Sun Jan 27, 2013 6:06 pm

Re: Get ground elevation (altitude) at arbitrary coordinates

Post by SJT »

You can definitely use SimConnect_RequestGroundInfo. The vertical heights in the bounding box are a bit confusing, I agree. Documentation does not say whether the heights are asl, agl - or what. I have assumed asl, and always set the minimum to zero, and maximum to 40, 0000 feet. Unless any new mountains have appeared - that seems to cover it! I can see no point whatsoever in setting a bounding box with minimum height > zero. If you're interested in submarine stuff, setting something <0 might make sense - but I haven't needed to.

Anyway - fwiw I have tested the results pretty comprehensively against non-Simconnect APIs (Bing and Google), and they seem always to come up with very comparable answers.
kwb
Posts: 10
Joined: Tue Aug 28, 2012 9:16 pm

Re: Get ground elevation (altitude) at arbitrary coordinates

Post by kwb »

I am just concerned about airfields below MSL like here: https://en.wikipedia.org/wiki/List_of_p ... _sea_level

Submarines do not matter for me.
SJT
Posts: 16
Joined: Sun Jan 27, 2013 6:06 pm

Re: Get ground elevation (altitude) at arbitrary coordinates

Post by SJT »

In that case, set a different minimum - say -2000 feet. For what I wanted the info (ground clearance over mountains while flying) 0 - 40000 works just fine. It's just a case of suck it and see for you, I suggest. The data is pretty easy to use once you've got it. It just takes a bit of thinking about as far as bounding box max min lats and longs are concerned, because if you make those too big, you'll get lots of variation in the returned data points. Also, you need to think about how far apart the sample points will be. Over a sand desert for example, you won't need many sample points because there won't be too much variation, but over (say) the mountains of the Himalayas, there can be vast variations in just a few hundred feet, so typically sample size will need to be more dense.
Locked