PTV Developer Routing API OpeningInterval is not applied - rest

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"
}
]
}
}
]
}

Related

Autocomplete: Read LAT/LON

Is there an easy way to obtain the geolocation data of an autocomplete reply?
Currently only text is returned in a query. How would one read the GPS coordinates for an entry?
https://autocomplete.search.hereapi.com/v1/autocomplete?apiKey=xxx&q=k%C3%B6ln%20&in=countryCode:DEU&lang=de&limit=20&resultType=city,postalCode
{
"title": "Deutschland, Köln, Anschlussstelle Köln-Messe",
"id": "here:af:street:kXSoQ5Ilp2fEnS-ifyMsXD",
"resultType": "street",
"address": {
"label": "Anschlussstelle Köln-Messe, 50679 Köln, Deutschland",
"countryCode": "DEU",
"countryName": "Deutschland",
"stateCode": "NW",
"state": "Nordrhein-Westfalen",
"countyCode": "K",
"county": "Köln",
"city": "Köln",
"street": "Anschlussstelle Köln-Messe",
"postalCode": "50679"
},
"highlights": {
"title": [
{
"start": 35,
"end": 39
}
],
"address": {
"label": [
{
"start": 16,
"end": 20
}
],
"street": [
{
"start": 16,
"end": 20
}
]
}
}
},
The idea of autocomplete is to provide key-by-key input completion for the end user. We believe the end user can decide based on the text response and does not need to show the position on the map. Only for the result that the user clicks on a lookup needs to be requested from the application which then shows the complete address including position.
So to get the geolocation, you need to use lookup endpoint while the user clicks, e.g: https://lookup.search.hereapi.com/v1/lookup?id=here:af:street:kXSoQ5Ilp2fEnS-ifyMsXD&apiKey={{YOUR_API_KEY}}
In addition, you can evalaute the autosuggestion endpoint (which contains the position info) and see if it can meet your requirement: https://developer.here.com/documentation/geocoding-search-api/dev_guide/topics/endpoint-autosuggest-brief.html

Getting speed limit based on a single coordinate using here REST API

I want to retrieve speed limit based on a single coordinate(of a road in the USA) using HERE REST API(not PDE). So, I only got the api_key(no app code). I searched and found some solutions which were deprecated and required the PDE api. If anybody knows the latest solution please let me know. Thanks. Anyway I got something which gives speed limit for two coordinates(not my case) and if I put the two coordinates same I get the wrong(very small) value for speed limit. which is given bellow:
https://router.hereapi.com/v8/routes?apiKey=APP_KEY&transportMode=car&origin=-37.956650,145.220673&destination=-37.956650,145.220673&spans=speedLimit&return=polyline
{
"routes": [
{
"id": "0a903f38-aecd-4850-a87e-0848c7583b8a",
"sections": [
{
"id": "4aa23cb0-0209-4e31-bca8-32f4cfb9f98e",
"type": "vehicle",
"departure": {
"time": "2021-02-25T12:52:34+11:00",
"place": {
"type": "place",
"location": {
"lat": -37.9566675,
"lng": 145.2206532
},
"originalLocation": {
"lat": -37.9566501,
"lng": 145.220673
}
}
},
"arrival": {
"time": "2021-02-25T12:52:34+11:00",
"place": {
"type": "place",
"location": {
"lat": -37.9566675,
"lng": 145.2206532
},
"originalLocation": {
"lat": -37.9566501,
"lng": 145.220673
}
}
},
"polyline": "BG1j2soC6iy_0IAA",
"spans": [
{
"offset": 0,
"speedLimit": 27.7777786
}
],
"transport": {
"mode": "car"
}
}
]
}
]
}
Is there any latest rest api service provided by Here that gives speed limit for a geo coordinate(not the pde one)?

How get total distance and time from waypoints in HERE REST API

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"
}
}

HTTP requests are tampered by other HTTP requests, with golang and standard library

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.

GET request endpoint results rider_id is null

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.