Clarify API and ensure bearings returned to users are in the range 0-359
This commit is contained in:
		
							parent
							
								
									84b618ed1a
								
							
						
					
					
						commit
						1b51163b1d
					
				@ -1,3 +1,8 @@
 | 
			
		||||
# 5.5.1
 | 
			
		||||
  - Changes from 5.5.0
 | 
			
		||||
    - Bugfixes
 | 
			
		||||
      - Fix #3418 and ensure we only return bearings in the range 0-359 in API responses
 | 
			
		||||
 | 
			
		||||
# 5.5.0
 | 
			
		||||
  - Changes from 5.4.0
 | 
			
		||||
    - API:
 | 
			
		||||
 | 
			
		||||
@ -577,9 +577,9 @@ step.
 | 
			
		||||
 | 
			
		||||
- `location`: A `[longitude, latitude]` pair describing the location of the turn.
 | 
			
		||||
- `bearing_before`: The clockwise angle from true north to the
 | 
			
		||||
  direction of travel immediately before the maneuver.
 | 
			
		||||
  direction of travel immediately before the maneuver.  Range 0-359.
 | 
			
		||||
- `bearing_after`: The clockwise angle from true north to the
 | 
			
		||||
  direction of travel immediately after the maneuver.
 | 
			
		||||
  direction of travel immediately after the maneuver.  Range 0-359.
 | 
			
		||||
- `type` A string indicating the type of maneuver. **new identifiers might be introduced without API change**
 | 
			
		||||
   Types  unknown to the client should be handled like the `turn` type, the existance of correct `modifier` values is guranteed.
 | 
			
		||||
  
 | 
			
		||||
@ -676,7 +676,7 @@ location of the StepManeuver. Further intersections are listed for every cross-w
 | 
			
		||||
**Properties**
 | 
			
		||||
 | 
			
		||||
- `location`: A `[longitude, latitude]` pair describing the location of the turn.
 | 
			
		||||
- `bearings`: A list of bearing values (e.g. [0,90,180,270]) that are available at the intersection. The bearings describe all available roads at the intersection.
 | 
			
		||||
- `bearings`: A list of bearing values (e.g. [0,90,180,270]) that are available at the intersection. The bearings describe all available roads at the intersection.  Values are between 0-359 (0=true north)
 | 
			
		||||
- `entry`: A list of entry flags, corresponding in a 1:1 relationship to the bearings. A value of `true` indicates that the respective road could be entered on a valid route.
 | 
			
		||||
  `false` indicates that the turn onto the respective road would violate a restriction.
 | 
			
		||||
- `in`: index into bearings/entry array. Used to calculate the bearing just before the turn. Namely, the clockwise angle from true north to the
 | 
			
		||||
 | 
			
		||||
@ -50,3 +50,20 @@ Feature: Features related to bugs
 | 
			
		||||
        And the data has been saved to disk
 | 
			
		||||
        When I try to run "osrm-extract {osm_file} --profile {profile_file}"
 | 
			
		||||
        Then it should exit successfully
 | 
			
		||||
 | 
			
		||||
    @3418
 | 
			
		||||
    Scenario: Bearings should be between 0-359
 | 
			
		||||
        Given the node locations
 | 
			
		||||
            | node | lon          | lat        |
 | 
			
		||||
            | a    | -122.0232176 | 37.3282203 |
 | 
			
		||||
            | b    | -122.0232199 | 37.3302422 |
 | 
			
		||||
            | c    | -122.0232252 | 37.3312787 |
 | 
			
		||||
 | 
			
		||||
        And the ways
 | 
			
		||||
            | nodes | name               | highway     |
 | 
			
		||||
            | ab    | Pear to Merrit     | residential |
 | 
			
		||||
            | bc    | Merritt to Apricot | residential |
 | 
			
		||||
 | 
			
		||||
        When I route I should get
 | 
			
		||||
            | waypoints | route | intersections  |
 | 
			
		||||
            | a,c       | Pear to Merrit,Merritt to Apricot,Merritt to Apricot | true:0;true:0 false:180;true:180  |
 | 
			
		||||
 | 
			
		||||
@ -192,8 +192,8 @@ util::json::Object makeStepManeuver(const guidance::StepManeuver &maneuver)
 | 
			
		||||
            detail::instructionModifierToString(maneuver.instruction.direction_modifier);
 | 
			
		||||
 | 
			
		||||
    step_maneuver.values["location"] = detail::coordinateToLonLat(maneuver.location);
 | 
			
		||||
    step_maneuver.values["bearing_before"] = std::round(maneuver.bearing_before);
 | 
			
		||||
    step_maneuver.values["bearing_after"] = std::round(maneuver.bearing_after);
 | 
			
		||||
    step_maneuver.values["bearing_before"] = std::fmod(std::round(maneuver.bearing_before), 360);
 | 
			
		||||
    step_maneuver.values["bearing_after"] = std::fmod(std::round(maneuver.bearing_after), 360);
 | 
			
		||||
    if (maneuver.exit != 0)
 | 
			
		||||
        step_maneuver.values["exit"] = maneuver.exit;
 | 
			
		||||
 | 
			
		||||
@ -207,9 +207,11 @@ util::json::Object makeIntersection(const guidance::Intersection &intersection)
 | 
			
		||||
    util::json::Array entry;
 | 
			
		||||
 | 
			
		||||
    bearings.values.reserve(intersection.bearings.size());
 | 
			
		||||
    std::copy(intersection.bearings.begin(),
 | 
			
		||||
              intersection.bearings.end(),
 | 
			
		||||
              std::back_inserter(bearings.values));
 | 
			
		||||
    std::transform(
 | 
			
		||||
        intersection.bearings.begin(),
 | 
			
		||||
        intersection.bearings.end(),
 | 
			
		||||
        std::back_inserter(bearings.values),
 | 
			
		||||
        [](const double bearing) -> util::json::Value { return std::fmod(bearing, 360); });
 | 
			
		||||
 | 
			
		||||
    entry.values.reserve(intersection.entry.size());
 | 
			
		||||
    std::transform(intersection.entry.begin(),
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user