libosmscout 0.1
Loading...
Searching...
No Matches
osmscout::MapService Class Reference

MapService offers services for retrieving data in a way that is helpful for drawing maps. More...

#include <MapService.h>

Classes

class  TypeDefinition
 

Public Types

using CallbackId = size_t
 
using TileStateCallback = std::function< void(const TileRef &)>
 
using TypeDefinitionRef = std::shared_ptr< TypeDefinition >
 

Public Member Functions

void AddTileDataToMapData (std::list< TileRef > &tiles, const TypeDefinition &typeDefinition, MapData &data) const
 Convert the data hold by the given tiles into the given map data, restricted to the object types of the given type definition.
 
void AddTileDataToMapData (std::list< TileRef > &tiles, MapData &data) const
 Convert the data hold by the given tiles into the given map data.
 
void CleanupTileCache ()
 Evict tiles from cache until tile count <= cacheSize.
 
void DeregisterTileStateCallback (CallbackId callbackId)
 
void FlushTileCache ()
 Evict all tiles from cache (tile count == 0)
 
size_t GetCacheSize () const
 
double GetConversionPhaseWarningThreshold () const
 Duration a phase of the tile data conversion may take before it is reported, see SetConversionPhaseWarningThreshold().
 
size_t GetCurrentCacheSize () const
 
bool GetGroundTiles (const GeoBox &boundingBox, const Magnification &magnification, std::list< GroundTile > &tiles) const
 Return all ground tiles for the given area and the given magnification.
 
bool GetGroundTiles (const Projection &projection, std::list< GroundTile > &tiles) const
 Return all ground tiles for the given projection data (bounding box and magnification).
 
SRTMDataRef GetSRTMData (const GeoBox &boundingBox) const
 
SRTMDataRef GetSRTMData (const Projection &projection) const
 
void InvalidateTileCache ()
 Mark all tiles in cache as incomplete, while keeping all data and type information stored in it.
 
bool LoadMissingTileData (const AreaSearchParameter &parameter, const Magnification &magnification, const TypeDefinition &typeDefinition, std::list< TileRef > &tiles) const
 
bool LoadMissingTileData (const AreaSearchParameter &parameter, const StyleConfig &styleConfig, std::list< TileRef > &tiles) const
 Load all missing data for the given tiles based on the given style config.
 
bool LoadMissingTileDataAsync (const AreaSearchParameter &parameter, const Magnification &magnification, const TypeDefinition &typeDefinition, std::list< TileRef > &tiles) const
 
bool LoadMissingTileDataAsync (const AreaSearchParameter &parameter, const StyleConfig &styleConfig, std::list< TileRef > &tiles) const
 Load all missing data for the given tiles based on the given style config.
 
TileRef LookupTile (const TileKey &key) const
 Return the given tile.
 
void LookupTiles (const Magnification &magnification, const GeoBox &boundingBox, std::list< TileRef > &tiles) const
 Return all tiles with the given covering the region given by the boundingBox.
 
void LookupTiles (const Projection &projection, std::list< TileRef > &tiles) const
 Return all tiles with the magnification defined by the projection that cover the region covered by the projection.
 
 MapService (const DatabaseRef &database)
 
CallbackId RegisterTileStateCallback (TileStateCallback callback)
 
void SetCacheSize (size_t cacheSize)
 
void SetConversionPhaseWarningThreshold (double milliseconds)
 Set the duration a phase of the tile data conversion may take before it is reported.
 
virtual ~MapService ()
 

Detailed Description

MapService offers services for retrieving data in a way that is helpful for drawing maps.

Currently the following functionalities are supported:

  • Get objects of a certain type in a given area and impose certain limits on the resulting data (size of area, number of objects, low zoom optimizations,...).

Member Typedef Documentation

◆ CallbackId

◆ TileStateCallback

using osmscout::MapService::TileStateCallback = std::function<void (const TileRef &)>

◆ TypeDefinitionRef

Constructor & Destructor Documentation

◆ MapService()

osmscout::MapService::MapService ( const DatabaseRef &  database)
explicit

◆ ~MapService()

osmscout::MapService::~MapService ( )
virtual

Member Function Documentation

◆ AddTileDataToMapData() [1/2]

void osmscout::MapService::AddTileDataToMapData ( std::list< TileRef > &  tiles,
const TypeDefinition &  typeDefinition,
MapData &  data 
) const

