46 auto frameSetPtr = std::dynamic_pointer_cast<ast::FrameSet>(framePtr);
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>
94 return ndarray::copy(arr);
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) {
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);
225 auto skyFramePtr = std::dynamic_pointer_cast<ast::SkyFrame>(currentFramePtr);
228 os <<
"frame is a " << currentFramePtr->getClassName() <<
", not a SkyFrame";
231 if (skyFramePtr->getLonAxis() != 1) {
241 os <<
"GenericEndpoint(" << endpoint.
getNAxes() <<
")";
246 os <<
"Point2Endpoint()";
251 os <<
"SpherePointEndpoint()";
256 template class BaseEndpoint<std::vector<double>, ndarray::Array<double, 2, 2>>;
257 template class BaseEndpoint<lsst::geom::Point2D, std::vector<lsst::geom::Point2D>>;
258 template class BaseEndpoint<lsst::geom::SpherePoint, std::vector<lsst::geom::SpherePoint>>;
260 template class BaseVectorEndpoint<lsst::geom::Point2D>;
261 template class BaseVectorEndpoint<lsst::geom::SpherePoint>;
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
ItemVariant const * other
void permAxes(std::vector< int > perm)
Permute the order in which a Frame's axes occur.
static constexpr int 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
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
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.
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)".
lsst::geom::SpherePoint SpherePoint
Point< double, 2 > Point2D
constexpr AngleUnit radians
constant with units of radians
A base class for image defects.