Using HERE for route optimization and delivery windows - here-api

New to HERE, so sorry for basic question.
We need to optimize routes. Typically start and end at some location, 20-30 waypoint along the way. Some of the stops have delivery windows (i.e deliver between 10:00 and 11:00 AM) some do not. Best way to accomplish this? Any relevant samples we can look at? Thanks

One of the option is HERE Matrix Routing API, it provides following features:
Large number of origins and destinations (up to 10,000)
Live traffic and historical speed patterns
Car, Truck, Pedestrian and Bicycle modes
Truck attributes such as dimensions, weight, tunnel restrictions and more
Avoiding areas and routing features, e.g., toll roads, ferries and motorways.
Choice between synchronous and asynchronous APIs for flexible result downloads
API document URI https://developer.here.com/documentation/matrix-routing-api/8.3.0/dev_guide/index.html
Request would be like :
POST https://matrix.router.hereapi.com/v8/matrix?async=false
Content-Type: application/json
Body:
{
"origins": [{"lat": 0.0, "lng": 0.0}, {"lat": 0.1, "lng": 0.1}, ...],
"destinations": [...], // if omitted same as origins
"regionDefinition": {
"type": "circle",
"center": {"lat": 0.0, "lng": 0.0},
"radius": 10000
}
}
Another option is HERE Routing API :
https://route.ls.hereapi.com/routing/7.2/calculateroute.json?waypoint0=52.5160%2C13.3779&waypoint1=52.5206%2C13.3862&mode=fastest%3Bcar%3Btraffic%3Aenabled&departure=now&apiKey=<API_KEY>

With the Tour Planning API you can solve many version of the vehicle routing problem. You can set delivery time windows for your depots and you can even specify details about your vehicles.
Here's an example with time windows.

Related

HERE Routing API V8: How to get route with multiple pass through waypoints

In v7, this is the way of getting route with multiple passthrough waypoints:
https://route.api.here.com/routing/7.2/calculateroute.json?waypoint0=32.353514,-61.126775&waypoint1=passThrough!32.365181,-61.102086&waypoint2=32.360273,-61.091979&mode=fastest;pedestrian...
In v8 api reference, there's "via" which seems to be used for stop over waypoints.
I tried https://router.hereapi.com/v8/routes?transportMode=pedestrian&return=summary,polyline,actions,instructions&origin=42.353514,-71.126775;42.365181,-71.102086&destination=42.360273,-71.091979&via=42.365181,-71.102086..
It's generating 2 legs ("section" in v8 definition) in the route. I'm expecting 1 leg.
This v8 developer guide page mentioned passThrough:
Waypoints may represent stopover points (that is, points where some time will be spent before retaking the route), or passthrough points that only influence the route's shape, but where no actual stop is carried out.
But I wasn't able to figure out how to query a route with multiple pass through points in v8.
Any advice?
Thanks!!
I am not sure if returning 2 sections instead of one in V8 is an issue.
Regarding the passthrough point, it's described in API reference as WaypointOptions for query parameter via:
Supported waypoint options:
- stopDuration: desired duration for the stop, in seconds.
So I assume that all requests treat via parameter without option stopDuration as passthrough point. But you always can add !stopDuration=0 to be 100% sure.
This request (with stopDuration=0 or without this option) https://router.hereapi.com/v8/routes?transportMode=car&return=travelSummary,summary,polyline,actions&origin=42.353514,-71.126775&destination=42.360273,-71.091979&via=42.365181,-71.102086!stopDuration=0&apikey=YOUR_API_KEY
returns summary:
"summary": {
"duration": 714,
"length": 3893,
"baseDuration": 637
}
and this request with stopDuration=900
https://router.hereapi.com/v8/routes?transportMode=car&return=travelSummary,summary,polyline,actions&origin=42.353514,-71.126775&destination=42.360273,-71.091979&via=42.365181,-71.102086!stopDuration=900&apikey=YOUR_API_KEY
returns summary:
"summary": {
"duration": 714,
"length": 3893,
"baseDuration": 1537
}
As you can see baseDuration was increased by 900 as requested.
Alternative option to solve this type of problem you can sent the two request.
For example : A-->B
B-->C
You pass the request like this
First request A-->B
https://router.hereapi.com/v8/routes?transportMode=pedestrian&return=summary,polyline,actions,instructions&origin=42.353514,-71.126775;42.365181,-71.102086&destination=42.365181,-71.102086
Second request B-->C
https://router.hereapi.com/v8/routes?transportMode=pedestrian&return=summary,polyline,actions,instructions&origin=42.365181,-71.102086&destination=42.360273,-71.091979
enter code here
Now add the result of both, you will get the desired distance and time.

