0

I'm trying to add an elevation layer to my program that's based on osgEarth. I've seen an example, osgearth_city, available in osgEarth source tree, which loads a TMSElevationLayer like this:

TMSElevationLayer* layer = new TMSElevationLayer();
layer->setURL("http://readymap.org/readymap/tiles/1.0.0/116/");
map->addLayer(layer);

But what I need is to use a set of local *.hgt tiles in the directory layout like /path/to/hgt/N/37/N55E037.hgt for the 55°N 37°E tile. I've found that GDALElevationLayer can be used to load individual *.hgt files, with

const auto gdal=new GDALElevationLayer;
gdal->setURL("/home/ruslan/hgt/N/37/N55E037.hgt");
map->addLayer(gdal);

But this way I'd have to manage the tileset myself: watch the location of the camera, load the required tiles, unload the ones no longer needed etc..

How can I instruct osgEarth to do the tile management automatically, like it does with TMSElevationLayer, but using the local *.hgt files?

Ruslan
  • 18,162
  • 8
  • 67
  • 136

1 Answers1

1

I recommend you create a VRT file using GDAL's gdalbuildvrt command line tool, as described here.

Also, since you are using DTED data, be sure to tell osgEarth to use the correct EGM96 reference ellipsoid:

layer->setVerticalDatum("egm96");
  • Is EGM96 always the correct ellipsoid for elevation data? Or do I have to somehow check that my dataset uses it? – Ruslan Dec 14 '20 at 20:23
  • DTED is known to be expressed relative to the EGM96 geoid. Not all elevation is, but it's pretty common. Unfortunately datasets do not usually convey that information so you have to figure it out and tell osgearth yourself. – Glenn Waldron Dec 16 '20 at 02:05
  • For some reason, when I set `GDALElevationLayer::setURL` to my `.vrt` file, most of the tiles take forever to load (after several have loaded) — even the map tiles, which work fine without this layer or when I pass the single `.hgt` file directly to it. Can the tile manager of `GDALElevationLayer` somehow conflict with that of `XYZImageLayer`? – Ruslan Dec 18 '20 at 16:34