HERE Traffic Incident API Call Not Displaying Accidents - here-api

I am using a HERE API call to request traffic incident data from a particular start time. Whenever I include the "type" key and specify "Accident" as the value, no response is returned. However, switching the value to "Construction" does provide a response.
Does anyone have information on how to make the API call return accident data specifically?
Here is the exact call I am using:
https://traffic.api.here.com/traffic/6.3/incidents.json?app_id={{app_id}}&app_code={{app_code}}&startTime=2017-01-01T00:00:00-05:00&type=Accident&bbox=52.5233,13.4035;52.5181,13.4159

There is no data returned as there are no “Accident” type incidents in that location. This can be seen when skipping the “type” parameter:
https://traffic.api.here.com/traffic/6.3/incidents.xml?app_id=APP_ID&app_code=APP_CODE&startTime=2017-01-01T00:00:00-05:00&bbox=52.5233,13.4035;52.5181,13.4159
Traffic Data is dynamic data. Accident can be located somewhere and disappear in a matter of minutes. We recommend to use wego.here.com to locate an accident, or Bing maps (they are all using our services and traffic data).
We were able to find one in Germany right now (should be there until 13:34 German time):
https://traffic.api.here.com/traffic/6.3/incidents.xml?app_id=app_id&app_code=app_code&startTime=2017-01-01T00:00:00-05:00&prox=51.52427,11.85887,15&type=Accident
Hope this helps! Happy Coding!

Related

speed limits on highway

I would like to do a project on speed limits on highways in germany. I want to know the distance between changes of the speed limit. To do this I need get a dataset which includes the speed limit traffic signs or the areas where a speed limit is set along ONE highway.
I havent worked with here yet. And before I dig into the details I would like to know if here is the right tool to do this project. And of course it would be nice if you could also tell me briefly how to do it, since I dont't even know where to start in here :)
Thanks a lot!
I tried Openstreetmaps before, but the data is too outdated. For example you cannot see speed limits due to construction works.
I found this link on other posts https://github.com/seaBass3/here-pde-speed-limit
but it seems not valid any more
This can be solved by different approaches, but one the most feasible, is the following:
By using the tool HereTraffic API v7 you can get real-time traffic flow and information about traffic signs, by using query parameters, response structures, and data types.
You can get all the information required on real-time traffic flow data in JSON, including information on speed and jam factor for the region(s) defined in each request. Can also deliver additional data such as the geometry of the road segments in relation to the flow.
Provides aggregated information about traffic incidents in JSON, including the type and location of each traffic incident, status, start and end time, and other relevant data. This data is useful to dynamically optimize route calculations.
And if you need historical information also like from past dates you can always use Here Probe Data to get the data which can be compared with different datasets.
This is one of the examples you can use in order to get all the information you need:
curl -H "Authorization: Bearer $TOKEN" "https://data.traffic.hereapi.com/v7/flow?locationReferencing=shape&in=bbox:13.400,52.500,13.405,52.505"

HERE traffic api - Getting historical traffic data

I would like to get a traffic data map tile for a specific time. To do this,
https://developer.here.com/documentation/map-tile/dev_guide/topics/resource-traffic-flowbasetile.html as written in the documentation, I passed the "time" parameter. however, it looks like it does not work properly.
Requested example URL:
https://1.traffic.maps.ls.hereapi.com/maptile/2.1/traffictile/newest/normal.day/13/4358/2842/512/png?apiKey=apikey&ppi=500&time=2021-08-03T16:00:00Z
The response of real time traffic data on 2021-09-21T16:31:00z. I got this result without passing time parameter at exactly this time 2021-09-21T16:31:00z.
https://1.traffic.maps.ls.hereapi.com/maptile/2.1/traffictile/newest/normal.day/13/4358/2842/512/png?apiKey={apikey}&ppi=500
The response of data when I passed the time parameter.
https://1.traffic.maps.ls.hereapi.com/maptile/2.1/traffictile/newest/normal.day/13/4358/2842/512/png?apiKey={apikey}&ppi=500&time=2021-09-21T16:31:00z
As I tested the historical data response with my already saved response(when i requested to realtime traffic data) they are not same. Historical traffic data always returns similar response with little changes but they are not right.
It even returns result for future dates like 2022. Is the API broken? It works for realtime traffic data but has problems when i specify the time.
In Here Map Tile V2, you need to pass a timestamp after 2009, as a time before the year 2009 is not supported. For rest, the historical traffic data tile works well.
To achieve your request you should not use a time before year 2009 as this is not supported.
Response with Time parameter --
https://1.traffic.maps.ls.hereapi.com/maptile/2.1/traffictile/newest/normal.day/13/4358/2842/512/png?apiKey={YOUR_API_KEY}&ppi=500&time=2021-09-13T16:00:00z
Also please check the documentation for your reference.
https://developer.here.com/documentation/map-tile/dev_guide/topics/resource-traffic-traffictile.html

