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);
79 for (
unsigned i = 0; i <
count; ++i) {
85 bool (*SkipIt)(
const BaseStar &))
const {
86 if (
count == 0)
return nullptr;
88 if (*it ==
nullptr)
return nullptr;
90 double minDist2 = maxDist * maxDist;
91 for (; *it !=
nullptr; ++it) {
92 if (SkipIt && SkipIt(**it))
continue;
94 if (dist2 < minDist2) {
104 bool (*SkipIt)(
const BaseStar &))
const {
106 if (
count == 0)
return nullptr;
108 if (*it ==
nullptr)
return nullptr;
111 double minDist1_2 = maxDist * maxDist;
112 double minDist2_2 = maxDist * maxDist;
113 for (; *it !=
nullptr; ++it) {
114 if (SkipIt && SkipIt(**it))
continue;
116 if (dist2 < minDist1_2) {
118 minDist2_2 = minDist1_2;
121 }
else if (dist2 < minDist2_2) {
136 if (begin ==
stars.end() || begin == end)
return stars.end();
137 int span = end - begin - 1;
139 int half_span = span / 2;
140 pstar middle = begin + half_span;
141 if ((*middle)->y < yVal) {
145 span -= (span - half_span);
155 int span = end - begin - 1;
157 int half_span = span / 2;
158 pstar middle = end - half_span;
159 if ((*middle)->y > yVal) {
163 span -= (span - half_span);
182 : finder(F), null_value(F.
stars.
end()) {
199 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)
void dump() const
mostly for debugging
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 Gtransfo.
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.
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)