-
Notifications
You must be signed in to change notification settings - Fork 84
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
Issue 73 #81
Issue 73 #81
Conversation
still need to add some more unit tests so this doesn't happen again
also ended up having to sort the distance-node pairs properly that come out of ch. for some reason ch gives the top N number of POIs, but not necessarily in the right order, so we have to sort by distance. In the case that we want the POI ids of the N closest POIs, we neeed to sort the node_ids by distance, so we use std::pair, which is painful but is par for the course for C++. anyway it gave the right result both before and after
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.
Good findings!
void ContractionHierarchies::createPOIIndex(unsigned categoryNum, unsigned maxDistanceToConsider, unsigned maxNumberOfPOIsInBucket){ | ||
CHASSERT(this->staticGraph != NULL, "Preprocessing not finished"); | ||
// reinitialize this bucket | ||
poiIndexArray[categoryNum] = CHPOIIndex(this->staticGraph, maxDistanceToConsider, maxNumberOfPOIsInBucket, numberOfThreads); |
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.
I think it's a good idea to check if the categoryNum is bigger than poiIndexArray size (given that's a std::vector), just in case.
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.
Looks good to me. Thanks for figuring this important bugfix, no problem to cut a new release.
@federicofernandez I added the check you asked for. Also do I need to call the destructor of the old index to not have a memory leak? |
Regarding the |
@federicofernandez that's what I thought but wanted an expert to double check. I think this is ready to merge, and I think we'll need to do a new release. Do we have any users that can look at the results visually (like on a map) and see if it works? |
This, I am hoping fixes #73.
There were two things broken here. First, when calling set_pois, we call the underlying set_pois routine in CH, which doesn't actually re-initialize the category, it just adds pois. This is not what was expected so I had to add the code to re-initialize. This behavior has actually been around since day 1.
Second, the code from 2 years ago which returned poi ids in addition to poi distances introduced a bug which doesn't return the first poi id encountered, which is a fairly egregious error.
@pksohn unfortunately because of this last one, I think we will have to cut a new release of pandana once we get this PR merged.