Kstars

highpmstarlist.cpp
1/*
2 SPDX-FileCopyrightText: 2007 James B. Bowlin <bowlin@mindspring.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "highpmstarlist.h"
8
9#include "skymesh.h"
10#include "skyobjects/starobject.h"
11
12#include <QDebug>
13
14typedef struct HighPMStar
15{
16 HighPMStar(Trixel t, StarObject *s) : trixel(t), star(s) {}
17 Trixel trixel;
18 StarObject *star { nullptr };
19
20} HighPMStar;
21
22HighPMStarList::HighPMStarList(double threshold) : m_reindexNum(J2000), m_threshold(threshold)
23{
24 m_skyMesh = SkyMesh::Instance();
25}
26
27HighPMStarList::~HighPMStarList()
28{
29 qDeleteAll(m_stars);
30 m_stars.clear();
31}
32
33bool HighPMStarList::append(Trixel trixel, StarObject *star, double pm)
34{
35 if (pm < m_threshold)
36 return false;
37
38 if (trixel >= m_skyMesh->size())
39 qDebug() << Q_FUNC_INFO << "### Trixel ID out of range for the Mesh currently in use!" << trixel;
40
41 m_stars.append(new HighPMStar(trixel, star));
42 if (m_maxPM >= pm)
43 return true;
44
45 m_maxPM = pm;
46 m_reindexInterval = StarObject::reindexInterval(pm);
47
48 return true;
49}
50
52{
53 m_reindexNum = KSNumbers(*num);
54}
55
57{
58 if (fabs(num->julianCenturies() - m_reindexNum.julianCenturies()) < m_reindexInterval)
59 return false;
60
61 m_reindexNum = KSNumbers(*num);
62 m_skyMesh->setKSNumbers(num);
63
64 int cnt(0);
65
66 for (auto &HPStar : m_stars)
67 {
68 Trixel trixel = m_skyMesh->indexStar(HPStar->star);
69
70 if (trixel == HPStar->trixel)
71 continue;
72 cnt++;
73 StarObject *star = HPStar->star;
74
75 // out with the old ...
76 if (HPStar->trixel >= m_skyMesh->size())
77 {
78 qDebug() << Q_FUNC_INFO << "### Expect an Index out-of-range error. star->trixel =" << HPStar->trixel;
79 }
80
81 StarList *old = starIndex->at(HPStar->trixel);
82 old->removeAt(old->indexOf(star));
83
84 float mag = star->mag();
85 //printf("\n mag = %4.2f trixel %d -> %d\n", mag, HPStar->trixel, trixel );
86
87 // in with the new ...
88 HPStar->trixel = trixel;
89 if (trixel >= m_skyMesh->size())
90 qDebug() << Q_FUNC_INFO << "### Expect an Index out-of-range error. trixel =" << trixel;
91
92 StarList *list = starIndex->at(trixel);
93 int j;
94 for (j = 0; j < list->size(); j++)
95 {
96 if (list->at(j)->mag() < mag)
97 continue;
98 list->insert(j, star);
99 break;
100 }
101 if (j == list->size())
102 list->append(star);
103
104 //for ( j = 0; j < list->size(); j++ ) {
105 // printf(" %4.2f\n", list->at(j)->mag() );
106 //}
107 }
108 return true;
109 //printf("Re-indexed %d stars at interval %6.1f\n", cnt, 100.0 * m_reindexInterval );
110}
111
113{
114 printf("\n");
115 printf("maxPM: %6.1f threshold %5.1f\n", m_maxPM, m_threshold);
116 printf("stars: %d\n", size());
117 printf("Update Interval: %6.1f years\n", 100.0 * m_reindexInterval);
118 printf("Last Update: %6.1f\n", 2000.0 + 100.0 * (int)m_reindexNum.julianCenturies());
119}
int size() const
returns the total number of trixels in the HTM.
Definition HTMesh.h:118
void setIndexTime(KSNumbers *num)
sets the time this list was last indexed to.
void stats()
prints out some brief statistics.
int size() const
returns the number of stars in the list.
HighPMStarList(double threshold)
Constructor.
bool append(Trixel trixel, StarObject *star, double pm)
adds the star located at trixel to the list if the pm is greater than the threshold.
bool reindex(KSNumbers *num, StarIndex *starIndex)
if the date in num differs from the last time we indexed by more than our update interval then we re-...
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition ksnumbers.h:43
double julianCenturies() const
Definition ksnumbers.h:88
static SkyMesh * Instance()
returns the default instance of SkyMesh or null if it has not yet been created.
Definition skymesh.cpp:39
void setKSNumbers(KSNumbers *num)
sets the time for indexing StarObjects and CLines.
Definition skymesh.h:145
Trixel indexStar(StarObject *star)
returns the trixel that contains the star at the set time with proper motion taken into account but n...
Definition skymesh.cpp:79
float mag() const
Definition skyobject.h:207
This is a subclass of SkyObject.
Definition starobject.h:33
static double reindexInterval(double pm)
returns the reindex interval (in centuries!) for the given magnitude of proper motion (in milliarcsec...
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
qsizetype indexOf(const AT &value, qsizetype from) const const
iterator insert(const_iterator before, parameter_type value)
void removeAt(qsizetype i)
qsizetype size() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.