#include <QPolygonF>
#include <QStringList>
+#include <math.h>
+
#define _TIMER
#ifdef _TIMER
#include <OSD_Timer.hxx>
double HYDROData_Bathymetry::GetAltitudeForPoint( const gp_XY& thePoint ) const
{
- double aResAltitude = GetInvalidAltitude();
+ double anInvalidAltitude = GetInvalidAltitude();
+ double aResAltitude = anInvalidAltitude;
AltitudePoints anAltitudePoints = GetAltitudePoints();
if ( anAltitudePoints.isEmpty() )
// [ 0 (top-left) ] [ 1 (top-right) ]
// thePoint
// [ 2 (bot-left) ] [ 3 (bot-right) ]
- AltitudePoint aBounds[ 4 ] = { AltitudePoint( -DBL_MAX, -DBL_MAX, GetInvalidAltitude() ),
- AltitudePoint( DBL_MAX, -DBL_MAX, GetInvalidAltitude() ),
- AltitudePoint( -DBL_MAX, DBL_MAX, GetInvalidAltitude() ),
- AltitudePoint( DBL_MAX, DBL_MAX, GetInvalidAltitude() ) };
+ AltitudePoint aBounds[ 4 ] = { AltitudePoint( -DBL_MAX, -DBL_MAX, anInvalidAltitude ),
+ AltitudePoint( DBL_MAX, -DBL_MAX, anInvalidAltitude ),
+ AltitudePoint( -DBL_MAX, DBL_MAX, anInvalidAltitude ),
+ AltitudePoint( DBL_MAX, DBL_MAX, anInvalidAltitude ) };
AltitudePoints::const_iterator aListItBeg = anAltitudePoints.constBegin();
AltitudePoints::const_iterator aListItEnd = anAltitudePoints.constEnd();
aBoundingRect << QPointF( aPoint.X(), aPoint.Y() );
}
+ const double LIMIT = 1E300;
+ if( fabs( aBounds[ 0 ].X() ) > LIMIT || fabs( aBounds[ 0 ].Y() ) > LIMIT ||
+ fabs( aBounds[ 1 ].X() ) > LIMIT || fabs( aBounds[ 1 ].Y() ) > LIMIT ||
+ fabs( aBounds[ 2 ].X() ) > LIMIT || fabs( aBounds[ 2 ].Y() ) > LIMIT ||
+ fabs( aBounds[ 3 ].X() ) > LIMIT || fabs( aBounds[ 3 ].Y() ) > LIMIT )
+ return anInvalidAltitude;
+
+
// Check if requested point is inside of our bounding rectangle
if ( !aBoundingRect.boundingRect().contains( thePoint.X(), thePoint.Y() ) )
return aResAltitude;