osgEarth 2.1.1
|
#include <osgEarth/SpatialReference>
#include <osgEarth/Registry>
#include <osgEarth/Cube>
#include <osgEarth/LocalTangentPlane>
#include <OpenThreads/ScopedLock>
#include <osg/Notify>
#include <ogr_api.h>
#include <ogr_spatialref.h>
#include <algorithm>
Go to the source code of this file.
Namespaces | |
namespace | anonymous_namespace{SpatialReference.cpp} |
Defines | |
#define | LC "[SpatialReference] " |
#define | USE_CUSTOM_MERCATOR_TRANSFORM 1 |
Functions | |
std::string | anonymous_namespace{SpatialReference.cpp}::getOGRAttrValue (void *_handle, const std::string &name, int child_num, bool lowercase=false) |
std::string & | anonymous_namespace{SpatialReference.cpp}::replaceIn (std::string &s, const std::string &sub, const std::string &other) |
static osg::Matrixd | getTransformFromExtents (double minX, double minY, double maxX, double maxY) |
static bool | mercatorToGeographic (double *x, double *y, double *z, int numPoints) |
static bool | geographicToMercator (double *x, double *y, double *z, int numPoints) |
#define LC "[SpatialReference] " |
Definition at line 30 of file SpatialReference.cpp.
#define USE_CUSTOM_MERCATOR_TRANSFORM 1 |
Definition at line 34 of file SpatialReference.cpp.
static bool geographicToMercator | ( | double * | x, |
double * | y, | ||
double * | z, | ||
int | numPoints | ||
) | [static] |
Definition at line 741 of file SpatialReference.cpp.
{ for( int i=0; i<numPoints; i++ ) { double xr = (osg::DegreesToRadians(x[i]) - (-osg::PI)) / (2.0*osg::PI); double sinLat = sin(osg::DegreesToRadians(y[i])); double oneMinusSinLat = 1-sinLat; if ( oneMinusSinLat != 0.0 ) { double yr = ((0.5 * log( (1+sinLat)/oneMinusSinLat )) - (-osg::PI)) / (2.0*osg::PI); x[i] = MERC_MINX + (xr * MERC_WIDTH); y[i] = MERC_MINY + (yr * MERC_HEIGHT); // z doesn't change } } return true; }
static osg::Matrixd getTransformFromExtents | ( | double | minX, |
double | minY, | ||
double | maxX, | ||
double | maxY | ||
) | [static] |
Definition at line 660 of file SpatialReference.cpp.
{
osg::Matrixd transform;
transform.set(
maxX-minX, 0.0, 0.0, 0.0,
0.0, maxY-minY, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
minX, minY, 0.0, 1.0);
return transform;
}
static bool mercatorToGeographic | ( | double * | x, |
double * | y, | ||
double * | z, | ||
int | numPoints | ||
) | [static] |
Definition at line 726 of file SpatialReference.cpp.
{ for( int i=0; i<numPoints; i++ ) { double xr = -osg::PI + ((x[i]-MERC_MINX)/MERC_WIDTH)*2.0*osg::PI; double yr = -osg::PI + ((y[i]-MERC_MINY)/MERC_HEIGHT)*2.0*osg::PI; x[i] = osg::RadiansToDegrees( xr ); y[i] = osg::RadiansToDegrees( 2.0 * atan( exp(yr) ) - osg::PI_2 ); // z doesn't change } return true; }