Skip to content
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

Added logic to deal with roundabout instructions that involve a high … #155

Merged
merged 1 commit into from
Mar 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed the coordinate precision in the geojson export from 4 to 6 decimals (Issue #136)
- Fixed the instructions='false' error when exporting as geojson (Issue #138)
- Fixed missing summary in the geojson output (Issue #139)
- Fixed error when a high exit number for a roundabout is used in instructions (Issue #145)

### Changed
- Updated logging so that stack traces are only output when debug logging is enabled (Issue #148)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,28 @@ public String getRoundabout(int exitNumber, String wayName)
boolean isWayNull = Helper.isEmpty(wayName);
String str = isWayNull ? _actionRoundaboutDefault: _actionRoundaboutName;
boolean isExitNull = (exitNumber == 0);
boolean highNumber = false;

// We need to check if the exit number is greater than 10, as that is the most we have in the n-th representation
highNumber = (exitNumber > _numerals.length-1);

//If there was an error in finding the exit number, return "UNKNOWN". If there is no way name, don't return a way name
if(isExitNull)
str = str.replace("{exit_number}", "UNKNOWN");
else
str = str.replace("{exit_number}", _numerals[exitNumber]);
else {
String numeral = "";
if(highNumber) {
// if it is a high number which is very rare, then we dont use the numeral representation, just the
// number itself
// Converting to the th is too complicated due to exceptions and the position of the "th"

numeral = Integer.toString(exitNumber);
} else {
numeral = _numerals[exitNumber];
}

str = str.replace("{exit_number}", numeral);
}
if (isWayNull)
return str;
else
Expand Down