46 if (transform.getToEndpoint().getNAxes() != 1) {
47 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
48 "To EndPoint of transform must have 1 axis but has " +
49 std::to_string(transform.getToEndpoint().getNAxes()));
54 return _transform.applyForward(position)[0];
58 ndarray::Array<double const, 1>
const& y)
const {
59 if (x.getSize<0>() != y.getSize<0>()) {
66 int const nPoints = x.getSize<0>();
67 ndarray::Array<double, 2, 2> xy = ndarray::allocate(ndarray::makeVector(2, nPoints));
68 for (
int col = 0; col < nPoints; ++col) {
73 auto res2D = _transform.getMapping()->applyForward(xy);
76 auto resShape = ndarray::makeVector(nPoints);
77 auto resStrides = ndarray::makeVector(1);
78 return ndarray::external(res2D.getData(), resShape, resStrides, res2D);
85struct PersistenceHelper {
93 bbox(
table::Box2IKey::addFields(schema,
"bbox",
"bounding box",
"pixel")),
94 frameSet(schema.addField<
table::Array<
std::uint8_t>>(
95 "frameSet",
"FrameSet contained in the Transform",
"", 0)) {}
97 PersistenceHelper(
table::Schema const& s) : schema(s), bbox(s[
"bbox"]), frameSet(s[
"frameSet"]) {}
100class TransformBoundedFieldFactory :
public table::io::PersistableFactory {
102 explicit TransformBoundedFieldFactory(
std::string const& name)
103 : afw::table::io::PersistableFactory(name) {}
105 std::shared_ptr<table::io::Persistable>
read(InputArchive
const& archive,
106 CatalogVector
const& catalogs)
const override {
109 table::BaseRecord
const& record = catalogs.front().front();
110 PersistenceHelper
const keys(record.getSchema());
111 auto bbox = record.get(
keys.bbox);
120std::string getTransformBoundedFieldPersistenceName() {
return "TransformBoundedField"; }
122TransformBoundedFieldFactory registration(getTransformBoundedFieldPersistenceName());
127 return getTransformBoundedFieldPersistenceName();
133 PersistenceHelper
const keys;
136 record->set(keys.bbox,
getBBox());
144 auto newTransform =
Transform(newMapping);
150 if (!rhsCasted)
return false;
152 return getBBox() == rhsCasted->getBBox() &&
#define LSST_EXCEPT(type,...)
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
SeriesMap then(Mapping const &next) const
lsst::geom::Box2I getBBox() const
Return the bounding box that defines the region where the field is valid.
BoundedField(BoundedField const &)=default
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
A class used as a handle to a particular field in a table.
Defines the fields and offsets for a table.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
A CRTP facade class for subclasses of Persistable.
io::OutputArchiveHandle OutputArchiveHandle
CatalogT< BaseRecord > BaseCatalog
BoxKey< lsst::geom::Box2I > Box2IKey
Point< double, 2 > Point2D
std::shared_ptr< table::io::Persistable > read(table::io::InputArchive const &archive, table::io::CatalogVector const &catalogs) const override