Geospatial filtering
This chapter provides examples on the geospatial filtering. For more information, see Geospatial filters.
Note
The geospatial filtering will affect the items that are returned, but it will not change the response format. So the examples below do not show the response data. See examples of responses in Request flow data and Request incident data.
Request flow or incidents within a radius around a location
Use the geospatial filter in=circle:{latitude},{longitude};r={radius}
to request /flow
or /incidents
within a certain radius around a location.
For example, to request flow around Berlin, Germany within a radius of 2000 meters, send a request as follows:
curl -H "Authorization: Bearer $TOKEN" "https://data.traffic.hereapi.com/v7/flow?in=circle:52.50811,13.47853;r=2000&locationReferencing=olr"
curl "https://data.traffic.hereapi.com/v7/flow?in=circle:52.50811,13.47853;r=2000&locationReferencing=olr&apiKey=$API_KEY"
To request incidents at the same location, use the following request:
curl -H "Authorization: Bearer $TOKEN" "https://data.traffic.hereapi.com/v7/incidents?in=circle:52.50811,13.47853;r=2000&locationReferencing=olr"
curl "https://data.traffic.hereapi.com/v7/incidents?in=circle:52.50811,13.47853;r=2000&locationReferencing=olr&apiKey=$API_KEY"
Request flow or incidents within a rectangular area
Use the geospatial filter in=bbox:{west longitude},{south latitude},{east longitude},{north latitude}
to request /flow
or /incidents
inside a rectangular bounding box.
For example, to request flow in an area of Berlin, Germany, send a request as follows:
curl -H "Authorization: Bearer $TOKEN" "https://data.traffic.hereapi.com/v7/flow?in=bbox:13.386969,52.527129,13.424134,52.549420&locationReferencing=olr"
curl "https://data.traffic.hereapi.com/v7/flow?in=bbox:13.386969,52.527129,13.424134,52.549420&locationReferencing=olr&apiKey=$API_KEY"
To request incidents at the same location, use the following request:
curl -H "Authorization: Bearer $TOKEN" "https://data.traffic.hereapi.com/v7/incidents?in=bbox:13.386969,52.527129,13.424134,52.549420&locationReferencing=olr"
curl "https://data.traffic.hereapi.com/v7/incidents?in=bbox:13.386969,52.527129,13.424134,52.549420&locationReferencing=olr&apiKey=$API_KEY"
Request flow or incidents within a corridor
Use the geospatial filter in=corridor:{polyline};r={radius}
to request /flow
or /incidents
inside a corridor of a certain width.
The polyline is a flexible polyline and specifies the waypoints of the corridor. The radius determines the distance in meters for the corridor to extend to each side of the waypoints. That is, a radius of 230 meters defines a corridor 460 meters wide.
A flexible polyline is a special encoding of a list of latitude and longitude pairs. Each coordinate is converted to an integer, the number of decimals to keep is specified by a precision. With a precision of 5, the latitude 50.1022829
would become 5010228
. Each such integer is then transformed into a series of characters from the set ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_
, so the whole polyline is finally represented by a string consisting of only those characters.
Example:
BFoz5xJ67i1B1B7PzIhaxL7Y
is the representation of the following polyline:
50.1022829,8.6982122
50.1020076,8.6956695
50.1006313,8.6914960
50.0987800,8.6875156
For more information, see flexible polyline.
To request flow within a corridor:
curl -H "Authorization: Bearer $TOKEN" "https://data.traffic.hereapi.com/v7/flow?in=corridor:BFoz5xJ67i1B1B7PzIhaxL7Y;r=230&locationReferencing=olr"
curl "https://data.traffic.hereapi.com/v7/flow?in=corridor:BFoz5xJ67i1B1B7PzIhaxL7Y;r=230&locationReferencing=olr&apiKey=$API_KEY"
To request incidents in the same corridor:
curl -H "Authorization: Bearer $TOKEN" "https://data.traffic.hereapi.com/v7/incidents?in=corridor:BFoz5xJ67i1B1B7PzIhaxL7Y;r=230&locationReferencing=olr"
curl "https://data.traffic.hereapi.com/v7/incidents?in=corridor:BFoz5xJ67i1B1B7PzIhaxL7Y;r=230&locationReferencing=olr&apiKey=$API_KEY"