diff --git a/src/star-id.cpp b/src/star-id.cpp index dcf225ba..00ac36de 100644 --- a/src/star-id.cpp +++ b/src/star-id.cpp @@ -52,6 +52,8 @@ StarIdentifiers TetraStarIdAlgorithm::Go(const unsigned char *database, // for(const Star &star : stars){ // std::cout << star.position.x << ", " << star.position.y << std::endl; // } + // std::cout << catalog.size() << std::endl; // 5000 stars + TetraDatabase db; db.fillStarTable(); @@ -70,8 +72,10 @@ StarIdentifiers TetraStarIdAlgorithm::Go(const unsigned char *database, copyStars.begin(), copyStars.end(), [](const Star &a, const Star &b) { return a.magnitude > b.magnitude; }); + // TODO: implement the generator function // Right now I'm just do a simplified way, taking the first 4 centroids + copyStars = std::vector(copyStars.begin(), copyStars.begin() + numPattStars); std::vector centroidIndices; @@ -263,17 +267,26 @@ StarIdentifiers TetraStarIdAlgorithm::Go(const unsigned char *database, ArgsortVector(catStarVecs, catRadii); for(int i = 0; i < numPattStars; i++){ - std::cout << "centroid: " << centroidIndices[i] - << ", starID: " << catSortedStarIDs[i]; - std::cout << std::endl; - result.push_back( - StarIdentifier(centroidIndices[i], catSortedStarIDs[i])); + // std::cout << "centroid: " << sortedCentroidIndices[i] + // << ", starID: " << catSortedStarIDs[i]; + // std::cout << std::endl; + + int centroidIndex = sortedCentroidIndices[i]; + int resultStarID = catSortedStarIDs[i]; + + int catalogIndex = FindCatalogStarIndex(catalog, resultStarID); + + // const CatalogStar *catStar = FindNamedStar(catalog, resultStarID); + std::cout << "catstar: " << catalogIndex << std::endl; + + result.push_back(StarIdentifier(centroidIndex, catalogIndex)); + // Ah, catalog is different than what Tetra expects } // TODO: StarIdentifier wants the catalog INDEX, not the real star ID std::cout << "SUCCESS: stars successfully matched" << std::endl; - return result; // TODO: work on this more + return result; } } diff --git a/src/star-utils.cpp b/src/star-utils.cpp index 5e34b92d..db0aea7b 100644 --- a/src/star-utils.cpp +++ b/src/star-utils.cpp @@ -43,6 +43,16 @@ const CatalogStar *FindNamedStar(const Catalog &catalog, int name) { return NULL; } +// TODO: ok? Seems kinda stupid, anyways here's a function to get index of a CatalogStar in catalog given name +int FindCatalogStarIndex(const Catalog &catalog, int name){ + for(int i = 0; i < (int)catalog.size(); i++){ + if(catalog[i].name == name){ + return i; + } + } + return -1; // no star found +} + /// @sa SerializeCatalogStar long SerializeLengthCatalogStar(bool inclMagnitude, bool inclName) { long starSize = SerializeLengthVec3(); diff --git a/src/star-utils.hpp b/src/star-utils.hpp index a93f16fb..5d371e8f 100644 --- a/src/star-utils.hpp +++ b/src/star-utils.hpp @@ -100,6 +100,8 @@ void SerializeCatalog(const Catalog &, bool inclMagnitude, bool inclName, unsign Catalog DeserializeCatalog(const unsigned char *buffer, bool *inclMagnitudeReturn, bool *inclNameReturn); const CatalogStar *FindNamedStar(const Catalog &, int name); +int FindCatalogStarIndex(const Catalog &, int name); + // TODO: make maxStars work right, need to sort by magnitude before filter! maxMagnitude is 10^-2 // (so 523 = 5.23) Catalog NarrowCatalog(const Catalog &, int maxMagnitude, int maxStars);