xyzspaces.iml.apis.data_interactive_api module

This module contains a DataInteractiveApiClient class to perform API operations.

The HERE API reference documentation used in this module can be found here: Interactive API Reference

class xyzspaces.iml.apis.data_interactive_api.DataInteractiveApi(base_url, auth, proxies=None)[source]

Bases: xyzspaces.iml.apis.api.Api

This class provides access to HERE platform Data Interactive APIs.

Interactive APIs offer a set of unique capabilities, enabling you to store, retrieve, search for, analyze and modify data at a feature (e.g., a place) and feature property (e.g., the name of the place) level. With interactive APIs, data is stored in GeoJSON and can be retrieved dynamically at any zoom level.

Parameters
__init__(base_url, auth, proxies=None)[source]
Parameters
static query_params_to_string(params)[source]

Convert query params in a dictionary to string.

This method is required as character encoding needs to be skipped for , to support OR condition, and if property value has any special character then character encoding is required. As python requests by default does encoding of all the characters hence, this needs to be handled separately. For more details please check: https://saeljira.it.here.com/browse/DH-1369.

Parameters

params (Dict[str, Union[str, list, tuple]]) – A dict to represent query params.

Returns

A string.

Return type

str

get_feature(layer_id, feature_id, selection=None, force2d=False)[source]

Return the feature with the provided feature_id.

Parameters
  • layer_id (str) – Identifier of the Interactive Map Layer.

  • feature_id (str) – Feature id which is to fetched.

  • selection (Optional[List[str]]) – A list, only these properties will be present in returned feature.

  • force2d (bool) – If set to True then features in the response will have only X and Y components, else all x,y,z coordinates will be returned.

Returns

Response from the API.

Return type

Dict

get_features(layer_id, feature_ids, selection=None, force2d=False)[source]

Return all of the features found for the provided list of feature ids.

The response is always a FeatureCollection, even if there are no features with the provided ids.

Parameters
  • layer_id (str) – Identifier of the Interactive Map Layer.

  • feature_ids (List) – A list of feature_ids to fetch.

  • selection (Optional[List[str]]) – A list, only these properties will be present in returned features.

  • force2d (bool) – If set to True then features in the response will have only X and Y components, else all x,y,z coordinates will be returned.

Returns

Response from the API.

Return type

Dict

get_statistics(layer_id, skip_cache=False)[source]

Return statistical information about this layer.

Parameters
  • layer_id (str) – Identifier of the Interactive Map Layer.

  • skip_cache (bool) – If set to True the response is not returned from cache. Default is False.

Returns

Response from the API.

Return type

Dict

get_features_by_bbox(layer_id, bbox, clip=False, limit=30000, params=None, selection=None, skip_cache=False, clustering=None, clustering_params=None, force2d=False)[source]

Return the features which are inside a bounding box stipulated by bbox parameter.

Parameters
  • layer_id (str) – Identifier of the Interactive Map Layer.

  • bbox (tuple) – A list of four numbers representing the West, South, East and North margins, respectively, of the bounding box.

  • clip (bool) – A Boolean indicating if the result should be clipped (default: False).

  • limit (int) – A maximum number of features to return in the result. Default is 30000. Hard limit is 100000.

  • params (Optional[dict]) –

    A dict to represent additional filters on features to be searched.

    Examples:

    • params={"name": "foo"} returns all features with a value of property name equal to foo.

    • params={"name!": "foo"} returns all features with a value of property name not equal to foo.

    • params={"count=gte": "10"} returns all features with a value of property count greater than or equal to 10.

    • params={"count=lte": "10"} returns all features with a value of property count less than or equal to 10.

    • params={"count=gt": "10"} returns all features with a value of property count greater than 10.

    • params={"count=lt": "10"} returns all features with a value of property count less than 10.

    • params={"name=cs": "bar"} returns all features with a value of property name which contains``bar``.

  • selection (Optional[List[str]]) – A list, only these properties will be present in returned features.

  • skip_cache (bool) – If set to True the response is not returned from cache. Default is False.

  • clustering (Optional[str]) – The clustering algorithm to apply to the data within the result. Clustering algorithms supported: hexbin, quadbin.

  • clustering_params (Optional[Dict]) – Parameters for the chosen clustering algorithm.

  • force2d (bool) – If set to True then features in the response will have only X and Y components, else all x,y,z coordinates will be returned.

Returns

Response from the API.

Return type

Dict

get_features_in_tile(layer_id, tile_type, tile_id, clip=False, params=None, selection=None, skip_cache=False, clustering=None, clustering_params=None, margin=0, limit=30000, force2d=False)[source]

Retrieve features in tile.