Convert the data hold by the given tiles into the given map data, restricted to the object types of the given type definition.

Convert the data hold by the given tiles to the given MapData class instance, restricted to the object types of the given type definition.

The restricted conversion holds the same uniqueness and order guarantees as the unrestricted one. It reserves its result from the objects the tiles hold rather than from the objects that match the type filter, because the matching count is only known once the objects have been visited; the reservation is therefore an upper bound.

The restricted conversion holds the same uniqueness and order guarantees as the unrestricted one. It reserves its result from the objects the tiles hold rather than from the objects that match the type filter, because the matching count is only known once the objects have been visited.

References osmscout::MapData::areas, osmscout::MapService::TypeDefinition::areaTypes, osmscout::MapData::nodes, osmscout::MapService::TypeDefinition::nodeTypes, osmscout::MapService::TypeDefinition::optimizedAreaTypes, osmscout::MapService::TypeDefinition::optimizedWayTypes, osmscout::MapData::ways, and osmscout::MapService::TypeDefinition::wayTypes.

◆ AddTileDataToMapData() [2/2]

void osmscout::MapService::AddTileDataToMapData ( std::list< TileRef > &  tiles,
MapData &  data 
) const

Convert the data hold by the given tiles into the given map data.

Convert the data hold by the given tiles to the given MapData class instance.

Every object of the tiles is placed in the result exactly once. The result is grouped by the source data file of the objects in a fixed order - the objects of nodes.dat, ways.dat, areas.dat and routes.dat first, then the objects of the optimized data files of a kind - and within a source data file the objects follow the order in which the tiles of the given list and their stored objects present them, which is reproducible for the same tile list.

An offset only identifies an object within one data file, so the objects of two data files that carry the same offset value are both part of the result. The heap allocation of the conversion is bounded by the number of distinct objects of the result plus a constant: seen objects are held as a set of file offsets, which allocates once per distinct object of a source data file, and each result vector is reserved once.

Every object of the tiles is placed in the result exactly once. The objects are grouped by the data file they were read from in a fixed order - the objects of nodes.dat, ways.dat, areas.dat and routes.dat first, then the objects of the optimized data files of a kind - and within a source data file they follow the order in which the tiles present them. An offset only identifies an object within one data file, so two data files that carry the same offset value both contribute their object.

The cost of the conversion follows the objects of the tiles: every stored object is examined once, on a first sight it is appended, and a repeated sight costs one lookup in the set of the offsets already seen, so a tile that repeats an object the view already holds does not make the result grow.

References osmscout::MapData::areas, osmscout::MapData::nodes, osmscout::MapData::routes, and osmscout::MapData::ways.

◆ CleanupTileCache()

void osmscout::MapService::CleanupTileCache ( )

Evict tiles from cache until tile count <= cacheSize.

References osmscout::DataTileCache::CleanupCache().

◆ DeregisterTileStateCallback()

void osmscout::MapService::DeregisterTileStateCallback ( CallbackId  callbackId)

◆ FlushTileCache()

void osmscout::MapService::FlushTileCache ( )

Evict all tiles from cache (tile count == 0)

References osmscout::DataTileCache::GetSize(), and osmscout::DataTileCache::SetSize().

◆ GetCacheSize()

size_t osmscout::MapService::GetCacheSize ( ) const

◆ GetConversionPhaseWarningThreshold()

double osmscout::MapService::GetConversionPhaseWarningThreshold ( ) const

Duration a phase of the tile data conversion may take before it is reported, see SetConversionPhaseWarningThreshold().

◆ GetCurrentCacheSize()

size_t osmscout::MapService::GetCurrentCacheSize ( ) const

◆ GetGroundTiles() [1/2]

bool osmscout::MapService::GetGroundTiles ( const GeoBox &  boundingBox,
const Magnification &  magnification,
std::list< GroundTile > &  tiles 
) const

Return all ground tiles for the given area and the given magnification.

Note
The returned ground tiles may result in a bigger area than given.
Parameters
boundingBoxBoundary coordinates
magnificationMagnification
tilesList of returned tiles
Returns
False, if there was an error, else true.

References osmscout::Log::Error(), osmscout::log, and osmscout::StopClock::Stop().

◆ GetGroundTiles() [2/2]

