Skip to content

Issue 218: Autoexpanding search for nodes around a certain coordinate - #221

Closed
JohannesPelzer wants to merge 2 commits into
graphhopper:masterfrom
JohannesPelzer:master
Closed

JohannesPelzer wants to merge 2 commits into
graphhopper:masterfrom
JohannesPelzer:master

Conversation

@JohannesPelzer

Copy link
Copy Markdown
Contributor

Implementation of autoexpanding search, following @karussell his suggestions in #218

@karussell

Copy link
Copy Markdown
Member

Thanks!

  • The region search in the old findNetworkEntriesSingleRegion should be removed
  • Would you mind to make this configurable? So that we can disable it by default until it is mature enough? E.g. reuse the old regionSearch parameter for this but per default regionSearch=false
  • At iteration==0 it should call findNetworkEntriesSingleRegion only once
  • The circle filtering is tricky, I think one has to calculate the spatial key (kind of a 'rounding') and from it one has to calculate the real center. Now it could happen that the query is at the edge of a tile and the radius for the first iteration can be very small (even 0)

@karussell

Copy link
Copy Markdown
Member

I thought a bit about this ... and the filtering this is not necessary! But it is necessary to check the distance r_min of the query location to the boundaries of the 'tile'. And if the distance to the closest point is larger than r_min one has to increase the search EVEN if a close point was found because another point in the other regions could be closer. I'll give you a sketch in a minute.

@karussell

Copy link
Copy Markdown
Member

location-index-special-case

Here X is the query location, C is the closest location if only points of the first tile M are taken into account. And P is the closest point if all necessary 9 tiles are taken into account.

I.e. only if r_min >= r (distance to closest point) we are on the safe side.
And r_min = min(r_min_lat, r_min_lon)

@JohannesPelzer

Copy link
Copy Markdown
Contributor Author

A small sketch how the circle filter should work in respect to the tile borders.
gh218_filteringborders

@karussell

Copy link
Copy Markdown
Member

Ah, yes! That would make it indeed faster!

@karussell

Copy link
Copy Markdown
Member

As discussed, unfortunately this optimization is not possible as we could miss an edge which is closest and has no nodes within the circle. So just grab all the nodes of the tile. The creation of the index makes sure we won't miss close edges with nodes in other tiles.

Then proceed with the next iteration IF r_min < dist(X,C). Important but simple: avoid all nodes which were already processed.

@JohannesPelzer

Copy link
Copy Markdown
Contributor Author

Just for information: There is an additional complication, which will be adressed by the new implementation.
rmin_and_nonsquare_tiles

@karussell

Copy link
Copy Markdown
Member

This sounds really good! But is it a lot more complex to implement?

@JohannesPelzer

Copy link
Copy Markdown
Contributor Author

New code is pushed and should be available.
Some minor changes allow to calculate rMin not only to the border of the current tile, but also to the border of bigger regions. So the case shown above should be covered.

@karussell

Copy link
Copy Markdown
Member

The GraphVisualizer seems interesting, do you have it somewhere :) ?

@karussell

Copy link
Copy Markdown
Member

Hmmh, there is a problem. When I fix the bug in getMinDistance (if dist < min) then I get problematic results. I'll have a look.

@karussell

Copy link
Copy Markdown
Member

BresenhamLine.calcPoints is imprecise - this problem was hidden before as we queried always 9 tiles instead of only 1 and so if the resulting tile of one point wasn't the exact one it didn't matter. But now 1 tile different matters. Ugly to fix, but I will try.

@karussell

Copy link
Copy Markdown
Member

As written in #232 we won't fix this less precise rasterization for now and only exit for every second iteration.

Also found a minor glitch in calculateRMin, which will speed-up all a bit. Will merge soon.

@karussell karussell added this to the 0.4 milestone Jul 11, 2014
@karussell

Copy link
Copy Markdown
Member

Merged: 97b10f1 and thanks again!

Also there was a bug in SpatialKeyAlgo which made the position off by 1/2 * cell_size. I'm wondering that everything worked at all ;) (just joking, was also hidden due to the neighboring search)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants