VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
makVrv::DtProceduralSoundscapeQuery Class Reference

Query helper that computes the signed distance (in metres) from a geographic point to the nearest matching polygon or raster boundary.

Each call to querySignedDistance() evaluates elevation conditions, raster sampling, and feature layer proximity in sequence. For FeatureSource layers, spatial bounds queries are issued against per-tile caches populated by background feature-fetch threads. For PolygonizedRaster mode, GDAL is used to polygonize raster tiles on background threads; results are cached per tile and evicted when the observer moves more than ~1 degree from the tile centre. Both caches are protected by internal mutexes.

Signed distance convention (spherical-mercator SRS)
  • Negative value: the point is inside a polygon. The magnitude is the distance from the point to the nearest edge.
  • Positive value: the point is outside all polygons. The value is the distance in meters to the nearest polygon edge.
  • DBL_MAX: the layer was not found, is not open, or no features exist within the query radius. The caller should treat this as silent (factor = 0).

Public Member Functions

 DtProceduralSoundscapeQuery (osgEarth::MapNode *mapNode)
 
virtual double querySignedDistance (const DtProceduralSoundscapeChannel &channel, double lon_deg, double lat_deg, double hat_m) const
 
 DtProceduralSoundscapeQuery (const DtProceduralSoundscapeQuery &)=delete
 
DtProceduralSoundscapeQuery & operator= (const DtProceduralSoundscapeQuery &)=delete
 
std::string getRasterStatus (const DtProceduralSoundscapeChannel &channel) const
 
DtPolygonCacheStats getPolygonCacheStats () const
 
DtPolygonCacheStats getFeatureTileCacheStats () const
 

Protected Member Functions

virtual double evaluateElevationConditions (const DtProceduralSoundscapeChannel &channel, osgEarth::Map *map, double lon_deg, double lat_deg) const
 
virtual double evaluateFeatureDistance (const DtProceduralSoundscapeChannel &channel, osgEarth::Map *map, double lon_deg, double lat_deg) const
 
virtual double evaluateRasterDistance (const DtProceduralSoundscapeChannel &channel, osgEarth::Map *map, double lon_deg, double lat_deg) const
 
virtual double evaluateRasterPolygonDistance (const DtProceduralSoundscapeChannel &channel, osgEarth::Map *map, double lon_deg, double lat_deg) const
 

Protected Attributes

osg::observer_ptr
< osgEarth::MapNode > 
myMapNode
 
const osgEarth::SpatialReference * myWgs84Srs {nullptr}
 
std::shared_ptr
< DtPolygonCacheData > 
myPolygonCache
 
std::shared_ptr
< DtFeatureTileCacheData > 
myFeatureTileCache
 
std::shared_ptr
< DtElevationSampleCache > 
myElevationSampleCache
 

Constructor & Destructor Documentation

makVrv::DtProceduralSoundscapeQuery::DtProceduralSoundscapeQuery ( osgEarth::MapNode *  mapNode)
explicit

Construct with the osgEarth MapNode that owns the feature layers.

Parameters
mapNodeMust remain valid for the lifetime of this object.
makVrv::DtProceduralSoundscapeQuery::DtProceduralSoundscapeQuery ( const DtProceduralSoundscapeQuery &  )
delete

Copy not allowed.

Member Function Documentation

virtual double makVrv::DtProceduralSoundscapeQuery::querySignedDistance ( const DtProceduralSoundscapeChannel &  channel,
double  lon_deg,
double  lat_deg,
double  hat_m 
) const
virtual

Query the signed distance from (lon_deg, lat_deg) to the nearest polygon in the FeatureSource layer described by channel.

Parameters
channelChannel configuration (layer name, attribute filter, query radius).
lon_degObserver longitude in decimal degrees (WGS84).
lat_degObserver latitude in decimal degrees (WGS84).
hat_mObserver height above the rendered terrain mesh in metres, as returned by DtObserver::heightAboveTerrain(). Negative means on or below the terrain surface. When this value exceeds channel.fadeDistanceMeters the channel is silenced, preventing ambient sounds while the observer is airborne. Using the scene intersection avoids the bathymetry artefact that affects the osgEarth ElevationPool (deep ocean floors).
Returns
Signed distance in meters, or DBL_MAX if the layer is absent/empty.
DtProceduralSoundscapeQuery& makVrv::DtProceduralSoundscapeQuery::operator= ( const DtProceduralSoundscapeQuery &  )
delete
std::string makVrv::DtProceduralSoundscapeQuery::getRasterStatus ( const DtProceduralSoundscapeChannel &  channel) const

