- if( _useAircraftPosition ) {
- _longitude_deg = _positionLongitudeNode->getDoubleValue();
- _latitude_deg = _positionLatitudeNode->getDoubleValue();
+ // get the aircraft's position if requested
+ if( _useAircraftPosition && _speed_kt < 0.5 ) {
+ _inputPosition = SGGeod::fromDegM(
+ _positionLongitudeNode->getDoubleValue(),
+ _positionLatitudeNode->getDoubleValue(),
+ SG_MAX_ELEVATION_M );
+ }
+
+ // need geocentric coordinates
+ SGGeoc center = SGGeoc::fromGeod( _inputPosition );
+
+ // if a speed is set, move the input position
+ if( _speed_kt >= 0.5 ) {
+ double distance_m = _speed_kt * dt * SG_NM_TO_METER;
+ center = center.advanceRadM( _heading_deg * SG_DEGREES_TO_RADIANS, distance_m );
+ _inputPosition = SGGeod::fromGeoc( center );
+ }
+
+ if( _signalNode->getBoolValue() ) {
+ // if we had finished the iteration and moved more than 10% of the radius
+ // of the sampling area, drop the oldest samples and continue sampling
+ if( SGGeoc::distanceM( center, SGGeoc::fromGeod(_outputPosition ) ) >= _recalc_distance_norm * _radius ) {
+ _elevations.resize( _max_samples * _reuse_samples_norm );
+ _signalNode->setBoolValue( false );
+ }