|
libosmscout 0.1
|
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 ¶meter, const Magnification &magnification, const TypeDefinition &typeDefinition, std::list< TileRef > &tiles) const |
| bool | LoadMissingTileData (const AreaSearchParameter ¶meter, 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 ¶meter, const Magnification &magnification, const TypeDefinition &typeDefinition, std::list< TileRef > &tiles) const |
| bool | LoadMissingTileDataAsync (const AreaSearchParameter ¶meter, 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 () |
MapService offers services for retrieving data in a way that is helpful for drawing maps.
Currently the following functionalities are supported:
| using osmscout::MapService::CallbackId = size_t |
| using osmscout::MapService::TileStateCallback = std::function<void (const TileRef &)> |
| using osmscout::MapService::TypeDefinitionRef = std::shared_ptr<TypeDefinition> |
|
explicit |
|
virtual |
| 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.
| 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.
| 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 |
References osmscout::DataTileCache::GetSize().
| double osmscout::MapService::GetConversionPhaseWarningThreshold | ( | ) | const |
Duration a phase of the tile data conversion may take before it is reported, see SetConversionPhaseWarningThreshold().
| size_t osmscout::MapService::GetCurrentCacheSize | ( | ) | const |
References osmscout::DataTileCache::GetCurrentSize().
| 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.
| boundingBox | Boundary coordinates |
| magnification | Magnification |
| tiles | List of returned tiles |
References osmscout::Log::Error(), osmscout::log, and osmscout::StopClock::Stop().
| 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).
| projection | projection defining bounding box and magnification |
| tiles | List of returned tiles |
References osmscout::Projection::GetDimensions(), and osmscout::Projection::GetMagnification().
| SRTMDataRef osmscout::MapService::GetSRTMData | ( | const GeoBox & | boundingBox | ) | const |
References osmscout::Log::Error(), osmscout::log, and osmscout::StopClock::Stop().
| SRTMDataRef osmscout::MapService::GetSRTMData | ( | const Projection & | projection | ) | const |
References osmscout::Projection::GetDimensions().
| 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 Magnification & | magnification, | ||
| const TypeDefinition & | typeDefinition, | ||
| std::list< TileRef > & | tiles | ||
| ) | const |
| 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.
| bool osmscout::MapService::LoadMissingTileDataAsync | ( | 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.
Return the given tile.
Note, that tiles may be partially prefilled or empty, if not already cached.
References osmscout::StopClock::Stop().
| 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().
| 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().
| MapService::CallbackId osmscout::MapService::RegisterTileStateCallback | ( | TileStateCallback | callback | ) |
| void osmscout::MapService::SetCacheSize | ( | size_t | cacheSize | ) |
References osmscout::DataTileCache::SetSize().
| 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.