Here-API - Getroute historical route data

I have searched the questions here and gone through a fair amount of the API. I have not found reference to requesting historic route data. My questions is this; Does the Here api support historical route data. An example request would be that I seek the mileage from point a to point b 365 days ago, when perhaps a key route obstruction existed such as a bridge was out or a road was closed for construction that resulted in more miles during that historic period.
I would like to answer this in two parts
Can a route be calculated for a past date ?
Yes, you can. You need to request a Time Aware Route like below. You can read more about it in the developer site.
`
GET https://route.api.here.com/routing/7.2/calculateroute.json
?app_id={YOUR_APP_ID}
&app_code={YOUR_APP_CODE}
&mode=fastest;car;
&waypoint0=geo!37.743385,-122.422835
&waypoint1=geo!37.743878,-122.423686
&departure=2014-03-12T10:00:00
&routeattributes=sh,bb,g
`
Will the map used for the query depend on the departure date ?
No, Here API always uses the current version of the map available unless you specify explicitly the map version. But you can specify only till previous two releases.
So for your question, you wont be able to get the map data for a past year even using map version. But what you can do, is explicitly avoid the bridge or road newly constructed so that the api doesn't suggest that route. You can do this through Custom Route Extension API like below example.
GET http://cre.api.here.com/2/overlays/upload.json
?map_name=OVERLAYBLOCKROAD
&overlay_spec=[{"op":"override","shape":[[50.10765,8.68774],[50.10914,8.68771]],"layer":"LINK_ATTRIBUTE_FCN","data":{"VEHICLE_TYPES":"0"}}]
&storage=readonly
&app_id={YOUR_APP_ID}
&app_code={YOUR_APP_CODE}

How to include custom segments in the list of segments when querying the Google Analytics API?

This may be a possible duplicate of this question, but according to all the Google Analytics documentation I really should be able to pull my list of custom segments.
Since I have a very large list of them, it would be suboptimal for me to manually copy the segment ids over one at a time.
I'm following this walk through. Steps to reproduce:
Create a custom segment using date of first session in your Google Analytics account.
Authorize the Google Analytics guide to access your Google Analytics account.
Try their on-page query tester, and inspect whether your custom segment is there.
One thing I've already ruled out was the user that created the segment. I've manually created a segment with the same user that I'm querying the API with and it still does not show. Is there a flag I need to set somewhere to include custom segments?
Edit:
It turns out that it will list some custom segments, but not ones created with date of first session, so this is a duplicate of this question, which means that there is a bug in the Google Analytics API.
There was a bug which is now fixed. So it is now possible to list the Date of Session Segments in the Google Analytics Management API by calling the segments.list() method.
So after days of trying to solve this one I've come to the conclusion that it cannot be done as asked.
There is, however, another way to do it. For every segment set up a daily (or weekly, etc) email report to a email as a TSV. In each email body specify the name of the segment so when you're consuming the emails you can know which segment the attached TSV is for. It doesn't look like the daily reports were designed with segments in mind, since non of the metadata included in the TSV mentions which segment it is for.
From there it's trivial. Connect to the email address using an IMAP client once a day and update the numbers.
Note that the daily email only contains the numbers for that day (not a specified range), so you'll need to first generate the report one time with the historical data to load in.
While hacky, one nice thing about this approach is that it keeps your reports in sync with your (faked through email) api code (provided you match the column headings in the TSV). So, if for example, a new filter is included into a report, the new daily fields will continue to update.
Unfortunately though, the past data won't be reflected in the change.
Obviously this isn't great, but if you are monitoring daily cohorts it's the best you've got if you need to stay with Google Analytics. I have raised this as a bug to the Google Analytics developers, but I haven't heard back as to whether or not they plan to fix it.

