Conversation
|
@emiltin |
|
ok. but is it really needed in the lua profiles then? can the capping be done on the c++ side? |
|
it is needed in profiles as the maximal turn penalty that is used in transit routing restrictions. The turn restriction value can be clipped in c++ by removing assertions, but it should be made explicit with warnings |
|
can the profile use a big constant as the max weight, and then let the c++ side cap it according to the current precision? |
fc018a9 to
af92624
Compare
|
all tests are green. profiles can now use constants.max_turn_weight if needed. it's defined as a constant with the value -1. this assumes that negative turn weights are not valid, is that true? this PR is a breaking change changes the profile interface a bit. |
10972c4 to
f46ec93
Compare
|
rebased |
|
travis is failing with link errors: it's compiling for me locally with gcc on linux. not sure why it's failing on travis? |
oxidase
left a comment
There was a problem hiding this comment.
undefined reference error can be related to different Release/Debug options in sol2:
struct S { static const int a = 1; };
int main() { return S::a; }
is ok, but &S::a would require a definition for S::a
| public: | ||
| static const constexpr int SUPPORTED_MIN_API_VERSION = 0; | ||
| static const constexpr int SUPPORTED_MAX_API_VERSION = 1; | ||
| static const constexpr int MAX_TURN_WEIGHT = -1; |
There was a problem hiding this comment.
Negative turn restrictions are correct values #3683
There was a problem hiding this comment.
ok, then of course we cannot use -1 as a special value
| turn_function(turn); | ||
|
|
||
| if( turn.weight == MAX_TURN_WEIGHT ) | ||
| turn.weight = context.properties.GetMaxTurnWeight(); |
There was a problem hiding this comment.
It is better to set here std::min(turn.weight, context.properties.GetMaxTurnWeight()) to avoid MAX_TURN_WEIGHT and print later number of clamped values
There was a problem hiding this comment.
you mean unconditionally cap the value? ie:
turn.weight = std::min(turn.weight, context.properties.GetMaxTurnWeight());what value should the profile use then to indicate max weight?
There was a problem hiding this comment.
the only purpose of the turn penalty maximum weight is to prevent int32_t overflows on c++ side. If turn penalties are modified on c++ then side the maximum value is not needed in Lua, but number of modifications must be reported as a warning.
|
@oxidase adjusted according to your suggestions. let's see what travis thinks. |
TheMarex
left a comment
There was a problem hiding this comment.
General idea is fine, however this is a breaking change to the profile API. That means we need to bump the version and offer a fallback using the global properties.
|
i think it's best to increase the api version to 2, and then incorporate other relevant changes to the api. it can then be merged at an appropriate osrm version change. |
|
library files like handlers.lua are tied to a specific version of the api, for example because it accceses properties.weight_name. |
|
for version 2 of the api we might want to improve the way versioning is handled: #4133 |
58a3ff5 to
6c8b7e4
Compare
TheMarex
left a comment
There was a problem hiding this comment.
Looks good! The only missing pieces are documentation now:
-
docs/profile.mdneeds to be updated -
CHANGELOG.mdneeds an entry for5.10
|
is it correctly understood that the weight is just the inverse of the rate? and that setting output.weight in way_function is just a shorthand for setting both forward and backward rates? should we change output.weigh to output.rate? |
|
seems that weight = distance/rate. i'm trying to explain this in doc/profiles.md Understanding speed, weight, rate and distanceWhen computing a route from A to B there can be different measure of what is the best route. Because speeds very on differnt types of roads, the shortest and the fastest route are typically different. But there are many other possible preferences. For example a user might prefer a bicycle route that follow parks or other green areas, even though both duration and distance are a bit longer. To handle this, OSRM doesn't simply choose the ways with the highest speed. Intead it uses the concept of The weight of a way is computed as distance / rate. The weight can be though of as the resistance or cost when passing a way. Routing will prefer ways with low weight. You should set the speed to you best estimante of the actual speed that will be used on a particual way. This will result in the best estimated travel times. If you want to prefer certain ways due to other factors than the speed, adjust the rate accordingly. If you adjust the speed, the time time estimation will be skewed. If you set the same rate on all ways, the result will be shortest path routing. |
|
looking at how raster source data is used i'm wondering about this bit: local sourceData = sources:query(profile.raster_source, segment.source.lon, segment.source.lat)
local invalid = sourceData.invalid_data()
if sourceData.datum ~= invalid then
-- use value in targetData.datumwouldn't it be easier if you could just do: local sourceDatum = sources:query(profile.raster_source, segment.source.lon, segment.source.lat)
if sourceDatum ~= nil then
-- use value in sourceDatumand maybe we should rename source to something like raster_data? sources seems like a very generic word. |
I think this is due to the fact that the C++ code will return an integer always. Probably needs a shim in the bindings to make this return
Hrm yeah what about |
|
makes sense. however i'm confused by your statement that rate depends on the geometric length on the way. isn't it the other way around: weight depends on the length of the way, while rate does not? . |
|
@emiltin yes, I meant you need the |
|
alright. if you set the weight, are the rates then ignored? |
|
why is there no forward_weight and backward_weight? |
2611c38 to
b27d45f
Compare
|
updated docs/profiles.md. might need a few adjustments regarding weight and rate. |
|
@emiltin just because we don't have |
40fa316 to
13a1769
Compare
|
updated changelog and rebased on master. |
docs/profiles.md
Outdated
| The weight of a way normally computed as length / rate. The weight can be though of as the resistance or cost when passing the way. Routing will prefer ways with low weight. | ||
|
|
||
| As you scroll down the file you'll see local variables, and then local functions, and finally... | ||
| You can also set the weight og a way to a fixed value, In this case it's not calculated based on the length or rate, and the rate is ignored. |
There was a problem hiding this comment.
typo the weight of a way to a fixed value
docs/profiles.md
Outdated
| To handle this, OSRM doesn't simply choose the ways with the highest speed. Intead it uses the concept of `weight` and `rate`. The rate is an abstract meassure that you can assign to ways as you like to make some ways preferable to others. Routing will prefer ways with high rate. | ||
|
|
||
| Towards the top of the file, a profile (such as [car.lua](../profiles/car.lua)) will typically define various configurations as global variables. A lot of these are look-up hashes of one sort or another. | ||
| The weight of a way normally computed as length / rate. The weight can be though of as the resistance or cost when passing the way. Routing will prefer ways with low weight. |
13a1769 to
3dd01cc
Compare
|
i ran the changelog through a spell checker (US english) and corrected a number of errors. |
|
should this wiki page https://github.com/Project-OSRM/osrm-backend/blob/master/docs/profiles.md be updated, or replaced with a reference to the file in the repo? |
|
@emiltin I think a link to the repo-docs would be best. |
|
ah, the main wiki page already uses a link to the repo file. |
Routing on proposed ways was blacklisted only for car profile. This adds the same blacklisting also for foot and bike profiles. It looks like this behavior was added in Project-OSRM/osrm-backend#4258 and then accidentally reverted when pull request with title "profiles api v2" at Project-OSRM/osrm-backend#4072 was merged. This commit restores the original change for bike and foot profiles.
improves the profile API and bumps the version from 1 to 2.
Tasklist
Requirements / Relations
This is a breaking change of the profile API.