-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Clean up FerrySpeedCalculator, use exact edge distance #2528
Conversation
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
if (durationInHours > 0) { | ||
if (estimatedLength != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
estimatedLength == null
can never happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
GHPoint estimatedCenter = null; | |
if (!Double.isNaN(firstLat) && !Double.isNaN(firstLon) && !Double.isNaN(lastLat) && !Double.isNaN(lastLon)) { | |
double estimatedDist = distCalc.calcDist(firstLat, firstLon, lastLat, lastLon); | |
// Add artificial tag for the estimated distance | |
way.setTag("estimated_distance", estimatedDist); | |
estimatedCenter = new GHPoint((firstLat + lastLat) / 2, (firstLon + lastLon) / 2); | |
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this cleanup and the previous work with the new tests :)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_distance
tag is now calledbeeline_distance
and 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_distance
did (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_distance
and we get the full point list of the edge bypoint_list
.More comments inline.