Replace generic catalog type and related minor polishing.
parent
1ebc427f41
commit
035aa30ae5
|
@ -10,8 +10,8 @@ class UserCategory;
|
|||
class AstroCatalog
|
||||
{
|
||||
public:
|
||||
typedef unsigned int IndexNumber;
|
||||
static const IndexNumber InvalidIndex = UINT_MAX;
|
||||
typedef uint32_t IndexNumber;
|
||||
static const IndexNumber InvalidIndex = UINT32_MAX;
|
||||
};
|
||||
|
||||
class AstroObject
|
||||
|
|
|
@ -68,7 +68,7 @@ DSODatabase::~DSODatabase()
|
|||
}
|
||||
|
||||
|
||||
DeepSkyObject* DSODatabase::find(const uint32_t catalogNumber) const
|
||||
DeepSkyObject* DSODatabase::find(const AstroCatalog::IndexNumber catalogNumber) const
|
||||
{
|
||||
Galaxy refDSO; //terrible hack !!
|
||||
refDSO.setIndex(catalogNumber);
|
||||
|
@ -92,7 +92,7 @@ DeepSkyObject* DSODatabase::find(const string& name) const
|
|||
|
||||
if (namesDB != nullptr)
|
||||
{
|
||||
uint32_t catalogNumber = namesDB->findCatalogNumberByName(name);
|
||||
AstroCatalog::IndexNumber catalogNumber = namesDB->findCatalogNumberByName(name);
|
||||
if (catalogNumber != AstroCatalog::InvalidIndex)
|
||||
return find(catalogNumber);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ vector<string> DSODatabase::getCompletion(const string& name) const
|
|||
|
||||
string DSODatabase::getDSOName(const DeepSkyObject* const & dso, bool i18n) const
|
||||
{
|
||||
uint32_t catalogNumber = dso->getIndex();
|
||||
AstroCatalog::IndexNumber catalogNumber = dso->getIndex();
|
||||
|
||||
if (namesDB != nullptr)
|
||||
{
|
||||
|
@ -137,7 +137,7 @@ string DSODatabase::getDSONameList(const DeepSkyObject* const & dso, const unsig
|
|||
{
|
||||
string dsoNames;
|
||||
|
||||
unsigned int catalogNumber = dso->getIndex();
|
||||
auto catalogNumber = dso->getIndex();
|
||||
|
||||
DSONameDatabase::NumberIndex::const_iterator iter = namesDB->getFirstNameIter(catalogNumber);
|
||||
|
||||
|
@ -239,12 +239,12 @@ bool DSODatabase::load(istream& in, const fs::path& resourcePath)
|
|||
}
|
||||
objType = tokenizer.getNameValue();
|
||||
|
||||
bool autoGenCatalogNumber = true;
|
||||
uint32_t objCatalogNumber = AstroCatalog::InvalidIndex;
|
||||
bool autoGenCatalogNumber = true;
|
||||
AstroCatalog::IndexNumber objCatalogNumber = AstroCatalog::InvalidIndex;
|
||||
if (tokenizer.getTokenType() == Tokenizer::TokenNumber)
|
||||
{
|
||||
autoGenCatalogNumber = false;
|
||||
objCatalogNumber = (uint32_t) tokenizer.getNumberValue();
|
||||
objCatalogNumber = (AstroCatalog::IndexNumber) tokenizer.getNumberValue();
|
||||
tokenizer.nextToken();
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class DSODatabase
|
|||
inline DeepSkyObject* getDSO(const uint32_t) const;
|
||||
inline uint32_t size() const;
|
||||
|
||||
DeepSkyObject* find(const uint32_t catalogNumber) const;
|
||||
DeepSkyObject* find(const AstroCatalog::IndexNumber catalogNumber) const;
|
||||
DeepSkyObject* find(const std::string&) const;
|
||||
|
||||
std::vector<std::string> getCompletion(const std::string&) const;
|
||||
|
@ -79,7 +79,7 @@ private:
|
|||
DSONameDatabase* namesDB{ nullptr };
|
||||
DeepSkyObject** catalogNumberIndex{ nullptr };
|
||||
DSOOctree* octreeRoot{ nullptr };
|
||||
uint32_t nextAutoCatalogNumber{ 0xfffffffe };
|
||||
AstroCatalog::IndexNumber nextAutoCatalogNumber{ 0xfffffffe };
|
||||
|
||||
double avgAbsMag{ 0.0 };
|
||||
};
|
||||
|
|
|
@ -6,13 +6,13 @@ uint32_t NameDatabase::getNameCount() const
|
|||
return nameIndex.size();
|
||||
}
|
||||
|
||||
void NameDatabase::add(const uint32_t catalogNumber, const std::string& name, bool replaceGreek)
|
||||
void NameDatabase::add(const AstroCatalog::IndexNumber catalogNumber, const std::string& name, bool replaceGreek)
|
||||
{
|
||||
if (name.length() != 0)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
uint32_t tmp;
|
||||
if ((tmp = getCatalogNumberByName(name)) != InvalidCatalogNumber)
|
||||
AstroCatalog::IndexNumber tmp;
|
||||
if ((tmp = getCatalogNumberByName(name)) != AstroCatalog::InvalidIndex)
|
||||
DPRINTF(LOG_LEVEL_INFO,"Duplicated name '%s' on object with catalog numbers: %d and %d\n", name.c_str(), tmp, catalogNumber);
|
||||
#endif
|
||||
// Add the new name
|
||||
|
@ -23,12 +23,12 @@ void NameDatabase::add(const uint32_t catalogNumber, const std::string& name, bo
|
|||
numberIndex.insert(NumberIndex::value_type(catalogNumber, fname));
|
||||
}
|
||||
}
|
||||
void NameDatabase::erase(const uint32_t catalogNumber)
|
||||
void NameDatabase::erase(const AstroCatalog::IndexNumber catalogNumber)
|
||||
{
|
||||
numberIndex.erase(catalogNumber);
|
||||
}
|
||||
|
||||
uint32_t NameDatabase::getCatalogNumberByName(const std::string& name) const
|
||||
AstroCatalog::IndexNumber NameDatabase::getCatalogNumberByName(const std::string& name) const
|
||||
{
|
||||
NameIndex::const_iterator iter = nameIndex.find(name);
|
||||
|
||||
|
@ -36,7 +36,7 @@ uint32_t NameDatabase::getCatalogNumberByName(const std::string& name) const
|
|||
{
|
||||
iter = nameIndex.find(ReplaceGreekLetterAbbr(name));
|
||||
if (iter == nameIndex.end())
|
||||
return InvalidCatalogNumber;
|
||||
return AstroCatalog::InvalidIndex;
|
||||
}
|
||||
return iter->second;
|
||||
}
|
||||
|
@ -49,9 +49,9 @@ uint32_t NameDatabase::getCatalogNumberByName(const std::string& name) const
|
|||
// preserve this order when inserting the names into the multimap
|
||||
// (not certain whether or not this behavior is in the STL spec.
|
||||
// but it works on the implementations I've tried so far.)
|
||||
std::string NameDatabase::getNameByCatalogNumber(const uint32_t catalogNumber) const
|
||||
std::string NameDatabase::getNameByCatalogNumber(const AstroCatalog::IndexNumber catalogNumber) const
|
||||
{
|
||||
if (catalogNumber == InvalidCatalogNumber)
|
||||
if (catalogNumber == AstroCatalog::InvalidIndex)
|
||||
return "";
|
||||
|
||||
NumberIndex::const_iterator iter = numberIndex.lower_bound(catalogNumber);
|
||||
|
@ -71,7 +71,7 @@ std::string NameDatabase::getNameByCatalogNumber(const uint32_t catalogNumber) c
|
|||
// preserve this order when inserting the names into the multimap
|
||||
// (not certain whether or not this behavior is in the STL spec.
|
||||
// but it works on the implementations I've tried so far.)
|
||||
NameDatabase::NumberIndex::const_iterator NameDatabase::getFirstNameIter(const uint32_t catalogNumber) const
|
||||
NameDatabase::NumberIndex::const_iterator NameDatabase::getFirstNameIter(const AstroCatalog::IndexNumber catalogNumber) const
|
||||
{
|
||||
NumberIndex::const_iterator iter = numberIndex.lower_bound(catalogNumber);
|
||||
|
||||
|
|
|
@ -19,17 +19,15 @@
|
|||
#include <celutil/debug.h>
|
||||
#include <celutil/util.h>
|
||||
#include <celutil/utf8.h>
|
||||
#include <celengine/astroobj.h>
|
||||
|
||||
// TODO: this can be "detemplatized" by creating e.g. a global-scope enum InvalidCatalogNumber since there
|
||||
// lies the one and only need for type genericity.
|
||||
class NameDatabase
|
||||
{
|
||||
public:
|
||||
typedef std::map<std::string, uint32_t, CompareIgnoringCasePredicate> NameIndex;
|
||||
typedef std::multimap<uint32_t, std::string> NumberIndex;
|
||||
enum {
|
||||
InvalidCatalogNumber = 0xffffffff
|
||||
};
|
||||
typedef std::map<std::string, AstroCatalog::IndexNumber, CompareIgnoringCasePredicate> NameIndex;
|
||||
typedef std::multimap<AstroCatalog::IndexNumber, std::string> NumberIndex;
|
||||
|
||||
public:
|
||||
NameDatabase() {};
|
||||
|
@ -37,15 +35,15 @@ class NameDatabase
|
|||
|
||||
uint32_t getNameCount() const;
|
||||
|
||||
void add(const uint32_t, const std::string&, bool parseGreek = true);
|
||||
void add(const AstroCatalog::IndexNumber, const std::string&, bool parseGreek = true);
|
||||
|
||||
// delete all names associated with the specified catalog number
|
||||
void erase(const uint32_t);
|
||||
void erase(const AstroCatalog::IndexNumber);
|
||||
|
||||
uint32_t getCatalogNumberByName(const std::string&) const;
|
||||
std::string getNameByCatalogNumber(const uint32_t) const;
|
||||
AstroCatalog::IndexNumber getCatalogNumberByName(const std::string&) const;
|
||||
std::string getNameByCatalogNumber(const AstroCatalog::IndexNumber) const;
|
||||
|
||||
NumberIndex::const_iterator getFirstNameIter(const uint32_t catalogNumber) const;
|
||||
NumberIndex::const_iterator getFirstNameIter(const AstroCatalog::IndexNumber catalogNumber) const;
|
||||
NumberIndex::const_iterator getFinalNameIter() const;
|
||||
|
||||
std::vector<std::string> getCompletion(const std::string& name, bool greek = true) const;
|
||||
|
|
|
@ -115,14 +115,10 @@ string Selection::getName(bool i18n) const
|
|||
switch (type)
|
||||
{
|
||||
case Type_Star:
|
||||
{
|
||||
return fmt::sprintf("#%d", star()->getIndex());
|
||||
}
|
||||
return fmt::sprintf("#%u", star()->getIndex());
|
||||
|
||||
case Type_DeepSky:
|
||||
{
|
||||
return fmt::sprintf("#%d", deepsky()->getIndex());
|
||||
}
|
||||
return fmt::sprintf("#%u", deepsky()->getIndex());
|
||||
|
||||
case Type_Body:
|
||||
{
|
||||
|
@ -140,11 +136,7 @@ string Selection::getName(bool i18n) const
|
|||
{
|
||||
const Star* parentStar = system->getStar();
|
||||
if (parentStar != nullptr)
|
||||
{
|
||||
string buf;
|
||||
buf = fmt::sprintf("#%d", parentStar->getIndex());
|
||||
name = buf + '/' + name;
|
||||
}
|
||||
name = fmt::sprintf("#%u/%s", parentStar->getIndex(), name);
|
||||
system = nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -300,7 +300,8 @@ public:
|
|||
const std::string& getInfoURL() const;
|
||||
inline bool hasCorona() const;
|
||||
|
||||
enum : uint32_t {
|
||||
enum : AstroCatalog::IndexNumber
|
||||
{
|
||||
MaxTychoCatalogNumber = 0xf0000000
|
||||
};
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ struct PtrCatalogNumberOrderingPredicate
|
|||
|
||||
static bool parseSimpleCatalogNumber(const string& name,
|
||||
const string& prefix,
|
||||
uint32_t* catalogNumber)
|
||||
AstroCatalog::IndexNumber* catalogNumber)
|
||||
{
|
||||
char extra[4];
|
||||
if (compareIgnoringCase(name, prefix, prefix.length()) == 0)
|
||||
|
@ -108,7 +108,7 @@ static bool parseSimpleCatalogNumber(const string& name,
|
|||
// characters other than whitespace are allowed after the number.
|
||||
if (sscanf(name.c_str() + prefix.length(), " %u %c", &num, extra) == 1)
|
||||
{
|
||||
*catalogNumber = (uint32_t) num;
|
||||
*catalogNumber = (AstroCatalog::IndexNumber) num;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ static bool parseSimpleCatalogNumber(const string& name,
|
|||
|
||||
|
||||
static bool parseHIPPARCOSCatalogNumber(const string& name,
|
||||
uint32_t* catalogNumber)
|
||||
AstroCatalog::IndexNumber* catalogNumber)
|
||||
{
|
||||
return parseSimpleCatalogNumber(name,
|
||||
HIPPARCOSCatalogPrefix,
|
||||
|
@ -127,7 +127,7 @@ static bool parseHIPPARCOSCatalogNumber(const string& name,
|
|||
|
||||
|
||||
static bool parseHDCatalogNumber(const string& name,
|
||||
uint32_t* catalogNumber)
|
||||
AstroCatalog::IndexNumber* catalogNumber)
|
||||
{
|
||||
return parseSimpleCatalogNumber(name,
|
||||
HDCatalogPrefix,
|
||||
|
@ -136,7 +136,7 @@ static bool parseHDCatalogNumber(const string& name,
|
|||
|
||||
|
||||
static bool parseTychoCatalogNumber(const string& name,
|
||||
uint32_t* catalogNumber)
|
||||
AstroCatalog::IndexNumber* catalogNumber)
|
||||
{
|
||||
int len = strlen(TychoCatalogPrefix);
|
||||
if (compareIgnoringCase(name, TychoCatalogPrefix, len) == 0)
|
||||
|
@ -145,7 +145,7 @@ static bool parseTychoCatalogNumber(const string& name,
|
|||
if (sscanf(string(name, len, string::npos).c_str(),
|
||||
" %u-%u-%u", &tyc1, &tyc2, &tyc3) == 3)
|
||||
{
|
||||
*catalogNumber = (uint32_t) (tyc3 * 1000000000 + tyc2 * 10000 + tyc1);
|
||||
*catalogNumber = (AstroCatalog::IndexNumber) (tyc3 * 1000000000 + tyc2 * 10000 + tyc1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ static bool parseTychoCatalogNumber(const string& name,
|
|||
|
||||
|
||||
static bool parseCelestiaCatalogNumber(const string& name,
|
||||
uint32_t* catalogNumber)
|
||||
AstroCatalog::IndexNumber* catalogNumber)
|
||||
{
|
||||
char extra[4];
|
||||
|
||||
|
@ -164,7 +164,7 @@ static bool parseCelestiaCatalogNumber(const string& name,
|
|||
unsigned int num;
|
||||
if (sscanf(name.c_str(), "#%u %c", &num, extra) == 1)
|
||||
{
|
||||
*catalogNumber = (uint32_t) num;
|
||||
*catalogNumber = (AstroCatalog::IndexNumber) num;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ StarDatabase::~StarDatabase()
|
|||
}
|
||||
|
||||
|
||||
Star* StarDatabase::find(uint32_t catalogNumber) const
|
||||
Star* StarDatabase::find(AstroCatalog::IndexNumber catalogNumber) const
|
||||
{
|
||||
Star refStar;
|
||||
refStar.setIndex(catalogNumber);
|
||||
|
@ -212,12 +212,12 @@ Star* StarDatabase::find(uint32_t catalogNumber) const
|
|||
}
|
||||
|
||||
|
||||
uint32_t StarDatabase::findCatalogNumberByName(const string& name) const
|
||||
AstroCatalog::IndexNumber StarDatabase::findCatalogNumberByName(const string& name) const
|
||||
{
|
||||
if (name.empty())
|
||||
return AstroCatalog::InvalidIndex;
|
||||
|
||||
uint32_t catalogNumber = AstroCatalog::InvalidIndex;
|
||||
AstroCatalog::IndexNumber catalogNumber = AstroCatalog::InvalidIndex;
|
||||
|
||||
if (namesDB != nullptr)
|
||||
{
|
||||
|
@ -256,7 +256,7 @@ uint32_t StarDatabase::findCatalogNumberByName(const string& name) const
|
|||
|
||||
Star* StarDatabase::find(const string& name) const
|
||||
{
|
||||
uint32_t catalogNumber = findCatalogNumberByName(name);
|
||||
AstroCatalog::IndexNumber catalogNumber = findCatalogNumberByName(name);
|
||||
if (catalogNumber != AstroCatalog::InvalidIndex)
|
||||
return find(catalogNumber);
|
||||
else
|
||||
|
@ -264,9 +264,9 @@ Star* StarDatabase::find(const string& name) const
|
|||
}
|
||||
|
||||
|
||||
uint32_t StarDatabase::crossIndex(const Catalog catalog, const uint32_t celCatalogNumber) const
|
||||
AstroCatalog::IndexNumber StarDatabase::crossIndex(const Catalog catalog, const AstroCatalog::IndexNumber celCatalogNumber) const
|
||||
{
|
||||
if (static_cast<uint32_t>(catalog) >= crossIndexes.size())
|
||||
if (static_cast<size_t>(catalog) >= crossIndexes.size())
|
||||
return AstroCatalog::InvalidIndex;
|
||||
|
||||
CrossIndex* xindex = crossIndexes[catalog];
|
||||
|
@ -286,7 +286,7 @@ uint32_t StarDatabase::crossIndex(const Catalog catalog, const uint32_t celCatal
|
|||
|
||||
// Return the Celestia catalog number for the star with a specified number
|
||||
// in a cross index.
|
||||
uint32_t StarDatabase::searchCrossIndexForCatalogNumber(const Catalog catalog, const uint32_t number) const
|
||||
AstroCatalog::IndexNumber StarDatabase::searchCrossIndexForCatalogNumber(const Catalog catalog, const AstroCatalog::IndexNumber number) const
|
||||
{
|
||||
if (static_cast<unsigned int>(catalog) >= crossIndexes.size())
|
||||
return AstroCatalog::InvalidIndex;
|
||||
|
@ -307,9 +307,9 @@ uint32_t StarDatabase::searchCrossIndexForCatalogNumber(const Catalog catalog, c
|
|||
}
|
||||
|
||||
|
||||
Star* StarDatabase::searchCrossIndex(const Catalog catalog, const uint32_t number) const
|
||||
Star* StarDatabase::searchCrossIndex(const Catalog catalog, const AstroCatalog::IndexNumber number) const
|
||||
{
|
||||
uint32_t celCatalogNumber = searchCrossIndexForCatalogNumber(catalog, number);
|
||||
AstroCatalog::IndexNumber celCatalogNumber = searchCrossIndexForCatalogNumber(catalog, number);
|
||||
if (celCatalogNumber != AstroCatalog::InvalidIndex)
|
||||
return find(celCatalogNumber);
|
||||
else
|
||||
|
@ -330,14 +330,14 @@ vector<string> StarDatabase::getCompletion(const string& name) const
|
|||
|
||||
|
||||
#if 0
|
||||
static void catalogNumberToString(uint32_t catalogNumber, char* buf, unsigned int bufSize)
|
||||
static void catalogNumberToString(AstroCatalog::IndexNumber catalogNumber, char* buf, unsigned int bufSize)
|
||||
{
|
||||
// TODO: implement using using fmt::write
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static string catalogNumberToString(uint32_t catalogNumber)
|
||||
static string catalogNumberToString(AstroCatalog::IndexNumber catalogNumber)
|
||||
{
|
||||
if (catalogNumber <= StarDatabase::MAX_HIPPARCOS_NUMBER)
|
||||
{
|
||||
|
@ -345,11 +345,11 @@ static string catalogNumberToString(uint32_t catalogNumber)
|
|||
}
|
||||
else
|
||||
{
|
||||
uint32_t tyc3 = catalogNumber / 1000000000;
|
||||
AstroCatalog::IndexNumber tyc3 = catalogNumber / 1000000000;
|
||||
catalogNumber -= tyc3 * 1000000000;
|
||||
uint32_t tyc2 = catalogNumber / 10000;
|
||||
AstroCatalog::IndexNumber tyc2 = catalogNumber / 10000;
|
||||
catalogNumber -= tyc2 * 10000;
|
||||
uint32_t tyc1 = catalogNumber;
|
||||
AstroCatalog::IndexNumber tyc1 = catalogNumber;
|
||||
return fmt::sprintf("TYC %d-%d-%d", tyc1, tyc2, tyc3);
|
||||
}
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ static string catalogNumberToString(uint32_t catalogNumber)
|
|||
// required as it's all wrapped in the string class.)
|
||||
string StarDatabase::getStarName(const Star& star, bool i18n) const
|
||||
{
|
||||
uint32_t catalogNumber = star.getIndex();
|
||||
AstroCatalog::IndexNumber catalogNumber = star.getIndex();
|
||||
|
||||
if (namesDB != nullptr)
|
||||
{
|
||||
|
@ -400,7 +400,7 @@ void StarDatabase::getStarName(const Star& star, char* nameBuffer, unsigned int
|
|||
{
|
||||
assert(bufferSize != 0);
|
||||
|
||||
uint32_t catalogNumber = star.getIndex();
|
||||
AstroCatalog::IndexNumber catalogNumber = star.getIndex();
|
||||
|
||||
if (namesDB != nullptr)
|
||||
{
|
||||
|
@ -444,7 +444,7 @@ string StarDatabase::getStarNameList(const Star& star, const unsigned int maxNam
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t hip = catalogNumber;
|
||||
AstroCatalog::IndexNumber hip = catalogNumber;
|
||||
if (hip != AstroCatalog::InvalidIndex && hip != 0 && count < maxNames)
|
||||
{
|
||||
if (hip <= Star::MaxTychoCatalogNumber)
|
||||
|
@ -453,12 +453,12 @@ string StarDatabase::getStarNameList(const Star& star, const unsigned int maxNam
|
|||
starNames += " / ";
|
||||
if (hip >= 1000000)
|
||||
{
|
||||
uint32_t h = hip;
|
||||
uint32_t tyc3 = h / 1000000000;
|
||||
AstroCatalog::IndexNumber h = hip;
|
||||
AstroCatalog::IndexNumber tyc3 = h / 1000000000;
|
||||
h -= tyc3 * 1000000000;
|
||||
uint32_t tyc2 = h / 10000;
|
||||
AstroCatalog::IndexNumber tyc2 = h / 10000;
|
||||
h -= tyc2 * 10000;
|
||||
uint32_t tyc1 = h;
|
||||
AstroCatalog::IndexNumber tyc1 = h;
|
||||
|
||||
starNames += fmt::sprintf("TYC %u-%u-%u", tyc1, tyc2, tyc3);
|
||||
}
|
||||
|
@ -471,7 +471,7 @@ string StarDatabase::getStarNameList(const Star& star, const unsigned int maxNam
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t hd = crossIndex(StarDatabase::HenryDraper, hip);
|
||||
AstroCatalog::IndexNumber hd = crossIndex(StarDatabase::HenryDraper, hip);
|
||||
if (count < maxNames && hd != AstroCatalog::InvalidIndex)
|
||||
{
|
||||
if (count != 0)
|
||||
|
@ -479,7 +479,7 @@ string StarDatabase::getStarNameList(const Star& star, const unsigned int maxNam
|
|||
starNames += fmt::sprintf("HD %u", hd);
|
||||
}
|
||||
|
||||
uint32_t sao = crossIndex(StarDatabase::SAO, hip);
|
||||
AstroCatalog::IndexNumber sao = crossIndex(StarDatabase::SAO, hip);
|
||||
if (count < maxNames && sao != AstroCatalog::InvalidIndex)
|
||||
{
|
||||
if (count != 0)
|
||||
|
@ -650,7 +650,7 @@ bool StarDatabase::loadBinary(istream& in)
|
|||
|
||||
while (((unsigned int) nStars) < totalStars)
|
||||
{
|
||||
uint32_t catNo = 0;
|
||||
AstroCatalog::IndexNumber catNo = 0;
|
||||
float x = 0.0f, y = 0.0f, z = 0.0f;
|
||||
int16_t absMag;
|
||||
uint16_t spectralType;
|
||||
|
@ -762,7 +762,7 @@ static void stcError(const Tokenizer& tok,
|
|||
*/
|
||||
bool StarDatabase::createStar(Star* star,
|
||||
DataDisposition disposition,
|
||||
uint32_t catalogNumber,
|
||||
AstroCatalog::IndexNumber catalogNumber,
|
||||
Hash* starData,
|
||||
const fs::path& path,
|
||||
bool isBarycenter)
|
||||
|
@ -941,7 +941,7 @@ bool StarDatabase::createStar(Star* star,
|
|||
details->setOrbit(orbit);
|
||||
|
||||
// See if a barycenter was specified as well
|
||||
uint32_t barycenterCatNo = AstroCatalog::InvalidIndex;
|
||||
AstroCatalog::IndexNumber barycenterCatNo = AstroCatalog::InvalidIndex;
|
||||
bool barycenterDefined = false;
|
||||
|
||||
string barycenterName;
|
||||
|
@ -1216,10 +1216,10 @@ bool StarDatabase::load(istream& in, const fs::path& resourcePath)
|
|||
}
|
||||
|
||||
// Parse the catalog number; it may be omitted if a name is supplied.
|
||||
uint32_t catalogNumber = AstroCatalog::InvalidIndex;
|
||||
AstroCatalog::IndexNumber catalogNumber = AstroCatalog::InvalidIndex;
|
||||
if (tokenizer.getTokenType() == Tokenizer::TokenNumber)
|
||||
{
|
||||
catalogNumber = (uint32_t) tokenizer.getNumberValue();
|
||||
catalogNumber = (AstroCatalog::IndexNumber) tokenizer.getNumberValue();
|
||||
tokenizer.nextToken();
|
||||
}
|
||||
|
||||
|
@ -1448,7 +1448,7 @@ void StarDatabase::buildIndexes()
|
|||
* in an stc file may reference each other (barycenters). Thus, a dynamic
|
||||
* structure like a map is both practical and essential.
|
||||
*/
|
||||
Star* StarDatabase::findWhileLoading(uint32_t catalogNumber) const
|
||||
Star* StarDatabase::findWhileLoading(AstroCatalog::IndexNumber catalogNumber) const
|
||||
{
|
||||
// First check for stars loaded from the binary database
|
||||
if (binFileCatalogNumberIndex != nullptr)
|
||||
|
@ -1466,7 +1466,7 @@ Star* StarDatabase::findWhileLoading(uint32_t catalogNumber) const
|
|||
}
|
||||
|
||||
// Next check for stars loaded from an stc file
|
||||
map<uint32_t, Star*>::const_iterator iter = stcFileCatalogNumberIndex.find(catalogNumber);
|
||||
map<AstroCatalog::IndexNumber, Star*>::const_iterator iter = stcFileCatalogNumberIndex.find(catalogNumber);
|
||||
if (iter != stcFileCatalogNumberIndex.end())
|
||||
{
|
||||
return iter->second;
|
||||
|
|
|
@ -110,9 +110,9 @@ class StarDatabase
|
|||
inline Star* getStar(const uint32_t) const;
|
||||
inline uint32_t size() const;
|
||||
|
||||
Star* find(uint32_t catalogNumber) const;
|
||||
Star* find(AstroCatalog::IndexNumber catalogNumber) const;
|
||||
Star* find(const std::string&) const;
|
||||
uint32_t findCatalogNumberByName(const std::string&) const;
|
||||
AstroCatalog::IndexNumber findCatalogNumberByName(const std::string&) const;
|
||||
|
||||
std::vector<std::string> getCompletion(const std::string&) const;
|
||||
|
||||
|
@ -148,12 +148,12 @@ class StarDatabase
|
|||
|
||||
// Not exact, but any star with a catalog number greater than this is assumed to not be
|
||||
// a HIPPARCOS stars.
|
||||
static const uint32_t MAX_HIPPARCOS_NUMBER = 999999;
|
||||
static const AstroCatalog::IndexNumber MAX_HIPPARCOS_NUMBER = 999999;
|
||||
|
||||
struct CrossIndexEntry
|
||||
{
|
||||
uint32_t catalogNumber;
|
||||
uint32_t celCatalogNumber;
|
||||
AstroCatalog::IndexNumber catalogNumber;
|
||||
AstroCatalog::IndexNumber celCatalogNumber;
|
||||
|
||||
bool operator<(const CrossIndexEntry&) const;
|
||||
};
|
||||
|
@ -161,9 +161,9 @@ class StarDatabase
|
|||
typedef std::vector<CrossIndexEntry> CrossIndex;
|
||||
|
||||
bool loadCrossIndex (const Catalog, std::istream&);
|
||||
uint32_t searchCrossIndexForCatalogNumber(const Catalog, const uint32_t number) const;
|
||||
Star* searchCrossIndex(const Catalog, const uint32_t number) const;
|
||||
uint32_t crossIndex (const Catalog, const uint32_t number) const;
|
||||
AstroCatalog::IndexNumber searchCrossIndexForCatalogNumber(const Catalog, const AstroCatalog::IndexNumber number) const;
|
||||
Star* searchCrossIndex(const Catalog, const AstroCatalog::IndexNumber number) const;
|
||||
AstroCatalog::IndexNumber crossIndex(const Catalog, const AstroCatalog::IndexNumber number) const;
|
||||
|
||||
void finish();
|
||||
|
||||
|
@ -172,14 +172,14 @@ class StarDatabase
|
|||
private:
|
||||
bool createStar(Star* star,
|
||||
DataDisposition disposition,
|
||||
uint32_t catalogNumber,
|
||||
AstroCatalog::IndexNumber catalogNumber,
|
||||
Hash* starData,
|
||||
const fs::path& path,
|
||||
const bool isBarycenter);
|
||||
|
||||
void buildOctree();
|
||||
void buildIndexes();
|
||||
Star* findWhileLoading(uint32_t catalogNumber) const;
|
||||
Star* findWhileLoading(AstroCatalog::IndexNumber catalogNumber) const;
|
||||
|
||||
int nStars{ 0 };
|
||||
|
||||
|
@ -187,7 +187,7 @@ private:
|
|||
StarNameDatabase* namesDB{ nullptr };
|
||||
Star** catalogNumberIndex{ nullptr };
|
||||
StarOctree* octreeRoot{ nullptr };
|
||||
uint32_t nextAutoCatalogNumber{ 0xfffffffe };
|
||||
AstroCatalog::IndexNumber nextAutoCatalogNumber{ 0xfffffffe };
|
||||
|
||||
std::vector<CrossIndex*> crossIndexes;
|
||||
|
||||
|
@ -198,12 +198,12 @@ private:
|
|||
Star** binFileCatalogNumberIndex{ nullptr };
|
||||
unsigned int binFileStarCount{ 0 };
|
||||
// Catalog number -> star mapping for stars loaded from stc files
|
||||
std::map<uint32_t, Star*> stcFileCatalogNumberIndex;
|
||||
std::map<AstroCatalog::IndexNumber, Star*> stcFileCatalogNumberIndex;
|
||||
|
||||
struct BarycenterUsage
|
||||
{
|
||||
uint32_t catNo;
|
||||
uint32_t barycenterCatNo;
|
||||
AstroCatalog::IndexNumber catNo;
|
||||
AstroCatalog::IndexNumber barycenterCatNo;
|
||||
};
|
||||
std::vector<BarycenterUsage> barycenters;
|
||||
};
|
||||
|
|
|
@ -18,7 +18,7 @@ using namespace std;
|
|||
|
||||
uint32_t StarNameDatabase::findCatalogNumberByName(const string& name) const
|
||||
{
|
||||
uint32_t catalogNumber = getCatalogNumberByName(name);
|
||||
auto catalogNumber = getCatalogNumberByName(name);
|
||||
if (catalogNumber != AstroCatalog::InvalidIndex)
|
||||
return catalogNumber;
|
||||
|
||||
|
@ -106,7 +106,7 @@ StarNameDatabase* StarNameDatabase::readNames(istream& in)
|
|||
|
||||
while (!failed)
|
||||
{
|
||||
uint32_t catalogNumber = AstroCatalog::InvalidIndex;
|
||||
auto catalogNumber = AstroCatalog::InvalidIndex;
|
||||
|
||||
in >> catalogNumber;
|
||||
if (in.eof())
|
||||
|
|
|
@ -101,7 +101,7 @@ SolarSystem* Universe::getSolarSystem(const Star* star) const
|
|||
if (star == nullptr)
|
||||
return nullptr;
|
||||
|
||||
uint32_t starNum = star->getIndex();
|
||||
auto starNum = star->getIndex();
|
||||
auto iter = solarSystemCatalog->find(starNum);
|
||||
if (iter != solarSystemCatalog->end())
|
||||
return iter->second;
|
||||
|
|
|
@ -191,8 +191,8 @@ QVariant StarTableModel::data(const QModelIndex& index, int role) const
|
|||
{
|
||||
case NameColumn:
|
||||
{
|
||||
uint32_t hipCatNo = star->getIndex();
|
||||
uint32_t hdCatNo = universe->getStarCatalog()->crossIndex(StarDatabase::HenryDraper, hipCatNo);
|
||||
auto hipCatNo = star->getIndex();
|
||||
auto hdCatNo = universe->getStarCatalog()->crossIndex(StarDatabase::HenryDraper, hipCatNo);
|
||||
if (hdCatNo != AstroCatalog::InvalidIndex)
|
||||
return QString("HD %1").arg(hdCatNo);
|
||||
else
|
||||
|
|
|
@ -1673,7 +1673,7 @@ void ShowWWWInfo(const Selection& sel)
|
|||
if (url.empty())
|
||||
{
|
||||
char name[32];
|
||||
sprintf(name, "HIP%d", sel.star()->getIndex() & ~0xf0000000);
|
||||
sprintf(name, "HIP%d", sel.star()->getIndex() & ~Star::MaxTychoCatalogNumber);
|
||||
url = string("http://simbad.u-strasbg.fr/sim-id.pl?protocol=html&Ident=") + name;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue