![]() |
Maria GDK 5.0.0.738
Documentation of native code in develop branch
|
#include <MTileCache.h>
Public Member Functions | |
TileCache (const MapContentQuery &mcq, std::shared_ptr< Maria::SystemTicker >systemTicker, std::shared_ptr< TileDataFactory > dataFactory, std::shared_ptr< ITileDataRequestHandler > requestHandler) | |
int | id () const |
std::shared_ptr< Maria::TileData > | getData (TileId id) const |
std::shared_ptr< Maria::TileData > | getTempData (TileId id) const |
void | expireData (TileId id) |
std::shared_ptr< Maria::TileData > | getOrCreateData (TileId id) |
void | insertData (const std::shared_ptr< TileData > &tile) |
void | clearData (TileId id) |
void | clearTempData (TileId id) |
void | clear () |
bool | isEmpty () const |
int | getNumTiles () const |
void | setName (const std::string &name) |
const std::string & | getName () const |
const MapContentQuery & | getMapContentQuery () const |
const std::shared_ptr< TileCacheSpec > & | getTileCacheSpec () const |
std::shared_ptr< RasterProjector > | getBaseTileProjector () const |
const std::shared_ptr< Maria::SharedCounter > & | getMemoryCounter () |
int | getTileIdsByState (Maria::TileData::TileState state, std::vector< Maria::TileId > &data) const |
std::vector< std::shared_ptr< Maria::TileData > > | getReadyTiles () const |
std::vector< std::shared_ptr< Maria::TileData > > | getAllTiles () const |
int | getIntersectingTileIds (const BasicGeoTypes::GeoRect &rc, std::vector< Maria::TileId > &data) |
int | getNumReadyTiles () const |
void | CalcIntersectingTiles (std::vector< TileId > &tileIds, const RasterProjector &rasterProjector, double pixelScale=1.0, bool requestTiles=true, int numParentLevels=0) |
void | CalcIntersectingTilesResolution (std::vector< TileId > &tileIds, const BasicGeoTypes::GeoRect &grc, double maxResolution, bool requestTiles=true, int numParentLevels=0) |
Calculate intersecting tiles inside the area with an optional maximum resolution. | |
double | CalcTileBoundsAndLevel (const std::shared_ptr< Maria::IProjector > &inputPj, const BasicGeoTypes::PointDXY &topLeft, int width, int height, double border, BasicGeoTypes::Extents &ext, int &level, int subdiv=4) |
int | CalcTileLevel (const RasterProjector &vp, double pixelScale) |
int | CalcMaxTileLevel (const RasterProjector &rp, double maxResolution) |
bool | calcIntersectingTileId (const BasicGeoTypes::GeoPos &pos, double resolution, Maria::TileId &tileId) |
Calculate tile ID intersecting the given point at the given resolution. | |
RasterProjector * | CreateRasterProjector (const TileId &tileId) |
Create a raster projector for a tile. | |
TileId | FindReadyParentTile (const TileId &tileId) |
Find closest parent tile of the given tile that has ready data. | |
std::shared_ptr< Maria::TileData > | GetReadyOrTempTile (const TileId &tileId) |
std::shared_ptr< Maria::TileData > | GetReadyOrParentTile (const TileId &tileId) |
Get a tile object for the given tile ID, if the tile is ready. If not, get the nearest ready parent tile. If no ready tiles exist, the root tile will be returned. | |
std::shared_ptr< Maria::TileData > | GetReadyOrParentTile (TileId tileId, int numParentLevels) |
Get a tile object for the given tile ID, if the tile is ready. If not, get the nearest ready parent tile. Do not traverse higher than numParentLevels parent levels. | |
std::shared_ptr< Maria::TileData > | GetReadyOrTempOrParentTile (TileId tileId, int numParentLevels) |
std::shared_ptr< Maria::TileData > | GetTileResolution (const BasicGeoTypes::GeoPos &pos, double resolution) |
bool | FindMaxResolution (const BasicGeoTypes::GeoPos &geoPos, double &maxResolution) |
double | FindMaxResolution (const BasicGeoTypes::GeoPos &geoPos) |
const std::vector< ResolutionArea > & | GetResolutionAreas () const |
void | SetResolutionAreas (const std::vector< ResolutionArea > &resolution_areas) |
bool | IntersectsBounds (const RasterProjector &rp) |
void | loadAsync (const std::shared_ptr< Maria::TileData > &tile) |
std::shared_ptr< Maria::TileData > | loadAsync (Maria::TileId tileId) |
void | waitForTile (std::shared_ptr< Maria::TileData > tileData, long timeout_ms) |
void | waitForTiles (const std::vector< std::shared_ptr< Maria::TileData > > &tiles, long timeout_ms) |
std::shared_ptr< Maria::TileData > | load (Maria::TileId tileId, long timeout_ms=0) |
std::vector< std::shared_ptr< Maria::TileData > > | loadTilesOrNearestResolution (const std::vector< std::shared_ptr< Maria::TileData > > &wantedTiles, long timeout_ms) |
int | calcTileLevel (double resolution) |
double | getResolution (int level) |
int | getTileQueueOverflow () const |
void | setDataFactory (const std::shared_ptr< TileDataFactory > &dataFactory) |
const std::shared_ptr< TileDataFactory > & | getDataFactory () const |
Protected Member Functions | |
void | CalcMaxTileLevel (TileId tileId, const BasicGeoTypes::GeoPos &ctr, const BasicGeoTypes::PointDXY ¢erPt, int &maxLevel, double maxResolution) |
void | CalcRenderTile (std::vector< TileId > &renderTiles, TileId tileId, const BasicGeoTypes::GeoRect &vpGeoRect, int maxLevel, bool requestTiles, int numParentLevels) |
bool | TileIntersect (const BasicGeoTypes::Extents &ext, TileId tileId) |
bool | TileIntersect (const BasicGeoTypes::Extents &ext, int lvl, int tx, int ty) |
Maria::TileId | FindReadyParentTile (int lvl, int tx, int ty) |
Protected Attributes | |
std::mutex | _mutex |
std::unordered_map< TileId, std::shared_ptr< TileData > > | _data |
std::unordered_map< TileId, std::shared_ptr< TileData > > | _tempData |
std::shared_ptr< Maria::SharedCounter > | _memCounter |
MapContentQuery | _mcq |
std::shared_ptr< TileCacheSpec > | _tcs |
std::shared_ptr< Maria::SystemTicker > | _ticker |
std::shared_ptr< Maria::TileDataFactory > | _dataFactory |
std::shared_ptr< ITileDataRequestHandler > | _requestHandler |
std::shared_ptr< RasterProjector > | _baseTileVP |
std::vector< ResolutionArea > | _resolution_areas |
int | _tileQueueOverflow |
std::string | _name |
int | _id |
Static Protected Attributes | |
static int | _idCounter = 1 |
TileCache - Short description. Detailed description.
bool Maria::TileCache::calcIntersectingTileId | ( | const BasicGeoTypes::GeoPos & | pos, |
double | resolution, | ||
Maria::TileId & | tileId | ||
) |
Calculate tile ID intersecting the given point at the given resolution.
pos | Geographical position to check. |
resolution | Minimum resolution in m/pixel. If 0, use the highest available resolution. |
tileId | Output value |
void TileCache::CalcIntersectingTiles | ( | std::vector< TileId > & | tileIds, |
const RasterProjector & | rasterProjector, | ||
double | pixelScale = 1.0 , |
||
bool | requestTiles = true , |
||
int | numParentLevels = 0 |
||
) |
Calculate intersecting tiles. This method will traverse the quadtree, returning the intersecting tiles at a resolution level matching the input viewport. This method is robust and should work for viewports that are partially outside of the domain of the tile cache projector.
void TileCache::CalcIntersectingTilesResolution | ( | std::vector< TileId > & | tileIds, |
const BasicGeoTypes::GeoRect & | grc, | ||
double | maxResolution, | ||
bool | requestTiles = true , |
||
int | numParentLevels = 0 |
||
) |
Calculate intersecting tiles inside the area with an optional maximum resolution.
tileIds | Output array of tile ids. |
grc | Bounding box in geographical coordinates. |
maxResolution | If > 0, indicates the maximum resolution of the returned tiles (in m/sample). If 0, the highest available resolution tiles are returned. |
requestTiles | If true, trigger loading of the tile data if not already loaded. |
numParentLevels | Number of parent levels to include. |
double TileCache::CalcTileBoundsAndLevel | ( | const std::shared_ptr< Maria::IProjector > & | inputPj, |
const BasicGeoTypes::PointDXY & | topLeft, | ||
int | width, | ||
int | height, | ||
double | border, | ||
BasicGeoTypes::Extents & | ext, | ||
int & | level, | ||
int | subdiv = 4 |
||
) |
Calculate tile level and bounding box in normalized coordinates. This method calculates takes an input projection and bounding box, and calculates the corresponding bounding box and level in the normalized tile cache coordinate system. This normalized bounding box can be used to find an intersecting set of tiles as well as the actual intersecting set of pixels in the tile cache. To find tile indexes, multiply with the number of tiles at that level, and for pixel, multiply this again with pixels per tile.
inputPj | The input projection. |
topLeft | Top left corner of the input bounding box in input coordinates |
width | Width of the input bounding box in input coordinates. |
height | Height of the input bounding box in input coordinates. |
border | An extra border around the input bounding box. This can be useful when extracting data for bilinear or higher order resampling. |
ext | Output bounding box in normalized tile cache coordinates. |
level | Output tile cache level. This is the level that has at least the same resolution as the input bounding box. |
subdiv | Number of subdivisions along the bounding box borders. For projections with much distortion, the borders of the projected bounding box will not be straight and we split along each edge in order to get as correct bounds as possible. Higher numbers will give a more correct bounding box, but with more calculations. |
int TileCache::calcTileLevel | ( | double | resolution | ) |
Calculates the minimum level required for the given pixel resolution. The returned level will have a pixel size <= resolution. Note that this method does not correct for variations in resolution due to the projection, such as with Google Mercator where the effective resolution increases when you move away from the equator.
RasterProjector * TileCache::CreateRasterProjector | ( | const TileId & | tileId | ) |
Create a raster projector for a tile.
tileId |
|
inline |
Move data from tiles to temp tiles. This way we can continue to use the tile while we are waiting for the updated tile data to be loaded.
|
inline |
Find the highest available resolution at the given point. This information is taken from the bounding area info on the catalog service, and may not be accurate. I.e you may get a higher resolution result than is actually available, due to the nature of bounding boxes.
Find closest parent tile of the given tile that has ready data.
tileId |
|
inline |
Get the base tile raster projector. This projector transforms from to a normalized projection, i.e. the domain is [0,1] in both directions. To get pixel coordinates, multiply by the number of pixels at the given level, and to get tile indexes, multiply by the number of tiles at that level.
int TileCache::getIntersectingTileIds | ( | const BasicGeoTypes::GeoRect & | rc, |
std::vector< Maria::TileId > & | data | ||
) |
Find all existing tiles intersecting a bounding box. This method will produce a list of tile ID's for all tiles intersecting the given geographical bounding box.
|
inline |
Get display name for the tile cache. If no display name has been specified, map signature is used.
|
inline |
Get a tile object for the given tile ID, if the tile is ready. If not, get the nearest ready parent tile. If no ready tiles exist, the root tile will be returned.
tileId | ID of the tile to get data for |
|
inline |
Get a tile object for the given tile ID, if the tile is ready. If not, get the nearest ready parent tile. Do not traverse higher than numParentLevels parent levels.
tileId | ID of the tile to get data for |
numParentLevels | Number of parent levels to check |
double TileCache::getResolution | ( | int | level | ) |
Get pixel resolution (in m/pixel) at the given quadtree level. Note that this method does not correct for variations in resolution due to the projection, such as with Google Mercator where the effective resolution increases when you move away from the equator.
|
inline |
Get number of overflow tiles on last intersection test. This is the number of intersecting tiles that could not be added to the tile queues due to full request queues.
|
inline |
Get the tile intersecting the given point at the given resolution. If the dataset has a maximum resolution lower than given, the highest possible resolution tile is returned. The returned tile may or may not be loaded, check state and load data if necessary.
bool TileCache::IntersectsBounds | ( | const RasterProjector & | rp | ) |
Check if the given viewport intersects any of the ResolutionAreas of this dataset.
std::shared_ptr< TileData > TileCache::load | ( | Maria::TileId | tileId, |
long | timeout_ms = 0 |
||
) |
Load the given tile ID
|
inline |
Request async loading of the given tile tile.
|
inline |
Request async loading of the given tile ID.
void TileCache::waitForTile | ( | std::shared_ptr< Maria::TileData > | tileData, |
long | timeout_ms | ||
) |
Block until the tile has been loaded. This method will wait until the given tile data has been loaded, or if timeout_ms miliseconds has passed. If timeout is set to 0, it will wait indefinitely.
void TileCache::waitForTiles | ( | const std::vector< std::shared_ptr< Maria::TileData > > & | tiles, |
long | timeout_ms | ||
) |
Block until all the tiles have been loaded. This method will wait until the given tile data has been loaded, or if timeout_ms miliseconds has passed. If timeout is set to 0, it will wait indefinitely.