Add support for classes on bicycle profile
This commit is contained in:
		
							parent
							
								
									9edd161da3
								
							
						
					
					
						commit
						73716bd651
					
				
							
								
								
									
										92
									
								
								features/bicycle/classes.feature
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								features/bicycle/classes.feature
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,92 @@
 | 
			
		||||
@routing @bicycle @mode
 | 
			
		||||
Feature: Bicycle - Mode flag
 | 
			
		||||
    Background:
 | 
			
		||||
        Given the profile "bicycle"
 | 
			
		||||
 | 
			
		||||
    Scenario: Bicycle - We tag ferries with a class
 | 
			
		||||
        Given the node map
 | 
			
		||||
            """
 | 
			
		||||
            a b
 | 
			
		||||
              c d
 | 
			
		||||
            """
 | 
			
		||||
 | 
			
		||||
        And the ways
 | 
			
		||||
            | nodes | highway | route |
 | 
			
		||||
            | ab    | primary |       |
 | 
			
		||||
            | bc    |         | ferry |
 | 
			
		||||
            | cd    | primary |       |
 | 
			
		||||
 | 
			
		||||
        When I route I should get
 | 
			
		||||
            | from | to | route       | turns                                              | classes                  |
 | 
			
		||||
            | a    | d  | ab,bc,cd,cd | depart,notification right,notification left,arrive | [()],[(ferry)],[()],[()] |
 | 
			
		||||
            | d    | a  | cd,bc,ab,ab | depart,notification right,notification left,arrive | [()],[(ferry)],[()],[()] |
 | 
			
		||||
            | c    | a  | bc,ab,ab    | depart,notification left,arrive                    | [(ferry)],[()],[()]      |
 | 
			
		||||
            | d    | b  | cd,bc,bc    | depart,notification right,arrive                   | [()],[(ferry)],[()]      |
 | 
			
		||||
            | a    | c  | ab,bc,bc    | depart,notification right,arrive                   | [()],[(ferry)],[()]      |
 | 
			
		||||
            | b    | d  | bc,cd,cd    | depart,notification left,arrive                    | [(ferry)],[()],[()]      |
 | 
			
		||||
 | 
			
		||||
    Scenario: Bicycle - We tag tunnel with a class
 | 
			
		||||
        Background:
 | 
			
		||||
            Given a grid size of 200 meters
 | 
			
		||||
 | 
			
		||||
        Given the node map
 | 
			
		||||
            """
 | 
			
		||||
            a b
 | 
			
		||||
              c d
 | 
			
		||||
            """
 | 
			
		||||
 | 
			
		||||
        And the ways
 | 
			
		||||
            | nodes | tunnel               |
 | 
			
		||||
            | ab    | no                   |
 | 
			
		||||
            | bc    | yes                  |
 | 
			
		||||
            | cd    |                      |
 | 
			
		||||
 | 
			
		||||
        When I route I should get
 | 
			
		||||
            | from | to | route       | turns                                      | classes                   |
 | 
			
		||||
            | a    | d  | ab,bc,cd,cd | depart,new name right,new name left,arrive | [()],[(tunnel)],[()],[()] |
 | 
			
		||||
 | 
			
		||||
    Scenario: Bicycle - We tag classes without intersections
 | 
			
		||||
        Background:
 | 
			
		||||
            Given a grid size of 200 meters
 | 
			
		||||
 | 
			
		||||
        Given the node map
 | 
			
		||||
            """
 | 
			
		||||
            a b c d
 | 
			
		||||
            """
 | 
			
		||||
 | 
			
		||||
        And the ways
 | 
			
		||||
            | nodes | name | tunnel |
 | 
			
		||||
            | ab    | road |        |
 | 
			
		||||
            | bc    | road | yes    |
 | 
			
		||||
            | cd    | road |        |
 | 
			
		||||
 | 
			
		||||
        When I route I should get
 | 
			
		||||
          | from | to | route     | turns         | classes               |
 | 
			
		||||
          | a    | d  | road,road | depart,arrive | [(),(tunnel),()],[()] |
 | 
			
		||||
 | 
			
		||||
    Scenario: Bicycle - From roundabout on ferry
 | 
			
		||||
        Given the node map
 | 
			
		||||
            """
 | 
			
		||||
                     c
 | 
			
		||||
                  /     \
 | 
			
		||||
            a---b         d---f--h
 | 
			
		||||
                  \     /
 | 
			
		||||
                     e
 | 
			
		||||
                     |
 | 
			
		||||
                     g
 | 
			
		||||
            """
 | 
			
		||||
 | 
			
		||||
        And the ways
 | 
			
		||||
            | nodes | oneway | highway | junction   | route    |
 | 
			
		||||
            | ab    | yes    | service |            |          |
 | 
			
		||||
            | cb    | yes    | service | roundabout |          |
 | 
			
		||||
            | dc    | yes    | service | roundabout |          |
 | 
			
		||||
            | be    | yes    | service | roundabout |          |
 | 
			
		||||
            | ed    | yes    | service | roundabout |          |
 | 
			
		||||
            | eg    | yes    | service |            |          |
 | 
			
		||||
            | df    |        |         |            | ferry    |
 | 
			
		||||
            | fh    | yes    | service |            |          |
 | 
			
		||||
 | 
			
		||||
        When I route I should get
 | 
			
		||||
            | from | to | route          | turns                                                                              | classes                          |
 | 
			
		||||
            | a    | h  | ab,df,df,fh,fh | depart,roundabout-exit-2,exit roundabout slight right,notification straight,arrive | [()],[(),()],[(ferry)],[()],[()] |
 | 
			
		||||