Parameters
  • layer_id (str) – Identifier of the Interactive Map Layer.

  • tile_type (str) – A string with the name of a tile type, one of “quadkeys”, “web”, “tms” or “here”. The type of tile identifier. “quadkey” - Virtual Earth, “web” - Web Mercator, “tms” - OSGEO Tile Map Service, “here” - Here Tile Schema.

  • tile_id (str) – The tile identifier can be provided as quadkey (1), Web Mercator level,x,y coordinates (1_1_0) or OSGEO Tile Map Service level,x,y (1_1_0).

  • clip (bool) – A Boolean indicating if the result should be clipped (default: False).

  • params (Optional[dict]) –

    A dict to represent additional filters on features to be searched.

    Examples:

    • params={"name": "foo"} returns all features with a value of property name equal to foo.

    • params={"name!": "foo"} returns all features with a value of property name not equal to foo.

    • params={"count=gte": "10"} returns all features with a value of property count greater than or equal to 10.

    • params={"count=lte": "10"} returns all features with a value of property count less than or equal to 10.

    • params={"count=gt": "10"} returns all features with a value of property count greater than 10.

    • params={"count=lt": "10"} returns all features with a value of property count less than 10.

    • params={"name=cs": "bar"} returns all features with a value of property name which contains``bar``.

  • selection (Optional[List[str]]) – A list, only these properties will be present in returned features.

  • skip_cache (bool) – If set to True the response is not returned from cache. Default is False.

  • clustering (Optional[str]) – The clustering algorithm to apply to the data within the result. Clustering algorithms supported: hexbin, quadbin.

  • clustering_params (Optional[Dict]) – Parameters for the chosen clustering algorithm.

  • margin (Optional[int]) – Margin in pixels on the respective projected level around the tile. Default is 0.

  • limit (int) – The maximum number of features in the response. Default is 30000. Hard limit is 100000.

  • force2d (bool) – If set to True then features in the response will have only X and Y components, else all x,y,z coordinates will be returned.

Returns

Response from the API.

Return type

Dict

Retrieve the features which are inside the specified radius.

The origin radius point is calculated based either on latitude & longitude or by specifying a feature’s geometry.

Parameters
  • layer_id (str) – Identifier of the Interactive Map Layer.

  • lat (Optional[float]) – The latitude in WGS’84 decimal degree (-90 to +90) of the center Point.

  • lng (Optional[float]) – The longitude in WGS’84 decimal degree (-180 to +180) of the center Point.

  • ref_catalog (Optional[str]) – The catalog HRN where the layer containing the referenced feature is stored. Always to use in combination with ref_feature_id.

  • ref_layer_id (Optional[str]) – As alternative for defining center coordinates, it is possible to reference a geometry in a layer. Therefore it is needed to provide the layer id where the referenced feature is stored. Always to use in combination with ref_feature_id.

  • ref_feature_id (Optional[str]) – The unique identifier of a feature in the referenced layer. The geometry of that feature gets used for the spatial query. Always to use in combination with ref_catalog and ref_layer_id.

  • radius (Optional[int]) – Radius in meter which defines the diameter of the search request.

  • limit (int) – The maximum number of features in the response. Default is 30000. Hard limit is 100000.

  • params (Optional[dict]) –

    A dict to represent additional filters on features to be searched.

    Examples:

    • params={"name": "foo"} returns all features with a value of property name equal to foo.

    • params={"name!": "foo"} returns all features with a value of property name not equal to foo.

    • params={"count=gte": "10"} returns all features with a value of property count greater than or equal to 10.

    • params={"count=lte": "10"} returns all features with a value of property count less than or equal to 10.

    • params={"count=gt": "10"} returns all features with a value of property count greater than 10.

    • params={"count=lt": "10"} returns all features with a value of property count less than 10.

    • params={"name=cs": "bar"} returns all features with a value of property name which contains``bar``.

  • selection (Optional[List[str]]) – A list, only these properties will be present in returned features.

  • skip_cache (bool) – If set to True the response is not returned from cache. Default is False.

  • force2d (bool) – If set to True then features in the response will have only X and Y components, else all x,y,z coordinates will be returned.

Returns

Response from the API.

Return type

Dict

get_features_with_geometry_intersection(layer_id, data, radius=None, limit=30000, params=None, selection=None, skip_cache=False, force2d=False)[source]

Retrieve the features which are inside the specified radius and geometry.

The origin point is calculated based on the geometry provided as payload.

