here-android-sdk-examples
here-android-sdk-examples copied to clipboard
How to get current speed limit of the road particularly for the Truck?
Now currently we are calculating speed limit using. Please check wether I am implementing it right or not.
private PositioningManager.OnPositionChangedListener mapPositionHandler = new PositioningManager.OnPositionChangedListener() {
@Override
public void onPositionUpdated(PositioningManager.LocationMethod method, GeoPosition position,
boolean isMapMatched) {
Log.e("PostionChanged", "Called");
if (position.isValid() && position instanceof MatchedGeoPosition) {
MatchedGeoPosition mgp = (MatchedGeoPosition) geoPosition;
float currentSpeedLimit=mgp.getRoadElement().getSpeedLimit();
}
}
@Override
public void onPositionFixChanged(PositioningManager.LocationMethod method,
PositioningManager.LocationStatus status) {
}
};
Hi @binod-techindustan
That is correct. Note, that you must use TransportMode.TRUCK
for route calculation, and then start navigation with that route, then RoadElement
will have truck's speed limit.
Also, you can use NavigationManager.SpeedWarningListener
API to notify user that speed was exceeded or otherwise.
Yes @NazarKacharaba I am setting TransportMode.TRUCK
while creating route.
@NazarKacharaba the issue is freeways speed limit in US for truck is 55 mph in most case but we are getting 65 mph. The values in android is not similar in iOS app too.
@binod-techindustan Could you provide coordinates for routes?
@NazarKacharaba one of our user report it. It was in Highway no 80 California, USA
@binod-techindustan We are looking into this.
Hi @NazarKacharaba I've faced the same issue. I get car speed limits with applied TransportMode.TRUCK. Route waypoints: Lithuania Kaunas - Lithuania Klaipeda
Also multiple pairs of coordinates for the routes: 52.491701, 13.263713 - 52.437601, 13.19663 55.125229, 23.748323 - 55.147642, 23.709234 52.392454, 13.523472 - 52.377956, 13.543050
@binod-techindustan Speed values on Highway no 80 California, USA is fixed for truck in the latest map update. Please use MapLoader.performMapDataUpdate()
to switch to the latest map version.
@VladChernetsky we will take a look at this routes
@NazarKacharaba where can I call this method. Should I call this method before loading map? Will there be an issue if I we call during map initialisation. So let me know the best place to perform the map updates.
You can find some instructions here
@NazarKacharaba I have check the instructions. But I am little confused, performing map data updation during navigation, will it cause lag in UI. Should we need to display progress, like updating Map and display the progress till completion?
You should perform map data update after you initialized MapEngine
, before any route calculation or navigation. Check if new update is available using checkForMapDataUpdate
method, and then update map calling performMapDataUpdate
.