lsst.afw  15.0-25-gacd707fca
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_CAMERAGEOM_TRANSFORMMAP_H)
24 #define LSST_AFW_CAMERAGEOM_TRANSFORMMAP_H
25 
26 #include <vector>
27 #include <map>
28 #include <unordered_map>
29 
30 #include "boost/iterator/transform_iterator.hpp"
31 #include "astshim/FrameSet.h"
32 
34 #include "lsst/afw/geom/Point.h"
36 
37 namespace lsst {
38 namespace afw {
39 namespace cameraGeom {
40 
57 class TransformMap final {
58 private:
59  // Functor for boost::transform_iterator: given an entry in a std::map or unordered_map, return the key
60  struct GetKey {
61  CameraSys const &operator()(std::pair<const CameraSys, int> const &p) const { return p.first; };
62  };
63 
64 public:
67  using CameraSysIterator = boost::transform_iterator<GetKey, CameraSysFrameIdMap::const_iterator>;
68 
81  CameraSys const &reference,
83 
90 
97 
100  TransformMap &operator=(TransformMap const &) = delete;
101  TransformMap &operator=(TransformMap &&) = delete;
103 
104  ~TransformMap();
105 
117  geom::Point2D transform(geom::Point2D const &point, CameraSys const &fromSys,
118  CameraSys const &toSys) const;
119 
126  CameraSys const &fromSys, CameraSys const &toSys) const;
127 
128  CameraSysIterator begin() const { return boost::make_transform_iterator(_frameIds.begin(), GetKey()); }
129 
130  CameraSysIterator end() const { return boost::make_transform_iterator(_frameIds.end(), GetKey()); }
131 
140  bool contains(CameraSys const &system) const noexcept;
141 
153  CameraSys const &toSys) const;
154 
160  size_t size() const noexcept;
161 
162 private:
174  int _getFrame(CameraSys const &system) const;
175 
185  std::shared_ptr<ast::Mapping const> _getMapping(CameraSys const &fromSys,
186  CameraSys const &toSys) const;
187 
189  static geom::Point2Endpoint _pointConverter;
190 
192  // May be shared between multiple copies of TransformMap, since TransformMap is immutable
193  std::shared_ptr<ast::FrameSet const> const _transforms;
194 
200  CameraSysFrameIdMap const _frameIds;
201 };
202 
203 } // namespace cameraGeom
204 } // namespace afw
205 } // namespace lsst
206 
207 #endif
A registry of 2-dimensional coordinate transforms for a specific camera.
Definition: TransformMap.h:57
Camera coordinate system; used as a key in in TransformMap.
Definition: CameraSys.h:83
TransformMap(CameraSys const &reference, std::unordered_map< CameraSys, std::shared_ptr< geom::TransformPoint2ToPoint2 >> const &transforms)
Define a set of camera transforms.
ItemVariant const * other
Definition: Schema.cc:55
CameraSysIterator end() const
Definition: TransformMap.h:130
TransformMap & operator=(TransformMap const &)=delete
A base class for image defects.
bool contains(CameraSys const &system) const noexcept
Can this transform to and from the specified coordinate system?
boost::transform_iterator< GetKey, CameraSysFrameIdMap::const_iterator > CameraSysIterator
Definition: TransformMap.h:67
STL class.
size_t size() const noexcept
Get the number of supported coordinate systems.
An endpoint for Point2D.
Definition: Endpoint.h:264
geom::Point2D transform(geom::Point2D const &point, CameraSys const &fromSys, CameraSys const &toSys) const
Convert a point from one camera coordinate system to another.
CameraSysIterator begin() const
Definition: TransformMap.h:128
std::shared_ptr< geom::TransformPoint2ToPoint2 > getTransform(CameraSys const &fromSys, CameraSys const &toSys) const
Get a Transform from one camera coordinate system to another.