fix bike speed on ped streets. cleanup of speed code

This commit is contained in:
Emil Tin 2012-05-03 13:51:24 +02:00
parent 86128892d7
commit 599c026407
4 changed files with 159 additions and 37 deletions

View File

@ -190,23 +190,27 @@ public:
//Is the highway tag listed as usable way?
if(("track" == highway && ("yes" == access || "yes" == accessTag)) || ("track" != highway && (0 < settings[highway] || "yes" == accessTag || "designated" == accessTag) )) {
if(!w.isDurationSet) {
if(0 < settings[highway]) {
if(0 < maxspeed)
if(settings.takeMinimumOfSpeeds)
w.speed = std::min(settings[highway], maxspeed);
else
w.speed = maxspeed;
else
w.speed = settings[highway];
} else {
if(0 < maxspeed)
if(settings.takeMinimumOfSpeeds)
w.speed = std::min(settings.defaultSpeed, maxspeed);
else w.speed = maxspeed;
else
w.speed = settings.defaultSpeed;
highway = "default";
int speed;
if( accessTag=="yes" || accessTag=="designated" )
speed = std::max( settings.defaultSpeed, settings[highway] );
else if( settings[highway]>0 )
speed = settings[highway];
else {
speed = settings.defaultSpeed;
}
if( !settings[highway]>0 )
highway = "default";
if( maxspeed>0 ) {
if( settings.takeMinimumOfSpeeds )
w.speed = std::min( speed, maxspeed );
else
w.speed = maxspeed;
}
else
w.speed = speed;
}
w.useful = true;

86
features/maxspeed.feature Normal file
View File

@ -0,0 +1,86 @@
@routing @maxspeed
Feature: Speed limits
Note:
60km/h = 100m/6s
30km/h = 100m/12s
15km/h = 100m/24s
10km/h = 100m/48s
5km/h = 100m/72s
Scenario: Obey speedlimits
Given the speedprofile "car"
And the speedprofile settings
| primary | 60 |
And a grid size of 100 meters
And the node map
| a | b |
| c | d |
And the ways
| nodes | highway | maxspeed |
| ab | primary | |
| cd | primary | 30 |
When I route I should get
| from | to | route | time |
| a | b | ab | 6s |
| c | d | cd | 12s |
Scenario: Go faster than speedprofile when takeMinimumOfSpeeds=no
Given the speedprofile "car"
And the speedprofile settings
| residential | 15 |
| takeMinimumOfSpeeds | no |
And a grid size of 100 meters
And the node map
| a | b |
And the ways
| nodes | highway | maxspeed |
| ab | residential | 30 |
When I route I should get
| from | to | route | time |
| a | b | ab | 12s |
Scenario: Bicycles can't go faster just because maxspeed is high
Given the speedprofile "bicycle"
And the speedprofile settings
| primary | 15 |
And a grid size of 100 meters
And the node map
| a | b |
| c | d |
And the ways
| nodes | highway | maxspeed |
| ab | primary | |
| cd | primary | 60 |
When I route I should get
| from | to | route | time |
| a | b | ab | 24s |
| c | d | cd | 24s |
Scenario: Bicycles should also obey maxspeed
Given the speedprofile "bicycle"
And the speedprofile settings
| primary | 15 |
And a grid size of 100 meters
And the node map
| a | b |
| c | d |
And the ways
| nodes | highway | maxspeed |
| ab | primary | |
| cd | primary | 10 |
When I route I should get
| from | to | route | time |
| a | b | ab | 24s |
| c | d | cd | 48s |

View File

@ -6,6 +6,23 @@ Feature: Estimation of travel time
Background: Use specific speeds
Given the speedprofile "bicycle"
And the speedprofile settings
| defaultSpeed | 15 |
| primary | 15 |
| footway | 5 |
Scenario: Time of travelling 100 meters
Given a grid size of 100 meters
Given the node map
| a | b |
And the ways
| nodes | highway |
| ab | primary |
When I route I should get
| from | to | route | time |
| a | b | ab | 24s |
Scenario: Basic travel time, 1m scale
Given a grid size of 1 meters
@ -175,4 +192,18 @@ Feature: Estimation of travel time
| 1 | 4 | ab | 72s |
| 4 | 3 | ab | 24s |
| 4 | 2 | ab | 48s |
| 4 | 1 | ab | 72s |
| 4 | 1 | ab | 72s |
@bike_speed
Scenario: Time of travel when bicycle=yes
Given the node map
| a | b |
| c | d |
And the ways
| nodes | highway | bicycle |
| ab | footway | yes |
When I route I should get
| from | to | route | time |
| a | b | ab | 24s |

View File

@ -1,23 +1,24 @@
[car]
accessTag = motorcar
defaultSpeed = 50
obeyOneways = yes
useRestrictions = yes
barrier = bollard
accessTag = motorcar
defaultSpeed = 60
obeyOneways = yes
useRestrictions = yes
barrier = bollard
takeMinimumOfSpeeds = yes
motorway = 100
motorway_link = 90
trunk = 90
trunk_link = 70
primary = 70
primary_link = 60
secondary = 60
secondary_link = 50
tertiary = 50
tertiary_link = 40
road = 40
residential = 40
unclassified = 30
service = 20
living_street = 10
motorway = 110
motorway_link = 90
trunk = 90
trunk_link = 70
primary = 70
primary_link = 60
secondary = 60
secondary_link = 50
tertiary = 50
tertiary_link = 40
road = 40
residential = 40
unclassified = 30
service = 20
living_street = 10