bool osmscout::MapService::GetGroundTiles ( const Projection &  projection,
std::list< GroundTile > &  tiles 
) const

Return all ground tiles for the given projection data (bounding box and magnification).

Note
The returned ground tiles may result in a bigger area than given.
Parameters
projectionprojection defining bounding box and magnification
tilesList of returned tiles
Returns
False, if there was an error, else true.

References osmscout::Projection::GetDimensions(), and osmscout::Projection::GetMagnification().

◆ GetSRTMData() [1/2]

SRTMDataRef osmscout::MapService::GetSRTMData ( const GeoBox &  boundingBox) const

◆ GetSRTMData() [2/2]

SRTMDataRef osmscout::MapService::GetSRTMData ( const Projection &  projection) const

◆ InvalidateTileCache()

void osmscout::MapService::InvalidateTileCache ( )

Mark all tiles in cache as incomplete, while keeping all data and type information stored in it.

References osmscout::DataTileCache::InvalidateCache().

◆ LoadMissingTileData() [1/2]

bool osmscout::MapService::LoadMissingTileData ( const AreaSearchParameter &  parameter,
const Magnification &  magnification,
const TypeDefinition &  typeDefinition,
std::list< TileRef > &  tiles 
) const

◆ LoadMissingTileData() [2/2]

bool osmscout::MapService::LoadMissingTileData ( const AreaSearchParameter &  parameter,
const StyleConfig &  styleConfig,
std::list< TileRef > &  tiles 
) const

Load all missing data for the given tiles based on the given style config.

The method returns, either after an error occurred or all tiles have been successfully loaded.

◆ LoadMissingTileDataAsync() [1/2]

bool osmscout::MapService::LoadMissingTileDataAsync ( const AreaSearchParameter &  parameter,
const Magnification &  magnification,
const TypeDefinition &  typeDefinition,
std::list< TileRef > &  tiles 
) const

◆ LoadMissingTileDataAsync() [2/2]

bool osmscout::MapService::LoadMissingTileDataAsync ( const AreaSearchParameter &  parameter,
const StyleConfig &  styleConfig,
std::list< TileRef > &  tiles 
) const

Load all missing data for the given tiles based on the given style config.

This method just triggers the loading but may return before all data has been loaded. Loading of tile data happens in the background. You have to register a callback to get notified about tile loading state.Dr

You can be sure, that callbacks are not called in the context of the calling thread.

◆ LookupTile()

TileRef osmscout::MapService::LookupTile ( const TileKey &  key) const

Return the given tile.

Note, that tiles may be partially prefilled or empty, if not already cached.

References osmscout::StopClock::Stop().

◆ LookupTiles() [1/2]

void osmscout::MapService::LookupTiles ( const Magnification &  magnification,
const GeoBox &  boundingBox,
std::list< TileRef > &  tiles 
) const

Return all tiles with the given covering the region given by the boundingBox.

Note, that tiles may be partially prefill or empty, if not already cached.

References osmscout::StopClock::Stop().

◆ LookupTiles() [2/2]

void osmscout::MapService::LookupTiles ( const Projection &  projection,
std::list< TileRef > &  tiles 
) const

Return all tiles with the magnification defined by the projection that cover the region covered by the projection.

Note, that tiles may be partially prefill or empty, if not already cached.

References osmscout::Projection::GetDimensions(), osmscout::Projection::GetMagnification(), and osmscout::StopClock::Stop().

◆ RegisterTileStateCallback()

MapService::CallbackId osmscout::MapService::RegisterTileStateCallback ( TileStateCallback  callback)

◆ SetCacheSize()

void osmscout::MapService::SetCacheSize ( size_t  cacheSize)

◆ SetConversionPhaseWarningThreshold()

void osmscout::MapService::SetConversionPhaseWarningThreshold ( double  milliseconds)

Set the duration a phase of the tile data conversion may take before it is reported.

Set the size of the tile data cache.

A conversion measures one phase per source data file - nodes, ways, optimized ways, areas, optimized areas and routes - and logs one warning naming a phase that took longer than this threshold, so that a slow pan step is attributable from the log of a user device. The default is 20 milliseconds, the value the copy phase of the previous implementation warned at. A threshold of zero reports every phase.

References milliseconds.


The documentation for this class was generated from the following files: