How to use the AndroidSDK to calculate routes using imperial units - here-api

I have set the NavigationManager to use imperial units. When I use the RouteCalculator the calculated route is shown in metric units
In the map initialization I have set the the navigation manager units
NavigationManager.getInstance().setDistanceUnit(NavigationManager.UnitSystem.IMPERIAL);
Later I build a list of waypoints and after checking that there are at least 2 waypoints call RouteCalculator to create a sample route.
if (waypoints.size() >= 2 && waypoints.get(0) != null && waypoints.get(1) != null) {
RouteCalculator.getInstance().calculateRoute(waypoints, routeOptions, routeResultList -> {
// for demo purposes we show only the first route
RouteCalculator.getInstance().showRoute(map, routeResultList.get(0));
});
}
When I display the first route details I expect the distances to be listed in miles, however they are listed in kilometres
This is using the Android Premium SDK Version 3.11

The SDK provides such option for guidance only in order to be aligned with Voice package commands. But you can do these transformations on application side if needed.

Related

How to enable the RealisticView events in HERE iOS Premium SDK 3.18+

Using the HERE iOS Premium SDK 3.18 to create a routing App and I can't figure out what is needed in order to enable the Realistic View events in order to get signpost data for maneuvers in the route.
I have specified the NavigationManager Delegate and created functions for the event callbacks. When I create a route and run a simulation on the route, I never receive either of the realistic view events. I have scoured the User Guide and the API Reference but can't get the events.
func navigationManager(_ navigationManager: NMANavigationManager, didUpdateRealisticViewsForNextManeuver realisticViews: [NSNumber : [String : NMAImage]]) {
mapState.status = "Realistic View Updated for Next Maneuver!"
}
func navigationManager(_ navigationManager: NMANavigationManager, didUpdateRealisticViewsForCurrentManeuver realisticViews: [NSNumber : [String : NMAImage]]) {
print("RealisticViews: \(realisticViews.count)")
for key in realisticViews.keys {
print("key: \(key)")
}
mapState.status = "Realistic View Updated for Current Maneuver!"
}
======
Update: I located my problem, I was missing the step to register the realisticview aspect ratios after doing that I started receiving the events. From the User Guide:
"The Realistic View feature is disabled by default. To enable it, use NMANavigationManager.realisticViewMode property and set the view mode to NMARealisticViewDay or NMARealisticViewNight. Next, register the desired image aspect ratios by using NMANavigationManager.realisticViewAspectRatios property."
====== Update: I located my problem, I was missing the step to register the realisticview aspect ratios after doing that I started receiving the events. From the User Guide:
"The Realistic View feature is disabled by default. To enable it, use NMANavigationManager.realisticViewMode property and set the view mode to NMARealisticViewDay or NMARealisticViewNight. Next, register the desired image aspect ratios by using NMANavigationManager.realisticViewAspectRatios property."

Network​ Information​ API downlink is never higher than 10 Mbit?

I try to get some information about the bandwidth of my users. Currently im running NetworkInformation/downlink in Google Tag Manager and pushing it to Google Analytics
https://wicg.github.io/netinfo/#downlink-attribute
https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/downlink
Why is there no value higher than 10 Mbit... this looks unrealistic to me? Also having the majority at exactly 10 Mbit downlink seem weird. Is there a limit at 10 Mbit?
Custom Javascript in GTM looks like this:
function () {
var con = navigator.connection || navigator.mozConnection || navigator.webkitConnetion
return Number(con.downlink);
}
As mentioned on the documentation, that's probably because your users are using a Chrome based navigator (or because all navigator implemented this cap since published)
So the speed indicator is capped to a maximum of 10Mpbs

How can I pass parameters into openhab2 transformations?

