RouteEngine¶
Quick reference¶
This notebook focuses on route acquisition, the head-agnostic route model and the search-along-route request. Most-used elements:
RouteEngine(credentials, on_routing_request=..., route_cache=...)RouteEngine.set_route_start/set_route_stop/set_route_width(...)RouteEngine.update_route_attributes()RouteEngine.search_at_position/search_flexpolylinebuild_corridor(...)/simplify_polyline(...)API.browse(..., polyline=..., width=...)
For the complete reference, see the API reference. For route architecture details, see Route engine and widget controller architecture. For the end-user behaviour, see Search Along the Route.
Methods used in this notebook¶
- class here_search_demo.route_engine.RouteEngine(credentials, *, routing_api=None, on_routing_request=None, route_cache=None, width=100, retrieve_route_fn=None)
Head-agnostic route state and routing retrieval service.
This class intentionally has no widget dependencies. It stores route/ranking state, computes derived search context, manages route cache, and retrieves route geometry through
RoutingAPI.
- async here_search_demo.widgets.route_geometry.build_corridor(points, width)
Return a Shapely polygon that is a
width-metre buffer around the polyline.Parameters¶
- points:
Route points in
(lat, lon)or(lat, lon, z)order.- width:
Buffer width in metres.
- here_search_demo.widgets.route_geometry.simplify_polyline(points, max_points, iterations=15)
Reduce
pointsto at mostmax_pointsusing GEOS Douglas–Peucker.- Return type:
list[tuple[float,float]]
- class here_search_demo.api.API(credentials=None, cache=None, raise_for_status=True, options=None, log_fn=None, on_request_sent=None, testing_header=False)
https://docs.here.com/geocoding-and-search/reference
- async autosuggest(session, q, latitude, longitude, polyline=None, width=None, all_along=None, x_headers=None, **kwargs)
Calls HERE Search Autosuggest endpoint
- Parameters:
session (
ClientSession) – instance of ClientSessionq (
str) – query textlatitude (
float) – search center latitudelongitude (
float) – search center longitudex_headers (
dict|None) – Optional X-* headers (X-Request-Id, X-AS-Session-ID, …)
- Param:
kwargs: additional request URL parameters
- Return type:
Response- Returns:
a Response object
- async browse(session, latitude, longitude, categories=None, food_types=None, chains=None, polyline=None, width=None, all_along=None, x_headers=None, **kwargs)
Calls HERE Search Browse endpoint
- Parameters:
session (
ClientSession) – instance of HTTPSessionlatitude (
float) – search center latitudelongitude (
float) – search center longitudecategories (
Sequence[str] |None) – Places category ids for filteringfood_types (
Sequence[str] |None) – Places cuisine ids for filteringchains (
Sequence[str] |None) – Places chain ids for filteringx_headers (
dict|None) – Optional X-* headers (X-Request-Id, X-AS-Session-ID, …)
- Param:
kwargs: additional request URL parameters
- Return type:
Response- Returns:
a Response object
- async discover(session, q, latitude, longitude, polyline=None, width=None, all_along=None, x_headers=None, **kwargs)
Calls HERE Search Discover endpoint
- Parameters:
session (
ClientSession) – instance of HTTPSessionq (
str) – query textlatitude (
float) – search center latitudelongitude (
float) – search center longitudex_headers (
dict|None) – Optional X-* headers (X-Request-Id, X-AS-Session-ID, …)
- Param:
kwargs: additional request URL parameters
- Return type:
Response- Returns:
a Response object