osgEarth 2.1.1
Public Member Functions | Private Attributes

osgEarth::MercatorLocator Class Reference

Inheritance diagram for osgEarth::MercatorLocator:
Collaboration diagram for osgEarth::MercatorLocator:

List of all members.

Public Member Functions

 MercatorLocator (const osgTerrain::Locator &prototype, const GeoExtent &dataExtent)
virtual bool convertModelToLocal (const osg::Vec3d &world, osg::Vec3d &local) const
virtual GeoLocatorcloneAndCrop (const osgTerrain::Locator &prototype, const GeoExtent &displayExtent)
virtual GeoLocatorgetGeographicFromGeocentric ()

Private Attributes

GeoExtent _geoDataExtent

Detailed Description

A terrain locator that generates texture coordinates that warp a Mercator image.

Note: the MercatorLocator doesn't have a "cropping" variation b/c it automatically self-crops as necessary.

Definition at line 79 of file Locators.


Constructor & Destructor Documentation

MercatorLocator::MercatorLocator ( const osgTerrain::Locator &  prototype,
const GeoExtent dataExtent 
)

Definition at line 197 of file Locators.cpp.

                                                                                                  :
GeoLocator( prototype, dataExtent )
{
    // assumption: incoming extent is Mercator SRS; transform it to LAT/LONG

    _geoDataExtent = dataExtent.transform( dataExtent.getSRS()->getGeographicSRS() );

    //double latmin, lonmin, latmax, lonmax;
    //mercatorToLatLon( dataExtent.xMin(), dataExtent.yMin(), latmin, lonmin );
    //mercatorToLatLon( dataExtent.xMax(), dataExtent.yMax(), latmax, lonmax );

    //_geoDataExtent = GeoExtent(
    //    dataExtent.getSRS()->getGeographicSRS(),
    //    lonmin, latmin, lonmax, latmax );
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

GeoLocator * MercatorLocator::cloneAndCrop ( const osgTerrain::Locator &  prototype,
const GeoExtent displayExtent 
) [virtual]

Clones the current locator, applying a new display (i.e. crop) extent.

Definition at line 215 of file Locators.cpp.

{
    return new MercatorLocator( prototype, getDataExtent() );
}

Here is the call graph for this function:

bool MercatorLocator::convertModelToLocal ( const osg::Vec3d &  world,
osg::Vec3d &  local 
) const [virtual]

Reimplemented from osgEarth::GeoLocator.

Definition at line 221 of file Locators.cpp.

{
    bool result = false;

    // required becasue of an OSG bug
    if ( !_inverseCalculated )
    {
        const_cast<MercatorLocator*>(this)->_inverse.invert( _transform );
        const_cast<MercatorLocator*>(this)->_inverseCalculated = true;
    }

    switch(_coordinateSystemType)
    {
    case(GEOCENTRIC):
        {
            double longitude, latitude, height;

            _ellipsoidModel->convertXYZToLatLongHeight(world.x(), world.y(), world.z(),
                latitude, longitude, height );

            local = osg::Vec3d(longitude, latitude, height) * _inverse;

            double lon_deg = osg::RadiansToDegrees(longitude);
            double lat_deg = osg::RadiansToDegrees(latitude);
            double xr, yr;

            getUV( _geoDataExtent, lon_deg, lat_deg, xr, yr );

            local.x() = xr;
            local.y() = 1.0-yr;
            result = true;
        }
        break;


    case(GEOGRAPHIC):
        {        
            local = world * _inverse;

            osg::Vec3d w = world;
            double lon_deg = w.x();
            double lat_deg = w.y();

            double xr, yr;
            getUV( _geoDataExtent, lon_deg, lat_deg, xr, yr );

            local.x() = xr;
            local.y() = 1.0-yr;
            result = true;
        }
        break;

    case(PROJECTED):
        {        
            local = world * _inverse;
            result = true;      
        }
        break;
    }

    return result;
}

Here is the call graph for this function:

GeoLocator * MercatorLocator::getGeographicFromGeocentric ( ) [virtual]

Definition at line 285 of file Locators.cpp.

{
    if (getCoordinateSystemType() == osgTerrain::Locator::GEOCENTRIC)
    {
        double xmin, ymin, xmax, ymax;
        getDataExtent().getBounds( xmin, ymin, xmax, ymax );
        MercatorLocator* geographic = new MercatorLocator( *this, getDataExtent() );
        geographic->setCoordinateSystemType( Locator::GEOGRAPHIC );
        geographic->setTransformAsExtents( xmin, ymin, xmax, ymax);
        return geographic;
    }
    return NULL;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 93 of file Locators.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines