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, GCPCoordTransformation, and GeoTransformCoordinateTransformation.

## Public Member Functions
virtual const OGRSpatialReference * | GetSourceCS () const =0
| Fetch internal source coordinate system.
virtual const OGRSpatialReference * | GetTargetCS () const =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 (size_t nCount, double *x, double *y, double *z=nullptr, int *pabSuccess=nullptr)
| Transform points from source to destination space.
virtual int | Transform (size_t nCount, double *x, double *y, double *z, double *t, int *pabSuccess)=0
| Transform points from source to destination space.
virtual int | TransformWithErrorCodes (size_t nCount, double *x, double *y, double *z, double *t, int *panErrorCodes)
| Transform points from source to destination space.
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.
virtual OGRCoordinateTransformation * | Clone () const =0
| Clone.
virtual OGRCoordinateTransformation * | GetInverse () const =0
| Return a coordinate transformation that performs the inverse transformation of the current one.

## Static Public Member Functions
static void | DestroyCT (OGRCoordinateTransformation *poCT)
| OGRCoordinateTransformation destructor.
static OGRCoordinateTransformationH | ToHandle (OGRCoordinateTransformation *poCT)
| Convert a OGRCoordinateTransformation* to a OGRCoordinateTransformationH.
static OGRCoordinateTransformation * | FromHandle (OGRCoordinateTransformationH hCT)
| Convert a OGRCoordinateTransformationH to a OGRCoordinateTransformation*.

## 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

  poCT | the object to delete

Since
  GDAL 1.7.0

## ◆ FromHandle()

static OGRCoordinateTransformation * OGRCoordinateTransformation::FromHandle | ( | OGRCoordinateTransformationH | hCT | ) |
| inline static

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 | ) |
| inline static

Convert a OGRCoordinateTransformation* to a OGRCoordinateTransformationH.

Since
  GDAL 2.3

## ◆ Transform() [1/2]

virtual int OGRCoordinateTransformation::Transform | ( | size_t | 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

  nCount | number of points to transform (`size_t` type since 3.9, `int` in previous versions).
  x | array of nCount X vertices, modified in place. Should not be NULL.
  y | array of nCount Y vertices, modified in place. Should not be NULL.
  z | array of nCount Z vertices, modified in place. Might be NULL.
  t | array of nCount time values, modified in place. Might be NULL.
  pabSuccess | array of per-point flags set to TRUE if that point transforms, or FALSE if it does not. Might be NULL.

Returns
  TRUE if a transformation could be found (but not all points may have necessarily succeed to transform), otherwise FALSE.

## ◆ Transform() [2/2]

int OGRCoordinateTransformation::Transform | ( | size_t | 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

  nCount | number of points to transform (`size_t` type since 3.9, `int` in previous versions).
  x | array of nCount X vertices, modified in place. Should not be NULL.
  y | array of nCount Y vertices, modified in place. Should not be NULL.
  z | array of nCount Z vertices, modified in place. Might be NULL.
  pabSuccess | array of per-point flags set to TRUE if that point transforms, or FALSE if it does not. Might be NULL.

Returns
  TRUE if a transformation could be found (but not all points may have necessarily succeed to transform), otherwise FALSE.

## ◆ 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
| ) |  |
| inline virtual

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

  xmin | Minimum bounding coordinate of the first axis in source CRS.
  ymin | Minimum bounding coordinate of the second axis in source CRS.
  xmax | Maximum bounding coordinate of the first axis in source CRS.
  ymax | Maximum bounding coordinate of the second axis in source CRS.
  out_xmin | Minimum bounding coordinate of the first axis in target CRS
  out_ymin | Minimum bounding coordinate of the second axis in target CRS.
  out_xmax | Maximum bounding coordinate of the first axis in target CRS.
  out_ymax | Maximum bounding coordinate of the second axis in target CRS.
  densify_pts | Recommended 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 | ( | size_t | 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

  nCount | number of points to transform (`size_t` type since 3.9, `int` in previous versions).
  x | array of nCount X vertices, modified in place. Should not be NULL.
  y | array of nCount Y vertices, modified in place. Should not be NULL.
  z | array of nCount Z vertices, modified in place. Might be NULL.
  t | array of nCount time values, modified in place. Might be NULL.
  panErrorCodes | Output 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 a transformation could be found (but not all points may have necessarily succeed to transform), otherwise FALSE.

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:

- ogr_spatialref.h
- ogrct.cpp