Skip to content
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

Closed
wants to merge 3 commits into from
Closed

Issue 73 #81

wants to merge 3 commits into from

Conversation

fscottfoti
Copy link
Contributor

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.

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
@coveralls
Copy link

coveralls commented May 12, 2017

Coverage Status

Coverage increased (+1.0%) to 89.372% when pulling f224eaa on issue-73 into 1e47450 on master.

Copy link
Contributor

@federicofernandez federicofernandez left a 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);
Copy link
Contributor

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.

Copy link
Contributor

@pksohn pksohn left a 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.

@fscottfoti
Copy link
Contributor Author

@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?

@coveralls
Copy link

coveralls commented May 12, 2017

Coverage Status

Coverage increased (+1.0%) to 89.372% when pulling 134788e on issue-73 into 1e47450 on master.

@federicofernandez
Copy link
Contributor

Regarding the CHPOIIndex destructor call, it will be automatically called when removed from the container. Then, if that class was properly designed, we shouldn't be generating any memory leak.

@fscottfoti
Copy link
Contributor Author

@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?

@fscottfoti fscottfoti closed this Jun 24, 2017
@fscottfoti fscottfoti deleted the issue-73 branch June 24, 2017 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Different results when making multiple calls with nearest_pois
4 participants