lsst.afw  13.0-94-ga1c444047
Public Types | Public Member Functions | List of all members
lsst::afw::geom::TransformMap< CoordSysT > Class Template Reference

A registry of 2-dimensional coordinate transforms, templated on a coordinate system type. More...

#include <TransformMap.h>

Public Types

typedef std::map< CoordSysT, std::shared_ptr< XYTransform const > > Transforms
 
typedef CoordSysT CoordSys
 

Public Member Functions

 TransformMap (CoordSysT const &nativeCoordSys, Transforms const &transforms)
 Construct a TransformMap. More...
 
 TransformMap ()
 null implementation to make SWIG willing to wrap a map that contains these More...
 
Point2D transform (Point2D const &fromPoint, CoordSysT const &fromSys, CoordSysT const &toCoordSys) const
 Convert a point from one coordinate system to another. More...
 
std::vector< Point2D > transform (std::vector< Point2D > const &pointList, CoordSysT const &fromCoordSys, CoordSysT const &toCoordSys) const
 Convert a list of Point2D from one coordinate system to another. More...
 
CoordSysT getNativeCoordSys () const
 
std::vector< CoordSysT > getCoordSysList () const
 Get a list of supported coordinate systems. More...
 
bool contains (CoordSysT const &coordSys) const
 Return true if the coordinate system is supported. More...
 
std::shared_ptr< XYTransform const > operator[] (CoordSysT const &coordSys) const
 Get an XYTransform that transforms from coordSys to nativeCoordSys in the forward direction. More...
 
Transforms::const_iterator begin () const
 
Transforms::const_iterator end () const
 
size_t size () const
 

Detailed Description

template<typename CoordSysT>
class lsst::afw::geom::TransformMap< CoordSysT >

A registry of 2-dimensional coordinate transforms, templated on a coordinate system type.

Contains a native CoordSysT and a map of CoordSysT:XYTransform (including an identity transform entry for native CoordSysT). Each map entry is an XYTransform whose forwardTransform method converts from the native system to CoordSysT.

TransformMap supports transforming between any two supported CoordSysT using the transform method. It also allows iteration over the map of CoordSysT: XYTransform:

If CoordSysT is not a plain old data type or std::string then:

At some point we will switch to using std::unordered_map (once we switch to C++11 and a SWIG that supports its collection classes). At that point instead of requiring CoordSysT.operator<, it will be necessary to specialize std::hash<CoordSysT>(CoordSysT const &).

Warning
: code that instantiates a templated version of TransformMap must include lsst/afw/geom/TransformMapImpl.h (else you will get linker errors).

Definition at line 65 of file TransformMap.h.

Member Typedef Documentation

◆ CoordSys

template<typename CoordSysT>
typedef CoordSysT lsst::afw::geom::TransformMap< CoordSysT >::CoordSys

Definition at line 68 of file TransformMap.h.

◆ Transforms

template<typename CoordSysT>
typedef std::map<CoordSysT, std::shared_ptr<XYTransform const> > lsst::afw::geom::TransformMap< CoordSysT >::Transforms

Definition at line 67 of file TransformMap.h.

Constructor & Destructor Documentation

◆ TransformMap() [1/2]

template<typename CoordSysT>
lsst::afw::geom::TransformMap< CoordSysT >::TransformMap ( CoordSysT const &  nativeCoordSys,
Transforms const &  transforms 
)
explicit

Construct a TransformMap.

Note
If transformMap includes a transform for nativeCoordSys then it is used (without checking); if not, then a unity transform is added.
Exceptions
pex::exceptions::InvalidParameterErrorif you specify the same coordSys more than once, or a transform is specified where coordSys == nativeCoordSys
Parameters
nativeCoordSysNative coordinate system for this registry
transformsa map of coordSys:xyTransform, where xyTransform.forward transforms coordSys to nativeCoordSys

Definition at line 36 of file TransformMapImpl.h.

◆ TransformMap() [2/2]

template<typename CoordSysT>
lsst::afw::geom::TransformMap< CoordSysT >::TransformMap ( )
explicit

null implementation to make SWIG willing to wrap a map that contains these

Definition at line 59 of file TransformMapImpl.h.

Member Function Documentation

◆ begin()

template<typename CoordSysT>
Transforms::const_iterator lsst::afw::geom::TransformMap< CoordSysT >::begin ( ) const
inline

Definition at line 138 of file TransformMap.h.

◆ contains()

template<typename CoordSysT>
bool lsst::afw::geom::TransformMap< CoordSysT >::contains ( CoordSysT const &  coordSys) const

Return true if the coordinate system is supported.

In Python this is renamed to contains; use as follows: coordSys in transformMap

Parameters
coordSyscoordinate system

Definition at line 131 of file TransformMapImpl.h.

◆ end()

template<typename CoordSysT>
Transforms::const_iterator lsst::afw::geom::TransformMap< CoordSysT >::end ( ) const
inline

Definition at line 140 of file TransformMap.h.

◆ getCoordSysList()

template<typename CoordSysT >
std::vector< CoordSysT > lsst::afw::geom::TransformMap< CoordSysT >::getCoordSysList ( ) const

Get a list of supported coordinate systems.

Returns
a list of coordinate systems, in undefined order.

Definition at line 110 of file TransformMapImpl.h.

◆ getNativeCoordSys()

template<typename CoordSysT>
CoordSysT lsst::afw::geom::TransformMap< CoordSysT >::getNativeCoordSys ( ) const
inline

Definition at line 109 of file TransformMap.h.

◆ operator[]()

template<typename CoordSysT>
std::shared_ptr< XYTransform const > lsst::afw::geom::TransformMap< CoordSysT >::operator[] ( CoordSysT const &  coordSys) const

Get an XYTransform that transforms from coordSys to nativeCoordSys in the forward direction.

Returns
a shared_ptr to an XYTransform
Exceptions
pex::exceptions::InvalidParameterErrorif coordSys is unknown
Parameters
coordSyscoordinate system whose XYTransform is wanted

Definition at line 120 of file TransformMapImpl.h.

◆ size()

template<typename CoordSysT>
size_t lsst::afw::geom::TransformMap< CoordSysT >::size ( ) const
inline

Definition at line 142 of file TransformMap.h.

◆ transform() [1/2]

template<typename CoordSysT>
Point2D lsst::afw::geom::TransformMap< CoordSysT >::transform ( Point2D const &  fromPoint,
CoordSysT const &  fromSys,
CoordSysT const &  toCoordSys 
) const

Convert a point from one coordinate system to another.

Returns
the transformed value as a Point2D
Exceptions
pex::exceptions::InvalidParameterErrorif toCoordSys is unknown
Parameters
fromPointpoint from which to transform
fromSyscoordinate system from which to transform
toCoordSyscoordinate system to which to transform

Definition at line 62 of file TransformMapImpl.h.

◆ transform() [2/2]

template<typename CoordSysT>
std::vector< Point2D > lsst::afw::geom::TransformMap< CoordSysT >::transform ( std::vector< Point2D > const &  pointList,
CoordSysT const &  fromCoordSys,
CoordSysT const &  toCoordSys 
) const

Convert a list of Point2D from one coordinate system to another.

Exceptions
pex::exceptions::InvalidParameterErrorif fromCoordSys or toCoordSys is unknown
Parameters
pointListlist of points to transform
fromCoordSysfrom coordinate system
toCoordSysto coordinate system

Definition at line 75 of file TransformMapImpl.h.


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