32 LOG_LOGGER _log =
LOG_GET(
"jointcal.FastFinder");
39 : baselist(list),
count(list.size()), stars(
count), nslice(nXSlice), index(nslice + 1) {
40 if (
count == 0)
return;
44 for (
auto const &ci : list) {
63 for (
unsigned islice = 1; islice <
nslice; ++islice) {
64 double xend = xmin + (islice)*
xstep;
65 while (istar <
count &&
stars[istar]->
x < xend) ++istar;
66 index[islice] = istar;
69 for (
unsigned islice = 0; islice <
nslice; ++islice) {
72 return (E1->y < E2->y);
78 for (
unsigned i = 0; i <
count; ++i) {
84 bool (*SkipIt)(
const BaseStar &))
const {
85 if (
count == 0)
return nullptr;
87 if (*it ==
nullptr)
return nullptr;
89 double minDist2 = maxDist * maxDist;
90 for (; *it !=
nullptr; ++it) {
91 if (SkipIt && SkipIt(**it))
continue;
93 if (dist2 < minDist2) {
103 bool (*SkipIt)(
const BaseStar &))
const {
105 if (
count == 0)
return nullptr;
107 if (*it ==
nullptr)
return nullptr;
110 double minDist1_2 = maxDist * maxDist;
111 double minDist2_2 = maxDist * maxDist;
112 for (; *it !=
nullptr; ++it) {
113 if (SkipIt && SkipIt(**it))
continue;
115 if (dist2 < minDist1_2) {
117 minDist2_2 = minDist1_2;
120 }
else if (dist2 < minDist2_2) {
135 if (begin ==
stars.end() || begin == end)
return stars.end();
136 int span = end - begin - 1;
138 int half_span = span / 2;
139 pstar middle = begin + half_span;
140 if ((*middle)->y < yVal) {
144 span -= (span - half_span);
154 int span = end - begin - 1;
156 int half_span = span / 2;
157 pstar middle = end - half_span;
158 if ((*middle)->y > yVal) {
162 span -= (span - half_span);
181 : finder(F), null_value(F.
stars.
end()) {
198 yEnd = where.
y + maxDist;
const FastFinder & finder
decltype(stars) typedef ::const_iterator pstar
std::vector< std::shared_ptr< const BaseStar > > stars
Iterator(const FastFinder &f, const Point &where, double maxDist)
pstar locateYEnd(pstar begin, pstar end, double yVal) const
The base class for handling stars. Used by all matching routines.
std::shared_ptr< const BaseStar > findClosest(const Point &where, const double maxDist, bool(*SkipIt)(const BaseStar &)=nullptr) const
Find the closest with some rejection capability.
FastFinder::Iterator Iterator
Class for a simple mapping implementing a generic AstrometryTransform.
Iterator beginScan(const Point &where, double maxDist) const
Iterator meant to traverse objects within some limiting distance.
FastFinder(const BaseStarList &list, const unsigned nXSlice=100)
Constructor.
void print(std::ostream &out) const
mostly for debugging
pstar locateYStart(pstar begin, pstar end, double yVal) const
void findRangeInSlice(const int iSlice, const double yStart, const double yEnd, pstar &start, pstar &end) const
This is an auxillary class for matching objects from starlists.
std::vector< unsigned > index
decltype(stars) typedef ::value_type stars_element
std::shared_ptr< const BaseStar > secondClosest(const Point &where, const double maxDist, std::shared_ptr< const BaseStar > &closest, bool(*SkipIt)(const BaseStar &)=nullptr) const
double computeDist2(const Point &other) const
distance squared to other
stars_element operator*() const
Fast locator in starlists.
#define LOGLS_ERROR(logger, message)