### Setup Example Catalogs and Layers Source: https://docs.here.com/data-sdk/docs/pysdk-here-platform-layers This code snippet demonstrates how to initialize the HERE Platform SDK and retrieve various layer types (versioned, volatile, index, stream, object store, and interactive map) from different catalogs. It sets up the necessary objects for reading data from these layers. ```python from here.platform import Platform platform = Platform() oma_catalog = platform.get_catalog('hrn:here:data::olp-here:oma-3') versioned_layer = oma_catalog.get_layer('topology_geometry_segment') wx_catalog = platform.get_catalog('hrn:here:data::olp-here:live-weather-eu') volatile_layer = wx_catalog.get_layer('latest-data') sdii_catalog = platform.get_catalog('hrn:here:data::olp-here:olp-sdii-sample-berlin-2') index_layer = sdii_catalog.get_layer('sample-index-layer') traffic_catalog = platform.get_catalog('hrn:here:data::olp-here:olp-traffic-1') stream_layer = traffic_catalog.get_layer('traffic-incidents-delta-stream') samples_catalog = platform.get_catalog('hrn:here:data::olp-here:here-geojson-samples') objectstore_layer = samples_catalog.get_layer('objectstore') test_catalog = platform.get_catalog(...) interactive_map_layer = test_catalog.get_layer(...) ``` -------------------------------- ### getStartVersion Source: https://docs.here.com/data-sdk/page/sdk-for-typescript-classes-olp_sdk_dataservice_read-catalogversionrequest Gets a catalog start version for the request. ```APIDOC ## Method: getStartVersion ### Description Gets a catalog start version for the request. ### Signature `getStartVersion(): undefined | number` ### Returns - **undefined | number** - The catalog start version. ``` -------------------------------- ### Initialize platform and get catalog Source: https://docs.here.com/data-sdk/docs/pysdk-here-platform-catalogs Initializes the HERE platform client and retrieves a catalog object using its HRN. This setup is required for all catalog operations in this section. ```python from here.platform import Platform platform = Platform() hrn = "hrn:here:data::olp-here:your-catalog" catalog = platform.get_catalog(hrn=hrn) ``` -------------------------------- ### Create a project with Platform.create_project Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-here-platform-platform Usage example for creating a project. Requires a Platform instance. The method returns a Project object. The example passes id, name, and description. ```python >>> from here.platform import Platform >>> platform = Platform() >>> project = platform.create_project(id="create-project", name="name", ... description="description") ``` -------------------------------- ### Install the SDK modules Source: https://docs.here.com/data-sdk/docs/get-data-object-store-layer Installs the required HERE Data SDK modules for authentication, dataservice read, and dataservice API. ```sh npm install --save @here/olp-sdk-authentication @here/olp-sdk-dataservice-read @here/olp-sdk-dataservice-api ``` -------------------------------- ### Create a catalog with Platform.create_catalog Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-here-platform-platform Usage example for creating a catalog. Requires a Platform instance. The method returns a Catalog object. The example passes id, name, summary, description, and tags. ```python >>> from here.platform import Platform >>> platform = Platform() >>> catalog = platform.create_catalog(id="create-catalog", name="name", ... summary="summary", description="description", tags=["tag1", "tag2"]) ``` -------------------------------- ### Install Data SDK modules with npm Source: https://docs.here.com/data-sdk/docs/get-started-with-here-data-sdk-for-typescript Run these npm commands to install the Data SDK modules for TypeScript development. ```sh npm install @here/olp-sdk-authentication npm install @here/olp-sdk-core npm install @here/olp-sdk-dataservice-read npm install @here/olp-sdk-dataservice-write npm install @here/olp-sdk-dataservice-api ``` -------------------------------- ### Upgrade all HERE Data SDK packages with pip install Source: https://docs.here.com/data-sdk/docs/pysdk-upgrade Use this command to upgrade all HERE Data SDK packages to specific versions. Always upgrade all installed SDK packages together; mixing versions is not supported. Remove packages you don't have installed from the command. ```bash pip install --extra-index-url https://repo.platform.here.com/artifactory/api/pypi/analytics-pypi/simple/ here-platform==2.33.0 here-geotiles==2.33.0 here-geopandas-adapter==2.33.0 here-content==2.33.0 here-inspector==2.33.0 ``` -------------------------------- ### getTile example usage Source: https://docs.here.com/data-sdk/page/sdk-for-typescript-modules-olp_sdk_dataservice_read Shows how to use the getTile function with a TileRequest and parameters. The example includes creating a TileRequest, setting parameters, and calling getTile with two different tile keys. ```typescript const params: GetTileParams = { settings: "% your `OlpClientSettings` instance % ", catalogHrn: "% the HRN instance of your catalog %", layerId: "% your layer ID %", layerType: "% versioned or volatile %", } const request = new TileRequest(); const tile1 = await getTile(request.withTileKey(yourTileKey1), params); const tile2 = await getTile(request.withTileKey(yourTileKey2), params); ``` -------------------------------- ### Get tile boundary polygon (duplicate example) Source: https://docs.here.com/data-sdk/docs/pysdk-here-geotiles Get the boundary of tile10 as a Shapely Polygon. This is a duplicate of the earlier example, shown again in the source. ```python print(ht.get_polygon(tile10)) POLYGON ((-87.5390625 41.8359375, -87.5390625 42.1875, -87.890625 42.1875, -87.890625 41.8359375, -87.5390625 41.8359375)) ``` -------------------------------- ### Create an npm project Source: https://docs.here.com/data-sdk/docs/get-data-object-store-layer Initializes a new npm project in a directory named example-app. ```sh mkdir example-app && cd example-app && npm init ``` -------------------------------- ### from_coordinates example Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-here-geotiles-heretile Example of using from_coordinates to get the tile ID for a given coordinate. ```python >>> # Berlin main station >>> from_coordinates(13.36937, 52.52507, 14) 377894440 ``` -------------------------------- ### Getting stream metadata in a DataFrame Source: https://docs.here.com/data-sdk/docs/pysdk-here-geopandas-adapter Example of getting stream metadata in a DataFrame using the GeoPandasAdapter. ```python from here.platform import Platform from here.geopandas_adapter import GeoPandasAdapter platform = Platform(adapter=GeoPandasAdapter()) sdii_catalog = platform.get_catalog("hrn:here:data::olp-here:olp-sdii-sample-berlin-2") stream_layer = sdii_catalog.get_layer("sample-streaming-layer") with stream_layer.subscribe() as subscription: partitions_df = stream_layer.get_stream_metadata(subscription=subscription) ``` -------------------------------- ### List projects using Platform.list_projects Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-here-platform-platform Demonstrates how to initialize the Platform object and retrieve a list of projects with a specified limit. ```python >>> from here.platform import Platform >>> platform = Platform() >>> resp = platform.list_projects(limit=10) ``` -------------------------------- ### Initialize SDK with credentials and configuration Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-modules-here-platform-platform Sets up the SDK client with credentials, application config, platform config, and optional proxies. Handles different credential types (Credentials and Token) and sets up authentication. Configures polling and retry times based on local environment. ```python self.credentials = credentials or PlatformCredentials.from_default() self.application_config = application_config or ApplicationConfig.from_default() self.application_config.additional_parameters = kwargs.copy() self._platform_config = platform_config or PlatformConfig.from_environment( self._environment ) self._polling_wait = ( 0.1 if self._local_environment else self.application_config.polling_wait ) self._retry_max_time = ( 5 if self._local_environment else self.application_config.retry_max_time ) self.proxies = proxies self.default_adapter: Adapter = DefaultAdapter() self.adapter: Adapter = adapter or self.default_adapter self.lookup_api_registry = LookupApiRegistry() self.billing_tag = billing_tag self._project_hrn = project_hrn if self._platform_config.account_url is None: self.auth = None else: if ( self.credentials is not None and self.credentials.cred_type == CredentialsType.Credentials ): aaa_oauth2_api = AAAOauth2Api( base_url=self.credentials.cred_properties["endpoint"], platform_config=self.platform_config, application_config=self.application_config, proxies=proxies, ) self.auth = Auth(self.credentials, aaa_oauth2_api=aaa_oauth2_api) elif ( self.credentials is not None and self.credentials.cred_type == CredentialsType.Token ): assert self.credentials self.auth = Auth(self.credentials) else: # Unexpected credentials type assert False if self._project_hrn and self.auth is not None: self.auth.set_scope(self._project_hrn) self.api_factory: APIFactory = APIFactory( platform_config=self.platform_config, application_config=self.application_config, auth=cast(Auth, self.auth), proxies=cast(dict, self.proxies), local_environment=self._local_environment, lookup_api_registry=self.lookup_api_registry, ) self._schema_reg: SchemaRegistry = None # type: ignore ``` -------------------------------- ### Get catalog details Source: https://docs.here.com/data-sdk/docs/pysdk-here-platform-catalogs Retrieves the details of the catalog identified by the HRN used in the setup. ```python catalog_details = catalog.get_details() ``` -------------------------------- ### Get a single service by HRN Source: https://docs.here.com/data-sdk/docs/pysdk-here-platform-services Connects to a service by providing its HRN. The example uses the HERE Routing service HRN. ```python routing_service = platform.get_service("hrn:here:service::olp-here:routing-8") ``` -------------------------------- ### Initialize Platform and Retrieve Service Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-modules-here-platform-platform Demonstrates how to initialize the Platform object and retrieve a specific service using its HRN. ```python >>> from here.platform import Platform >>> platform = Platform() >>> platform.get_service("hrn:here:service::olp-here:routing-8") #doctest: +ELLIPSIS >>> ``` -------------------------------- ### constructor Source: https://docs.here.com/data-sdk/page/sdk-for-typescript-classes-olp_sdk_core-olpclientsettings Creates a new instance of OlpClientSettings. ```APIDOC ## constructor ### Description Creates a new instance of OlpClientSettings. ### Signature `constructor()` ### Parameters No parameters are documented. ### Returns A new OlpClientSettings instance. ``` -------------------------------- ### get(path: str, params: dict | None = None, headers: dict | None = None, as_json: bool = True, success_codes: List[int] = [200], **kwargs) -> Any Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-here-platform-service Perform a GET request on the service for the given path of the service. Example, `service.get("/path")`. ```APIDOC ## Service.get ### Description Perform a GET request on the service for the given path of the service. Example, `service.get("/path")` ### Parameters - **path** (str) - Required - Path to be called on the service. - **params** (dict | None) - Optional - Parameters to pass to the API. - **headers** (dict | None) - Optional - Request headers. Defaults to the Api headers property. - **as_json** (bool) - Optional - A boolean to indicate type of response. If True then response will be returned in json format. If False, requests.Response object will be returned. - **success_codes** (List[int]) - Optional - List of HTTP response codes which are treated as success. - **kwargs** (optional) - Optional arguments that can be passed to requests' GET call. ### Returns Response from the API. ### Raises PlatformException - in case of unsuccessful response ``` -------------------------------- ### Create a project: instantiate Platform Source: https://docs.here.com/data-sdk/docs/pysdk-here-platform-projects Creates a Platform instance to interact with the HERE platform. ```python platform = Platform() ``` -------------------------------- ### Get a specific catalog version Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-modules-here-platform-catalog Returns details of a single catalog version. Raises ValueError if the version is not a non-negative integer or if the version does not exist (start >= latest). Uses the data metadata API to list versions for the range [version-1, version]. ```python def get_version(self, version: int) -> Version: """ Return details of a single version which is specified. :param version: An int to specify the specific version for which catalog details are needed :return: details of the version specified :raises ValueError:The value of the version is not an integer or when the value is greater than the latest catalog version or less than 0 """ if type(version) == int and version >= 0: start = version - 1 end = version latest = self.latest_version() else: raise ValueError( f"Invalid Version value -> {version}, expected positive integer value." ) if latest is None: latest = -1 if start >= latest: raise ValueError(f"Version {version} does not exist.") get_version_resp = self._data_metadata_api.list_versions( start, end, billing_tag=self.billing_tag ) return Version(get_version_resp["versions"][0]) ``` -------------------------------- ### Set up a Node.js project for HERE Data SDK Source: https://docs.here.com/data-sdk/docs/get-partition-metadata-index-layer Commands to create an npm project, initialize TypeScript, install Node types, and install the required HERE Data SDK modules for the Node.js app. ```sh mkdir example-app && cd example-app && npm init ``` ```sh tsc --init ``` ```sh npm install --save-dev @types/node ``` ```sh npm install --save @here/olp-sdk-authentication @here/olp-sdk-dataservice-read @here/olp-sdk-dataservice-api ``` -------------------------------- ### getChanges(builder, params) Source: https://docs.here.com/data-sdk/page/sdk-for-typescript-modules-olp_sdk_dataservice_api-metadataapi Gets the latest partition metadata in a version range for a versioned layer or a time range for a volatile layer. For versioned layers, the range is expressed as a start and end version and might not return all changes for partitions added and removed in between. ```APIDOC ## getChanges(builder, params) ### Description Gets the latest partition metadata in a version range for a versioned layer or a time range for a volatile layer. For versioned layers, the range is expressed as a start and end version and might not return all changes for the partitions which were added and removed in between the specified start and end versions. ### Method Function call ### Signature `getChanges(builder: RequestBuilder, params: { additionalFields?: string[]; billingTag?: string; endVersion?: number; layerId: string; range?: string; sinceTime?: number; startVersion?: number }): Promise` ### Parameters - **builder** (RequestBuilder) - Required - The request builder used to construct the API request. - **params** (object) - Required - An object containing the parameters for the request. - **additionalFields** (string[]) - Optional - Additional fields to include in the response. - **billingTag** (string) - Optional - A billing tag for cost tracking. - **endVersion** (number) - Optional - The end version for versioned layers. - **layerId** (string) - Required - The ID of the layer. - **range** (string) - Optional - The range for the request. - **sinceTime** (number) - Optional - The start time for volatile layers. - **startVersion** (number) - Optional - The start version for versioned layers. ### Returns - **Promise** - A promise that resolves to the partition metadata. ### Defined in [@here/olp-sdk-dataservice-api/lib/metadata-api.ts:224](https://github.com/heremaps/here-data-sdk-typescript/blob/4fafecd/@here/olp-sdk-dataservice-api/lib/metadata-api.ts#L224) ``` -------------------------------- ### Create a project: call create_project Source: https://docs.here.com/data-sdk/docs/pysdk-here-platform-projects Creates a project with the specified ID, name, and description. ```python project = platform.create_project(project_id, project_name, project_desc) ``` -------------------------------- ### Jupyter async fix for large uploads (50 MB+) Source: https://docs.here.com/data-sdk/docs/pysdk-here-platform-layers Add at the start of a Jupyter notebook before calling write_partitions when publishing more than 50 MB to a single partition. It re-applies the event loop when using nested or external multipart uploads. The statements are an explicit setup requirement. ```python import nest_asyncio import asyncio nest_asyncio.apply(loop=asyncio.get_event_loop()) ``` -------------------------------- ### Leave a project using Platform.leave_project Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-here-platform-platform Imports Platform, creates an instance, and calls leave_project with a project HRN. The doctest is skipped, so no output is shown. ```python >>> from here.platform import Platform >>> platform = Platform() >>> platform.leave_project("hrn:here:authorization::" "olp-here:project/test") # doctest: +SKIP ``` -------------------------------- ### Python: Get index partitions metadata as DataFrame with GeoPandasAdapter Source: https://docs.here.com/data-sdk/docs/pysdk-here-geopandas-adapter Example of enabling `GeoPandasAdapter` and calling `get_partitions_metadata` on an index layer to obtain metadata as a `pd.DataFrame` instead of a list or dict. Requires the HERE Data SDK and GeoPandasAdapter import. The returned DataFrame is not indexed, and the data handle is used in place of partition id. ```python from here.platform import Platform from here.geopandas_adapter import GeoPandasAdapter platform = Platform(adapter=GeoPandasAdapter()) sdii_catalog = platform.get_catalog("hrn:here:data::olp-here:olp-sdii-sample-berlin-2") index_layer = sdii_catalog.get_layer("sample-index-layer") partitions_df = index_layer.get_partitions_metadata(query="hour_from=ge=10") ``` -------------------------------- ### Content class initialization with catalog HRN and version detection Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-modules-here-content-content Initializes the Content class with a catalog HRN and platform. Sets the catalog HRN, internal catalog using the default adapter, platform reference, and detects the version from the catalog's latest_version or configuration. Raises an exception if the catalog is empty. ```python # The catalog HRN, as passed self.catalog_hrn = catalog_hrn # This is the catalog used to access the data, adapter is never applied to it # This catalog is for internal use only of the content and content binding self._catalog = platform.get_catalog(catalog_hrn, adapter=platform.default_adapter) # Platform instance, for internal use of content and content binding self._platform = platform # The version must be set or detected once and in one place, otherwise # we risk operating on two different versions if the catalog is modified # between multiple `latest_version` calls. self.version: int = ( version or self._catalog.latest_version() or self._catalog.configuration.version ) if not self.version: raise Exception(f"Catalog {catalog_hrn} is empty.") # todo: check that a version exists if specified from outside # todo: generalize also for catalogs without versioned layers to support volatile layers ``` -------------------------------- ### list_versions: Return information about specific catalog versions Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-modules-here-platform-api-data_metadata_api Sends a GET request to the /versions endpoint. Returns an empty dictionary if the catalog has no versions. If the requested range exceeds 1000 versions, a 400 Bad Request is returned. The startVersion parameter uses -1 to start from version 0; endVersion must be a valid catalog version greater than startVersion. ```python @[docs] def list\_versions( self, start\_version: int, end\_version: int, billing\_tag: Optional\[str] = None, ) -> dict: """ Return information about specific catalog version(s). If the catalog doesn't contain any versions, an empty dictionary is returned. Maximum number of versions to be returned per call is 1000 versions. If requested range is bigger than 1000 versions, 400 Bad Request will be returned. :param start\_version: The version number after which list of returned versions will begin. Minimum value -1 will return list starting with version 0. :param end\_version: The end of the range of versions you want to get (inclusive). This must be a valid catalog version greater than the startVersion. The maximum value for this parameter is returned from the /versions/latest endpoint. If this version does not exist, 400 Bad Request is returned :param billing\_tag: Billing Tag is an optional free-form tag which is used for grouping billing records together. :return: response from the API. :raises PlatformException: If platform responds with an HTTP error. """ path = "/versions" url = self.format\_url(self.base\_url, path) params = { "startVersion": start\_version, "endVersion": end\_version, "billingTag": billing\_tag, } resp = self.get(url, params=params) if resp.status\_code == 200: resp\_json: dict = resp.json() return resp\_json elif resp.status\_code == 404: return {} else: raise PlatformException(resp) ``` -------------------------------- ### Delete Catalog Example Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-here-platform-platform Example usage of the delete_catalog method. ```python >>> from here.platform import Platform >>> platform = Platform() >>> platform.delete_catalog("hrn:here:data::olp-here:delete") ``` -------------------------------- ### new OlpClientSettings(params) Source: https://docs.here.com/data-sdk/page/sdk-for-typescript-classes-olp_sdk_core-olpclientsettings Constructor for the OlpClientSettings class. ```APIDOC ## new OlpClientSettings(params) ### Description Creates the OlpClientSettings instance. ### Method constructor ### Parameters - **params** (OlpClientSettingsParams) - Required - Parameters used to construct the OlpClientSettings class. ### Returns OlpClientSettings - The OlpClientSettings instance. ``` -------------------------------- ### List all services with platform.list_services() Source: https://docs.here.com/data-sdk/docs/pysdk-here-platform-services Lists all services the account has access to and prints each service's name and HRN. The output is truncated in the documentation for clarity. ```python from here.platform import Platform platform = Platform() services = platform.list_services() for service in services: print(f"{service.name} ({service.hrn})") ``` ```text Fuel prices (hrn:here:service::olp-here:fuel-prices-3) HERE Destination Weather (hrn:here:service::olp-here:destination-weather-3) HERE Isoline Routing (hrn:here:service::olp-here:routing-isoline-8) HERE Routing (hrn:here:service::olp-here:routing-8) HERE Routing - Transit (hrn:here:service::olp-here:transit-routing-8) HERE Search - One Box Search (hrn:here:service::olp-here:search-discover-7) HERE Search - Reverse Geocoder (hrn:here:service::olp-here:search-revgeocode-7) ``` -------------------------------- ### from_coordinates boundary example Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-here-geotiles-heretile Example of using from_coordinates at boundary conditions. ```python >>> # Longitude boundary >>> from_coordinates(90, 45, 2) 23 >>> # Latitude boundary >>> from_coordinates(45, 0, 2) 22 ``` -------------------------------- ### GET request Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-modules-here-platform-service Performs a GET request on the service for a given path. ```python def get( self, path: str, params: Optional\[dict] = None, headers: Optional\[dict] = None, as\_json: bool = True, success\_codes: List\[int] = \[200], \*\*kwargs, ) -> Any: """ Perform a GET request on the service for the given :param:`path` of the service Example, `service.get("/path")` :param path: path to be called on the service. :param params: Parameters to pass to the API. :param headers: Request headers. Defaults to the Api headers property. :param as\_json: A boolean to indicate type of response. If `True` then response will be returned in json format. If `False`, `requests.Response` object will be returned :param success\_codes: List of http response codes which are treated as success :param kwargs: Optional arguments that can be passed to requests' GET call :return: response from the API. :raises PlatformException: in case of unsuccessful response """ url = self.\_format\_url(path) resp = self.\_api\_factory.get\_api(API.SERVICE, service\_base\_url=self.base\_url).get( url, params, headers, \*\*kwargs ) if resp.status\_code in success\_codes: return resp.json() if as\_json else resp else: raise PlatformException(resp) ``` -------------------------------- ### Example credentials.properties file Source: https://docs.here.com/data-sdk/docs/pysdk-credentials Shows the format of the generated app credentials file from the HERE Platform, with placeholders for user ID, client ID, access key ID, access key secret, and token endpoint URL. ```properties here.user.id = here.client.id = here.access.key.id = here.access.key.secret = here.token.endpoint.url = ``` -------------------------------- ### Get project with platform.get_project Source: https://docs.here.com/data-sdk/docs/pysdk-here-platform Gets a project object for the given HRN. ```python from here.platform import Platform platform = Platform() project_object = platform.get_project("hrn:here:authorization::olp-here:project/test") ``` -------------------------------- ### Create project with platform.create_project Source: https://docs.here.com/data-sdk/docs/pysdk-here-platform Creates a project with the given HRN. ```python from here.platform import Platform platform = Platform() created_project_object = platform.create_project("hrn:here:authorization::olp-here:sample-test-project") ``` -------------------------------- ### Install node types Source: https://docs.here.com/data-sdk/docs/get-data-object-store-layer Installs the @types/node package as a dev dependency. ```sh npm install --save-dev @types/node ``` -------------------------------- ### Platform.__init__ Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-here-platform-platform Initializes a Platform instance with credentials, application configuration, environment, proxies, billing tag, adapter, and project HRN. This is the entry point for interacting with the HERE platform. ```APIDOC ## Platform.__init__ ### Description Initializes a Platform instance with credentials, application configuration, environment, proxies, billing tag, adapter, and project HRN. This is the entry point for interacting with the HERE platform. ### Method Constructor ### Signature ```python Platform(credentials: PlatformCredentials | None = None, application_config: ApplicationConfig | None = None, environment: Environment | None = None, proxies: dict | None = None, billing_tag: str | None = None, adapter: Adapter | None = None, project_hrn: str | None = None) ``` ### Parameters - **credentials** (PlatformCredentials | None) - Optional - Platform credentials for authentication. - **application_config** (ApplicationConfig | None) - Optional - Application configuration. - **environment** (Environment | None) - Optional - Environment settings. - **proxies** (dict | None) - Optional - Proxy configuration. - **billing_tag** (str | None) - Optional - Billing tag for usage tracking. - **adapter** (Adapter | None) - Optional - Adapter for HTTP requests. - **project_hrn** (str | None) - Optional - Project HRN (HERE Resource Name). ### Returns - **Platform** - A new Platform instance. ``` -------------------------------- ### Instantiate OlpClientSettings Source: https://docs.here.com/data-sdk/docs/create-platform-client-settings Create the olpClientSettings instance by specifying the target environment and providing the getToken method. ```typescript const olpClientSettings = new OlpClientSettings({ environment: "here | here-dev | here-cn | here-cn-dev | http://YourLocalEnvironment", getToken: () => userAuth.getToken() }); ``` -------------------------------- ### Python: read index layer partitions data as DataFrame with GeoPandasAdapter Source: https://docs.here.com/data-sdk/docs/pysdk-here-geopandas-adapter Calls `read_partitions` on an index layer to fetch and decode data, returning a `pd.DataFrame` or `gpd.GeoDataFrame`. If no `partition_ids` are provided, the whole layer is read. Requires prior setup of the `index_layer` from the previous example. The returned DataFrame is not indexed, data from multiple partitions are combined, and a `partition_id` column is added; data handle replaces partition id. ```python partitions_df = index_layer.read_partitions(query="hour_from=ge=10") ``` -------------------------------- ### Create Platform and get service by HRN Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-here-platform-platform Creates a Platform instance and retrieves a service using its HRN. The output shows the returned Service object. ```python >>> platform = Platform() >>> platform.get_service("hrn:here:service::olp-here:routing-8") ``` -------------------------------- ### contains_point example Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-here-geotiles-heretile Example of using contains_point to check if a tile contains a point. ```python >>> tile = from_x_y_level(2, 1, 2) >>> contains_point(tile, Point(90, 45)) True >>> contains_point(tile, Point(0, 0)) True ``` -------------------------------- ### Get catalog layer Source: https://docs.here.com/data-sdk/docs/pysdk-here-platform-catalogs Gets a Layer object for the given layer ID. ```python layer = catalog.get_layer(layer_id=layer_id) ``` -------------------------------- ### constructor Source: https://docs.here.com/data-sdk/page/sdk-for-typescript-classes-olp_sdk_dataservice_write-startbatchrequest Creates a new StartBatchRequest instance. ```APIDOC ## constructor ### Description Creates a new StartBatchRequest instance. ### Method constructor ### Signature `new StartBatchRequest()` ### Parameters None ### Returns - **StartBatchRequest** - A new instance of StartBatchRequest. ``` -------------------------------- ### Get details of a single version Source: https://docs.here.com/data-sdk/docs/pysdk-here-platform-catalogs Gets the details of the specified version of the catalog. ```python version = catalog.get_version() ``` -------------------------------- ### DataQueryApi.__init__ Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-modules-here-platform-api-data_query_api Instantiates a DataQueryApi object with the provided configuration and authentication. ```APIDOC ## DataQueryApi.__init__ ### Description Instantiates a DataQueryApi object with the provided configuration and authentication. ### Method Constructor ### Signature ```python DataQueryApi( base_url: str, platform_config: PlatformConfig, application_config: ApplicationConfig, auth: Optional[Auth], proxies: Optional[dict] = None ) ``` ### Parameters - **base_url** (str) - Required - Base URL for the API. - **platform_config** (PlatformConfig) - Required - Configuration information for the API. - **application_config** (ApplicationConfig) - Required - Configuration information for the API. - **auth** (Optional[Auth]) - Required - An Authentication instance. - **proxies** (Optional[dict]) - Optional - Proxy configuration. Defaults to environment proxy configuration. ``` -------------------------------- ### Get the Platform status Source: https://docs.here.com/data-sdk/docs/pysdk-here-platform Gets the platform status and shows the returned status object. ```python from here.platform import Platform platform = Platform() status = platform.get_status() status ``` ```text {'result': {'status': 'ok', 'description': 'all systems operational'}} ``` -------------------------------- ### Get catalog latest version Source: https://docs.here.com/data-sdk/docs/pysdk-here-platform-catalogs Gets the latest version of the catalog available on the platform. ```python catalog_latest_version = catalog.latest_version() ``` -------------------------------- ### Catalog constructor Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-modules-here-platform-catalog Initializes a Catalog instance with its HRN, platform, optional adapter, and billing tag. ```python [docs] class Catalog: """HERE platform catalog abstraction.""" def __init__( self, hrn: str, platform: "Platform", adapter: Optional[Adapter] = None, billing_tag: Optional[str] = None, ): """ Instantiate catalog given its HRN, API instances, and schema registry. :param hrn: the HERE Resource Name of the catalog :param platform: a Platform instance :param adapter: the `Adapter` to transform data between different representations `None` to use the default adapter of the platform. :param billing_tag: A string to represent a grouping of billing records. """ self.hrn = hrn self.platform = platform self.adapter: Adapter = adapter or self.platform.adapter self._data_config_api = self.platform.data_config_api # type: ignore self._base_api: BaseApi = self.platform.base_api self.billing_tag: Optional[str] = billing_tag self._api_factory: APIFactory = self.platform.api_factory ``` -------------------------------- ### Create a subscription with configuration object Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-modules-here-platform-api-data_config_api Sends a POST request to /subscriptions with a configuration object. Returns the JSON response on 202 Accepted, otherwise raises PlatformException. ```python def create_subscription(self, configuration_object: dict) -> dict: """ Creates a subscription between source catalog/layer and target catalog/layer :param configuration_object: A subscription configuration object. :return: response from the API. :raises PlatformException: If platform responds with an HTTP error. """ path = "/subscriptions" url = self.format_url(self.base_url, path) resp = self.post(url, data=configuration_object) if resp.status_code == 202: resp_json: dict = resp.json() return resp_json else: raise PlatformException(resp) ``` -------------------------------- ### Get catalog first version Source: https://docs.here.com/data-sdk/docs/pysdk-here-platform-catalogs Gets the first version of the catalog available on the platform. ```python catalog_first_version = catalog.first_version() ``` -------------------------------- ### Multipart upload with start_multipart_upload_by_handle Source: https://docs.here.com/data-sdk/page/data-sdk-for-python-modules-here-platform-partition Starts a multipart upload to a blob store. Validates part_size between 5 and 50 MB, generates a new data handle if needed, and initiates the upload via start_multipart_upload_by_handle. Uses asyncio to run read_and_upload_parts and collects the results. ```python if not (5 <= part_size <= 50): raise ValueError(f"part_size must be between 5 and 50 MB, got {part_size}") if not self.data_handle: self.__generate_new_handle() content_type = self.layer.configuration.content_type assert content_type content_encoding = self.layer.configuration.content_encoding or "identity" multi_parts = self.layer._data_blob_api.start_multipart_upload_by_handle( layer_id=self.layer.id, data_handle=self.data_handle, content_type=content_type, billing_tag=self.billing_tag, content_encoding=content_encoding, ) upload_url = multi_parts["links"]["uploadPart"]["href"] logger.debug(f"URL: {upload_url}") try: loop = asyncio.get_event_loop() except RuntimeError: logger.info("No current event loop, creating new one") loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) headers = self.layer._base_api.headers.copy() future = asyncio.ensure_future( self.read_and_upload_parts(path_or_data, upload_url, content_type, headers, part_size) ) results = loop.run_until_complete(future) parts = [] for result in results: for k, v in result.items(): ``` -------------------------------- ### get Source: https://docs.here.com/data-sdk/page/sdk-for-typescript-classes-olp_sdk_core-apicacherepository Gets a base URL from the cache for a given service, service version, and cache type. ```APIDOC ## get(service: string, serviceVersion: string, type: CacheType): undefined | string ### Description Gets a base URL from the cache. ### Parameters - **service** (string) - Required - The name of the API service for which you want to get the base URL. - **serviceVersion** (string) - Required - The service version. - **type** (CacheType) - Required - The cache type. ### Returns - **undefined | string** - The base URL of the service, or undefined if the base URL does not exist. ```