Skip to content
This repository has been archived by the owner on Mar 1, 2021. It is now read-only.

Dedupe query results #91

Merged
merged 2 commits into from
Jan 18, 2017
Merged

Conversation

stefanholder
Copy link
Contributor

@stefanholder stefanholder commented Jan 12, 2017

Dedupes the QueryResults of each GPX entry by node id after calling QueryGraph.lookup as discussed in #81. This only dedupes tower nodes but not virtual nodes since there is at most one QueryResult per edge and virtual nodes are inserted into the middle of an edge.

Reducing the number of QueryResults improves performance since less shortest/fastest routes need to be computed.

Also updated README.md.

public List<QueryResult> findNClosest(final double queryLat, final double queryLon, final EdgeFilter edgeFilter,
double gpxAccuracyInMetern) {
/**
* Returns all edges whose starting points are within the specified radius around the
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karussell: Can you please check if this javadoc comment is correct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd reword it to make it clearer that there's no (general) guarantee it finds all such edges (due to searching only nine tiles).

Copy link
Member

@karussell karussell Jan 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no guarantee if the distance is larger than the cell radius which is usually not the case

Copy link
Contributor Author

@stefanholder stefanholder Jan 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of writing "Returns all edges whose starting points are within the specified radius ..." is it correct to write "Returns all edges that are within the specified radius ..."?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you mean this part. Yes, this version would be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}
return gpxEntryLocations;
}

private List<Collection<QueryResult>> dedupeQueryResultsByClosestNode(
List<Collection<QueryResult>> queriesPerEntry) {
final List<Collection<QueryResult>> result = new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here an init would be good: new ArrayList<>(queriesPerEntry.size())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

List<Collection<QueryResult>> queriesPerEntry) {
final List<Collection<QueryResult>> result = new ArrayList<>();

final Comparator<QueryResult> dedupeComparator = new Comparator<QueryResult>() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of comparator and TreeSet can we use a HashMap<closest node, query result>? (less memory intense as array based)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@stefanholder
Copy link
Contributor Author

I added a commit with the changes discussed above. I will squash this with the previous commit when the PR is approved.

Copy link
Member

@karussell karussell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

// QueryResult nodes with virtual nodes. Virtual nodes are not deduped since there is at
// most one QueryResult per edge and virtual nodes are inserted into the middle of an edge.
// Reducing the number of QueryResults improves performance since less shortest/fastest
// routes need to be computed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you add a "See #91" here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this PR does not contain additional information I don't see the benefit of this. But I will do this if you generally prefer linking to PRs from the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the number "#91" no link?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - please feel free to merge or squash (hope this works :)) ... BTW: have now enabled both again as often it is very convenient to avoid manual squashing. But will deactivate it as soon as we see this does not work well somehow

stefanholder added a commit to stefanholder/map-matching that referenced this pull request Jan 17, 2017
@stefanholder
Copy link
Contributor Author

Squashed commits.

@stefanholder
Copy link
Contributor Author

Referenced PR in commit messages.

@karussell
Copy link
Member

Thanks - do you want to merge it or prefer that I do it?

@stefanholder
Copy link
Contributor Author

Thanks - do you want to merge it or prefer that I do it?

It's probably cleaner if a reviewer does the merge.

@karussell
Copy link
Member

It's probably cleaner if a reviewer does the merge.

Good point!

@karussell karussell merged commit bcbb7d2 into graphhopper:master Jan 18, 2017
@karussell karussell added this to the 0.9 milestone Jan 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants