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

Avoids out of bounds exception in addTrafficToSource() #384

Merged
merged 4 commits into from
Oct 17, 2017
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Mapbox welcomes participation and contributions from everyone.

### v0.6.2 - October 7, 2017

* Fixed an issue with the Location Engine not being activated correctly inside the Navigation-UI lib [#321](https://github.com/mapbox/mapbox-navigation-android/pull/321)
* Fixed bottom sheet not getting placed correctly when the device is rotated [#320](https://github.com/mapbox/mapbox-navigation-android/pull/320)
* Fixed missing reroute UI when a navigation session reroute occurs [#319](https://github.com/mapbox/mapbox-navigation-android/pull/319)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,16 @@ private FeatureCollection addTrafficToSource(DirectionsRoute route) {
if (leg.getAnnotation() != null) {
if (leg.getAnnotation().getCongestion() != null) {
for (int i = 0; i < leg.getAnnotation().getCongestion().length; i++) {
double[] startCoord = lineString.getCoordinates().get(i).getCoordinates();
double[] endCoord = lineString.getCoordinates().get(i + 1).getCoordinates();

LineString congestionLineString = LineString.fromCoordinates(new double[][] {startCoord, endCoord});
Feature feature = Feature.fromGeometry(congestionLineString);
feature.addStringProperty(CONGESTION_KEY, leg.getAnnotation().getCongestion()[i]);
features.add(feature);
// See https://github.com/mapbox/mapbox-navigation-android/issues/353
if (leg.getAnnotation().getCongestion().length + 1 <= lineString.getCoordinates().size()) {
double[] startCoord = lineString.getCoordinates().get(i).getCoordinates();
double[] endCoord = lineString.getCoordinates().get(i + 1).getCoordinates();

LineString congestionLineString = LineString.fromCoordinates(new double[][] {startCoord, endCoord});
Feature feature = Feature.fromGeometry(congestionLineString);
feature.addStringProperty(CONGESTION_KEY, leg.getAnnotation().getCongestion()[i]);
features.add(feature);
}
}
}
} else {
Expand Down