Reading traffic flow data from HERE maps rest API - here-api

I am trying to use HERE maps REST API to get information about real-time traffic flow. The sample requests in HERE documentation work fine, however, I cannot find anywhere any documentation of the response (meaning of particular tags, such as <TRAFFICML_REALTIME>, <FIS> or <RW>).
Does anyone know how to obtain such a documentation?
Note: On HERE website I have found that all technical questions should be posted here and that their development support team is actively monitoring StackOverflow. There is no direct option to contact them.

Some of the tag meanings
"RWS" - A list of Roadway (RW) items
"RW" = This is the composite item for flow across an entire roadway. A roadway item will be present for each roadway with traffic flow information available
"FIS" = A list of Flow Item (FI) elements
"FI" = A single flow item
"TMC" = An ordered collection of TMC locations
"PC" = Point TMC Location Code
"DE" = Text description of the road
"QD" = Queuing direction. '+' or '-'. Note this is the opposite of the travel direction in the fully qualified ID, For example for location 107+03021 the QD would be '-'
"LE" = Length of the stretch of road. The units are defined in the file header
"CF" = Current Flow. This element contains details about speed and Jam Factor information for the given flow item.
"CN" = Confidence, an indication of how the speed was determined. -1.0 road closed. 1.0=100% 0.7-100% Historical Usually a value between .7 and 1.0
"FF" = The free flow speed on this stretch of road.
"JF" = The number between 0.0 and 10.0 indicating the expected quality of travel. When there is a road closure, the Jam Factor will be 10. As the number approaches 10.0 the quality of travel is getting worse. -1.0 indicates that a Jam Factor could not be calculated
"SP" = Speed (based on UNITS) capped by speed limit
"SU" = Speed (based on UNITS) not capped by speed limit
"TY" = Type information for the given Location Referencing container. This may be freely defined string

You should find it under "Meta Resources" in the documentation, following should provide the required info
http://traffic.cit.api.here.com/traffic/6.0/xsd/flow.xsd?app_id=DemoAppId01082013GAL%20&app_code=AJKnXv84fjrb0KIHawS0Tg

Related

How to request a navigation with heading?

I would like to use the HERE navigation API so that I arrive at the destination in a certain heading (in degrees from north, for example). This may require a detour to arrive at the destination in the correct direction. Can this be done? How?
EDIT: Also for a regular routing request, I would like to know the heading at the destination.
Please check Fleet Telematics API documentation on how to provide the heading for a waypoint - https://developer.here.com/documentation/fleet-telematics/api-reference.html. The documentation also helps us understand how to retrieve heading information in the response using customattributes parameter.
waypoint0 ... waypointN
required
string
Comma separated waypoint latitude, longitude in WGS-84 degree. A route must consist of at least 2 waypoints (start and destination). The maximum number of waypoints is limited. However, this limit is not a fixed number but is a result of the limit for the overall processing time. Set a transit radius by ;10000 to only influence the route to go via a certain city Set a heading by ;;;140 (degree clockwise from North) to improve map matching To define a loading/delay time at a waypoint, use stopOver[,timeInSeconds]!. Example: &waypoint1=stopOver,300!50.12,8.65. The optional specifications altitude, custom label, !StreetPosition and !LinkPosition are currently supported. The coordinates may be directly followed by ;transitRadius;label;heading. Waypoints can have opening and closing times, can be unsorted or optional. Details are in Key Concepts / Waypoint sorting, optional Pickup and Opening Times

Here api not showing any data in /places/v1/dicover/here for specific lat long

I am using here map api for getting nearby places but it is giving blank data (/places/v1/descover/here). While in /descover/explore/ it is giving so many records on same lat long. I am sharing screenshot for better understanding, Visit https://www.awesomescreenshot.com/image/3804672/65583a3e4f228ade754feba101ef26eb.
This depends on the use case you have.
The Here entrypoint helps users to identify direct places at their location or at a point selected on a map by returning places close to a given point, sorted by distance. (Normally the closest known places are returned, but if the uncertainty in the position is high then some nearer places are excluded from the result in favour of more popular places in the area of uncertainty.)
Then again the Explore entrypoint retrieves a complete list of relevant places nearby a given position or area. It answers the question "What interesting places are in the viewport of the map?" The results presented to the user are confined to those located in the current map view or search area and are ordered by popularity.
In general I would recommend to use the Explore entrypoint as the Here one is deprecated:
https://developer.here.com/documentation/places/topics_api/entrypoint-maturity-availability.html

