lsst.afw  13.0-92-g8ecf155+1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
transformMap.h
Go to the documentation of this file.
1 #ifndef AFW_GEOM_PYTHON_TRANSFORMMAP_H_INCLUDED
2 #define AFW_GEOM_PYTHON_TRANSFORMMAP_H_INCLUDED
3 /*
4  * LSST Data Management System
5  * Copyright 2016 AURA/LSST.
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 <https://www.lsstcorp.org/LegalNotices/>.
23  */
24 #include "pybind11/pybind11.h"
25 #include "pybind11/stl.h"
26 
27 #include <memory>
28 #include <string>
29 #include <vector>
30 
31 #include "lsst/afw/geom/Point.h"
33 
34 namespace lsst {
35 namespace afw {
36 namespace geom {
37 namespace python {
38 
45 template <typename CoordSysT>
46 pybind11::class_<TransformMap<CoordSysT>, std::shared_ptr<TransformMap<CoordSysT>>> declareTransformMap(
47  pybind11::module &mod, std::string const &prefix) {
48  using namespace pybind11::literals;
49 
50  using Map = TransformMap<CoordSysT>;
51 
52  const std::string className = prefix + "TransformMap";
53  pybind11::class_<Map, std::shared_ptr<Map>> cls(mod, className.c_str());
54 
55  /* Constructors */
56  cls.def(pybind11::init<>());
57  cls.def(pybind11::init<CoordSysT const &, typename Map::Transforms const &>(), "nativeCoordSys"_a,
58  "transforms"_a);
59 
60  /* Operators */
61  cls.def("__getitem__", &Map::operator[], "coordSys"_a);
62  cls.def("__len__", &Map::size);
63  cls.def("__contains__", &Map::contains);
64 
65  /* Members */
66  cls.def("transform",
67  (Point2D (Map::*)(Point2D const &, CoordSysT const &, CoordSysT const &) const) & Map::transform,
68  "point"_a, "fromCoordSys"_a, "toCoordSys"_a);
69  cls.def("transform", (std::vector<Point2D> (Map::*)(std::vector<Point2D> const &, CoordSysT const &,
70  CoordSysT const &) const) &
71  Map::transform,
72  "points"_a, "fromCoordSys"_a, "toCoordSys"_a);
73  cls.def("getNativeCoordSys", &Map::getNativeCoordSys);
74  cls.def("getCoordSysList", &Map::getCoordSysList);
75 
76  return cls;
77 };
78 }
79 }
80 }
81 } // lsst::afw::geom::python
82 
83 #endif
A registry of 2-dimensional coordinate transforms, templated on a coordinate system type...
Definition: TransformMap.h:65
pybind11::class_< TransformMap< CoordSysT >, std::shared_ptr< TransformMap< CoordSysT > > > declareTransformMap(pybind11::module &mod, std::string const &prefix)
Declare an instantiation of TransformMap.
Definition: transformMap.h:46
double const _a
Definition: RandomImage.cc:77