LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
PositionFunctor.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008 - 2012 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
34 #ifndef LSST_AFW_MATH_DETAIL_POSITIONFUNCTOR_H
35 #define LSST_AFW_MATH_DETAIL_POSITIONFUNCTOR_H
36 
37 #include "lsst/afw/geom/Point.h"
40 #include "lsst/afw/image/Wcs.h"
41 
42 namespace lsst {
43 namespace afw {
44 namespace math {
45 namespace detail {
46 
59  public:
60  typedef boost::shared_ptr<PositionFunctor> Ptr;
61 
62  explicit PositionFunctor() {};
63  virtual ~PositionFunctor() {};
64 
65  virtual lsst::afw::geom::Point2D operator()(int destCol, int destRow) const = 0;
66  };
67 
68 
74  public:
75  typedef boost::shared_ptr<WcsPositionFunctor> Ptr;
76 
78  lsst::afw::geom::Point2D const &destXY0,
79  lsst::afw::image::Wcs const &destWcs,
80  lsst::afw::image::Wcs const &srcWcs
81  ) :
83  _destXY0(destXY0),
84  _destWcs(destWcs),
85  _srcWcs(srcWcs)
86  {}
87 
88  virtual ~WcsPositionFunctor() {};
89 
90  virtual lsst::afw::geom::Point2D operator()(int destCol, int destRow) const {
91  double const col = lsst::afw::image::indexToPosition(destCol + _destXY0[0]);
92  double const row = lsst::afw::image::indexToPosition(destRow + _destXY0[1]);
93  lsst::afw::geom::Angle sky1, sky2;
94  _destWcs.pixelToSky(col, row, sky1, sky2);
95  return _srcWcs.skyToPixel(sky1, sky2);
96  }
97 
98  private:
102  };
103 
104 
110  public:
111  // NOTE: The transform will be called to locate a *source* pixel given a *dest* pixel
112  // ... so we actually want to use the *inverse* transform of the affineTransform we were given.
113  // Thus _affineTransform is initialized to affineTransform.invert()
115  lsst::afw::geom::Point2D const &destXY0,
116  lsst::afw::geom::AffineTransform const &affineTransform
118  ) :
119  PositionFunctor(),
120  _destXY0(destXY0),
121  _affineTransform() {
122  _affineTransform = affineTransform.invert();
123  }
124 
125  virtual lsst::afw::geom::Point2D operator()(int destCol, int destRow) const {
126  double const col = lsst::afw::image::indexToPosition(destCol + _destXY0[0]);
127  double const row = lsst::afw::image::indexToPosition(destRow + _destXY0[1]);
129  return p;
130  }
131  private:
134  };
135 
136 }}}} // namespace lsst::afw::math::detail
137 
138 #endif // !defined(LSST_AFW_MATH_DETAIL_POSITIONFUNCTOR_H)
A coordinate class intended to represent absolute positions.
boost::shared_ptr< PositionFunctor > Ptr
double indexToPosition(double ind)
Convert image index to image position.
Definition: ImageUtils.h:54
lsst::afw::image::Wcs const & _srcWcs
geom::Point2D skyToPixel(geom::Angle sky1, geom::Angle sky2) const
Convert from sky coordinates (e.g. RA/dec) to pixel positions.
Definition: Wcs.cc:782
AffineTransform const invert() const
boost::shared_ptr< WcsPositionFunctor > Ptr
Derived functor class to transform pixel position for a destination image to its position in the sour...
AffineTransformPositionFunctor(lsst::afw::geom::Point2D const &destXY0, lsst::afw::geom::AffineTransform const &affineTransform)
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
lsst::afw::geom::Point2D const & _destXY0
boost::shared_ptr< coord::Coord > pixelToSky(double pix1, double pix2) const
Convert from pixel position to sky coordinates (e.g. RA/dec)
Definition: Wcs.cc:858
Image utility functions.
Derived functor class to transform pixel position for a destination image to its position in the sour...
virtual lsst::afw::geom::Point2D operator()(int destCol, int destRow) const
Base class to transform pixel position for a destination image to its position in the original source...
WcsPositionFunctor(lsst::afw::geom::Point2D const &destXY0, lsst::afw::image::Wcs const &destWcs, lsst::afw::image::Wcs const &srcWcs)
An affine coordinate transformation consisting of a linear transformation and an offset.
int row
Definition: CR.cc:153
virtual lsst::afw::geom::Point2D operator()(int destCol, int destRow) const
virtual lsst::afw::geom::Point2D operator()(int destCol, int destRow) const =0
int col
Definition: CR.cc:152
lsst::afw::image::Wcs const & _destWcs