Google maps API duration_in_traffic with waypoints

I need to get the duration_in_traffic for 3 legs of a journey. I make a call to google directions service with an origin, 2 waypoints, and a destination. Google then returns a JSON object with one route, comprised of 3 legs as expected, but only gives duration, not duration_in_traffic. Without the waypoints it does return the duration_in_traffic. If you include the waypoints and set stopover=false, then it routes the journey via the waypoints, reports the duration_in_traffic but doesn't return the information as separate legs.
I need the separate legs as I need to calculate information for each leg (e.g. fuel usage).
I could split the work into 3 separate calls, but that means incurring 3x the cost and paying Google more for the privilege.
Is there a way of getting duration_in_traffic AND having the results split into legs, using just one call?
This really makes sense, after all my investigation, it looks like we have to make 3 different calls to calculate the traffic duration for each routes. I am having the same issue.
But this could help at some point.
https://maps.googleapis.com/maps/api/directions/json?origin=Edison NJ&destination=Morristown, NJ&waypoints=via:Scotch Plains, NJ|via:Basking Ridge, NJ&departure_time=now&key=YOURKEY
You have to use via: keyword in waypoints to plan your destination using specific points. This returns one leg with total duration in traffic and total miles in the route. This should help you.
This describes, when you want to go to Morristown NJ from Edison NJ, you will be going through Scotch Plains and Basking Ridge waypoints.
{
distance: {
text: "19.2 mi",
value: 30859
},
duration: {
text: "40 mins",
value: 2379
},
duration_in_traffic: {
text: "35 mins",
value: 2120
}
For more info go to
https://developers.google.com/maps/documentation/directions/intro#Waypoints

To get more than 5 reviews from google places API

I am doing an application where I extract the google reviews using google places API.When I read the document related to it in "https://developers.google.com/maps/documentation/javascript/places",I found out that I could get only 5 top reviews.Is there any option to get more reviews.
In order to have access to more than 5 reviews with the Google API you have to purchase Premium data Access from Google.
That premium plan will grant you access to all sorts of additional data points you have to shell out a pretty penny.
If you are a Business owner wanting to retrieve all of your reviews, you can do so but first you have to get verified and could do this through the MyBusiness API more info here: https://developers.google.com/my-business/
There is a feature request for that: Issue 7630: Response to Include More Than 5 Reviews ─ I'd recommend you "star" it to receive updates.
Unfortunately there's no way to get more than 5 reviews in the places API unless you are the business owner after getting verified as Tekill said.
But it looks like there are some external services that can get all the reviews. My guess is that they scrape them from Google Maps directly:
Some of these services are Wextractor, ReviewShake and AllReviews
Alternatively, you can use a third party solution like SerpApi to scrape all the reviews of any place. It's a paid API with a free trial.
Each page fatches 10 results. To implement the pagination just use the start parameter which defines the result offset (e.g., 0 (default) is the first page of results, 10 is the 2nd page of results, 20 is the 3rd page of results, etc.)
Example python code (available in other libraries also):
from serpapi import GoogleSearch
params = {
"engine": "google_maps_reviews",
"place_id": "0x89c259a61c75684f:0x79d31adb123348d2",
"api_key": "SECRET_API_KEY"
}
search = GoogleSearch(params)
results = search.get_dict()
reviews = results['reviews']
Example output:
"reviews": [
{
"user": {
"name": "Waylon Bilbrey",
"link": "https://www.google.com/maps/contrib/107691056156160235121?hl=en-US&sa=X&ved=2ahUKEwiUituIlpTvAhVYCc0KHbvTCrgQvvQBegQIARAx",
"thumbnail": "https://lh3.googleusercontent.com/a-/AOh14GjOj6Wjfk1kSYjhvH7WIBNMdl4nPj6FvUhvYcR6=s40-c0x00000000-cc-rp",
"reviews": 1
},
"rating": 4,
"date": "a week ago",
"snippet": "I've been here multiple times. The coffee itself is just average to me. The service is good (the people working are nice). The aesthetic is obviously what brings the place some fame. A little overpriced (even for NY). A very small cup for $6 where I feel like the price comes from the top rainbow foam decor , when I'm going to cover it anyways. If it's for an insta pic then it may be worth it?"
},
{
"user": {
"name": "Amber Grace Sale",
"link": "https://www.google.com/maps/contrib/106390058588469541899?hl=en-US&sa=X&ved=2ahUKEwiUituIlpTvAhVYCc0KHbvTCrgQvvQBegQIARA7",
"thumbnail": "https://lh3.googleusercontent.com/a-/AOh14Gj84nHu_9V_0V4yRbZcr-8ZTYAHua6gUBP8fC7W=s40-c0x00000000-cc-rp-ba3",
"local_guide": true,
"reviews": 33,
"photos": 17
},
"rating": 5,
"date": "2 years ago",
"snippet": "They really take pride in their espresso roast here and the staff is extremely knowledgeable on the subject. It’s also a GREAT place to do work although a table is no guarantee; you might have to wait for a bit. My almond milk cappuccino was very acidic at the end which wasn’t expected but I could still tell the bean was high quality. Their larger lattés they put in a tall glass cup which looks really really cool. Would definitely go again.",
"likes": 2,
"images": [
"https://lh5.googleusercontent.com/p/AF1QipMup24_dHrWtNN4ZD70EPsiRMf_tykcUkPw6A1H=w100-h100-p-n-k-no"
]
},
{
"user": {
"name": "Kelvin Petar",
"link": "https://www.google.com/maps/contrib/100859090874785206875?hl=en-US&sa=X&ved=2ahUKEwiUituIlpTvAhVYCc0KHbvTCrgQvvQBegQIARBG",
"thumbnail": "https://lh3.googleusercontent.com/a-/AOh14GhdIvUDamzfPqbYIpwhnGJV2XWSi77iVXfEsiKS=s40-c0x00000000-cc-rp",
"reviews": 3
},
"rating": 4,
"date": "3 months ago",
"snippet": "Stumptown Cafe is the perfect place to work or catch up with friends. Never too loud, never too dead. Their lattes and deliciously addicting and the toasts are tasty as well. Wifi is always fast, which is a huge plus! The staff are the friendliest, I highly recommend this place!"
},
...
]
You can check out the documentation for more details.
Disclaimer: I work at SerpApi.
Adding to the answer of #miguev, there's at the moment no way to get more than 5 top reviews without using premium APIs (according to a Google Maps guy I had a talk with) and that's pricey.
We tried to sign for The Google Maps Platform Premium Plan to show them on pages like this but Google said it's no longer available for sign up or new customers. Right now we're limited to 5 reviews only.

Is there any way I can get a list of all possible responses from the google vision api?

I am using the google cloud vision api to analyze pictures. Is there a list of all the possible responses for the labelAnnotations method?
The API reference of Vision API gives an overview of all the possible JSON responses for the different image annotation requests.
The labelAnnotation request returns a generic EntityAnnotation response, you can find the JSON representation here, also containing more information about the JSON representation of BoundingPoly, LocationInfo and Property:
{
"mid": string,
"locale": string,
"description": string,
"score": number,
"confidence": number,
"topicality": number,
"boundingPoly": {
object(BoundingPoly)
},
"locations": [
{
object(LocationInfo)
}
],
"properties": [
{
object(Property)
}
],
}
I think you're asking whether you can get a look at the list of possible labels/entities that the Cloud Vision API will detect. If that's the case, the short answer is no, not in any manageable way.
The more complicated answer is sort of, since most labels will have a property for the knowledge graph entry (e.g., {desc: 'dog', mid: '/m/0bt9lr'}). This means that you can look-up more information about the label/entity using the Knowledge Graph API.
While you can't "store a copy" of Google's Knowledge Graph as a list of choices in a drop-down on a page, you can use the API to do a look-up after the Vision API responds with an ID.

Microsoft Band Web Tile Not Refreshing

This post is similar to Microsoft Band Web Tile not Updating, but the response marked as an answer to that question didn't really solve my issue, so I thought I'd start a new post.
I recently purchased a Band 2 and am trying to set up a web tile that will pull data from a service that provides data in JSON format (not an rss feed). So, I created a single-page non-feed tile using the 5-step authoring tool. When I first deployed the tile to my band, it successfully polled the service and displayed data; however, since that point, the data displayed on the web tile has not updated, even though the refresh interval is set (the default of 30 minutes).
The service that's being called is an ASP.Net Web API service. It is setting the following cache-related headers:
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Last-Modified:
ETag:
If I review the HTTP logs for the site, I can see where my service endpoint is getting called from my band/phone, roughly every 30 minutes, and the server responds with a 200 OK response on every call - I'm not seeing a 304 Not Modified response on the server side of the transaction.
My band is paired with an Android device (Samsung GS5). I've also tried pairing with an iPhone 6, as well, with the same result. Other tiles on the band seem to work fine (i.e., the standard ones that come with the MS Health app). as part of pairing/re-pairing, I've done a factory reset twice, and that didn't seem to help. I've tried re-starting both phones (when they were paired), as well. That doesn't help, either.
What am I missing?
For reference, here is what the web tile's manifest.json file contains (with placeholders for some data points:
{
"manifestVersion": 1,
"name": "<Name Here>",
"description": "<Description here>",
"version": 1,
"versionString": "1",
"author": "<Author Here>",
"organization": "",
"contactEmail": "",
"tileIcon": {
"46": "icons/tileIcon.png"
},
"icons": {},
"refreshIntervalMinutes": 30,
"resources": [
{
"url": "<URL Here>",
"style": "Simple",
"content": {
"_1_bg": "BG",
"_1_datestring": "DateString",
"_1_trend": "Trend",
"_1_direction": "Direction"
}
}
],
"pages": [
{
"layout": "MSBand_MetricsWithIcons",
"condition": "true",
"textBindings": [
{
"elementId": "12",
"value": "BG: {{_1_bg}}"
},
{
"elementId": "22",
"value": "{{_1_datestring}}"
},
{
"elementId": "32",
"value": "Trend: {{_1_trend}}, {{_1_direction}}"
}
]
}
],
"notifications": [
{
"condition": "{{_1_bg}} >= 250",
"title": "HIGH BG: {{_1_bg}}",
"body": "{{_1_datestring}}"
},
{
"condition": "{{_1_bg}} <= 80",
"title": "Low BG: {{_1_bg}}",
"body": "{{_1_datestring}}"
},
{
"condition": "{{_1_bg}} <= 55",
"title": "REALLY LOW: {{_1_bg}}",
"body": "{{_1_datestring}}"
}
]
}
Can you supply the URL for the resource? If so I can take a look at your server responses and see why the tile is not refreshing.
Better yet, can you share the webtile and I can try that to see why it is not refreshing. You can build your WebTile at https://developer.microsofthealth.com/WebTile/ and choose to submit it. Reply here with the name of it and I will take a look.
By the way, here is how we handle refresh on a simple tile:
If Etag was in the last response then use that with next request to let the server decide if there is something new to provide.
If Etag was not supplied, then look for Last-Modified and use that when available.
Else, process the downloaded data and send to the tile.
So, if you have Etag or Last-Modified in your server responses then we will use that to send in future requests and that may be causing your problem. In that case you would want to make sure that Etag and Last-Modified are not being sent in your server responses.
Some things I can think of:
Are you keeping the tile open on your WebTile while the updates are happening? If so, then tiles in some FW versions of the band do not update when new data comes in, close the tile and open it after the sync.
You can test your tile syncing more often than 30 minutes by hitting the sync icon on the top left of the left nav bar inside the Microsoft Health app.
After that, if you are still having problems please send feedback from inside the Microsoft Health app. Access via Left Nav, bottom under Settings, use the "Help and Feedback".
When reporting feedback, if you can attach the webtile that will help us test the webtile you are having problems with.
I share the frustration here. I too have exactly the same issue it seems. I have also been a developer for 20 years. My answer to this problem now is that there is a bug perhaps when JSON is used, and/or with Android phones. I've tried to get answers and discussions with Microsoft but not had any luck. My issue is at Web Tile works once but never refreshes

Resources