Skip to content

Commit

Permalink
TerrainConstraint: add filters
Browse files Browse the repository at this point in the history
  • Loading branch information
gwaldron committed Feb 2, 2022
1 parent 2ff2f10 commit 697c0fe
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/osgEarth/TerrainConstraintLayer
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace osgEarth
public:
META_LayerOptions(osgEarth, Options, VisibleLayer::Options);
OE_OPTION_LAYER(FeatureSource, featureSource);
OE_OPTION_VECTOR(ConfigOptions, filters);
OE_OPTION(bool, removeInterior);
OE_OPTION(bool, removeExterior);
OE_OPTION(bool, hasElevation);
Expand Down Expand Up @@ -74,6 +75,10 @@ namespace osgEarth
//! Visibility toggle from VisibleLayer
virtual void setVisible(bool value) override;

FeatureFilterChain* getFilters() const {
return _filterchain.get();
}

protected:

virtual Status openImplementation() override;
Expand All @@ -90,6 +95,8 @@ namespace osgEarth
private:

void create();

osg::ref_ptr<FeatureFilterChain> _filterchain;
};
} // namespace osgEarth

Expand Down
18 changes: 16 additions & 2 deletions src/osgEarth/TerrainConstraintLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
*/

#include <osgEarth/TerrainConstraintLayer>
#include <osgEarth/FeatureCursor>
#include <osgEarth/Map>
#include <osgEarth/Progress>
#include <osgEarth/AltitudeFilter>

using namespace osgEarth;

Expand Down Expand Up @@ -49,6 +47,10 @@ TerrainConstraintLayer::Options::fromConfig(const Config& conf)
conf.get("remove_exterior", removeExterior());
conf.get("has_elevation", hasElevation());
conf.get("min_level", minLevel());

const Config& filtersConf = conf.child("filters");
for (auto& child : filtersConf.children())
filters().push_back(ConfigOptions(child));
}

Config
Expand All @@ -60,6 +62,14 @@ TerrainConstraintLayer::Options::getConfig() const
conf.set("remove_exterior", removeExterior());
conf.set("has_elevation", hasElevation());
conf.set("min_level", minLevel());

if (filters().empty() == false)
{
Config temp;
for (unsigned i = 0; i < filters().size(); ++i)
temp.add(filters()[i].getConfig());
conf.set("filters", temp);
}
return conf;
}

Expand Down Expand Up @@ -94,6 +104,10 @@ TerrainConstraintLayer::openImplementation()
if (fsStatus.isError())
return fsStatus;

_filterchain = FeatureFilterChain::create(
options().filters(),
getReadOptions());

return Status::NoError;
}

Expand Down
2 changes: 2 additions & 0 deletions src/osgEarthDrivers/engine_rex/MeshEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ MeshEditor::MeshEditor(const TileKey& key, unsigned tileSize, const Map* map, Pr
{
osg::ref_ptr<FeatureCursor> cursor = fs->createFeatureCursor(
key,
layer->getFilters(),
nullptr,
progress);

Edit edit;
Expand Down

0 comments on commit 697c0fe

Please sign in to comment.