HERE Maps JS API Routing with ABR and Height limitations - javascript

I've recently came across a problem I'm using here maps JS api routing in specifically, and I am trying to add restrictions for example using height or weight. For some reason it ignores it, I'm using fleet telematics tiles as well from HERE, so its showing me relative information regarding here.
my options are:
let routingParameters = {
'routingMode': 'short',
'transportMode': 'truck',
'origin': locationPoints.A.lat+','+locationPoints.A.lon,
'destination': locationPoints.B.lat+','+locationPoints.B.lon,
'truck': {
'height': 600,
'grossWeight': 22000
},
'return': 'polyline,summary'
};
Everything is fine with routing itself, maybe I am missing something? Is there an option to avoid those things?
Logically speaking, it wouldn't be possible to drive trough a 4.5 under tunnel with 6m of height, so it shouldn't be an option even if there wouldnt be a good road for it routing wise.

I managed to figure it out, seems like they key has to be in the key itself, for example.
let routingParameters = {
'routingMode': 'short',
'transportMode': 'truck',
'origin': locationPoints.A.lat+','+locationPoints.A.lon,
'destination': locationPoints.B.lat+','+locationPoints.B.lon,
'truck[height]': 600,
'return': 'polyline,summary'
};
Will most definetely work. Who ever will run across the same problem.

Related

How do you include a set with a relative path in a SAP hybrid app?

