Added support for imagery and DEM's that wrap around the dateline, this required
two passes over the copying of imagery and DEM's to the destination graphs, once for the original position, and once for the wrap around 360 degrees on or before. Also fixed the GeospationExtents constructor that was setting the _max to DBL_MIN rather than -DBL_MAX. This bug causesd the y axis to be computed incorrectly.
This commit is contained in:
@@ -52,16 +52,19 @@ class GeospatialExtents
|
||||
{
|
||||
public:
|
||||
|
||||
osg::Vec2d _min;
|
||||
osg::Vec2d _max;
|
||||
|
||||
osg::Vec2d _min;
|
||||
osg::Vec2d _max;
|
||||
bool _isGeographic;
|
||||
|
||||
inline GeospatialExtents() :
|
||||
_min(DBL_MAX,DBL_MAX),
|
||||
_max(DBL_MIN,DBL_MIN) {}
|
||||
_max(-DBL_MAX,-DBL_MAX),
|
||||
_isGeographic(false) {}
|
||||
|
||||
inline GeospatialExtents(double xmin, double ymin, double xmax, double ymax) :
|
||||
inline GeospatialExtents(double xmin, double ymin, double xmax, double ymax, bool isGeographic) :
|
||||
_min(xmin, ymin),
|
||||
_max(xmax, ymax){}
|
||||
_max(xmax, ymax),
|
||||
_isGeographic(isGeographic) {}
|
||||
|
||||
inline double& xMin() { return _min.x(); }
|
||||
inline double xMin() const { return _min.x(); }
|
||||
@@ -96,19 +99,35 @@ public:
|
||||
return 0.25f*((_max-_min).length2());
|
||||
}
|
||||
|
||||
GeospatialExtents intersect(const GeospatialExtents& e) const
|
||||
GeospatialExtents intersection(const GeospatialExtents& e, double xoffset) const
|
||||
{
|
||||
return GeospatialExtents(osg::maximum(xMin(),e.xMin()),osg::maximum(yMin(),e.yMin()),
|
||||
osg::minimum(xMax(),e.xMax()),osg::minimum(yMax(),e.yMax()));
|
||||
return GeospatialExtents(osg::maximum(xMin(),e.xMin()+xoffset),osg::maximum(yMin(),e.yMin()),
|
||||
osg::minimum(xMax(),e.xMax()+xoffset),osg::minimum(yMax(),e.yMax()),_isGeographic);
|
||||
}
|
||||
|
||||
/** Return true if this bounding box intersects the specified bounding box. */
|
||||
bool intersects(const GeospatialExtents& bb) const
|
||||
{
|
||||
return osg::maximum(xMin(),bb.xMin()) <= osg::minimum(xMax(),bb.xMax()) &&
|
||||
osg::maximum(yMin(),bb.yMin()) <= osg::minimum(yMax(),bb.yMax());
|
||||
if (_isGeographic)
|
||||
{
|
||||
// first check vertical axis overlap
|
||||
if (osg::maximum(yMin(),bb.yMin()) > osg::minimum(yMax(),bb.yMax())) return false;
|
||||
|
||||
// next check if overlaps directly without any 360 degree horizontal shifts.
|
||||
if (osg::maximum(xMin(),bb.xMin()) <= osg::minimum(xMax(),bb.xMax())) return true;
|
||||
|
||||
// next check if a 360 rotation will produce an overlap
|
||||
float rotationAngle = (xMin() > bb.xMin()) ? 360.0 : -360;
|
||||
return (osg::maximum(xMin(),bb.xMin()+rotationAngle) <= osg::minimum(xMax(),bb.xMax()+rotationAngle));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (osg::maximum(xMin(),bb.xMin()) <= osg::minimum(xMax(),bb.xMax()) &&
|
||||
osg::maximum(yMin(),bb.yMin()) <= osg::minimum(yMax(),bb.yMax()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void expandBy(const osg::BoundingSphere& sh)
|
||||
{
|
||||
if (!sh.valid()) return;
|
||||
@@ -187,14 +206,9 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced
|
||||
return *this;
|
||||
}
|
||||
|
||||
void computeExtents()
|
||||
{
|
||||
_extents.init();
|
||||
_extents.expandBy( osg::Vec3(0.0,0.0,0.0)*_geoTransform);
|
||||
_extents.expandBy( osg::Vec3(_numValuesX,_numValuesY,0.0)*_geoTransform);
|
||||
}
|
||||
void computeExtents();
|
||||
|
||||
osg::ref_ptr<osg::CoordinateSystemNode> _cs;
|
||||
osg::ref_ptr<osg::CoordinateSystemNode> _cs;
|
||||
osg::Matrixd _geoTransform;
|
||||
GeospatialExtents _extents;
|
||||
unsigned int _numValuesX;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user