libosmscout  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups
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  CLASS_FINAL
 

Public Types

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

Public Member Functions

void AddTileDataToMapData (std::list< TileRef > &tiles, MapData &data) const
 Convert the data hold by the given tiles to the given MapData class instance. More...
 
void AddTileDataToMapData (std::list< TileRef > &tiles, const TypeDefinition &typeDefinition, MapData &data) const
 Convert the data hold by the given tiles to the given MapData class instance. More...
 
void CleanupTileCache ()
 Evict tiles from cache until tile count <= cacheSize. More...
 
void DeregisterTileStateCallback (CallbackId callbackId)
 
void FlushTileCache ()
 Evict all tiles from cache (tile count == 0) More...
 
size_t GetCacheSize () const
 
bool GetGroundTiles (const Projection &projection, std::list< GroundTile > &tiles) const
 Return all ground tiles for the given projection data (bounding box and magnification). More...
 
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. More...
 
void InvalidateTileCache ()
 Mark all tiles in cache as incomplete, while keeping all data and type information stored in it. More...
 
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. More...
 
bool LoadMissingTileData (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. More...
 
bool LoadMissingTileDataAsync (const AreaSearchParameter &parameter, const Magnification &magnification, const TypeDefinition &typeDefinition, std::list< TileRef > &tiles) const
 
TileRef LookupTile (const TileId &id) const
 Return the given tile. More...
 
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. More...
 
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. More...
 
 MapService (const DatabaseRef &database)
 
CallbackId RegisterTileStateCallback (TileStateCallback callback)
 
void SetCacheSize (size_t cacheSize)
 Set the size of the tile data cache. More...
 
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

typedef std::function<void(const TileRef&)> osmscout::MapService::TileStateCallback
typedef std::shared_ptr<TypeDefinition> osmscout::MapService::TypeDefinitionRef

Constructor & Destructor Documentation

osmscout::MapService::MapService ( const DatabaseRef database)
osmscout::MapService::~MapService ( )
virtual

Member Function Documentation

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

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

References osmscout::log, and osmscout::Log::Warn().

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

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

References osmscout::log, and osmscout::Log::Warn().

void osmscout::MapService::CleanupTileCache ( )

Evict tiles from cache until tile count <= cacheSize.

References osmscout::DataTileCache::CleanupCache().

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

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

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

size_t osmscout::MapService::GetCacheSize ( ) const
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().

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(), and osmscout::log.

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().

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 occured or all tiles have been successfully loaded.

bool osmscout::MapService::LoadMissingTileData ( const AreaSearchParameter parameter,
const Magnification magnification,
const TypeDefinition &  typeDefinition,
std::list< TileRef > &  tiles 
) const
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.

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

Return the given tile.

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

References osmscout::DataTileCache::GetTile().

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::DataTileCache::GetTilesForBoundingBox().

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::DataTileCache::GetTilesForBoundingBox().

MapService::CallbackId osmscout::MapService::RegisterTileStateCallback ( TileStateCallback  callback)
void osmscout::MapService::SetCacheSize ( size_t  cacheSize)

Set the size of the tile data cache.

References osmscout::DataTileCache::SetSize().


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