Repository navigation
Use entire road geometry for NameSimilarityEdgeFilter - #2320
Conversation
| private static BBox createBBox(NodeAccess na, EdgeIteratorState edgeState) { | ||
| return BBox.fromPoints(na.getLat(edgeState.getBaseNode()), na.getLon(edgeState.getBaseNode()), | ||
| na.getLat(edgeState.getAdjNode()), na.getLon(edgeState.getAdjNode())); | ||
| private static BBox createBBox(EdgeIteratorState edgeState) { |
There was a problem hiding this comment.
This method was no longer used since #1950, but it did the same wrong thing (exclude pillar nodes)
| PointList geometry = edgeState.fetchWayGeometry(FetchMode.ALL); | ||
| BBox bbox = new BBox(180, -180, 90, -90); | ||
| for (int i = 0; i < geometry.getSize(); i++) { | ||
| bbox.minLon = Math.min(bbox.minLon, geometry.getLon(i)); | ||
| bbox.maxLon = Math.max(bbox.maxLon, geometry.getLon(i)); | ||
| bbox.minLat = Math.min(bbox.minLat, geometry.getLat(i)); | ||
| bbox.maxLat = Math.max(bbox.maxLat, geometry.getLat(i)); | ||
| } |
There was a problem hiding this comment.
Finding the bounds of a point list is maybe something we do elsewhere already and we could create a helper method for this otherwise. Unfortunately I could not find something like it. -> Ah we have BBox#update, I updated this.
Btw. why has PointList getSize() and size()? And looking at point list I was not even sure if (should be ok)size() really returns the number of elements or rather the capacity?!
There was a problem hiding this comment.
Maybe we should store the bounds of each edge including the geometry for such use cases. There are two very similar todos here:
graphhopper/core/src/main/java/com/graphhopper/storage/GraphEdgeIdFinder.java
Lines 226 to 228 in e806a5c
| na.getLat(edgeState.getAdjNode()), na.getLon(edgeState.getAdjNode())); | ||
| private static BBox createBBox(EdgeIteratorState edgeState) { | ||
| // we should include the entire geometry, see #2319 | ||
| PointList geometry = edgeState.fetchWayGeometry(FetchMode.ALL); |
There was a problem hiding this comment.
I've seen this usage pattern a few times now. We create a PointList only to do some logic with each point and throw it away later. Wouldn't it be better to be able to consume them on-the-fly with a visitor pattern?
e.g edgeState.visitWayGeometry(FetchMode.ALL, visitor);
There was a problem hiding this comment.
Yes, maybe. But for this case I wonder if we should simply store the bounding box for each edge. It looks like this would improve the code in GraphEdgeIdFinder and CustomWeightingHelper as well?! (but obviously we'd have to measure the difference to actually know if it makes a difference).
There was a problem hiding this comment.
I wonder if we should simply store the bounding box for each edge.
My europe import logs roughly 92 million edges. That's about 2.8GB of bbox information if we stored minlon,minlat,maxlon,maxlat per edge?
There was a problem hiding this comment.
Yes, if we used four doubles (4*8=32bytes). But that would be very wasteful. We can definitely reduce precision there (4*4bytes is more than enough), and maybe we can even just store the indices of the point list. Then maybe 4bytes per edge is enough (assuming no geometry has more than 256 points, but not sure if this is true).
There was a problem hiding this comment.
... and we could probably even somehow restrict this to 'curved' edges only, because for straight edges using the tower node coordinates as bounding box is often sufficient. For example we could store a allPillarNodesWithinTowerNodesBBox bit and only when it is false we would access the additional bbox data. Otherwise we would calculate the bbox from the tower node coordinates. I think there would be very many edges with allPillarNodesWithinTowerNodesBBox=true.
|
I had to fix the routing measurement for point_hint, because so far we always set the point_hint to the name of the very first edge. But to test the speed of the look-ups with point hints I think we should rather use some point hint that cannot be found (worst case scenario in terms of performance). I fixed this here: b8a25d7 and it changed the measured routing CH speed with point hints from about 1.5ms to 1.8ms, so we can probably say that point_hints make route calculation (including location lookup, but no instructions, serialization etc.) about 20% slower. After fixing this I compared the performance (
The difference is less than 3% even on the smaller map where I assume the relative amount of time spent to lookup the locations is larger (because the routes are shorter). I think we can conclude that the bbox/geometry check does not play an important role and not too surprisingly the majority of the additional time we need to use Btw I also did a quick performance comparison for the current scenario where we only use the tower nodes. Not using a |
Fixes #2319