Skip to content

Commit

Permalink
Merge pull request #227 from heremaps/esd/41350
Browse files Browse the repository at this point in the history
Update example apps for release 4.13.5.0
  • Loading branch information
HERE-SDK-Support-Team authored Mar 30, 2023
2 parents eaf4188 + 35b220c commit d1baba6
Show file tree
Hide file tree
Showing 13 changed files with 204 additions and 118 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ For an overview of the existing features, please check the _Developer's Guide_ f

> For now, the _Navigate Edition_ is only available upon request. Please contact your HERE representative to receive access including a set of evaluation credentials.
## List of Available Example Apps (Version 4.13.4.0)
## List of Available Example Apps (Version 4.13.5.0)

- **HelloMap**: Shows the classic 'Hello World'.
- **HelloMapKotlin**: Shows the classic 'Hello World' using Kotlin language (Android only).
Expand Down
2 changes: 1 addition & 1 deletion examples/latest/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This folder contains the HERE SDK examples apps for version: 4.13.4.0
This folder contains the HERE SDK examples apps for version: 4.13.5.0

- HERE SDK for Android ([Lite Edition](lite/android/), [Explore Edition](explore/android/), [Navigate Edition](navigate/android/))
- HERE SDK for iOS ([Lite Edition](lite/ios/), [Explore Edition](explore/ios/), [Navigate Edition](navigate/ios/))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.here.sdk.core.GeoPolyline;
import com.here.sdk.core.Point2D;
import com.here.sdk.core.errors.InstantiationErrorException;
import com.here.sdk.core.threading.TaskHandle;
import com.here.sdk.mapview.MapCamera;
import com.here.sdk.mapview.MapImage;
import com.here.sdk.mapview.MapImageFactory;
Expand Down Expand Up @@ -125,15 +126,15 @@ private void logRouteViolations(Route route) {
private void logRouteSectionDetails(Route route) {
DateFormat dateFormat = new SimpleDateFormat("HH:mm");

for (int i = 0; i< route.getSections().size(); i++) {
for (int i = 0; i < route.getSections().size(); i++) {
Section section = route.getSections().get(i);

Log.d(TAG, "Route Section : " + (i+1));
Log.d(TAG, "Route Section : " + (i + 1));
Log.d(TAG, "Route Section Departure Time : "
+ dateFormat.format(section.getDepartureLocationTime().localTime));
Log.d(TAG, "Route Section Arrival Time : "
+ dateFormat.format(section.getArrivalLocationTime().localTime));
Log.d(TAG, "Route Section length : " + section.getLengthInMeters() + " m");
Log.d(TAG, "Route Section length : " + section.getLengthInMeters() + " m");
Log.d(TAG, "Route Section duration : " + section.getDuration().getSeconds() + " s");
}
}
Expand All @@ -144,8 +145,8 @@ private void showRouteDetails(Route route) {
int lengthInMeters = route.getLengthInMeters();

String routeDetails = "Travel Time: " + formatTime(estimatedTravelTimeInSeconds)
+ ", traffic delay: " + formatTime(estimatedTrafficDelayInSeconds)
+ ", Length: " + formatLength(lengthInMeters);
+ ", traffic delay: " + formatTime(estimatedTrafficDelayInSeconds)
+ ", Length: " + formatLength(lengthInMeters);

showDialog("Route Details", routeDetails);
}
Expand Down Expand Up @@ -265,8 +266,19 @@ private void clearRoute() {

// This renders the traffic flow on top of the route as multiple MapPolylines per span.
private void showTrafficOnRoute(Route route) {
if (route.getLengthInMeters() / 1000 > 5000) {
Log.d(TAG, "Skip showing traffic-on-route for longer routes.");
return;
}

for (Section section : route.getSections()) {
for (Span span : section.getSpans()) {
TrafficSpeed trafficSpeed = span.getTrafficSpeed();
Color lineColor = getTrafficColor(trafficSpeed.jamFactor);
if (lineColor == null) {
// We skip rendering low traffic.
continue;
}
GeoPolyline spanGeoPolyline;
try {
// A polyline needs to have two or more coordinates.
Expand All @@ -276,8 +288,6 @@ private void showTrafficOnRoute(Route route) {
return;
}
float widthInPixels = 10;
TrafficSpeed trafficSpeed = span.getTrafficSpeed();
Color lineColor = getTrafficColor(trafficSpeed.jamFactor);
MapPolyline trafficSpanMapPolyline = new MapPolyline(spanGeoPolyline, widthInPixels, lineColor);
mapView.getMapScene().addMapPolyline(trafficSpanMapPolyline);
mapPolylines.add(trafficSpanMapPolyline);
Expand All @@ -290,9 +300,11 @@ private void showTrafficOnRoute(Route route) {
// 4 <= jamFactor < 8: Moderate or slow traffic.
// 8 <= jamFactor < 10: Severe traffic.
// jamFactor = 10: No traffic, ie. the road is blocked.
// Returns null in case of no or light traffic.
@Nullable
private Color getTrafficColor(Double jamFactor) {
if (jamFactor == null || jamFactor < 4) {
return Color.valueOf(0, 0, 0, 0); // Fully transparent (RGBA)
return null;
} else if (jamFactor >= 4 && jamFactor < 8) {
return Color.valueOf(1, 1, 0, 0.63f); // Yellow
} else if (jamFactor >= 8 && jamFactor < 10) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,19 @@ class RoutingExample {

// This renders the traffic flow on top of the route as multiple MapPolylines per span.
_showTrafficOnRoute(here.Route route) {
if (route.lengthInMeters / 1000 > 5000) {
print("Skip showing traffic-on-route for longer routes.");
return;
}

for (var section in route.sections) {
for (var span in section.spans) {
TrafficSpeed trafficSpeed = span.trafficSpeed;
Color? lineColor = _getTrafficColor(trafficSpeed.jamFactor);
if (lineColor == null) {
// We skip rendering low traffic.
continue;
}
GeoPolyline spanGeoPolyline;
try {
// A polyline needs to have two or more coordinates.
Expand All @@ -162,8 +173,6 @@ class RoutingExample {
return;
}
double widthInPixels = 10;
TrafficSpeed trafficSpeed = span.trafficSpeed;
Color lineColor = _getTrafficColor(trafficSpeed.jamFactor ?? 0);
MapPolyline trafficSpanMapPolyline = new MapPolyline(spanGeoPolyline, widthInPixels, lineColor);
_hereMapController.mapScene.addMapPolyline(trafficSpanMapPolyline);
_mapPolylines.add(trafficSpanMapPolyline);
Expand All @@ -176,9 +185,10 @@ class RoutingExample {
// 4 <= jamFactor < 8: Moderate or slow traffic.
// 8 <= jamFactor < 10: Severe traffic.
// jamFactor = 10: No traffic, ie. the road is blocked.
Color _getTrafficColor(double jamFactor) {
if (jamFactor < 4) {
return Color.fromARGB(0, 0, 0, 0); // Fully transparent
// Returns null in case of no or light traffic.
Color? _getTrafficColor(double? jamFactor) {
if (jamFactor == null || jamFactor < 4) {
return null;
} else if (jamFactor >= 4 && jamFactor < 8) {
return Color.fromARGB(160, 255, 255, 0); // Yellow
} else if (jamFactor >= 8 && jamFactor < 10) {
Expand Down
49 changes: 31 additions & 18 deletions examples/latest/explore/ios/Routing/Routing/RoutingExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ class RoutingExample {
}
}
}

private func logRouteSectionDetails(route: Route) {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "HH:mm"

for (i, sections) in route.sections.enumerated() {
print("Route Section : " + String(i));
print("Route Section Departure Time : " + dateFormatter.string(from: sections.departureLocationTime!.localTime));
Expand All @@ -96,7 +96,7 @@ class RoutingExample {
let estimatedTravelTimeInSeconds = route.duration
let estimatedTrafficDelayInSeconds = route.trafficDelay
let lengthInMeters = route.lengthInMeters

let routeDetails = "Travel Time (h:m): " + formatTime(sec: estimatedTravelTimeInSeconds)
+ ", Traffic Delay (h:m): " + formatTime(sec: estimatedTrafficDelayInSeconds)
+ ", Length: " + formatLength(meters: lengthInMeters)
Expand All @@ -121,7 +121,7 @@ class RoutingExample {
private func showRouteOnMap(route: Route) {
// Optionally, clear any previous route.
clearMap()

// Show route as polyline.
let routeGeoPolyline = route.geometry
let routeMapPolyline = MapPolyline(geometry: routeGeoPolyline,
Expand All @@ -135,10 +135,10 @@ class RoutingExample {

// Optionally, render traffic on route.
showTrafficOnRoute(route)

let startPoint = route.sections.first!.departurePlace.mapMatchedCoordinates
let destination = route.sections.last!.arrivalPlace.mapMatchedCoordinates

// Draw a circle to indicate starting point and destination.
addCircleMapMarker(geoCoordinates: startPoint, imageName: "green_dot.png")
addCircleMapMarker(geoCoordinates: destination, imageName: "green_dot.png")
Expand Down Expand Up @@ -201,17 +201,26 @@ class RoutingExample {

// This renders the traffic flow on top of the route as multiple MapPolylines per span.
private func showTrafficOnRoute(_ route: Route) {
if route.lengthInMeters / 1000 > 5000 {
print("Skip showing traffic-on-route for longer routes.");
return
}

for section in route.sections {
for span in section.spans {
let trafficSpeed = span.trafficSpeed
guard let lineColor = getTrafficColor(trafficSpeed.jamFactor) else {
// Skip rendering low traffic.
continue
}
// A polyline needs to have two or more coordinates.
guard let spanGeoPolyline = try? GeoPolyline(vertices: span.polyline) else {
print("Error: Initialization of GeoPolyline failed.")
return
}
let trafficSpeed = span.trafficSpeed
let trafficSpanMapPolyline = MapPolyline(geometry: spanGeoPolyline,
widthInPixels: 10,
color: getTrafficColor(trafficSpeed.jamFactor ?? 0))
color: lineColor)
mapView.mapScene.addMapPolyline(trafficSpanMapPolyline)
mapPolylineList.append(trafficSpanMapPolyline)
}
Expand All @@ -223,17 +232,21 @@ class RoutingExample {
// 4 <= jamFactor < 8: Moderate or slow traffic.
// 8 <= jamFactor < 10: Severe traffic.
// jamFactor = 10: No traffic, ie. the road is blocked.
private func getTrafficColor(_ jamFactor: Double) -> UIColor {
if (jamFactor < 4) {
return UIColor(red: 0, green: 0, blue: 0, alpha: 0) // Fully transparent
} else if (jamFactor >= 4 && jamFactor < 8) {
return UIColor(red: 1, green: 1, blue: 0, alpha: 0.63) // Yellow
} else if (jamFactor >= 8 && jamFactor < 10) {
return UIColor(red: 1, green: 0, blue: 0, alpha: 0.63) // Red
}
return UIColor(red: 0, green: 0, blue: 0, alpha: 0.63) // Black
// Returns nil in case of no or light traffic.
private func getTrafficColor(_ jamFactor: Double?) -> UIColor? {
guard let jamFactor = jamFactor else {
return nil
}
if jamFactor < 4 {
return nil
} else if jamFactor >= 4 && jamFactor < 8 {
return UIColor(red: 1, green: 1, blue: 0, alpha: 0.63) // Yellow
} else if jamFactor >= 8 && jamFactor < 10 {
return UIColor(red: 1, green: 0, blue: 0, alpha: 0.63) // Red
}
return UIColor(red: 0, green: 0, blue: 0, alpha: 0.63) // Black
}

func clearMap() {
clearWaypointMapMarker()
clearRoute()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,11 @@ public void onRealisticViewWarningUpdated(@NonNull RealisticViewWarning realisti
}

RealisticView realisticView = realisticViewWarning.realisticView;
if (realisticView == null) {
Log.d(TAG, "A RealisticView just passed. No SVG data delivered.");
return;
}

String signpostSvgImageContent = realisticView.signpostSvgImageContent;
String junctionViewSvgImageContent = realisticView.junctionViewSvgImageContent;
// The resolution-independent SVG data can now be used in an application to visualize the image.
Expand All @@ -582,9 +587,9 @@ private String getRoadName(Maneuver maneuver) {
RoadTexts nextRoadTexts = maneuver.getNextRoadTexts();

String currentRoadName = currentRoadTexts.names.getDefaultValue();
String currentRoadNumber = currentRoadTexts.numbers.getDefaultValue();
String currentRoadNumber = currentRoadTexts.numbersWithDirection.getDefaultValue();
String nextRoadName = nextRoadTexts.names.getDefaultValue();
String nextRoadNumber = nextRoadTexts.numbers.getDefaultValue();
String nextRoadNumber = nextRoadTexts.numbersWithDirection.getDefaultValue();

String roadName = nextRoadName == null ? nextRoadNumber : nextRoadName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.here.sdk.core.GeoPolyline;
import com.here.sdk.core.Point2D;
import com.here.sdk.core.errors.InstantiationErrorException;
import com.here.sdk.core.threading.TaskHandle;
import com.here.sdk.mapview.MapCamera;
import com.here.sdk.mapview.MapImage;
import com.here.sdk.mapview.MapImageFactory;
Expand Down Expand Up @@ -125,15 +126,15 @@ private void logRouteViolations(Route route) {
private void logRouteSectionDetails(Route route) {
DateFormat dateFormat = new SimpleDateFormat("HH:mm");

for (int i = 0; i< route.getSections().size(); i++) {
for (int i = 0; i < route.getSections().size(); i++) {
Section section = route.getSections().get(i);

Log.d(TAG, "Route Section : " + (i+1));
Log.d(TAG, "Route Section : " + (i + 1));
Log.d(TAG, "Route Section Departure Time : "
+ dateFormat.format(section.getDepartureLocationTime().localTime));
Log.d(TAG, "Route Section Arrival Time : "
+ dateFormat.format(section.getArrivalLocationTime().localTime));
Log.d(TAG, "Route Section length : " + section.getLengthInMeters() + " m");
Log.d(TAG, "Route Section length : " + section.getLengthInMeters() + " m");
Log.d(TAG, "Route Section duration : " + section.getDuration().getSeconds() + " s");
}
}
Expand All @@ -144,8 +145,8 @@ private void showRouteDetails(Route route) {
int lengthInMeters = route.getLengthInMeters();

String routeDetails = "Travel Time: " + formatTime(estimatedTravelTimeInSeconds)
+ ", traffic delay: " + formatTime(estimatedTrafficDelayInSeconds)
+ ", Length: " + formatLength(lengthInMeters);
+ ", traffic delay: " + formatTime(estimatedTrafficDelayInSeconds)
+ ", Length: " + formatLength(lengthInMeters);

showDialog("Route Details", routeDetails);
}
Expand Down Expand Up @@ -265,8 +266,19 @@ private void clearRoute() {

// This renders the traffic flow on top of the route as multiple MapPolylines per span.
private void showTrafficOnRoute(Route route) {
if (route.getLengthInMeters() / 1000 > 5000) {
Log.d(TAG, "Skip showing traffic-on-route for longer routes.");
return;
}

for (Section section : route.getSections()) {
for (Span span : section.getSpans()) {
TrafficSpeed trafficSpeed = span.getTrafficSpeed();
Color lineColor = getTrafficColor(trafficSpeed.jamFactor);
if (lineColor == null) {
// We skip rendering low traffic.
continue;
}
GeoPolyline spanGeoPolyline;
try {
// A polyline needs to have two or more coordinates.
Expand All @@ -276,8 +288,6 @@ private void showTrafficOnRoute(Route route) {
return;
}
float widthInPixels = 10;
TrafficSpeed trafficSpeed = span.getTrafficSpeed();
Color lineColor = getTrafficColor(trafficSpeed.jamFactor);
MapPolyline trafficSpanMapPolyline = new MapPolyline(spanGeoPolyline, widthInPixels, lineColor);
mapView.getMapScene().addMapPolyline(trafficSpanMapPolyline);
mapPolylines.add(trafficSpanMapPolyline);
Expand All @@ -290,9 +300,11 @@ private void showTrafficOnRoute(Route route) {
// 4 <= jamFactor < 8: Moderate or slow traffic.
// 8 <= jamFactor < 10: Severe traffic.
// jamFactor = 10: No traffic, ie. the road is blocked.
// Returns null in case of no or light traffic.
@Nullable
private Color getTrafficColor(Double jamFactor) {
if (jamFactor == null || jamFactor < 4) {
return Color.valueOf(0, 0, 0, 0); // Fully transparent (RGBA)
return null;
} else if (jamFactor >= 4 && jamFactor < 8) {
return Color.valueOf(1, 1, 0, 0.63f); // Yellow
} else if (jamFactor >= 8 && jamFactor < 10) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ class NavigationExample {
RoadTexts nextRoadTexts = maneuver.nextRoadTexts;

String? currentRoadName = currentRoadTexts.names.getDefaultValue();
String? currentRoadNumber = currentRoadTexts.numbers.getDefaultValue();
String? currentRoadNumber = currentRoadTexts.numbersWithDirection.getDefaultValue();
String? nextRoadName = nextRoadTexts.names.getDefaultValue();
String? nextRoadNumber = nextRoadTexts.numbers.getDefaultValue();
String? nextRoadNumber = nextRoadTexts.numbersWithDirection.getDefaultValue();

String? roadName = nextRoadName == null ? nextRoadNumber : nextRoadName;

Expand Down Expand Up @@ -584,7 +584,12 @@ class NavigationExample {
print("A RealisticView just passed.");
}

RealisticView realisticView = realisticViewWarning.realisticView;
RealisticView? realisticView = realisticViewWarning.realisticView;
if (realisticView == null) {
print("A RealisticView just passed. No SVG content delivered.");
return;
}

String signpostSvgImageContent = realisticView.signpostSvgImageContent;
String junctionViewSvgImageContent = realisticView.junctionViewSvgImageContent;
// The resolution-independent SVG data can now be used in an application to visualize the image.
Expand Down
Loading

0 comments on commit d1baba6

Please sign in to comment.