GDAL
Public Member Functions | Static Public Member Functions | List of all members
OGRCoordinateTransformation Class Referenceabstract

Interface for transforming between coordinate systems. More...

#include <ogr_spatialref.h>

Inherited by AxisMappingCoordinateTransformation, CompositeCT, CutlineTransformer, and GCPCoordTransformation.

Public Member Functions

virtual OGRSpatialReferenceGetSourceCS ()=0
 Fetch internal source coordinate system.
 
virtual OGRSpatialReferenceGetTargetCS ()=0
 Fetch internal target coordinate system.
 
virtual bool GetEmitErrors () const
 Whether the transformer will emit CPLError.
 
virtual void SetEmitErrors (bool)
 Set if the transformer must emit CPLError.
 
int Transform (int nCount, double *x, double *y, double *z=nullptr, int *pabSuccess=nullptr)
 Transform points from source to destination space. More...
 
virtual int Transform (int nCount, double *x, double *y, double *z, double *t, int *pabSuccess)=0
 Transform points from source to destination space. More...
 
virtual int TransformWithErrorCodes (int nCount, double *x, double *y, double *z, double *t, int *panErrorCodes)
 Transform points from source to destination space. More...
 
virtual int TransformBounds (const double xmin, const double ymin, const double xmax, const double ymax, double *out_xmin, double *out_ymin, double *out_xmax, double *out_ymax, const int densify_pts)
 Transform boundary. More...
 
virtual OGRCoordinateTransformationClone () const =0
 Clone. More...
 
virtual OGRCoordinateTransformationGetInverse () const =0
 Return a coordinate transformation that performs the inverse transformation of the current one. More...
 

Static Public Member Functions

static void DestroyCT (OGRCoordinateTransformation *poCT)
 OGRCoordinateTransformation destructor. More...
 
static OGRCoordinateTransformationH ToHandle (OGRCoordinateTransformation *poCT)
 Convert a OGRCoordinateTransformation* to a OGRCoordinateTransformationH. More...
 
static OGRCoordinateTransformationFromHandle (OGRCoordinateTransformationH hCT)
 Convert a OGRCoordinateTransformationH to a OGRCoordinateTransformation*. More...
 

Detailed Description

Interface for transforming between coordinate systems.

Currently, the only implementation within OGR is OGRProjCT, which requires the PROJ library.

Also, see OGRCreateCoordinateTransformation() for creating transformations.

Member Function Documentation

◆ Clone()

virtual OGRCoordinateTransformation * OGRCoordinateTransformation::Clone ( ) const
pure virtual

Clone.

Since
GDAL 3.1

◆ DestroyCT()

void OGRCoordinateTransformation::DestroyCT ( OGRCoordinateTransformation poCT)
static

OGRCoordinateTransformation destructor.

This function is the same as OGRCoordinateTransformation::~OGRCoordinateTransformation() and OCTDestroyCoordinateTransformation()

This static method will destroy a OGRCoordinateTransformation. It is equivalent to calling delete on the object, but it ensures that the deallocation is properly executed within the OGR libraries heap on platforms where this can matter (win32).

Parameters
poCTthe object to delete
Since
GDAL 1.7.0

◆ FromHandle()

static OGRCoordinateTransformation * OGRCoordinateTransformation::FromHandle ( OGRCoordinateTransformationH  hCT)
inlinestatic

Convert a OGRCoordinateTransformationH to a OGRCoordinateTransformation*.

Since
GDAL 2.3

◆ GetInverse()

virtual OGRCoordinateTransformation * OGRCoordinateTransformation::GetInverse ( ) const
pure virtual

Return a coordinate transformation that performs the inverse transformation of the current one.

In some cases, this is not possible, and this method might return nullptr, or fail to perform the transformations.

Returns
the new coordinate transformation, or nullptr in case of error.
Since
GDAL 3.3

◆ ToHandle()

static OGRCoordinateTransformationH OGRCoordinateTransformation::ToHandle ( OGRCoordinateTransformation poCT)
inlinestatic

Convert a OGRCoordinateTransformation* to a OGRCoordinateTransformationH.

Since
GDAL 2.3

◆ Transform() [1/2]

