lsst.afw  14.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TransformMap.h
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2014 LSST Corporation.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <http://www.lsstcorp.org/LegalNotices/>.
21  */
22 
23 #if !defined(LSST_AFW_GEOM_TRANSFORMMAP_H)
24 #define LSST_AFW_GEOM_TRANSFORMMAP_H
25 
26 #include <string>
27 #include <utility>
28 #include <vector>
29 #include <map>
30 #include "lsst/afw/geom/Point.h"
32 
33 namespace lsst {
34 namespace afw {
35 namespace geom {
36 
64 template <typename CoordSysT>
65 class TransformMap {
66 public:
67  typedef std::map<CoordSysT, std::shared_ptr<XYTransform const>> Transforms;
68  typedef CoordSysT CoordSys; // needed by SWIG; see TransformMap.i
69 
79  explicit TransformMap(CoordSysT const &nativeCoordSys,
80  Transforms const &transforms
81  );
83 
85  explicit TransformMap();
86 
94  Point2D transform(Point2D const &fromPoint,
95  CoordSysT const &fromSys,
96  CoordSysT const &toCoordSys
97  ) const;
98 
104  std::vector<Point2D> transform(std::vector<Point2D> const &pointList,
105  CoordSysT const &fromCoordSys,
106  CoordSysT const &toCoordSys
107  ) const;
108 
109  CoordSysT getNativeCoordSys() const { return _nativeCoordSys; }
110 
116  std::vector<CoordSysT> getCoordSysList() const;
117 
124  bool contains(CoordSysT const &coordSys
125  ) const;
126 
134  std::shared_ptr<XYTransform const> operator[](
135  CoordSysT const &coordSys
136  ) const;
137 
138  typename Transforms::const_iterator begin() const { return _transforms.begin(); }
139 
140  typename Transforms::const_iterator end() const { return _transforms.end(); }
141 
142  size_t size() const { return _transforms.size(); }
143 
144 private:
145  CoordSysT _nativeCoordSys;
146  Transforms _transforms;
147 };
148 }
149 }
150 }
151 
152 #endif
A registry of 2-dimensional coordinate transforms, templated on a coordinate system type...
Definition: TransformMap.h:65
std::shared_ptr< XYTransform const > operator[](CoordSysT const &coordSys) const
Get an XYTransform that transforms from coordSys to nativeCoordSys in the forward direction...
std::vector< CoordSysT > getCoordSysList() const
Get a list of supported coordinate systems.
CoordSysT getNativeCoordSys() const
Definition: TransformMap.h:109
bool contains(CoordSysT const &coordSys) const
Return true if the coordinate system is supported.
Transforms::const_iterator end() const
Definition: TransformMap.h:140
std::map< CoordSysT, std::shared_ptr< XYTransform const > > Transforms
Definition: TransformMap.h:67
Point2D transform(Point2D const &fromPoint, CoordSysT const &fromSys, CoordSysT const &toCoordSys) const
Convert a point from one coordinate system to another.
Transforms::const_iterator begin() const
Definition: TransformMap.h:138
TransformMap()
null implementation to make SWIG willing to wrap a map that contains these