I've made an app in SAP UI5 that works in online mode when using a browser, and offline mode when using a mobile device. I'm trying to display some options in a popup that are fetched from a set. The problem is that the set is found when I run it in online mode, but not offline.
The set is an extension of another set, and depends upon a variable, e.g. /FooSet('P1')/Types, where P1 is a variable.
The implementation for fetching the items from the set and displaying them in the popup is the following:
this._popup.getAggregation('_dialog').getContent()[1].bindAggregation("items", {
path: "/FooSet('" + varType + "')/Types",
template: new sap.m.StandardListItem({
title: "{Title}",
description: "{Desc}"
});
As mentioned, this works fine online, but the Types set is empty when running it offline.
I suspect that the problem lies in the definingRequests.json file, which contains all the sets that are to be included in the offline app. Here's a snippet:
{
"definingRequests": {
"FooSet": "/FooSet",
"BarSet": "/BarSet",
"ZooSet": "/ZooSet"
}
}
Here, the three sets are included; I'm getting the correct data from FooSet, for example, which contains the different variables like P1, P2, P3 and so on. So my question is: How do I include the Types set from /FooSet('P1')/Types when there's a variable like P1 involved?
I've already tried defining it like "Types": "/Types", as well as "Types": "/FooSet/Types", but that's not working neither.
Thanks in advance!
As suspected, I was just defining the set incorrectly in definingRequests.json.
It was supposed to be "TypesSet": "/TypesSet", not "Types": "/Types", even though the path is named Types. All is good now :)

AWSIoT: AWSIoTShadowClient vs AWSIoTMQTTClient

I have an IoT Project which is:
2 bulbs, connect to 2 Raspberry Pi (python)
web app (Javascript) with 3 buttons: one to turn on/off bulb 1, one to turn on/off bulb 2, one to turn on/off both bulbs.
I approached 2 different ways
using AWSIoTMQTTClient:
Pi:
class CallbackContainer(object):
def __init__(self, client):
self._client = client
def messagePrint(self, client, userdata, message):
print("Received a new message: ")
print(message.payload)
print("from topic: ")
print(message.topic)
print("--------------\n\n")
myAWSIoTMQTTClient = AWSIoTMQTTClient("myClientID")
myAWSIoTMQTTClient.configureEndpoint("xxxxx.iot.eu-west-1.amazonaws.com", 8883)
myAWSIoTMQTTClient.configureCredentials("./certs/rootCA.pem", "./certs/xxxxxxx-private.pem.key", "./certs/xxxxxxx-certificate.pem.crt")
myAWSIoTMQTTClient.configureConnectDisconnectTimeout(10) # 10 sec
myAWSIoTMQTTClient.configureMQTTOperationTimeout(5) # 5 sec
myCallbackContainer = CallbackContainer(myAWSIoTMQTTClient)
myAWSIoTMQTTClient.connect()
myAWSIoTMQTTClient.subscribe("topic_both", 0, myCallbackContainer.messagePrint)
myAWSIoTMQTTClient.subscribe("topic_bulb1", 0, myCallbackContainer.messagePrint)
while True:
time.sleep(1)
Javascript:
var params = {
payload: JSON.stringify(body),
topic: myTopic, //"topic_both" or "topic_bulb1"
qos: 0
};
var iotPromise = iotData.publish(params).promise();
using AWSIoTShadowClient:
Pi:
def customShadowCallback_Delta(payload, responseStatus, token):
print(responseStatus)
payloadDict = json.loads(payload)
print("++++++++DELTA++++++++++")
print("property: " + str(payloadDict["state"]))
print("+++++++++++++++++++++++\n\n")
#Need to handle JSON to control bulbs
thingName = "control_bulb"
myAWSIoTMQTTShadowClient = AWSIoTMQTTShadowClient("myClientID")
myAWSIoTMQTTShadowClient.configureEndpoint("xxxxxx.iot.eu-west-1.amazonaws.com", 8883)
myAWSIoTMQTTShadowClient.configureCredentials("/certs/rootCA.pem", "/certs/xxxxx-private.pem.key", "/certs/xxxxx-certificate.pem.crt")
myAWSIoTMQTTShadowClient.configureConnectDisconnectTimeout(10) # 10 sec
myAWSIoTMQTTShadowClient.configureMQTTOperationTimeout(5) # 5 sec
myAWSIoTMQTTShadowClient.connect()
deviceShadowHandler = myAWSIoTMQTTShadowClient.createShadowHandlerWithName(thingName, True)
deviceShadowHandler.shadowRegisterDeltaCallback(customShadowCallback_Delta)
while True:
time.sleep(1)
JavaScript:
var params = {
payload: '{"state":{"desired":' + JSON.stringify(body) + '}}',
thingName: 'control_bulb'
};
iotData.updateThingShadow(params, function(err, data) {
}
Both approaches manage to achieve the purpose of the project. However, my questions :
What different between AWSIoTMQTTClient vs AWSIoTShadowClient in terms of performance, security, maintenance?
In which use-case, is AWSIoTShadowClient or AWSIoTMQTTClient used?
Thanks
The two different clients represent two different (albeit superficially similar) features of AWS IoT:
AWSIoTMQTTClient provides a general interface to AWS IoT's MQTT broker. All it does is allow you to send and receive messages across topics. In fact, if you really wanted to you could use any MQTT client for this (for example Paho MQTT), but I would stick to AWS' as it is ready-configured for their broker.
AWSIoTShadowClient is an interface specifically for the AWS IoT Device Shadow. The device shadow is an AWS-managed, per-decice, two-way synchronized 'state'. It just so happens that one way of interacting with the shadow is MQTT. But the aim isn't just to send/receive messages, it's to provide a mechanism for devices to persist and take their state from the cloud. (more specifics here)
So to address your question:
Performance: both use the same underlying protocol and so have similar performance. At a push AWSIoTMQTTClient could perform better if you specialised it to your own usage, rather than following the Device Shadow pattern; but I would expect any gains to be negligible.
Security: once again both are secured in exactly the same way using AWS IoT's client/certificate security model. AWSIoTShadowClient is likely more secure by default as it is already configured to ensure that only a device can set it's reported state.
Maintenance: This depends a bit. If your use case (discussed next) is to have device report its state, and have that state inspectable and updatable from the cloud, then the AWSIoTShadowClient is much more maintainable; simply because that is what it's designed and tested to do- you'll have to write and maintain less of your own code!
Picking an approach:
Device Shadow: If you don't have a reason no to, use the shadow. It's a managed and well tested pattern (that includes edge cases, such as the blub being offline when you request it to change) for having your devices send send/receive/synchronize state from the cloud. It's built into AWS so you can easily view/change this state in the console. It's also got built-in persistence, so you can always inspect that latest state even if you aren't constantly listening for changes on the broker.
Your own MQTT topics: There's a few reasons not to use the shadow. The shadow requires you to send JSON payloads, and in highly battery/network constrained situations you might want to use your own binary protocol to save bytes. Similarly it's about double the cost (although still really cheap). Finally if you readings are fast moving, write-only, telemetries that you do not need to persist and can subscribe to when you're interested, you might skip the shadow because you don't need any of its features.
So in your case, I would say you want to use the shadow.

Javascript frequency analyzer using chart library

I'm currently trying to make a frequency analyzer using web technologies, especially Meteor.
For now, I tried to use the Google Charts library that create SVG pictures. The chart needs to be refreshed about 10 times by second and the performance aren't satisfying. It takes all the CPU resource.
I'm a bit new to web development (especially in graphical and performances issues) so if you could point into the right direction to make my research, I'd appreciate it.
I ended up using the library CanvasJs which appears to be one of the fastest. There is an option interactivityEnabled: false to disable interactions with the chart which increase performance.
Even if there is yet no direct Meteor integration, just put the js file in the ./client/compatibility and it works fine.
You could very easily accomplish this with ZingChart. We don't have a Meteor integration (yet), but the demo below should be a good start for you. Run the snippet below to see it live.
I'm on the ZingChart team! Let me know if you have questions.
var MAXVALUES = 100;
var myConfig = {
type: "line",
series : [
{
values : []
}
]
};
zingchart.render({
id : 'myChart',
data : myConfig,
height: 400,
width: 600
});
var myValues = [];
setInterval(function(){
myValues.push( Math.floor(Math.random() * 10 ) );
if(myValues.length == MAXVALUES+1){
myValues.shift();
}
console.log(myValues)
zingchart.exec('myChart', 'setseriesvalues', {
values : [myValues]
})
},60)
<script src="http://cdn.zingchart.com/zingchart.min.js"></script>
<div id='myChart'></div>
Use the canvas element. You should be able to get 60 per second and if it's a audio source the Audio API provides a DSP for spectral analysis.
Here is an example audio spectrum visualizer

OpenLayers GetFeatureInfo requests not being triggered

I'm creating a little web page containing a map using the Google Maps API and the OpenLayers JS library (v2.13). The base layer of the map is Google Street Maps, and that works fine, I can pan around the map, zoom in etc.
I'm adding a number of layers to the map, which come from a Web Mapping Service hosted on a remote server that I don't own or have access to (the code, I mean). And that works fine too, the layers overlay onto the Google Map just fine.
The problem is when I click on the layer features on the map, the WMSGetFeatureInfo controls are not working. No request is sent to the specified URL, no callback function is triggered, nothing happens at all. Here's some code:
var remoteGeoServer = "https://www.remotegeoserver.com/geoserver/wms";
var options = {
controls: [],
maxExtent: new OpenLayers.Bounds(420000, 485000, 770000, 985000),
projection: "EPSG:2157",
units: 'm',
scales: [5000000, 2500000, 1250000, 600000, 400000, 200000, 100000, 50000, 25000]
};
var map = new OpenLayers.Map('map-container', options);
// ... define styles, rules etc.
var overlayLayer = new OpenLayers.Layer.WMS("Overlayed Layer", remoteGeoServer, {<some_options>}); // other layers are created too...
var infoControls = {
click: new OpenLayers.Control.WMSGetFeatureInfo({
url: "/geoserver/wms",
title: 'Identify features by clicking',
layers: [overlayedLayer],
infoFormat: 'text/plain',
queryVisible: true
})
};
var baseLayer = new OpenLayers.Layer.Google("Google Streets", {numZoomLevels: 20});
map.addLayers( [baseLayer, overlayLayer] );
map.setBaseLayer( baseLayer );
for (var i in infoControls) {
infoControls[i].events.register("getfeatureinfo", this, showInfo);
map.addControl(infoControls[i]);
}
// ... and later
function showInfo(evt) {
console.log("Hurray!");
}
infoControls.click.activate();
I should explain that, even though the url in the infoControls is called "/geoserver/wms", there is no web mapping server running on my server. I just forward on the GetFeatureInfo request to the remote server that runs the actual geoserver. Otherwise the same-origin policy kicks in and the GetFeatureInfo requests are rejected.
But nothing happens, my "/geoserver/wms" endpoint never gets called. Am I doing something wrong? Also, and this isn't my main question, but why am I able to successfully give OpenLayers the remote server URL when creating the layers (should same-origin policy not apply - the map still works fine though, and the GET image requests to the remote server are successful).
Something else worth noting is that when I replace the local url path in infoControls with the remote server url, clicking the map triggers the same-origin policy error in the debug console.
I found a few different potential solutions for this problem that other people were having but none of them worked for me. In the end, the only thing that did work was this:
The URL used in the layer creation constructor(s) (in OpenLayers.Layer.WMS) MUST be the same as the URL used for the GetFeatureInfo constructor (in OpenLayers.Control.WMSGetFeatureInfo)
Otherwise, the map layers will work but the GetFeatureInfo requests will fail. I don't know if just the domain needs to be the same, or the full URL.
I'm not particularly happy about this. It means that I have to create an endpoint on my server that acts as a proxy and routes GetMap requests to the actual remote geoserver. I didn't need to do this before (why not - same-origin policy ??) and now it drives up latency for the layers showing up in the map (not to mention my server gets hammered with GetMap requests).
This seems to be an issue with OpenLayers (but I'm not sure of that). I'd be very interested in hearing about a solution if anyone knows of one.

how to use bespin commands on embedded bespin?

I set my embedded bespin as below, which works good:
_editorComponent = new bespin.editor.Component('editor', {
language : my_language,
loadfromdiv : true,
set : {
fontsize : 10,
tabsize : 4,
highlightline : 'on'
}
});
and html part for this:
<div id='editor'>some code...</div>
By following embedded bespin's code, i was able to find out getContent and setContent, however i couldnt find anything on Bespin documentation for further implementations of Bespin.
Is there anyone who knows how to add search and replace functionality to it? for example from above instance:
_editorComponent.searchText("some_string");
_editorComponent.replaceText("some_string","another_string");
_editorComponent.focusText("some_string");
Do we have such commands on bespin, which i can use on my application?
Edit: Response to same question on google groups:
There was some support for
search once upon a time in Bespin, but
it's not back to the rebooted Bespin
yet. But it's definitely one of the
features on my to-be-implemented list
;)
So this can only be done with workarounds for now, any workaround is more than welcome.
Edit: response to same question on google groups:
There was some support for search once upon a time in Bespin, but it's
not back to the rebooted Bespin yet. But it's definitely one of the
features on my to-be-implemented list ;)

Categories

Resources