virtual int OGRCoordinateTransformation::Transform ( int  nCount,
double *  x,
double *  y,
double *  z,
double *  t,
int *  pabSuccess 
)
pure virtual

Transform points from source to destination space.

This method is the same as the C function OCTTransform4D().

Parameters
nCountnumber of points to transform.
xarray of nCount X vertices, modified in place. Should not be NULL.
yarray of nCount Y vertices, modified in place. Should not be NULL.
zarray of nCount Z vertices, modified in place. Might be NULL.
tarray of nCount time values, modified in place. Might be NULL.
pabSuccessarray of per-point flags set to TRUE if that point transforms, or FALSE if it does not. Might be NULL.
Returns
TRUE if some or all points transform successfully, or FALSE if if none transform.

◆ Transform() [2/2]

int OGRCoordinateTransformation::Transform ( int  nCount,
double *  x,
double *  y,
double *  z = nullptr,
int *  pabSuccess = nullptr 
)

Transform points from source to destination space.

This method is the same as the C function OCTTransformEx().

Parameters
nCountnumber of points to transform.
xarray of nCount X vertices, modified in place. Should not be NULL.
yarray of nCount Y vertices, modified in place. Should not be NULL.
zarray of nCount Z vertices, modified in place. Might be NULL.
pabSuccessarray of per-point flags set to TRUE if that point transforms, or FALSE if it does not. Might be NULL.
Returns
TRUE if some or all points transform successfully, or FALSE if if none transform.

◆ TransformBounds()

virtual int OGRCoordinateTransformation::TransformBounds ( const double  xmin,
const double  ymin,
const double  xmax,
const double  ymax,
double *  out_xmin,
double *  out_ymin,
double *  out_xmax,
double *  out_ymax,
const int  densify_pts 
)
inlinevirtual

Transform boundary.

This method is the same as the C function OCTTransformBounds().

Transform boundary densifying the edges to account for nonlinear transformations along these edges and extracting the outermost bounds.

If the destination CRS is geographic, the first axis is longitude, and xmax < xmin then the bounds crossed the antimeridian. In this scenario there are two polygons, one on each side of the antimeridian. The first polygon should be constructed with (xmin, ymin, 180, ymax) and the second with (-180, ymin, xmax, ymax).

If the destination CRS is geographic, the first axis is latitude, and ymax < ymin then the bounds crossed the antimeridian. In this scenario there are two polygons, one on each side of the antimeridian. The first polygon should be constructed with (ymin, xmin, ymax, 180) and the second with (ymin, -180, ymax, xmax).

Parameters
xminMinimum bounding coordinate of the first axis in source CRS.
yminMinimum bounding coordinate of the second axis in source CRS.
xmaxMaximum bounding coordinate of the first axis in source CRS.
ymaxMaximum bounding coordinate of the second axis in source CRS.
out_xminMinimum bounding coordinate of the first axis in target CRS
out_yminMinimum bounding coordinate of the second axis in target CRS.
out_xmaxMaximum bounding coordinate of the first axis in target CRS.
out_ymaxMaximum bounding coordinate of the second axis in target CRS.
densify_ptsRecommended to use 21. This is the number of points to use to densify the bounding polygon in the transformation.
Returns
TRUE if successful. FALSE if failures encountered.
Since
3.4

◆ TransformWithErrorCodes()

virtual int OGRCoordinateTransformation::TransformWithErrorCodes ( int  nCount,
double *  x,
double *  y,
double *  z,
double *  t,
int *  panErrorCodes 
)
virtual

Transform points from source to destination space.

This method is the same as the C function OCTTransform4DWithErrorCodes().

Parameters
nCountnumber of points to transform.
xarray of nCount X vertices, modified in place. Should not be NULL.
yarray of nCount Y vertices, modified in place. Should not be NULL.
zarray of nCount Z vertices, modified in place. Might be NULL.
tarray of nCount time values, modified in place. Might be NULL.
panErrorCodesOutput array of nCount value that will be set to 0 for success, or a non-zero value for failure. Refer to PROJ 8 public error codes. Might be NULL
Returns
TRUE if some or all points transform successfully, or FALSE if if none transform.
Since
GDAL 3.3, and PROJ 8 to be able to use PROJ public error codes

The documentation for this class was generated from the following files: