GeoLocator* SpatialReference::createLocator(double xmin, double ymin, double xmax, double ymax, bool plate_carre ) const { if ( !_initialized ) const_cast<SpatialReference*>(this)->init(); GeoLocator* locator = new GeoLocator( GeoExtent(this, xmin, ymin, xmax, ymax) ); locator->setEllipsoidModel( (osg::EllipsoidModel*)getEllipsoid() ); locator->setCoordinateSystemType( isGeographic()? osgTerrain::Locator::GEOGRAPHIC : osgTerrain::Locator::PROJECTED ); // note: not setting the format/cs on purpose. if ( isGeographic() && !plate_carre ) { locator->setTransform( getTransformFromExtents( osg::DegreesToRadians( xmin ), osg::DegreesToRadians( ymin ), osg::DegreesToRadians( xmax ), osg::DegreesToRadians( ymax ) ) ); } else { locator->setTransform( getTransformFromExtents( xmin, ymin, xmax, ymax ) ); } return locator; }
GeoLocator* GeoLocator::getGeographicFromGeocentric( ) const { if (getCoordinateSystemType() == osgTerrain::Locator::GEOCENTRIC) { double xmin, ymin, xmax, ymax; getDataExtent().getBounds( xmin, ymin, xmax, ymax ); GeoLocator* geographic = new GeoLocator( getDataExtent() ); geographic->setCoordinateSystemType( Locator::GEOGRAPHIC ); geographic->setTransformAsExtents( xmin, ymin, xmax, ymax); return geographic; } return NULL; }
GeoLocator* GeoLocator::createForExtent( const GeoExtent& extent, const class MapInfo& map) { double xmin, ymin, xmax, ymax; extent.getBounds( xmin, ymin, xmax, ymax ); // A locator will place the tile on the globe: GeoLocator* locator = extent.getSRS()->createLocator( extent.xMin(), extent.yMin(), extent.xMax(), extent.yMax(), map.isPlateCarre() ); if ( map.isGeocentric() ) locator->setCoordinateSystemType( osgTerrain::Locator::GEOCENTRIC ); return locator; }
GeoLocator* CubeSpatialReference::createLocator(double xmin, double ymin, double xmax, double ymax) const { int face; CubeUtils::cubeToFace( xmin, ymin, xmax, ymax, face ); GeoLocator* result = new CubeFaceLocator( face ); osg::Matrixd transform; transform.set( xmax-xmin, 0.0, 0.0, 0.0, 0.0, ymax-ymin, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, xmin, ymin, 0.0, 1.0); result->setTransform( transform ); return result; }