lsst.astshim  master-gd1207e8857
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
WcsMap.h
1 /*
2  * LSST Data Management System
3  * Copyright 2016 AURA/LSST.
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 <https://www.lsstcorp.org/LegalNotices/>.
21  */
22 #ifndef ASTSHIM_WCSMAP_H
23 #define ASTSHIM_WCSMAP_H
24 
25 #include <memory>
26 #include <sstream>
27 
28 #include "astshim/base.h"
29 #include "astshim/detail/utils.h"
30 #include "astshim/Mapping.h"
31 
32 namespace ast {
33 
47 enum class WcsType {
48  AZP = AST__AZP,
49  SZP = AST__SZP,
50  TAN = AST__TAN,
51  STG = AST__STG,
52  SIN = AST__SIN,
53  ARC = AST__ARC,
54  ZPN = AST__ZPN,
55  ZEA = AST__ZEA,
56  AIR = AST__AIR,
57  CYP = AST__CYP,
58  CEA = AST__CEA,
59  CAR = AST__CAR,
60  MER = AST__MER,
61  SFL = AST__SFL,
62  PAR = AST__PAR,
63  MOL = AST__MOL,
64  AIT = AST__AIT,
65  COP = AST__COP,
66  COE = AST__COE,
67  COD = AST__COD,
68  COO = AST__COO,
69  BON = AST__BON,
70  PCO = AST__PCO,
71  TSC = AST__TSC,
72  CSC = AST__CSC,
73  QSC = AST__QSC,
74  NCP = AST__NCP,
75  GLS = AST__GLS,
76  TPN = AST__TPN,
77  HPX = AST__HPX,
78  XPH = AST__XPH,
79  WCSBAD = AST__WCSBAD,
80 };
81 
145 class WcsMap: public Mapping {
146 friend class Object;
147 public:
207  explicit WcsMap(int ncoord, WcsType type, int lonax, int latax, std::string const & options="") :
208  Mapping(reinterpret_cast<AstMapping *>(
209  astWcsMap(ncoord, static_cast<int>(type), lonax, latax, options.c_str())))
210  {}
211 
212  virtual ~WcsMap() {}
213 
214  WcsMap(WcsMap const &) = delete;
215  WcsMap(WcsMap &&) = default;
216  WcsMap & operator=(WcsMap const &) = delete;
217  WcsMap & operator=(WcsMap &&) = default;
218 
220  std::shared_ptr<WcsMap> copy() const {
221  return std::static_pointer_cast<WcsMap>(_copyPolymorphic());
222  }
223 
225  double getNatLat() const { return getD("NatLat"); }
226 
228  double getNatLon() const { return getD("NatLon"); }
229 
236  double getPVi_m(int i, int m) const {
237  std::stringstream os;
238  os << "PV" << i << "_" << m;
239  return getD(os.str());
240  }
241 
243  int getPVMax(int axis) const {
244  return getI(detail::formatAxisAttr("PVMax", axis));
245  }
246 
248  int getWcsAxis(int lonlat) const {
249  return getI(detail::formatAxisAttr("WcsAxis", lonlat));
250  }
251 
253  WcsType getWcsType() const { return static_cast<WcsType>(getI("WcsType")); }
254 
255 protected:
256  virtual std::shared_ptr<Object> _copyPolymorphic() const override {
257  return _copyImpl<WcsMap, AstWcsMap>();
258  }
259 
261  explicit WcsMap(AstWcsMap * rawptr) :
262  Mapping(reinterpret_cast<AstMapping *>(rawptr))
263  {
264  if (!astIsAWcsMap(getRawPtr())) {
265  std::ostringstream os;
266  os << "this is a " << getClass() << ", which is not a WcsMap";
267  throw std::invalid_argument(os.str());
268  }
269  }
270 };
271 
272 } // namespace ast
273 
274 #endif
int getWcsAxis(int lonlat) const
Get WcsAxis(lonlat) for lon or lat: FITS-WCS projection axis.
Definition: WcsMap.h:248
double getNatLon() const
get NatLon: native longitude of the reference point of a FITS-WCS projection.
Definition: WcsMap.h:228
WcsMap(int ncoord, WcsType type, int lonax, int latax, std::string const &options="")
Definition: WcsMap.h:207
std::string getClass() const
Definition: Object.h:117
WcsMap(AstWcsMap *rawptr)
Construct a WcsMap from a raw AST pointer.
Definition: WcsMap.h:261
WcsType
Definition: WcsMap.h:47
Definition: Mapping.h:59
Definition: Object.h:49
std::shared_ptr< WcsMap > copy() const
Return a deep copy of this object.
Definition: WcsMap.h:220
double getPVi_m(int i, int m) const
Definition: WcsMap.h:236
double getD(std::string const &attrib) const
Definition: Object.h:360
virtual std::shared_ptr< Object > _copyPolymorphic() const override
Definition: WcsMap.h:256
WcsType getWcsType() const
Get WcsType: FITS-WCS projection type.
Definition: WcsMap.h:253
Definition: WcsMap.h:145
int getI(std::string const &attrib) const
Definition: Object.h:386
int getPVMax(int axis) const
Get PVMax(axis) for one axis: maximum number of FITS-WCS projection parameters.
Definition: WcsMap.h:243
double getNatLat() const
get NatLat: native latitude of the reference point of a FITS-WCS projection.
Definition: WcsMap.h:225
AstObject const * getRawPtr() const
Definition: Object.h:260