How to make osgEarth automatically manage HGT elevation tiles?

395 views Asked by At

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?

1

There are 1 answers

3
Glenn Waldron On

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");