Data Modelling for Big Data

I have this type of database to implement
Circled point are various cities.
People are travelling from one city to another.
Number of people travelling from one city to another are shown by the weight over the edges.
Circle G : is my goal city
What I want to achieve?
total number of people reaching "G"?
What path they followed to reach goal "G"?
e.g :
200 people started from A->F..!
100 goes back to A using Path F->A
from remaining 100 only 20 user made to reach Goal "G"
so, the number of people reaching "G" from the right side is 80
What information I need at point ā€œGā€
80 people from right side = 20(from A->F->G) + 60 (from A->D->F->G)
This is a small graph.
I want to implement this on a graph having 1000+ Nodes?
Right now the approach I am taking to solve this is (using ArangoDB) :
I am creating One Vertex collection and One Edge collection.
Each City (A, B, C, D) is document inside same collection.
I am saving the complete previous path for every people travelling.
e.g John is travelling from A->G
The details I am saving at F for John: {"John : A_D_F"}
The details I am saving at city G for John: {"John : A_D_F_G"}
I am repeating this for Every single people travelling.
In short I want to achieve funneling at Any point(city) in the graph.
What is the better way of data modelling for this type of graph in Arango or other Big Data Storage and which Big Data Storage will be best?
Thanks..!
You are right in your conclusion to treat this a graph problem. Irrespective of the tech stack that you want to use, I suggest you model your data by following some of the best practices/examples outlined in these links
https://neo4j.com/developer/guide-data-modeling/
https://www.infoq.com/articles/data-modeling-graph-databases
There are a lot of proven choices with reference to scaling to a 1000 or even 10000 node graph
Here is one possible way to model this:
a] Treat the Cities and Persons as Nodes
b] Then model the City-to-City path as Relationships
c] Also then add the Person-has-travelled-to-City as a Relationship
d] If you need to sequence the relationship you can use Properties on the Person-to-City relationship
Next step is to
Create these in a Graphdb of your choice
Create the Sample Dataset
Run your queries and check the answers
See if you need to optimize either the model or the Data
Hope this helps

R: Google Distance Matrix API request rate limit exceeded

I know that similar questions have been asked before, but from what I've been able to gather, none of the answers seem to apply to my case.
What I'm trying to do is replicate this, but in the R language : Computing the optimal road trip across the us
Everything works perfectly until I ask the Googles for the distance matrix for more than 10 locations. In my script (to follow) I list my API key, and on the API website I can see that my successful runs of the program (when the number of locations is less than 10) increase my usage for the day, so I know that my API is working... I think.
What I don't understand is why do I receive the "rate limit exceeded" error for, say, a distance matrix with 11 locations? If I have 1,500 requests left, I should certainly not have any issues, right? I should add that I am not familiar with other programming languages such as Java and Python, so that could explain part of my confusion.
Here be the relevant code:
# Request object from API
r <- GET(
"https://maps.googleapis.com/maps/api/distancematrix/json",
query = list(
origins = places,
destinations = places,
key = "INSERT API KEY HERE")
)
stop_for_status(r)
distances <- content(r)
The variable 'places' is simply a list containing the locations that I want distances to/from.
RTM?
Each query sent to the Google Maps Distance Matrix API is limited by
the number of allowed elements, where the number of origins times the
number of destinations defines the number of elements.
The Google Maps Distance Matrix API has the following limits in place:
Standard Usage Limits
Users of the standard API:
2,500 free elements per day
100 elements per query
100 elements per 10 seconds
Ergo: I think you have to split it up into several queries, with a 10 seconds pause in between, in order to get the full distance matrix.

Access Google's Traffic Data through a Web Service

