OTB  6.7.0
Orfeo Toolbox
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
otb::SpatialReference Class Reference

#include <otbSpatialReference.h>

+ Collaboration diagram for otb::SpatialReference:

Public Types

enum  hemisphere {
  hemisphere::north,
  hemisphere::south
}
 
typedef std::unique_ptr
< OGRSpatialReference,
internal::OGRSpatialReferenceDeleter
OGRSpatialReferencePtr
 

Public Member Functions

bool NormalizeESRI ()
 
SpatialReferenceoperator= (const SpatialReference &other) noexcept
 
 SpatialReference (const SpatialReference &other) noexcept
 
unsigned int ToEPSG () const
 
std::string ToWkt () const
 

Static Public Member Functions

static SpatialReference FromDescription (const std::string &sr_description)
 
static SpatialReference FromEPSG (unsigned int epsg)
 
static SpatialReference FromUTM (unsigned int zone, hemisphere hem)
 
static SpatialReference FromWGS84 ()
 
static void UTMFromGeoPoint (double lon, double lat, unsigned int &zone, hemisphere &hem)
 

Private Member Functions

 SpatialReference (const OGRSpatialReference *ref)
 
 SpatialReference (OGRSpatialReferencePtr ref)
 

Private Attributes

OGRSpatialReferencePtr m_SR
 

Friends

class CoordinateTransformation
 
OTBGdalAdapters_EXPORT friend bool operator!= (const SpatialReference &sr1, const SpatialReference &sr2) noexcept
 
OTBGdalAdapters_EXPORT friend bool operator== (const SpatialReference &sr1, const SpatialReference &sr2) noexcept
 

Detailed Description

This class is a wrapper around OGRSpatialReference.

This class is a wrapper around OGRSpatialReference. It aims at manipulating spatial reference within OTB, in a safe and easy way. The class provides several constructors that all enforce the RAII: either they fail or they provide a definitive, valid object.

Building a SpatialReference requires to call one of the From*() method. There are no public constructors (appart from copy and assignment)

Definition at line 76 of file otbSpatialReference.h.

Member Typedef Documentation

Definition at line 84 of file otbSpatialReference.h.

Member Enumeration Documentation

Build a SpatialReference from a UTM zone passed to OGRSpatialReference::SetUTM() from GDAL

Parameters
zoneUTM zone to use
hemhemisphere::north or hemisphere::south
Exceptions
InvalidSRDescriptionExceptionin case of failure of setUTM()
Enumerator
north 
south 

Definition at line 125 of file otbSpatialReference.h.

Constructor & Destructor Documentation

otb::SpatialReference::SpatialReference ( const SpatialReference other)
noexcept

Copy constructor.

otb::SpatialReference::SpatialReference ( const OGRSpatialReference *  ref)
private

Constructor from wrapped type. ref will be cloned.

otb::SpatialReference::SpatialReference ( OGRSpatialReferencePtr  ref)
private

Constructor from unique_ptr to wrapped type. On success (no throw) the passed unique_ptr will be cleared, and ownership transferred

Member Function Documentation

static SpatialReference otb::SpatialReference::FromDescription ( const std::string &  sr_description)
static

Build a SpatialRereference from a description string. The description string is passed to OGRSpatialReference:SetFromUserInput() from GDAL. Currently, supported syntax is:

  • Well Known Text definition
  • "EPSG:n" and "EPSGA:n" form EPSG codes
  • PROJ definitions
  • WMS auto projections ...
    Parameters
    descriptiona string containing the description of the spatial reference to parse
    Exceptions
    InvalidSRDescriptionExceptionin case of failure of SetFromUserInput()

Referenced by otb::GenericMapProjection< TDirectionOfMapping, TScalarType, NInputDimensions, NOutputDimensions >::SetWkt().

static SpatialReference otb::SpatialReference::FromEPSG ( unsigned int  epsg)
static

Build a SpatialReference from an epsg code

Parameters
epsgEPSG code passed to OGRSpatialReference::importFromEPSGA() from GDAL
Exceptions
InvalidSRDescriptionExceptionin case of failure of importFromEPSGA()

Referenced by otb::MapFileProductWriter< TInputImage >::InitializeVectorData(), otb::MapFileProductWriter< TInputImage >::Tiling(), and otb::MapFileProductWriter< TInputImage >::Write().

static SpatialReference otb::SpatialReference::FromUTM ( unsigned int  zone,
hemisphere  hem 
)
static
static SpatialReference otb::SpatialReference::FromWGS84 ( )
static
bool otb::SpatialReference::NormalizeESRI ( )

Try to normalize spatial reference fields to be compatible with ESRI.

Returns
True on success. Not modified if false is returned
SpatialReference& otb::SpatialReference::operator= ( const SpatialReference other)
noexcept

Asignment operator.

unsigned int otb::SpatialReference::ToEPSG ( ) const

Convert the spatial reference to an EPSG code

Returns
If no EPSG code was found or the EPSG code
std::string otb::SpatialReference::ToWkt ( ) const

Export the spatial reference to a Well Known Text string

Returns
A string containing the Well Known Text description

Referenced by otb::Multi3DMapToDEMFilter< T3DImage, TMaskImage, TOutputDEMImage >::SetOutputParametersFromImage(), and otb::GenericRSResampleImageFilter< TInputImage, TOutputImage >::SetOutputParametersFromMap().

static void otb::SpatialReference::UTMFromGeoPoint ( double  lon,
double  lat,
unsigned int &  zone,
hemisphere hem 
)
static

Find which UTM zone a given (lat,lon) point falls in.

Precondition
-180<=lon<=180
-90<=lat<=90
Parameters
lonPoint longitude
latPoint lattitude
zoneOutput UTM zone
hemoutput hemisphere

Referenced by otb::GenericRSResampleImageFilter< TInputImage, TOutputImage >::SetOutputParametersFromMap().

Friends And Related Function Documentation

friend class CoordinateTransformation
friend

Definition at line 78 of file otbSpatialReference.h.

OTBGdalAdapters_EXPORT friend bool operator!= ( const SpatialReference sr1,
const SpatialReference sr2 
)
friend

Different operator (based on OGRSpatialReference::IsSame())

OTBGdalAdapters_EXPORT friend bool operator== ( const SpatialReference sr1,
const SpatialReference sr2 
)
friend

Equal operator (based on OGRSpatialReference::IsSame())

Member Data Documentation

OGRSpatialReferencePtr otb::SpatialReference::m_SR
private

Definition at line 182 of file otbSpatialReference.h.


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