32LOG_LOGGER _log =
LOG_GET(
"lsst.jointcal.FastFinder");
40 if (
count == 0)
return;
44 for (
auto const &ci :
list) {
63 for (
unsigned islice = 1; islice <
nslice; ++islice) {
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) {
138 int half_span = span / 2;
139 auto middle =
begin + half_span;
140 if ((*middle)->y < yVal) {
144 span -= (span - half_span);
156 int half_span = span / 2;
157 auto middle =
end - half_span;
158 if ((*middle)->y > yVal) {
162 span -= (span - half_span);
186 startSlice = std::max(0, int((where.x - maxDist - finder.xmin) / finder.xstep));
189 endSlice = std::min(int(finder.nslice), int((where.x + maxDist - finder.xmin) / finder.xstep) + 1);
198 yEnd = where.
y + maxDist;
#define LOGLS_ERROR(logger, message)
Fast locator in starlists.
The base class for handling stars. Used by all matching routines.
Iterator meant to traverse objects within some limiting distance.
Iterator(const FastFinder &f, const Point &where, double maxDist)
stars_element operator*() const
const FastFinder & finder
decltype(stars)::const_iterator pstar
decltype(stars)::value_type stars_element
pstar locateYStart(pstar begin, pstar end, double yVal) const
void findRangeInSlice(int iSlice, double yStart, double yEnd, pstar &start, pstar &end) const
void print(std::ostream &out) const
mostly for debugging
std::shared_ptr< const BaseStar > findClosest(const Point &where, double maxDist, bool(*SkipIt)(const BaseStar &)=nullptr) const
Find the closest with some rejection capability.
const BaseStarList baselist
FastFinder(const BaseStarList &list, unsigned nXSlice=100)
Constructor.
std::shared_ptr< const BaseStar > secondClosest(const Point &where, double maxDist, std::shared_ptr< const BaseStar > &closest, bool(*SkipIt)(const BaseStar &)=nullptr) const
Iterator beginScan(const Point &where, double maxDist) const
std::vector< unsigned > index
std::vector< std::shared_ptr< const BaseStar > > stars
pstar locateYEnd(pstar begin, pstar end, double yVal) const
double computeDist2(const Point &other) const
distance squared to other
StarList< BaseStar > BaseStarList
FastFinder::Iterator Iterator