Is there a way I can access traffic data that Google provides through a web service?
There seems to be a GTrafficOverlay that puts traffic on top of a route on an embedded google map, but no direct web service that I can consume to, say, give the source and the destination and find the traffic between them?
Is there any other source I can get this data from?
UPDATE (May 2022): From #AbdullahTahan:
Now google has this feature but it's paid and costs 0.01$ per request check this https://developers.google.com/maps/documentation/distance-matrix/distance-matrix#distance-matrix-advanced
UPDATE (March 2016): A lot has happened since this answer was written in 2011, but the core points appear to hold up: You won't find raw traffic data in free API services (at least not for the U.S., and probably not most other places). But if you don't mind paying a bit and/or if you just need things like "travel time for a specific route taking traffic into consideration" you have options. #Anto's answer, for example, points to Google's Maps For Work as a paid API service that allows you to get travel times taking traffic into consideration.
ORIGINAL ANSWER: There is no way (or at least no reasonably easy and convenient way) to get the raw traffic data from Google Maps Javascript API v3. Even if you could do it, doing so is likely to violate some clause in the Terms Of Service for Google Maps. You would have to get this information from another service. I doubt there is a free service that provides this information at the current time, but I would love it if someone proved me wrong on that.
As #crdzoba points out, Bing Maps API exposes some traffic data. Perhaps that can fill your needs. It's not clear from the documentation how much traffic data that exposes as it's only data about "incidents". Slow traffic due to construction would be in there, but it's not obvious to me whether slow traffic due simply to volume would be.
Apparently the information is available using the Google Directions API in its professional edition Maps for work. According to the API's documentation:
Note: Maps for Work users must include client and signature parameters with their requests instead of a key.
[...]
duration_in_traffic indicates the total duration of this leg, taking into account current traffic conditions. The duration in traffic will only be returned if all of the following are true:
The directions request includes a departure_time parameter set to a value within a few minutes of the current time.
The request includes a valid Google Maps API for Work client and signature parameter.
Traffic conditions are available for the requested route.
The directions request does not include stopover waypoints.
You might want to take a look at HERE MAP SERVICE. They have direct traffic data you can use, which is exactly what you need: https://developer.here.com/api-explorer/rest/traffic/traffic-flow-bounding-box
For example, by querying an area of interest, you might get something like this:
{
"RWS": [
{
"RW": [
{
"FIS": [
{
"FI": [
{
"TMC": {
"PC": 32483,
"DE": "SOHO",
"QD": "+",
"LE": 0.71682
},
"CF": [
{
"TY": "TR",
"SP": 9.1,
"SU": 9.1,
"FF": 17,
"JF": 3.2911,
"CN": 0.9
}
]
}
]
}
],
....
This example shows a current average speed SU of 9.1, where the free flow speed FF would be 17. The Jam factor JF is 3.3, which is still considered free flow but getting sluggish.
The units used (miles/km) can be defined in the API call.
To avoid dealing with TMC locations, you can ask for geocoordinates of the road segments by adding responseattributes=sh in the request.
The abbreviations used can be found here Interpreting HERE Maps real-time traffic tags:
"RWS" - A list of Roadway (RW) items
"RW" = This is the composite item for flow across an entire roadway. A roadway item will be present for each roadway with
traffic flow information available
"FIS" = A list of Flow Item (FI) elements
"FI" = A single flow item
"TMC" = An ordered collection of TMC locations
"PC" = Point TMC Location Code
"DE" = Text description of the road
"QD" = Queuing direction. '+' or '-'. Note this is the opposite of the travel direction in the fully qualified ID, For example for
location 107+03021 the QD would be '-'
"LE" = Length of the stretch of road. The units are defined in the file header
"CF" = Current Flow. This element contains details about speed and Jam Factor information for the given flow item.
"CN" = Confidence, an indication of how the speed was determined. -1.0 road closed. 1.0=100% 0.7-100% Historical Usually
a value between .7 and 1.0 "FF" = The free flow speed on this
stretch of road.
"JF" = The number between 0.0 and 10.0 indicating the expected quality of travel. When there is a road closure, the Jam Factor
will be 10. As the number approaches 10.0 the quality of travel is
getting worse. -1.0 indicates that a Jam Factor could not be
calculated
"SP" = Speed (based on UNITS) capped by speed limit
"SU" = Speed (based on UNITS) not capped by speed limit
"TY" = Type information for the given Location Referencing container. This may be freely defined string
Also the source comes from
https://developer.here.com/rest-apis/documentation/traffic/topics/additional-parameters.html
Bing Maps API has a REST service that returns traffic info
http://msdn.microsoft.com/en-us/library/hh441725
Rather than trying to pull the raw traffic data, you can try a different approach.
The Google Directions API allows you to query the api with a particular route and returns a JSON string or XML element as a result.
This result includes the element - ' duration_in_traffic '
This indicates the total duration of the particular leg of the journey, taking into account current traffic conditions. (for information on 'leg' and other elements of the JSON string returned by the Directions API refer link below)
https://developers.google.com/maps/documentation/directions/#JSON
I haven't tried this myself but just something I came across in the documentation.
In India we are using http://www.itrafficnews.com. But the data is posted by the users. I dont think google will provide the data.
Maybe you should have a look at Mapquests Traffic API: http://www.mapquestapi.com/traffic/
The webservice is unfortunately only available for some citys in the US, I think. But probably it solves your problem.
I don't think Google will provide this API. And traffic data not only contains the incident data.
Today many online maps show city traffic, but they have not provide the API for the developer. We even don't know where they get the traffic data. Maybe the government has the data.
So I think you could think about it from another direction. For example, there are many social network website out there. Everybody could post the traffic information on the website. We can collection these information to get the traffic status. Or maybe we can create a this type website.
But that type traffic data (talked about above) is not accurate. Even the information provided by human will be wrong.
Luckily I found that my city now provides an Mobile App called "Real-time Bus Information". It could tell the citizen where the bus is now, and when will arrive at the bus station. And I sniff the REST API in this App.
The data from REST API give the important data, for example the lat and lon, and also the bus speed. And it's real-time data! So I think we could compute the traffic status from these data (by some programming).
Here is some sample data : https://github.com/sp-chenyang/bus/blob/master/sample_data/bjgj_aibang_com_8899_bjgj_php_city_linename_stationno_datatype_type.json
Even the bus data will not enough to compute the accurate real-time traffic status. Incidents, traffic light and other things will affect the traffic status. But I think this is the beginning.
At the end, I think you could try to find whether your city provides these data.
PS: I am always thinking that life will be better for people in the future , but not now.
It is possible to get traffic data.
Below is my implementation in python. The API has some quota & is not fully free, but good enough for small projects
import requests
import time
import json
while True:
url = "https://maps.googleapis.com/maps/api/distancematrix/json"
querystring = {"units":"metric","departure_time":str(int(time.time())),"traffic_model":"best_guess","origins":"ITPL,Bangalore","destinations":"Tin Factory,Bangalore","key":"GetYourKeyHere"}
headers = {
'cache-control': "no-cache",
'postman-token': "something"
}
response = requests.request("GET", url, headers=headers, params=querystring)
d = json.loads(response.text)
print("On", time.strftime("%I:%M:%S"),"time duration is",d['rows'][0]['elements'][0]['duration']['text'], " & traffic time is ",d['rows'][0]['elements'][0]['duration_in_traffic']['text'])
time.sleep(1800)
print(response.text)
Response is :-
{
"destination_addresses": [
"Tin Factory, Swamy Vivekananda Rd, Krishna Reddy Industrial Estate, Dooravani Nagar, Bengaluru, Karnataka 560016, India"
],
"origin_addresses": [
"Whitefield Main Rd, Pattandur Agrahara, Whitefield, Bengaluru, Karnataka 560066, India"
],
"rows": [
{
"elements": [
{
"distance": {
"text": "10.5 km",
"value": 10505
},
"duration": {
"text": "35 mins",
"value": 2120
},
"duration_in_traffic": {
"text": "45 mins",
"value": 2713
},
"status": "OK"
}
]
}
],
"status": "OK"
}
You need to pass "departure_time":str(int(time.time())) is a required query string parameter for traffic information.
Your traffic information would be present in duration_in_traffic.
Refer this documentation for more info.
https://developers.google.com/maps/documentation/distance-matrix/intro#traffic-model
There is a project called Open Traffic which is not fully functional right now but seems to be the right answer in the future.
OpenTraffic is a global data platform to process anonymous positions of vehicles and smartphones into real-time and historical traffic statistics. We're building this in the open, using fully open-source software, with involvement from a growing list of partners.

Resources