@ -193,6 +193,16 @@ function setup()
 | 
			
		||||
      sett = 10
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    classes = Sequence {
 | 
			
		||||
        'ferry', 'tunnel'
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    -- Which classes should be excludable
 | 
			
		||||
    -- This increases memory usage so its disabled by default.
 | 
			
		||||
    excludable = Sequence {
 | 
			
		||||
--        Set {'ferry'}
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    tracktype_speeds = {
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
@ -650,6 +660,9 @@ function process_way(profile, way, result)
 | 
			
		||||
    -- set name, ref and pronunciation
 | 
			
		||||
    WayHandlers.names,
 | 
			
		||||
 | 
			
		||||
    -- set classes
 | 
			
		||||
    WayHandlers.classes,
 | 
			
		||||
 | 
			
		||||
    -- set weight properties of the way
 | 
			
		||||
    WayHandlers.weights
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -306,37 +306,46 @@ end
 | 
			
		||||
 | 
			
		||||
-- add class information
 | 
			
		||||
function WayHandlers.classes(profile,way,result,data)
 | 
			
		||||
    if not profile.classes then
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    local allowed_classes = Set {}
 | 
			
		||||
    for k, v in pairs(profile.classes) do
 | 
			
		||||
        allowed_classes[v] = true
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    local forward_toll, backward_toll = Tags.get_forward_backward_by_key(way, data, "toll")
 | 
			
		||||
    local forward_route, backward_route = Tags.get_forward_backward_by_key(way, data, "route")
 | 
			
		||||
    local tunnel = way:get_value_by_key("tunnel")
 | 
			
		||||
 | 
			
		||||
    if tunnel and tunnel ~= "no" then
 | 
			
		||||
    if allowed_classes["tunnel"] and tunnel and tunnel ~= "no" then
 | 
			
		||||
      result.forward_classes["tunnel"] = true
 | 
			
		||||
      result.backward_classes["tunnel"] = true
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if forward_toll == "yes" then
 | 
			
		||||
    if allowed_classes["toll"] and forward_toll == "yes" then
 | 
			
		||||
        result.forward_classes["toll"] = true
 | 
			
		||||
    end
 | 
			
		||||
    if backward_toll == "yes" then
 | 
			
		||||
    if allowed_classes["toll"] and backward_toll == "yes" then
 | 
			
		||||
        result.backward_classes["toll"] = true
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if forward_route == "ferry" then
 | 
			
		||||
    if allowed_classes["ferry"] and forward_route == "ferry" then
 | 
			
		||||
        result.forward_classes["ferry"] = true
 | 
			
		||||
    end
 | 
			
		||||
    if backward_route == "ferry" then
 | 
			
		||||
    if allowed_classes["ferry"] and backward_route == "ferry" then
 | 
			
		||||
        result.backward_classes["ferry"] = true
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if result.forward_restricted then
 | 
			
		||||
    if allowed_classes["restricted"] and result.forward_restricted then
 | 
			
		||||
        result.forward_classes["restricted"] = true
 | 
			
		||||
    end
 | 
			
		||||
    if result.backward_restricted then
 | 
			
		||||
    if allowed_classes["restricted"] and result.backward_restricted then
 | 
			
		||||
        result.backward_classes["restricted"] = true
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if data.highway == "motorway" or data.highway == "motorway_link" then
 | 
			
		||||
    if allowed_classes["motorway"] and (data.highway == "motorway" or data.highway == "motorway_link") then
 | 
			
		||||
        result.forward_classes["motorway"] = true
 | 
			
		||||
        result.backward_classes["motorway"] = true
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user