45 auto frameSetPtr = std::dynamic_pointer_cast<ast::FrameSet>(framePtr);
54template <
typename Po
int,
typename Array>
62template <
typename Po
int,
typename Array>
64 return this->getNAxes() == other.getNAxes() &&
typeid(*this) ==
typeid(other);
67template <
typename Po
int,
typename Array>
69 return std::make_shared<ast::Frame>(getNAxes());
72template <
typename Po
int,
typename Array>
74 if (nAxes != this->getNAxes()) {
76 os <<
"number of axes provided " << nAxes <<
" != " << this->getNAxes() <<
" required";
81template <
typename Po
int>
93 return ndarray::copy(arr);
103 return ndarray::copy(
data);
109 os <<
"nAxes = " << nAxes <<
" != 2";
117 for (
int axInd = 0; axInd < nAxes; ++axInd) {
118 result[axInd] = point[axInd];
126 ndarray::Array<double, 2, 2>
data = ndarray::allocate(ndarray::makeVector(nAxes, nPoints));
127 auto dataColIter =
data.transpose().begin();
128 for (
auto const& point : arr) {
129 for (
int axInd = 0; axInd < nAxes; ++axInd) {
130 (*dataColIter)[axInd] = point[axInd];
141 for (
int axInd = 0; axInd < nAxes; ++axInd) {
148 ndarray::Array<double, 2, 2>
const&
data)
const {
152 array.reserve(nPoints);
153 for (
auto const& dataCol :
data.transpose()) {
154 array.emplace_back(dataCol[0], dataCol[1]);
161 std::string className = getCurrentFrame(framePtr)->getClassName();
162 if (className !=
"Frame") {
164 os <<
"frame is a " << className <<
", not a Frame";
172 os <<
"nAxes = " << nAxes <<
" != 2";
180 for (
int axInd = 0; axInd < nAxes; ++axInd) {
181 result[axInd] = point[axInd].asRadians();
189 ndarray::Array<double, 2, 2>
data = ndarray::allocate(ndarray::makeVector(nAxes, nPoints));
190 auto dataColIter =
data.transpose().begin();
191 for (
auto const& point : arr) {
192 for (
int axInd = 0; axInd < nAxes; ++axInd) {
193 (*dataColIter)[axInd] = point[axInd].asRadians();
206 ndarray::Array<double, 2, 2>
const&
data)
const {
211 for (
auto const& dataCol :
data.transpose()) {
218 return std::make_shared<ast::SkyFrame>();
223 auto currentFramePtr = getCurrentFrame(framePtr);
224 auto skyFramePtr = std::dynamic_pointer_cast<ast::SkyFrame>(currentFramePtr);
227 os <<
"frame is a " << currentFramePtr->getClassName() <<
", not a SkyFrame";
230 if (skyFramePtr->getLonAxis() != 1) {
235 framePtr->permAxes(perm);
240 os <<
"GenericEndpoint(" << endpoint.
getNAxes() <<
")";
245 os <<
"Point2Endpoint()";
250 os <<
"SpherePointEndpoint()";
255template class BaseEndpoint<std::vector<double>, ndarray::Array<double, 2, 2>>;
256template class BaseEndpoint<lsst::geom::Point2D, std::vector<lsst::geom::Point2D>>;
257template class BaseEndpoint<lsst::geom::SpherePoint, std::vector<lsst::geom::SpherePoint>>;
259template class BaseVectorEndpoint<lsst::geom::Point2D>;
260template class BaseVectorEndpoint<lsst::geom::SpherePoint>;
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
static int constexpr CURRENT
index of current frame
Virtual base class for endpoints, which are helper classes for Transform.
int _getNPoints(ndarray::Array< double, 2, 2 > const &data) const
virtual std::shared_ptr< ast::Frame > makeFrame() const
Create a Frame that can be used with this end point in a Transform.
BaseEndpoint(BaseEndpoint const &)=default
virtual bool operator==(BaseEndpoint const &other) const noexcept
Determine whether two endpoints represent the same conversion.
void _assertNAxes(int nAxes) const
int _getNAxes(ndarray::Array< double, 2, 2 > const &data) const
Base class for endpoints with Array = std::vector<Point> where Point has 2 dimensions.
int getNPoints(Array const &arr) const override
Return the number of points in an array.
A generic endpoint for data in the format used by ast::Mapping.
std::vector< double > dataFromPoint(Point const &point) const override
Get raw data from a single point.
Array arrayFromData(ndarray::Array< double, 2, 2 > const &data) const override
Get an array of points from raw data.
Point pointFromData(std::vector< double > const &data) const override
Get a single point from raw data.
ndarray::Array< double, 2, 2 > dataFromArray(Array const &arr) const override
Get raw data from an array of points.
An endpoint for lsst::geom::Point2D.
Point2Endpoint()
Construct a Point2Endpoint.
ndarray::Array< double, 2, 2 > dataFromArray(Array const &arr) const override
Get raw data from an array of points.
std::vector< double > dataFromPoint(Point const &point) const override
Get raw data from a single point.
Point pointFromData(std::vector< double > const &data) const override
Get a single point from raw data.
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 Frame, not a subclass.
An endpoint for lsst::geom::SpherePoint.
ndarray::Array< double, 2, 2 > dataFromArray(Array const &arr) const override
Get raw data from an array of points.
std::vector< double > dataFromPoint(Point const &point) const override
Get raw data from a single point.
SpherePointEndpoint()
Construct a SpherePointEndpoint.
Array arrayFromData(ndarray::Array< double, 2, 2 > const &data) const override
Get an array of points from raw data.
std::shared_ptr< ast::Frame > makeFrame() const override
Create a Frame that can be used with this end point in a Transform.
Point pointFromData(std::vector< double > const &data) const override
Get a single point 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.
Point in an unspecified spherical coordinate system.
Reports invalid arguments.
T emplace_back(T... args)
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)".
AngleUnit constexpr radians
constant with units of radians