Skip to content

Commit

Permalink
Fix #2310 Update FeatureModelLayer on the fly failed
Browse files Browse the repository at this point in the history
gwaldron committed Oct 23, 2023
1 parent 80f0bce commit b3aa22c
Showing 4 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/osgEarth/FeatureModelGraph.cpp
Original file line number Diff line number Diff line change
@@ -705,7 +705,7 @@ FeatureModelGraph::open()
_lodmap.resize(lod + 1, 0L);
_lodmap[lod] = level;

OE_INFO << LC << _session->getFeatureSource()->getName()
OE_DEBUG << LC << _session->getFeatureSource()->getName()
<< ": No levels specified, so adding one for LOD=" << lod
<< ", maxRange=" << maxRange.get()
<< std::endl;
7 changes: 6 additions & 1 deletion src/osgEarth/FeatureModelLayer.cpp
Original file line number Diff line number Diff line change
@@ -111,7 +111,12 @@ void FeatureModelLayer::dirty()
// create the scene graph
if (isOpen())
{
create();
if (getFeatureSource())
{
// tell the source to recompute its profile, etc.
getFeatureSource()->dirty();
create();
}
}
}

4 changes: 4 additions & 0 deletions src/osgEarth/OGRFeatureSource
Original file line number Diff line number Diff line change
@@ -123,6 +123,10 @@ namespace osgEarth

virtual void buildSpatialIndex();

//! Call this if the underlying geometry changes and we need to
//! recompute the profile.
void dirty() override;

protected:

virtual ~OGRFeatureSource();
29 changes: 29 additions & 0 deletions src/osgEarth/OGRFeatureSource.cpp
Original file line number Diff line number Diff line change
@@ -698,6 +698,35 @@ OGRFeatureSource::openImplementation()
return Status::NoError;
}

void
OGRFeatureSource::dirty()
{
if (_profile.valid())
{
setFeatureProfile(new FeatureProfile(_profile->getExtent()));
}
else if (_geometry.valid())
{
// if the user specified explicit geometry, use that and the calculated
// extent of the geometry to derive a profile.
GeoExtent ex;
if (_profile.valid())
{
ex = GeoExtent(_profile->getSRS(), _geometry->getBounds());
}

if (!ex.isValid())
{
// default to WGS84 Lat/Long
//osg::ref_ptr<const Profile> gg = Profile::create(Profile::GLOBAL_GEODETIC);
//ex = gg->getExtent();
ex = GeoExtent(SpatialReference::get("wgs84"), _geometry->getBounds());
}

setFeatureProfile(new FeatureProfile(ex));
}
}

const Status&
OGRFeatureSource::create(const FeatureProfile* profile,
const FeatureSchema& schema,

0 comments on commit b3aa22c

Please sign in to comment.