Return a short human-readable status string for the raster source of channel, for use in debug overlays.

Returns an empty string when the channel has no raster source. Otherwise returns one of:

  • "Layer not in map" - the named ImageLayer was not found or is not open.
  • "Pending" - the GDALPolygonize worker thread is still running.
  • "Failed" - createImage or GDAL step failed permanently.
  • "Ready (N polygons)"- polygons are cached and ready.
DtPolygonCacheStats makVrv::DtProceduralSoundscapeQuery::getPolygonCacheStats ( ) const

Capture a snapshot of the polygon tile cache for debug/profiling display. Thread-safe: takes the cache mutex briefly.

DtPolygonCacheStats makVrv::DtProceduralSoundscapeQuery::getFeatureTileCacheStats ( ) const

Capture a snapshot of the feature tile cache for debug/profiling display. Thread-safe: takes the cache mutex briefly.

virtual double makVrv::DtProceduralSoundscapeQuery::evaluateElevationConditions ( const DtProceduralSoundscapeChannel &  channel,
osgEarth::Map *  map,
double  lon_deg,
double  lat_deg 
) const
protectedvirtual

Evaluate each DtElevationCondition against the terrain MSL elevation sampled from the osgEarth ElevationPool.

Returns 0.0 (unconstrained) when elevationConditions is empty - no pool query is performed in that case.

hat_m is NOT a parameter here. It is applied as a universal final constraint in querySignedDistance so that it gates every return path (elevation, raster, and feature distance) consistently, including the case where a feature polygon returns a very negative signed distance while the observer is airborne.

Returns
0.0 if elevationConditions is empty (unconstrained). The maximum signed distance across all conditions when data is available. DBL_MAX if the elevation pool or sample data is unavailable (fail-closed).
virtual double makVrv::DtProceduralSoundscapeQuery::evaluateFeatureDistance ( const DtProceduralSoundscapeChannel &  channel,
osgEarth::Map *  map,
double  lon_deg,
double  lat_deg 
) const
protectedvirtual

Query the feature source for the minimum signed distance from the observer to any polygon that passes all attributeFilters.

Returns
Minimum signed distance in metres to a matching polygon, or DBL_MAX if the layer is absent, not open, or contains no matching features.
virtual double makVrv::DtProceduralSoundscapeQuery::evaluateRasterDistance ( const DtProceduralSoundscapeChannel &  channel,
osgEarth::Map *  map,
double  lon_deg,
double  lat_deg 
) const
protectedvirtual

Sample an osgEarth ImageLayer and return a signed distance in metres.

Handles both SDF and Classification modes of DtRasterSource.

Returns
Signed distance (SDF) or 0.0/DBL_MAX (Classification), or DBL_MAX if the layer is absent or data is unavailable.
virtual double makVrv::DtProceduralSoundscapeQuery::evaluateRasterPolygonDistance ( const DtProceduralSoundscapeChannel &  channel,
osgEarth::Map *  map,
double  lon_deg,
double  lat_deg 
) const
protectedvirtual

Polygonise a raster ImageLayer at LOD 10 on a background thread and return the signed distance from the observer to the nearest matching polygon once the cache is populated.

Returns DBL_MAX (silent) while the background GDALPolygonize job is pending. Results are cached per tile and evicted when the observer moves more than ~1 degree from the tile centre.

Member Data Documentation

osg::observer_ptr<osgEarth::MapNode> makVrv::DtProceduralSoundscapeQuery::myMapNode
protected
const osgEarth::SpatialReference* makVrv::DtProceduralSoundscapeQuery::myWgs84Srs {nullptr}
protected

WGS84 SpatialReference pointer, cached at construction to avoid per-call registry mutex contention. The osgEarth registry keeps the object alive for the process lifetime, so the raw pointer is stable.

std::shared_ptr<DtPolygonCacheData> makVrv::DtProceduralSoundscapeQuery::myPolygonCache
mutableprotected

Shared cache for polygonised raster tiles (render thread + worker threads).

std::shared_ptr<DtFeatureTileCacheData> makVrv::DtProceduralSoundscapeQuery::myFeatureTileCache
mutableprotected

Shared cache for fetched feature tile geometry (render thread + worker threads).

std::shared_ptr<DtElevationSampleCache> makVrv::DtProceduralSoundscapeQuery::myElevationSampleCache
mutableprotected

Per-channel async elevation sample cache (render thread reads, background threads write). Eliminates all main-thread getSample() cost.


The documentation for this class was generated from the following file:

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)