Skip to content

Commit

Permalink
XYZ: add min_level and max_level to support elevation
Browse files Browse the repository at this point in the history
  • Loading branch information
gwaldron committed Jan 29, 2025
1 parent 8f70f61 commit 7501ae1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/osgEarth/XYZ
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ namespace osgEarth { namespace XYZ
OE_OPTION(URI, url);
OE_OPTION(bool, invertY, false);
OE_OPTION(std::string, format, {});
OE_OPTION(unsigned, minLevel, 0);
OE_OPTION(unsigned, maxLevel, 19);
static Config getMetadata();
virtual Config getConfig() const;
private:
Expand All @@ -85,6 +87,8 @@ namespace osgEarth { namespace XYZ
OE_OPTION(URI, url);
OE_OPTION(bool, invertY, false);
OE_OPTION(std::string, format, {});
OE_OPTION(unsigned, minLevel, 0);
OE_OPTION(unsigned, maxLevel, 19);
OE_OPTION(std::string, elevationEncoding, {});
OE_OPTION(bool, stitchEdges, false);
OE_OPTION(RasterInterpolation, interpolation, INTERP_BILINEAR);
Expand Down
16 changes: 14 additions & 2 deletions src/osgEarth/XYZ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ XYZImageLayerOptions::getConfig() const
conf.set("url", _url);
conf.set("format", _format);
conf.set("invert_y", _invertY);
conf.set("min_level", minLevel());
conf.set("max_level", maxLevel());
return conf;
}

Expand All @@ -132,6 +134,8 @@ XYZImageLayerOptions::fromConfig(const Config& conf)
conf.get("url", _url);
conf.get("format", _format);
conf.get("invert_y", _invertY);
conf.get("min_level", minLevel());
conf.get("max_level", maxLevel());
}

Config
Expand All @@ -157,6 +161,8 @@ XYZElevationLayerOptions::getConfig() const
conf.set("url", _url);
conf.set("format", _format);
conf.set("invert_y", _invertY);
conf.set("min_level", minLevel());
conf.set("max_level", maxLevel());
conf.set("elevation_encoding", _elevationEncoding);
conf.set("stitch_edges", stitchEdges());
return conf;
Expand All @@ -168,6 +174,8 @@ XYZElevationLayerOptions::fromConfig(const Config& conf)
conf.get("url", _url);
conf.get("format", _format);
conf.get("invert_y", _invertY);
conf.get("min_level", minLevel());
conf.get("max_level", maxLevel());
conf.get("elevation_encoding", _elevationEncoding);
conf.get("interpretation", elevationEncoding()); // compat with QGIS
conf.get("stitch_edges", stitchEdges());
Expand Down Expand Up @@ -240,7 +248,10 @@ XYZImageLayer::openImplementation()

if (dataExtents.empty())
{
dataExtents.push_back(DataExtent(getProfile()->getExtent()));
dataExtents.push_back(DataExtent(
getProfile()->getExtent(),
options().minLevel().value(),
options().maxLevel().value()));
}

setDataExtents(dataExtents);
Expand Down Expand Up @@ -314,7 +325,8 @@ XYZElevationLayer::openImplementation()

setProfile(_imageLayer->getProfile());

DataExtentList de{ DataExtent(getProfile()->getExtent()) };
DataExtentList de;
_imageLayer->getDataExtents(de);
setDataExtents(de);

return Status::NoError;
Expand Down

0 comments on commit 7501ae1

Please sign in to comment.