Parameters
  • layer_id (str) – Identifier of the Interactive Map Layer.

  • data (dict) – Geometry which will be used in intersection.

  • radius (Optional[int]) – Radius in meter which defines the diameter of the search request.

  • limit (int) – The maximum number of features in the response. Default is 30000. Hard limit is 100000.

  • params (Optional[dict]) –

    A dict to represent additional filters on features to be searched.

    Examples:

    • params={"name": "foo"} returns all features with a value of property name equal to foo.

    • params={"name!": "foo"} returns all features with a value of property name not equal to foo.

    • params={"count=gte": "10"} returns all features with a value of property count greater than or equal to 10.

    • params={"count=lte": "10"} returns all features with a value of property count less than or equal to 10.

    • params={"count=gt": "10"} returns all features with a value of property count greater than 10.

    • params={"count=lt": "10"} returns all features with a value of property count less than 10.

    • params={"name=cs": "bar"} returns all features with a value of property name which contains``bar``.

  • selection (Optional[List[str]]) – A list, only these properties will be present in returned features.

  • skip_cache (bool) – If set to True the response is not returned from cache. Default is False.

  • force2d (bool) – If set to True then features in the response will have only X and Y components, else all x,y,z coordinates will be returned.

Returns

Response from the API.

Return type

Dict

search_features(layer_id, limit=30000, params=None, selection=None, skip_cache=False, force2d=False)[source]

Search for features in the layer.

The results are unordered and the request does not allow to continue the search,

Parameters
  • layer_id (str) – Identifier of the Interactive Map Layer.

  • limit (int) – The maximum number of features in the response. Default is 30000. Hard limit is 100000.

  • params (Optional[dict]) –

    A dict to represent additional filters on features to be searched.

    Examples:

    • params={"name": "foo"} returns all features with a value of property name equal to foo.

    • params={"name!": "foo"} returns all features with a value of property name not equal to foo.

    • params={"count=gte": "10"} returns all features with a value of property count greater than or equal to 10.

    • params={"count=lte": "10"} returns all features with a value of property count less than or equal to 10.

    • params={"count=gt": "10"} returns all features with a value of property count greater than 10.

    • params={"count=lt": "10"} returns all features with a value of property count less than 10.

    • params={"name=cs": "bar"} returns all features with a value of property name which contains``bar``.

  • selection (Optional[List[str]]) – A list, only these properties will be present in returned features.

  • skip_cache (bool) – If set to True the response is not returned from cache. Default is False.

  • force2d (bool) – If set to True then features in the response will have only X and Y components, else all x,y,z coordinates will be returned.

Returns

Response from the API.

Return type

Dict

iter_features(layer_id, limit=30000, page_token=None, selection=None, skip_cache=False, force2d=False)[source]

Iterate over all of the features in the layer.

The features in the response are ordered so that no feature is returned twice.

Parameters
  • layer_id (str) – Identifier of the Interactive Map Layer.

  • limit (int) – The maximum number of features in the response in single iteration. Default is 30000. Hard limit is 100000.

  • page_token (Optional[str]) – The page token where the iteration will continue.

  • selection (Optional[List[str]]) – A list, only these properties will be present in returned features.

  • skip_cache (bool) – If set to True the response is not returned from cache. Default is False.

  • force2d (bool) – If set to True then features in the response will have only X and Y components, else all x,y,z coordinates will be returned.

Returns

Response from the API.

Return type

Dict

put_features(layer_id, data)[source]

Create or replace the provided features.

Parameters
  • layer_id (str) – Identifier of the Interactive Map Layer.

  • data (dict) – Request body representing FeatureCollection to create or replace.

Returns

Response from the API.

post_features(layer_id, data)[source]

Create or patch features.

Parameters
  • layer_id (str) – Identifier of the Interactive Map Layer.

  • data (dict) – Request body representing FeatureCollection to create or update.

Returns

Response from the API.

delete_features(layer_id, feature_ids)[source]

Delete multiple features from the layer.

Parameters
  • layer_id (str) – Identifier of the Interactive Map Layer.

  • feature_ids (List[str]) – A list of feature_ids to be deleted.

Returns

Response from the API.

put_feature(layer_id, feature_id, data)[source]

Creates or replace a feature in the layer.

Parameters
  • layer_id (str) – Identifier of the Interactive Map Layer.

  • feature_id (str) – Feature id which is to fetched.

  • data (dict) – Request body representing feature to create or replace.

Returns

Response from the API.

patch_feature(layer_id, feature_id, data)[source]

Patch an existing feature.

Parameters
  • layer_id (str) – Identifier of the Interactive Map Layer.

  • feature_id (str) – Feature id which is to fetched.

  • data (dict) – Request body representing feature to change.

Returns

Response from the API.

delete_feature(layer_id, feature_id)[source]

Delete an existing feature.

Parameters
  • layer_id (str) – Identifier of the Interactive Map Layer.

  • feature_id (str) – Feature id which is to fetched.

Returns

Response from the API.