Google Maps - Caching - Methods

Ok! So I have spoken to a google representative about this issue, however since I am not enterprise level, he can't push me to tech support and suggested that I use the SO for answers. Here is the question...
In Google Maps Terms it states the following:
(b) No Pre-Fetching, Caching, or Storage of Content. You must not pre-fetch, cache, or store
any Content, except that you may store: (i) limited amounts of Content for the purpose of
improving the performance of your Maps API Implementation if you do so temporarily (and in
no event for more than 30 calendar days), securely, and in a manner that does not permit
use of the Content outside of the Service; and (ii) any content identifier or key that
the Maps APIs Documentation specifically permits you to store. For example, you must not
use the Content to create an independent database of "places" or other local listings
information.
This led me to originally believe that google would not allow caching of any type of information. However, then I read the following:
When to Use Client-Side Geocoding
The basic answer is "almost always." As geocoding limits are per user session, there is no risk that your application will reach a global limit as your userbase grows. Client-side geocoding will not face a quota limit unless you perform a batch of geocoding requests within a user session. Therefore, running client-side geocoding, you generally don't have to worry about your quota.
Two basic architectures for client-side geocoding exist.
Run the geocoding and display entirely in the browser. For instance, the user enters an address on your page. Your application geocodes it. Then your page uses the geocode to create a marker on the map. Or your app does some simple analysis using the geocode. No data is sent to your server. This reduces load on your server, but doesn't give you any sense of what your users are doing.
Run the geocode in the browser and then send it to the server. For instance, the user enters an address. Your application geocodes it in the browser. The app then sends the data to your server. The server responds with some data, such as nearby points of interest. This allows you to customize a response based on your own data, and also to cache the geocode if you want. This cache allows you to optimize even more. You can even query the server with the address, see if you have a recently cached geocode for it, and if you do, use that. If you don't, then return no result to the browser, and let it geocode the result and send it back to the server to for caching.
So one side says you cannot cache, the other side tells you, you should. Another solution it states is to always use clientside when you can, but then this becomes a grey area as well, because both examples state that you must have a user input data. What if the jquery read data from a div or span and then geocoded the information? The user wouldn't have actually done the geocode,but it was still done client-side? I'm trying to create a site that has a bunch of events generated by users and this site could get pretty loaded, so I am trying to determine the best practice in being able to do this. Google suggested here, so before you go and say this is "off-topic" please note, this is where they stated me to post.
Any feedback would be greatly appreciated.
The first quote does not explicitly forbid caching data at all. It is ambiguous as to how much you can cache (what number explicitly is "limited amounts"?) but it does not forbid caching.
You are allowed to cache the data if it helps improve the performance of your site as long as you retain the data for no longer than 30 days and do not make it available in any way to any other service except the service that originally retrieved the data.
Regarding user interaction - if your user explicitly enters a page with the expectation that they will be shown geocoded information I would assume that this would fulfill "user interaction".
As an example from a project I worked on last year I had it set up to do the following:
- Show markers on the map
- If the user clicked a marker they were shown a popup with data from the cache if available, otherwise a geocode would be performed and the returned information would be cached along with the date/time of the cache.
Another page of the site showed a history of these markers at 5 minute intervals throughout the day. If cached data was present (from clicking the map marker as in the previous part) this would be shown, otherwise a geocode would be performed and the data cached as before. The user clicking to run the report was (in my opinion) enough "user interaction" to not count as pre-fetching as the user had to manually select a timeframe before the report would be displayed.
A cronjob then ran every day at midnight which would go through each record with cached data over 25 days old and remove it.
As it was I was caching much less than 10% of the marker positions being shown (20+ markers being updated every minute, but the report was being run on maybe 3-5 markers each day and only geocoding data for every 5th point).

Resources