-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code sweep #122
base: master
Are you sure you want to change the base?
Code sweep #122
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,16 +97,24 @@ const Catalog &CatalogRead() { | |
char *tsvPath = getenv("LOST_BSC_PATH"); | ||
catalog = BscParse(tsvPath ? tsvPath : DEFAULT_BSC_PATH); | ||
// perform essential narrowing | ||
// remove all stars with exactly the same position as another, keeping the one with brighter magnitude | ||
// remove all stars with exactly the same position as another, keeping the one with brighter | ||
// magnitude | ||
std::sort(catalog.begin(), catalog.end(), [](const CatalogStar &a, const CatalogStar &b) { | ||
return a.spatial.x < b.spatial.x; | ||
if (a.spatial.x != b.spatial.x) { | ||
return a.spatial.x < b.spatial.x; | ||
} else if (a.spatial.y != b.spatial.y) { | ||
return a.spatial.y < b.spatial.y; | ||
} | ||
return a.spatial.z < b.spatial.z; | ||
}); | ||
for (int i = catalog.size(); i > 0; i--) { | ||
if ((catalog[i].spatial - catalog[i-1].spatial).Magnitude() < 5e-5) { // 70 stars removed at this threshold. | ||
if (catalog[i].magnitude > catalog[i-1].magnitude) { | ||
catalog.erase(catalog.begin() + i); | ||
} else { | ||
for (int i = catalog.size() - 1; i > 0; i--) { // [BUG]? catalog[catalog.size()] is invalid | ||
if ((catalog[i].spatial - catalog[i - 1].spatial).Magnitude() < 5e-5) { // 70 stars removed at this threshold. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, this loop indexing looks like a bug, good catch!
Actually, this happens before the MultiDatabase -- the reason there isn't an error is just because of the extra empty padding at the end of the vector. |
||
if (catalog[i].magnitude > catalog[i - 1].magnitude) { | ||
// [BUG]? If mag of i > mag of i-1, we want to keep i, not i-1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you fool, brighter magnitudes have smaller (This behavior, for |
||
catalog.erase(catalog.begin() + i - 1); | ||
i--; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
} else { | ||
catalog.erase(catalog.begin() + i); | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ StarIdentifiers GeometricVotingStarIdAlgorithm::Go( | |
StarIdentifiers identified; | ||
MultiDatabase multiDatabase(database); | ||
const unsigned char *databaseBuffer = multiDatabase.SubDatabasePointer(PairDistanceKVectorDatabase::kMagicValue); | ||
if (databaseBuffer == NULL) { | ||
if (databaseBuffer == nullptr) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. like with |
||
return identified; | ||
} | ||
DeserializeContext des(databaseBuffer); | ||
|
@@ -173,7 +173,7 @@ class PairDistanceInvolvingIterator { | |
* If another PairDistanceInvolvingIterator is equal to this, then it is done iterating. | ||
*/ | ||
PairDistanceInvolvingIterator() | ||
: pairs(NULL), end(NULL) { }; | ||
: pairs(nullptr), end(nullptr) { }; | ||
|
||
/** | ||
* The main constructor. | ||
|
@@ -252,7 +252,7 @@ std::vector<int16_t> ConsumeInvolvingIterator(PairDistanceInvolvingIterator it) | |
/** | ||
* Given the result of a pair-distance kvector query, build a hashmultimap of stars to other stars | ||
* that appeared with it in the query. | ||
* | ||
* | ||
* The resulting map is "symmetrical" in the sense that if a star B is in the map for star A, then | ||
* star A is also in the map for star B. | ||
*/ | ||
|
@@ -447,7 +447,7 @@ IRUnidentifiedCentroid *SelectNextUnidentifiedCentroid(std::vector<IRUnidentifie | |
return result; | ||
} | ||
|
||
return NULL; | ||
return nullptr; | ||
} | ||
|
||
const float kAngleFrom90SoftThreshold = M_PI_4; // TODO: tune this | ||
|
@@ -510,7 +510,7 @@ int IdentifyRemainingStarsPairDistance(StarIdentifiers *identifiers, | |
while (!belowThresholdUnidentifiedCentroids.empty() || !aboveThresholdUnidentifiedCentroids.empty()) { | ||
IRUnidentifiedCentroid *nextUnidentifiedCentroid | ||
= SelectNextUnidentifiedCentroid(&aboveThresholdUnidentifiedCentroids, &belowThresholdUnidentifiedCentroids); | ||
if (nextUnidentifiedCentroid == NULL) { | ||
if (nextUnidentifiedCentroid == nullptr) { | ||
break; | ||
} | ||
|
||
|
@@ -574,7 +574,7 @@ StarIdentifiers PyramidStarIdAlgorithm::Go( | |
StarIdentifiers identified; | ||
MultiDatabase multiDatabase(database); | ||
const unsigned char *databaseBuffer = multiDatabase.SubDatabasePointer(PairDistanceKVectorDatabase::kMagicValue); | ||
if (databaseBuffer == NULL || stars.size() < 4) { | ||
if (databaseBuffer == nullptr || stars.size() < 4) { | ||
std::cerr << "Not enough stars, or database missing." << std::endl; | ||
return identified; | ||
} | ||
|
@@ -643,7 +643,7 @@ StarIdentifiers PyramidStarIdAlgorithm::Go( | |
/ std::max(std::max(iSinInner, jSinInner), kSinInner); | ||
|
||
if (expectedMismatches > maxMismatchProbability) { | ||
std::cout << "skip: mismatch prob." << std::endl; | ||
std::cerr << "skip: mismatch prob." << std::endl; | ||
continue; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you choose to change this one typedef among all the typedefs. There's probably about a dozen other typedefs