I have a openhab 2.1 setup, and I am using the http binding to get the additional data from my hue bridge that is not available in the hue binding (yet). I am mostly interested in the light- and temperature sensors built into the motion sensors, but I also want to be able to react to button presses (and, since this is interactive, with as little delay as possible).
So i chose to go with polling the bridge using the http binding.
I have:
hue.url=http://192.168.61.21/api/[KEY]/sensors/
hue.updateInterval=500
and I am using JS or JSONPATH transformations to extract values.
the problem I am having is this:
I can easily do:
Number hue_dimmer_buttons_study_1 "Study Dimmer (last button)" { http="<[hue:500:JSONPATH($.16.state.buttonevent)]" }
Number hue_dimmer_scene_study_1 "Study Dimmer (current scene)" { http="<[hue:500:JSONPATH($.17.state.status)]" }
and get the values from entire list. But I can only do EITHER a transformation like this and get the raw value from the JSON, OR I can do additional transformations (such as mapping "true" to "ON" and 1995 to 19.95) - I cannot do both.
Also, if I retrieve all sensor states anyways, I might as well retrieve all values from the same string - for this, my only option is to write one (for example) getHueTemperature.js for EACH SENSOR, i.e.:
getHueTemperature14.js:
(function(i) {
return JSON.parse(input).14.state.temperature / 100;
})(input)
and then do:
[...] { http="<[hue:500:JS(getHueTemperature14.js)]" }
I cannot pass in which element I want to extract from and then use one transformation for all sensors, such as:
getHueTemperature.js:
(function(i) {
return JSON.parse(input)[element].state.temperature / 100;
})(input, element)
and then:
[...] { http="<[hue:500:JS(getHueTemperature.js,14)]" }
... or can i? any help would be very much appreciated.
thanks
.rm

Errors When Calculating Distance Between Two Addresses

I have the following script which is being used in a spreadsheet to calculate the driving distance between two cities or a city and a zip code of another city. It is being run for approximately 25 locations simultaneously. To better explain, I have cell B3 in which I enter a new city every time. The script is then used in cells adjacent to my 25 plant locations to calculate the distance from each of my plants to the variable city.
It uses google sheets built in mapping api and works on 80% of the calculations but returns "TypeError: Can Not Read Property "legs" from undefined. (line 16). The plants that it fails on vary with every new city so its not like it is for certain locations. It is almost like the api times out before it completes some of them. I split it into two separate scripts with a varied name and that worked for a day but then 20% fail again.
To make things slightly more odd, I have another script that sorts the plants based on closest distance to the variable address. When you sort the plants, even the ones with errors go to their correct location based on distance. So it is like the distance script is obtaining the correct disance but displaying the error anyways.
Clear as mud? Would love any input I could get on how to correct the issue or an alternate mapping api that could solve my problems.
function distancecalcone(origin,destination) {
var directions = Maps.newDirectionFinder()
//Set the Method of Transporation. The available "modes" are WALKING, DRIVING, BICYCLING, TRANSIT.
.setMode(Maps.DirectionFinder.Mode.DRIVING)
//Set the Orgin
.setOrigin(origin)
//Set the Destination
.setDestination(destination)
//Retrieve the Distance
.getDirections();
return directions.routes[0].legs[0].distance.value/1609.34;
}
Have you tried using a try-catch block around directions.routes[0].legs[0].distance.value ?
try{
return directions.routes[0].legs[0].distance.value/1609.34;
}
catch (e){
console.log("error",e)
}
or you could try something like this
alert(directions);
alert(directions.routes[0]);
alert(directions.routes[0].legs[0]);
alert(directions.routes[0].legs[0].distance);
alert(directions.routes[0].legs[0].distance.value);
and so on...to find out which one comes up as undefined the first. That might help you to debug the issue.
Enable Direction Api
1)Go to "google cloud platform"
2)go to "Api and services"
3)search for "direction api" and enable it
The directions service is subject to a quota and a rate limit. Check the return status before parsing the result.
For lots of distances (or at least more than 10), look at the DistanceMatrix.
I'm able to run the script from the Script editor, but not from spreadsheet. The error is "unable to read property legs" when the function is called from spreadsheet. But the property is in place when called from Script editor and contain correct values.
You probably need to use WEB API and have API KEY:
Google Apps Script - How to get driving distance from Maps for two points in spreadsheet

Which optional parameters do improve the accuracy of a google geolocation request result?

I am using gsm cell data to get the current device position. To do this I use the Google Maps Geolocation API. All fields seem to be optional in the first part of the needed JSON parameters (URL: https://www.googleapis.com/geolocation/v1/geolocate?key=API_key):
{
"homeMobileCountryCode": 310,
"homeMobileNetworkCode": 410,
"radioType": "gsm",
"carrier": "Vodafone",
"cellTowers": [
// See the Cell Tower Objects section below.
],
"wifiAccessPoints": [
// See the WiFi Access Point Objects section below.
]
}
Do the first 4 parameters homeMCC, homeMNC, radio Type and carrier have any influences on the accuracy? or the response time? I could not make out any differences.
I can believe that the Google database of cell IDs is organised by carrier and network type, so there might in theory be a quicker response if you supply these parameters, but it would surely be negligible. Can't think of a technical reason why it would need to know your home operator details too. The only information these parameters would give them is (1) whether you're roaming or not and (2) any stored information that they might be holding about individual operators. Does Google have special agreements with any operators?

Resources