I need to get the total distance and time from waypoints in HERE REST API.
Now i use the routing api:
https://route.api.here.com/routing/7.2/calculateroute.json
"app_id=" + API_ID
"&app_code=" + APP_CODE
"&waypoint0=geo!" + fromCoordsLocation
"&waypoint1=geo!" + toCoordsLocation
"&mode=fastest;car"
and read them from json summary object (Response->Route->Summary). This method returns all the maneuvers and for long distances the callback is slow. there is something that allows only the summary (or the total distance and time) to be received?
Check out these additional properties so you can customize the request as you want. In this case I used representation = overview, your request will be
https://route.api.here.com/routing/7.2/calculateroute.json
"app_id=" + API_ID
"&app_code=" + APP_CODE
"&waypoint0=geo!" + fromCoordsLocation
"&waypoint1=geo!" + toCoordsLocation
"&mode=fastest;car&representation=overview"
The response will be decreased to 78 lines with default 232 lines:
{
"response": {
"metaInfo": {
"timestamp": "2019-11-14T10:03:16Z",
"mapVersion": "8.30.102.151",
"moduleVersion": "7.2.201945-5699",
"interfaceVersion": "2.6.74",
"availableMapVersion": [
"8.30.102.151"
]
},
"route": [
{
"waypoint": [
{
"linkId": "-53623477",
"mappedPosition": {
"latitude": 52.4999825,
"longitude": 13.3999652
},
"originalPosition": {
"latitude": 52.5,
"longitude": 13.4
},
"type": "stopOver",
"spot": 0.3538462,
"sideOfStreet": "left",
"mappedRoadName": "Neuenburger Straße",
"label": "Neuenburger Straße",
"shapeIndex": 0,
"source": "user"
},
{
"linkId": "+1215312511",
"mappedPosition": {
"latitude": 52.4992955,
"longitude": 13.4491968
},
"originalPosition": {
"latitude": 52.5,
"longitude": 13.45
},
"type": "stopOver",
"spot": 1.0,
"sideOfStreet": "left",
"mappedRoadName": "Schlesische Straße",
"label": "Schlesische Straße",
"shapeIndex": 56,
"source": "user"
}
],
"mode": {
"type": "fastest",
"transportModes": [
"car"
],
"trafficMode": "disabled",
"feature": []
},
"summary": {
"distance": 3847,
"trafficTime": 869,
"baseTime": 667,
"flags": [
"noThroughRoad",
"builtUpArea",
"park",
"privateRoad"
],
"text": "The trip takes <span class=\"length\">3.8 km</span> and <span class=\"time\">11 mins</span>.",
"travelTime": 667,
"_type": "RouteSummaryType"
}
}
],
"language": "en-us"
}
}
Related
Im trying to calculate a route from Berlin to Rome using the Routing API with an openingInterval specified for the waypoint in Rome.
The openingInterval is not used, instead I’m getting a route violation for the openingInterval.
My request:
https://api.myptv.com/routing/v1/routes?options[trafficMode]=AVERAGE&options[startTime]=2022-01-25T13:00:00&results=VIOLATION_EVENTS,SCHEDULE_EVENTS
Body:
{
"waypoints": [
{
"offRoad": {
"latitude": 52.461790,
"longitude": 13.324184
}
},
{
"offRoad": {
"latitude": 41.889511,
"longitude": 12.381591,
"openingIntervals": [
{
"start": "2022-01-25T10:00:00",
"end": "2022-01-25T20:00:00"
}
]
}
}
]
}
I get the following response:
{
"distance": 1508861,
"travelTime": 68832,
"violated": true,
"events": [
{
"latitude": 52.461790044,
"longitude": 13.324184073,
"startsAt": "2022-01-25T13:00:00+01:00",
"distanceFromStart": 0,
"travelTimeFromStart": 0,
"countryCode": "DE",
"utcOffset": 60,
"schedule": {
"duration": 0,
"scheduleTypes": [
"SERVICE"
]
}
},
{
"latitude": 41.889511025,
"longitude": 12.381590967,
"startsAt": "2022-01-26T08:07:12+01:00",
"distanceFromStart": 1508861,
"travelTimeFromStart": 68832,
"countryCode": "IT",
"utcOffset": 60,
"violation": {
"type": "SCHEDULE",
"scheduleViolationTypes": [
"OPENING_INTERVAL"
]
},
"schedule": {
"duration": 0,
"scheduleTypes": [
"SERVICE"
]
}
}
]
}
The routing should arrive at around 7am in Rome and have to wait there for the openingInterval, but instead the route finishes without waiting.
What am I doing wrong?
While all waypoints are always open per default as soon as you set openingIntervals the waypoint will only be open during these intervals and closed otherwise.
In your case you are arriving on the next day since your route is quite long, while your openingInterval is specified for the same day.
If you don’t know if you will arrive on the same day you started the route, I suggest adding the openingInterval for the next day as well, like this:
{
"waypoints": [
{
"offRoad": {
"latitude": 52.461790,
"longitude": 13.324184
}
},
{
"offRoad": {
"latitude": 41.889511,
"longitude": 12.381591,
"openingIntervals": [
{
"start": "2021-01-25T10:00:00",
"end": "2021-01-25T20:00:00"
},
{
"start": "2021-01-26T10:00:00",
"end": "2021-01-26T20:00:00"
}
]
}
}
]
}
cat main.go:
```
package main
import (
"encoding/json"
"log"
"net"
"net/http"
"net/http/fcgi"
"os"
)
func main() {
//setup the config
configFile := "config.json"
fd, err := os.Open(configFile)
if err != nil {
log.Fatalf("Can't open config file: %v", configFile)
}
CFG := config{}
err = json.NewDecoder(fd).Decode(&CFG)
if err != nil {
log.Fatalf("parse config error: %v", err)
}
//init DB connection
db.InitConnectionInfo(CFG.Database.Host, CFG.Database.Port, CFG.Database.Database, CFG.Database.Username, CFG.Database.Password)
//register HTTP handler
sessionHandler := &handlers.SessionHandler{}
http.Handle("/sessions", sessionHandler)
http.Handle("/sessions/", sessionHandler)
userHandler := &handlers.UserHandler{
Facebook: &oa.OAuth{AppId: CFG.Facebook.Key, Secret: CFG.Facebook.Secret},
Sina: &oa.OAuth{AppId: CFG.Sina.Key, Secret: CFG.Sina.Secret},
Google: &oa.OAuth{AppId: CFG.Google.Key, Secret: CFG.Google.Secret},
Tencent: &oa.OAuth{AppId: CFG.Tencent.Key, Secret: CFG.Tencent.Secret},
Mixpanel: &hu.Share{Token: CFG.Mixpanel.Token},
FacebookShare: &hu.Share{Token: CFG.Facebook.Token},
SinaShare: &hu.Share{Token: CFG.Sina.Token},
GoogleShare: &hu.Share{Token: CFG.Google.Token},
TencentShare: &hu.Share{Token: CFG.Tencent.Token},
}
http.Handle("/users", userHandler)
http.Handle("/users/", userHandler)
//and so on ...
//run server
log.Println("start listen: ", CFG.FcgiAddr)
l, _ := net.Listen("tcp", CFG.FcgiAddr)
log.Fatalf("server error is %v", fcgi.Serve(l, nil))
//##select {}
log.Println("end listen")
}
```
build it and deploy behind nginx.
then client query /users/1234567/places, /users/1234567, and so on...
get the response is {blank data}, {normal user(1234567) data} or {normal user(1234567) data}, {normal user(1234567) data}.
same prefix of query, and same handler, looks like it is overload the response by subsequent HTTP request.
How can I do it?
May need me to give an example of a response:
correct response is :
{
"meta": {
"code": 200,
"text": "OK"
},
"data": {
"count": 21,
"place-tag-maps": [{
"id": "95842310160384",
"place-id": "95551731663150",
"tag-id": "95551579750669",
"ct": "2014-07-01T09:07:28Z"
}, {
"id": "95842310160385",
"place-id": "95551731663150",
"tag-id": "95551579750694",
"ct": "2015-01-15T17:41:23Z"
}, {
"id": "96262389694470",
"place-id": "95551731663150",
"tag-id": "95910120456455",
"ct": "2016-07-18T13:11:39Z"
}, ...],
"places": [{
"id": "95551731663150",
"name": "Kam Fung Restaurant",
"address": "G/F, 41 Spring Garden Ln",
"coordinate": {
"latitude": 22.275576,
"longitude": 114.172582
},
"telephone": "+852 2572 0526",
"city-id": "95530516807703",
"city": "Hong Kong",
"country": "Hong Kong",
"type": "4sq",
"ref-id": "4b1613f8f964a520cdb623e3",
"ct": "2016-02-23T07:42:43.565489Z",
"mt": "2017-02-22T09:35:48.302929Z",
"rating": 7.5,
"stats": {
"foursquare": {
"count": 111,
"value": 7.5
},
"spottly": {
"save-count": 12
}
},
"permanent-close": false,
"price": ""
}, ...],
"posts": [{
"collection-id": "95551746474003",
"coordinate": {
"latitude": 22.275576,
"longitude": 114.172582
},
"ct": "2017-02-22T09:35:47Z",
"facebook-tag-users": [],
"id": "97501586849795",
"medias": [],
"message": "",
"mt": "2017-02-22T09:35:47Z",
"owner-id": "96527264645120",
"place-id": "95551731663150",
"share-to": [],
"star": 5,
"status": "Done",
"tags": []
}, ...],
"users": [{
"id": "95551581323446",
"uid": "hk_epicurus",
"uid-ignore-case": "hk_epicurus",
"name": "Hk Epicurus",
"head": "https://d278wa0j9nq2mp.cloudfront.net/uploader/54aa335ddf4e63450002919a.jpeg",
"site": "www.hkepicurus.com",
"location": "Hong Kong",
"description": "Hong Kong Food \u0026 Travel Bear.\nGrew up in Aust, Malaysia, Tokyo \u0026 HK. \nInstagram: EpicurusHongKong\nFacebook, Spottly \u0026 Twitter: HK Epicurus \n微博: 香港美食-伊比\nFacebook Fans Page: http://on.fb.me/1qDyiIk",
"ct": "2013-10-13T19:12:41Z",
"mt": "2015-11-08T15:22:45Z"
}, ...]
}
}
and
{
"meta": {
"code": 200,
"text": "OK"
},
"data": {
"friends": [{
"id": "97331335725056",
"from-id": "97273770803200",
"to-id": "96527264645120",
"ct": "2017-01-23T07:58:41Z"
}],
"user": {
"ct": "2013-04-30T23:30:05Z",
"description": "Founder and Chief Everything Officer of Spottly. Loves to eat. Have a really bad memory. Wants to remember the best places and make travel research better",
"followers": {
"count": 41291
},
"followings": {
"count": 322
},
"head": "https://d278wa0j9nq2mp.cloudfront.net/uploader/525ffac8df4e6347870145ef.jpeg",
"id": "96527264645120",
"location": "Vancouver | Hong Kong | Beijing ",
"mt": "2015-10-27T09:47:12Z",
"name": "Edwyn Chan",
"site": "http://spottly.com/edwyn",
"uid": "edwyn",
"uid-ignore-case": "edwyn"
}
}
}
but mistake response is
{
"meta": {
"code": 200,
"text": "OK"
}
}
and
{
"meta": {
"code": 200,
"text": "OK"
},
"data": {
"friends": [{
"id": "97331335725056",
"from-id": "97273770803200",
"to-id": "96527264645120",
"ct": "2017-01-23T07:58:41Z"
}],
"user": {
"ct": "2013-04-30T23:30:05Z",
"description": "Founder and Chief Everything Officer of Spottly. Loves to eat. Have a really bad memory. Wants to remember the best places and make travel research better",
"followers": {
"count": 41291
},
"followings": {
"count": 322
},
"head": "https://d278wa0j9nq2mp.cloudfront.net/uploader/525ffac8df4e6347870145ef.jpeg",
"id": "96527264645120",
"location": "Vancouver | Hong Kong | Beijing ",
"mt": "2015-10-27T09:47:12Z",
"name": "Edwyn Chan",
"site": "http://spottly.com/edwyn",
"uid": "edwyn",
"uid-ignore-case": "edwyn"
}
}
}
the first response is error. or it's same as the second response.
sequence request is correct response, parallel request is incorrect response.
problem resolved。
the basic reason is this case:
var x = &{...} //init value
fillX(..., x) //fill the fields of x pointer
//here the fields of x pointer is not same to inner of fillX func
so, change to
var x = &{...}
x = fullX(..., x)
the problem resolved.
but why go pointer is the behavior?
Finally, this problem resolved.
Because the http.Handle register path-pattern and handler pair, the handler is construct by register time only-once, not for any request of path-pattern.
if record info within handler, It will been change by after request.
why is it that the riders have a null rider_id in the example? but the description says otherwise? riders[].rider_id : The hashed rider uuid. It doesnt say anything about it being may be null. Else what's the point of returning it. GET request
or is just an example, and the actual response has all of these ids not null
{
"product_id": "17cb78a7-b672-4d34-a288-a6c6e44d5315",
"request_id": "a1111c8c-c720-46c3-8534-2fcdd730040d",
"status": "accepted",
"surge_multiplier": 1.0,
"shared": true,
"driver": {
"phone_number": "(555)555-5555",
"sms_number": "(555)555-5555",
"rating": 5,
"picture_url": "https:\/\/d1w2poirtb3as9.cloudfront.net\/img.jpeg",
"name": "Bob"
},
"vehicle": {
"make": "Bugatti",
"model": "Veyron",
"license_plate": "I<3Uber",
"picture_url": "https:\/\/d1w2poirtb3as9.cloudfront.net\/car.jpeg"
},
"location": {
"latitude": 37.3382129093,
"longitude": -121.8863287568,
"bearing": 328
},
"pickup": {
"latitude": 37.3303463,
"longitude": -121.8890484,
"eta": 5
},
"destination": {
"latitude": 37.6213129,
"longitude": -122.3789554,
"eta": 19
},
"waypoints": [
{
"rider_id":null,
"latitude":37.77508531,
"type":"pickup",
"longitude":-122.3976683872
},
{
"rider_id":null,
"latitude":37.773133,
"type":"dropoff",
"longitude":-122.415069
},
{
"rider_id":"8KwsIO_YG6Y2jijSMf",
"latitude":37.7752423,
"type":"dropoff",
"longitude":-122.4175658
}
],
"riders": [
{
"rider_id":"8KwsIO_YG6Y2jijSMf",
"first_name":"Alec",
"me": true
},
{
"rider_id":null,
"first_name":"Kevin",
"me": false
}
]
}
The riders array, as specified in the GET /request/{request_id} reference page, is returned only for shared rides (uberPOOL rides). You will only be able to get a non-null rider_id if that rider account has already authenticated with your developer app.
This means that if any rider_id in the riders array is null, the rider account associated with that rider_id has not authenticated with your app.
hi i need List grouping control by using js view.but openui5 provides code by using xml view.
https://openui5.hana.ondemand.com/explored.html#/sample/sap.m.sample.ListGrouping/preview
how to convert this code into js view and how to make ListGrouping able to selection for both element level and group level and change this as dropdown box
List.view.xml
<mvc:View
controllerName="sap.m.sample.ListGrouping.List"
xmlns:l="sap.ui.layout"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">
<List
items="{
path: '/ProductCollection',
sorter: {
path: 'SupplierName',
descending: false,
group: true
},
groupHeaderFactory: '.getGroupHeader'
}"
headerText="Products" >
<StandardListItem
title="{Name}"
description="{ProductId}"
icon="{ProductPicUrl}"
iconDensityAware="false"
iconInset="false" />
</List>
</mvc:View>
List.controller.js
sap.ui.define([
'jquery.sap.global',
'sap/m/GroupHeaderListItem',
'sap/ui/core/mvc/Controller',
'sap/ui/model/json/JSONModel'
], function(jQuery, GroupHeaderListItem, Controller, JSONModel) {
"use strict";
var ListController = Controller.extend("sap.m.sample.ListGrouping.List", {
onInit : function (evt) {
// set explored app's demo model on this sample
var oModel = new JSONModel(jQuery.sap.getModulePath("sap.ui.demo.mock", "/products.json"));
this.getView().setModel(oModel);
},
getGroupHeader: function (oGroup){
return new GroupHeaderListItem( {
title: oGroup.key,
upperCase: false
} );
}
});
return ListController;
});
how to write the same code by using js view
I have tried like as follows, but i am getting Error: Missing template or factory function for aggregation items of Element sap.m.List#__list0 !
List.view.js
sap.ui.jsview("oui5mvc.List", {
getControllerName : function() {
return "oui5mvc.List";
},
createContent : function(oController) {
odbbshiftGlobalId = this.getId();
var oMyFlexbox = new sap.m.FlexBox({
items: [
oList = new sap.m.List({
width: '500px',
group: true,
groupHeaderFactory: '.getGroupHeader',
items: [
]
}),
]
});
oMyFlexbox.placeAt(this.getId()).addStyleClass("tes");
}
});
List.controller.js
sap.ui.controller("oui5mvc.List", {
onInit: function() {
var data = {
"ProductCollection": [
{
"ProductId": "1239102",
"Name": "Power Projector 4713",
"Category": "Projector",
"SupplierName": "Titanium",
"Description": "A very powerful projector with special features for Internet usability, USB",
"WeightMeasure": 1467,
"WeightUnit": "g",
"Price": 856.49,
"CurrencyCode": "EUR",
"Status": "Available",
"Quantity": 3,
"UoM": "PC",
"Width": 51,
"Depth": 42,
"Height": 18,
"DimUnit": "cm",
"ProductPicUrl": "https://openui5.hana.ondemand.com/test-resources/sap/ui/demokit/explored/img/HT-6100.jpg"
},
{
"ProductId": "2212-121-828",
"Name": "Gladiator MX",
"Category": "Graphics Card",
"SupplierName": "Technocom",
"Description": "Gladiator MX: DDR2 RoHS 128MB Supporting 512MB Clock rate: 350 MHz Memory Clock: 533 MHz, Bus Type: PCI-Express, Memory Type: DDR2 Memory Bus: 32-bit Highlighted Features: DVI Out, TV Out , HDTV",
"WeightMeasure": 321,
"WeightUnit": "g",
"Price": 81.7,
"CurrencyCode": "EUR",
"Status": "Discontinued",
"Quantity": 10,
"UoM": "PC",
"Width": 34,
"Depth": 14,
"Height": 2,
"DimUnit": "cm",
"ProductPicUrl": "https://openui5.hana.ondemand.com/test-resources/sap/ui/demokit/explored/img/HT-1071.jpg"
},
{
"ProductId": "K47322.1",
"Name": "Hurricane GX",
"Category": "Graphics Card",
"SupplierName": "Red Point Stores",
"Description": "Hurricane GX: DDR2 RoHS 512MB Supporting 1024MB Clock rate: 550 MHz Memory Clock: 933 MHz, Bus Type: PCI-Express, Memory Type: DDR2 Memory Bus: 64-bit Highlighted Features: DVI Out, TV-In, TV-Out, HDTV",
"WeightMeasure": 588,
"WeightUnit": "g",
"Price": 219,
"CurrencyCode": "EUR",
"Status": "Out of Stock",
"Quantity": 25,
"UoM": "PC",
"Width": 34,
"Depth": 14,
"Height": 2,
"DimUnit": "cm",
"ProductPicUrl": "https://openui5.hana.ondemand.com/test-resources/sap/ui/demokit/explored/img/HT-1072.jpg"
},
],
"ProductCollectionStats": {
"Counts": {
"Total": 14,
"Weight": {
"Ok": 7,
"Heavy": 5,
"Overweight": 2
}
},
"Groups": {
"Category": {
"Projector": 1,
"Graphics Card": 2,
"Accessory": 4,
"Printer": 2,
"Monitor": 3,
"Laptop": 1,
"Keyboard": 1
},
"SupplierName": {
"Titanium": 3,
"Technocom": 3,
"Red Point Stores": 5,
"Very Best Screens": 3
}
},
"Filters": [
{
"type": "Category",
"values": [
{
"text": "Projector",
"data": 1
},
{
"text": "Graphics Card",
"data": 2
},
{
"text": "Accessory",
"data": 4
},
{
"text": "Printer",
"data": 2
},
{
"text": "Monitor",
"data": 3
},
{
"text": "Laptop",
"data": 1
},
{
"text": "Keyboard",
"data": 1
}
]
},
{
"type": "SupplierName",
"values": [
{
"text": "Titanium",
"data": 3
},
{
"text": "Technocom",
"data": 3
},
{
"text": "Red Point Stores",
"data": 5
},
{
"text": "Very Best Screens",
"data": 3
}
]
}
]
}
};
var oTemplate11 = new sap.m.StandardListItem({title : "{Name}"});
oList.setModel(new sap.ui.model.json.JSONModel(data));
oList.bindItems("/ProductCollection");
oList.placeAt('content');
},
getGroupHeader: function (oGroup){
return new sap.m.GroupHeaderListItem( {
title: oGroup.key,
upperCase: false
});
},
});
Your call to bind items to the list is not entirely correct.
The method takes an object with binding information as parameter instead of just the path to the model property. See the documentation for bindItems and bindAggregation in general.
In your case it should look like
oList.bindItems({
path: "/ProductCollection",
template: new sap.m.StandardListItem({
title: "{Name}",
description: "{ProductId}",
icon: "{ProductPicUrl}"
})
});
I have the following json output string:
{
"meta": {
"limit": 20,
"next": null,
"offset": 0,
"previous": null,
"total_count": 1
},
"objects": [{
"bcontext": "/api/v2.0/buildercontext/2/",
"bugs": [],
"build": {
"bldtype": "obj",
"branch": "main",
"buildstatus": [{
"build": "/api/v2.0/build/2140634/",
"failurereason": "_checkfailures (seen: FAIL - /testrun/18647678/ - area[4769] AIM-SANITY)",
"id": "1294397",
"lastupdate": "2015-03-31T14:30:18",
"overridden": false,
"overridedesc": "",
"overrideuser": null,
"recommended": false,
"resource_uri": "/api/v2.0/buildstatus/1294397/",
"slatype": {
"id": "26",
"name": "VA_Bats",
"resource_uri": "/api/v2.0/sla/26/"
}
}],
"changeset": "494625",
"coverage": false,
"deliverables": ["/api/v2.0/deliverable/4296455/", "/api/v2.0/deliverable/4296956/", "/api/v2.0/deliverable/4296959/", "/api/v2.0/deliverable/4296986/", "/api/v2.0/deliverable/4296992/", "/api/v2.0/deliverable/4296995/", "/api/v2.0/deliverable/4297034/", "/api/v2.0/deliverable/4297058/"],
"git_host": null,
"git_repo": null,
"id": "2140634",
"p4host": {
"id": "10",
"p4port": "perforce-rhino.eng.com:1800",
"p4weburl": "http://p4web.eng.com:1800",
"resource_uri": "/api/v2.0/perforceserver/10/"
},
"resource_uri": "/api/v2.0/build/2140634/",
"site": "/api/v2.0/site/25/",
"site_name": "mbu",
"slastested": ["/api/v2.0/sla/26/"],
"submit_time": "2015-03-31T05:40:21",
"submit_user": "haharonof"
},
"builder": "/api/v2.0/builder/1423/",
"clean": true,
"componentbuilds": "vcops-vsphere-solution-pak=sb-5242047,vrops=sb-5242013,vscm=sb-5242025,vsutilities=sb-5242029;parentbuilder=1410",
"deleted": false,
"endtime": "2015-03-31T06:20:58",
"helpzillas": [],
"id": "4296956",
"location": {
"httpserver": "sc-prd-cat-services001.eng.com",
"id": "1",
"name": "PA",
"nfsserver": "cat-results.eng.com",
"pxedir": "/mts/builder-pxe",
"resource_uri": "/api/v2.0/location/1/",
"resultspath": "/results"
},
"nfsserver": "build-storage60",
"p4client": "vmktestdevnanny-builder-1423",
"path": "/storage60/release/sb-5242148",
"ready": true,
"resource_uri": "/api/v2.0/deliverable/4296956/",
"result": "PASS",
"sbbuildid": 5242148,
"sbjobid": 5242148,
"sbuser": "arajamanickam",
"starttime": "2015-03-31T06:16:50",
"targetchangeset": "494625",
"targets": "vcopssuitevm",
"triagetime": null,
"vmodl": null
}]
}
I want to get sbbuildid using powershell. How can I get this?
By converting your json to an object, using the ConvertFrom-Json cmdlet (assuming $jsonString contains the json above):
$jsonObj = $jsonString | ConvertFrom-Json
$jsonObj.objects.sbbuildid
$sb_build_id = $build_info.Substring($build_info.IndexOf("sbbuildid") + 11, 8).trim()
Put whole string in $build_info