55 template <
typename Po
int,
typename Array>
63 template <
typename Po
int,
typename Array>
65 return this->getNAxes() ==
other.getNAxes() &&
typeid(*this) ==
typeid(
other);
68 template <
typename Po
int,
typename Array>
70 return std::make_shared<ast::Frame>(getNAxes());
73 template <
typename Po
int,
typename Array>
75 if (nAxes != this->getNAxes()) {
77 os <<
"number of axes provided " << nAxes <<
" != " << this->getNAxes() <<
" required";
82 template <
typename Po
int>
88 this->_assertNAxes(_getNAxes(point));
92 ndarray::Array<double, 2, 2> GenericEndpoint::dataFromArray(Array
const& arr)
const {
93 this->_assertNAxes(_getNAxes(arr));
94 return ndarray::copy(arr);
98 this->_assertNAxes(data.
size());
102 ndarray::Array<double, 2, 2> GenericEndpoint::arrayFromData(ndarray::Array<double, 2, 2>
const&
data)
const {
103 this->_assertNAxes(_getNAxes(data));
104 return ndarray::copy(data);
110 os <<
"nAxes = " << nAxes <<
" != 2";
118 for (
int axInd = 0; axInd < nAxes; ++axInd) {
119 result[axInd] = point[axInd];
127 ndarray::Array<double, 2, 2>
data = ndarray::allocate(ndarray::makeVector(nAxes, nPoints));
128 auto dataColIter = data.transpose().begin();
129 for (
auto const& point : arr) {
130 for (
int axInd = 0; axInd < nAxes; ++axInd) {
131 (*dataColIter)[axInd] = point[axInd];
142 for (
int axInd = 0; axInd < nAxes; ++axInd) {
143 result[axInd] = data[axInd];
149 ndarray::Array<double, 2, 2>
const&
data)
const {
153 array.reserve(nPoints);
154 for (
auto const& dataCol : data.transpose()) {
155 array.emplace_back(dataCol[0], dataCol[1]);
162 std::string className = getCurrentFrame(framePtr)->getClassName();
163 if (className !=
"Frame") {
165 os <<
"frame is a " << className <<
", not a Frame";
173 os <<
"nAxes = " << nAxes <<
" != 2";
181 for (
int axInd = 0; axInd < nAxes; ++axInd) {
182 result[axInd] = point[axInd].asRadians();
190 ndarray::Array<double, 2, 2>
data = ndarray::allocate(ndarray::makeVector(nAxes, nPoints));
191 auto dataColIter = data.transpose().begin();
192 for (
auto const& point : arr) {
193 for (
int axInd = 0; axInd < nAxes; ++axInd) {
194 (*dataColIter)[axInd] = point[axInd].asRadians();
207 ndarray::Array<double, 2, 2>
const&
data)
const {
211 array.reserve(nPoints);
212 for (
auto const& dataCol : data.transpose()) {
219 return std::make_shared<ast::SkyFrame>();
224 auto currentFramePtr = getCurrentFrame(framePtr);
228 os <<
"frame is a " << currentFramePtr->getClassName() <<
", not a SkyFrame";
231 if (skyFramePtr->getLonAxis() != 1) {
236 framePtr->permAxes(perm);
241 os <<
"GenericEndpoint(" << endpoint.
getNAxes() <<
")";
246 os <<
"Point2Endpoint()";
251 os <<
"SpherePointEndpoint()";
int _getNPoints(ndarray::Array< double, 2, 2 > const &data) const
A coordinate class intended to represent absolute positions.
ndarray::Array< double, 2, 2 > dataFromArray(Array const &arr) const override
std::ostream & operator<<(std::ostream &os, GenericEndpoint const &endpoint)
Print "GenericEndpoint(_n_)" to the ostream where _n_ is the number of axes, e.g. "GenericAxes(4)"...
std::shared_ptr< Frame > getFrame(int iframe, bool copy=true) const
Obtain a deep copy of the specified Frame.
Point pointFromData(std::vector< double > const &data) const override
Get a single point from raw data.
Base class for endpoints with Array = std::vector<Point> where Point has 2 dimensions.
std::vector< lsst::geom::Point2D > Array
ItemVariant const * other
static int constexpr CURRENT
index of current frame
Point pointFromData(std::vector< double > const &data) const override
Get a single point from raw data.
AngleUnit constexpr radians
constant with units of radians
void _assertNAxes(int nAxes) const
Point< double, 2 > Point2D
Array arrayFromData(ndarray::Array< double, 2, 2 > const &data) const override
Get an array of points from raw data.
void normalizeFrame(std::shared_ptr< ast::Frame > framePtr) const override
Check that framePtr points to a SkyFrame and set longitude axis to 0, latitude to 1...
SkyFrame is a specialised form of Frame which describes celestial longitude/latitude coordinate syste...
A base class for image defects.
A generic endpoint for data in the format used by ast::Mapping.
std::vector< double > dataFromPoint(Point const &point) const override
An endpoint for lsst::geom::SpherePoint.
T dynamic_pointer_cast(T... args)
SpherePointEndpoint()
Construct a SpherePointEndpoint.
std::vector< double > dataFromPoint(Point const &point) const override
std::shared_ptr< ast::Frame > makeFrame() const override
Create a Frame that can be used with this end point in a Transform.
int getNPoints(Array const &arr) const override
int _getNAxes(ndarray::Array< double, 2, 2 > const &data) const
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Array arrayFromData(ndarray::Array< double, 2, 2 > const &data) const override
Get an array of points from raw data.
Point in an unspecified spherical coordinate system.
Reports invalid arguments.
lsst::geom::SpherePoint SpherePoint
An endpoint for lsst::geom::Point2D.
void normalizeFrame(std::shared_ptr< ast::Frame > framePtr) const override
Check that framePtr points to a Frame, not a subclass.
A FrameSet consists of a set of one or more Frames (which describe coordinate systems), connected together by Mappings (which describe how the coordinate systems are inter-related).
BaseEndpoint(BaseEndpoint const &)=default
ndarray::Array< double, 2, 2 > dataFromArray(Array const &arr) const override
Virtual base class for endpoints, which are helper classes for Transform.