Offline mode

OCMAM can load map data from a local folder on your Edge device instead of the network. When creating a DataStoreClient instance, to make it use the offline data, specify the path to the protected cache folder in DataStoreClientSettings.

Note: You cannot change the path to the cache folder once a DataStoreClient instance is created.

Example:

olp::clientmap::datastore::DataStoreServerSettings server_settings;

server_settings.cache_settings.disk_path_protected
    = "path-to-disk-protected-cache";

In the example above, "path-to-disk-protected-cache" is the path to the protected cache folder.

In this section, learn how to:

Switch to offline mode

If you do not want a DataStoreServer instance to get data from the network, set it to offline mode using the SetOnline method of the DataStoreServer class.

Example:

server->SetOnline( false );

In the example above, server is a shared pointer to the previously created DataStoreServer instance.

Get offline data

To get the offline data that can be used by OCMAM, use the ocm-packager tool. The tool can download map data for tiles that cover a given rectangle defined in geographic coordinates.

Example:

ocm-packager -c hrn:here:data::olp-here:ocm -g rendering routing --south-west 52.48 13.46 --north-east 52.5 13.48 -l 14 -o .\mapdata

In the example above, the following parameters are used:

  • 52.48 and 13.36 – the latitude and longitude (in degrees) of the south-west corner of the rectangle.
  • 52.5 and 13.28 – the latitude and longitude (in degrees) of the north-east corner of the rectangle.
  • 14 – the level of tiles to download.
  • .\mapdata – the path to the folder to which the map data is saved.

To learn how to use the ocm-packager tool, use the -h command line argument.

Protect tiles from eviction

To prevent tiles that belong to a specific geographical area from being evicted from the mutable disk cache, use the Protect method of the DataStoreServer class. Tiles are protected from eviction until you release them.

Note: Tiles of all levels from zero to a specified maximum level that overlap with a given geographical rectangle are protected. If the maximum tile level is not specified, it is set internally to 14.

Example:

const olp::geo::GeoRectangle geo_rectangle{
    olp::geo::GeoCoordinates::FromDegrees( 35.66, 139.80 ),
    olp::geo::GeoCoordinates::FromDegrees( 35.67, 139.81 )};

server->Protect( "catalog-hrn", catalog_version,
                 olp::clientmap::datastore::ProtectRequest( )
                     .WithGeoRectangle( geo_rectangle )
                     .WithMaxLevel( 14 ) );

In the example above, the following objects and parameters are used:

  • geo_rectangle – defines the geographical rectangle that you want to protect from eviction.
  • server – a shared pointer to the previously created DataStoreServer instance.
  • "catalog-hrn" – the HERE Resource Name (HRN) of the catalog which data you want to protect.
  • catalog_version – the version of the catalog which data you want to protect.
  • max_level – the maximum level of tiles that you want to protect.

After the application shuts down, the DataStoreServer instance is destroyed. For all catalogs, save the ProtectRequest instances for the protected areas on the disk. When you launch your application, create a new DataStoreServer instance, add catalogs to it, and then call the Protect method with the same ProtectRequest instances again.

Allow eviction of tiles

To allow eviction of a previously protected geographical area from the mutable disk cache, use the Release method of the DataStoreServer class and specify exactly the same ProtectRequest instance that you used to protect the area.

The tiles that are no longer protected can be evicted from the cache based on the least recently used (LRU) principle. If you remove protection only from one overlapping area, the overlapping tiles will still be protected. Every tile has a reference counter and can only be released when the counter reaches 0. If you protected a geographical area and then restarted your application, to release the protected tiles, protect the area again.

Example:

const olp::geo::GeoRectangle geo_rectangle{
    olp::geo::GeoCoordinates::FromDegrees( 35.66, 139.80 ),
    olp::geo::GeoCoordinates::FromDegrees( 35.67, 139.81 )};

server->Release( "catalog-hrn", catalog_version,
                    olp::clientmap::datastore::ProtectRequest( )
                        .WithGeoRectangle( geo_rectangle )
                        .WithMaxLevel( 14 ) );

In the example above, the following objects and parameters are used:

  • geo_rectangle – defines the geographical rectangle for which you want to allow the eviction.
  • server – a shared pointer to the previously created DataStoreServer instance.
  • "catalog-hrn" – the HERE Resource Name (HRN) of the catalog for which you want to allow the eviction.
  • catalog_version – the version of the catalog for which you want to allow the eviction.
  • max_level – the maximum level of tiles for which you want to allow the eviction.

results matching ""

    No results matching ""