Repository navigation
Clean up FerrySpeedCalculator, use exact edge distance - #2528
Conversation
| private final double unknownSpeed, maxSpeed; | ||
|
|
||
| public FerrySpeedCalculator(double speedFactor, double maxSpeed, double longSpeed, double shortSpeed, double unknownSpeed) { | ||
| public FerrySpeedCalculator(double speedFactor, double maxSpeed, double unknownSpeed) { |
There was a problem hiding this comment.
longSpeed and shortSpeed were never used, because the distance was never missing (see below). At least when this code was used with our OSMReader. Also note that longSpeed and shortSpeed made no sense anyway for some encoders, because they exceeded maxSpeed (and this was not accounted for here). Even worse: maxSpeed is used in some (but not all) cases to cap the speed.
| // Check if our graphhopper specific artificially created estimated_distance way tag is present | ||
| Number estimatedLength = way.getTag("estimated_distance", null); | ||
| if (durationInHours > 0) { | ||
| if (estimatedLength != null) { |
There was a problem hiding this comment.
estimatedLength == null can never happen.
There was a problem hiding this comment.
I understand this now: Before #2448, #2457, cb38af6, estimatedLength == null could happen when the first/last OSM node of a ferry way was missing:
graphhopper/core/src/main/java/com/graphhopper/reader/osm/OSMReader.java
Lines 206 to 212 in f95397b
And the reason we have to consider the distance of the entire way is that 1) the duration tag refers to the duration of the entire way and 2) ferry ways sometimes intersect and are thus split into several edges for which we cannot directly use the duration tag.
|
Thanks for taking a look. I think we can merge here, but this is probably not finished yet. I still don't like how the |
| } else if (durationInHours > 1) { | ||
| // lengthy ferries should be faster than short trip ferry | ||
| return longSpeed; | ||
| } else { | ||
| return shortSpeed; | ||
| } |
There was a problem hiding this comment.
lengthy ferries should be faster than short trip ferry
I still think this is something we might have to do. If the duration tag is missing we probably should apply a faster speed for long ferries than for short ones. Especially because the unknownSpeed is very slow (5km/h). There is probably no ferry that crosses the sea at 5km/h. But so far we only applied this long/shortSpeed when the distance was missing (which never happened anyway), not when the duration was missing, or at least we only distinguished between "very slow/unknownSpeed and "as slow as possible"/speedFactor / 2 in this case.
We probably need to figure out how often the duration is missing and if yes if it is sometimes missing also for longer ferries. I can imagine that mappers skip the duration tag for short ferries that just cross a river, but for longer distance ferries this seems like a mapping error and we could even print a warning, report this to OSM and/or skip the ferry in this case. I opened #2532 for this.
There was a problem hiding this comment.
We probably need to figure out how often the duration is missing and if yes if it is sometimes missing also for longer ferries.
It is in fact missing in very many cases and also for longer ferries like this one: https://www.openstreetmap.org/way/999670971. More precisely, around 21400 of 24400 (87%) ferries are missing the duration tag and around 10% of them are longer than 20km. Simply falling back to the unknownSpeed=5km/h is thus not a good idea. Here is the route. The average speed is 6km/h (unknownSpeed=5, but rounded to 6, because of speedFactor=2). It takes more than eleven days when really this ferry only needs around two (35km/h).
|
There is another problem: Some ferry ways share nodes with each other, for example 'Burgeo - Ramea' and 'Grey River - Ramea' here: https://www.openstreetmap.org/way/168781977. This means that since #2448 we use the duration tag of the OSM way, even though they only represent a part of the ferry way. In this case we fall back to the |
# Conflicts: # CHANGELOG.md # core/src/main/java/com/graphhopper/reader/osm/OSMReader.java
Work for #2526.
The
estimated_distancetag is now calledbeeline_distanceand represents the straight line distance between the tower nodes of the edge, not the straight line distance between the first and last nodes of the OSM way asestimated_distancedid (at some point). We can also use this for the bendiness calculation withoutapplyWayTags(see #2469). The actual length of the road/edge is now stored in an artificial tagroad_distanceand we get the full point list of the edge bypoint_list.More comments inline.