Maria GDK 5.0.0.738
Documentation of native code in develop branch
Loading...
Searching...
No Matches
Maria::TileCache Class Reference

#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::TileDatagetData (TileId id) const
 
std::shared_ptr< Maria::TileDatagetTempData (TileId id) const
 
void expireData (TileId id)
 
std::shared_ptr< Maria::TileDatagetOrCreateData (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 MapContentQuerygetMapContentQuery () const
 
const std::shared_ptr< TileCacheSpec > & getTileCacheSpec () const
 
std::shared_ptr< RasterProjectorgetBaseTileProjector () 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.
 
RasterProjectorCreateRasterProjector (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::TileDataGetReadyOrTempTile (const TileId &tileId)
 
std::shared_ptr< Maria::TileDataGetReadyOrParentTile (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::TileDataGetReadyOrParentTile (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::TileDataGetReadyOrTempOrParentTile (TileId tileId, int numParentLevels)
 
std::shared_ptr< Maria::TileDataGetTileResolution (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::TileDataloadAsync (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::TileDataload (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 &centerPt, 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
 

Detailed Description

TileCache - Short description. Detailed description.

Member Function Documentation

◆ calcIntersectingTileId()

bool Maria::TileCache::calcIntersectingTileId ( const BasicGeoTypes::GeoPos pos,
double  resolution,
Maria::TileId tileId 
)

Calculate tile ID intersecting the given point at the given resolution.

Parameters
posGeographical position to check.
resolutionMinimum resolution in m/pixel. If 0, use the highest available resolution.
tileIdOutput value
Returns
True on success, false on failure, for example if the point is outside the tile cache area.

◆ CalcIntersectingTiles()

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.

◆ CalcIntersectingTilesResolution()

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.

Parameters
tileIdsOutput array of tile ids.
grcBounding box in geographical coordinates.
maxResolutionIf > 0, indicates the maximum resolution of the returned tiles (in m/sample). If 0, the highest available resolution tiles are returned.
requestTilesIf true, trigger loading of the tile data if not already loaded.
numParentLevelsNumber of parent levels to include.

◆ CalcTileBoundsAndLevel()

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.

Parameters
inputPjThe input projection.
topLeftTop left corner of the input bounding box in input coordinates
widthWidth of the input bounding box in input coordinates.
heightHeight of the input bounding box in input coordinates.
borderAn extra border around the input bounding box. This can be useful when extracting data for bilinear or higher order resampling.
extOutput bounding box in normalized tile cache coordinates.
levelOutput tile cache level. This is the level that has at least the same resolution as the input bounding box.
subdivNumber 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.
Note
The output bounding box will not include parts of the input that are outside of the definition area of the tile cache projection.
Returns
A number between 0.0 and 1.0 indicating the validity of the input rectangle over the tile cache coordinate system. 1.0 mans that the rectangle is entirely within the tile cache coordinate system while 0.0 means that none of the transforms were valid. This also happens if the center point of the rectangle is invalid.

◆ calcTileLevel()

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.

◆ CreateRasterProjector()

RasterProjector * TileCache::CreateRasterProjector ( const TileId tileId)

Create a raster projector for a tile.

Parameters
tileId
Returns
A raster projector for the given tile ID with correct projection and position

◆ expireData()

void Maria::TileCache::expireData ( TileId  id)
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.

◆ FindMaxResolution()

bool Maria::TileCache::FindMaxResolution ( const BasicGeoTypes::GeoPos geoPos,
double &  maxResolution 
)
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.

◆ FindReadyParentTile()

TileId Maria::TileCache::FindReadyParentTile ( const TileId tileId)
inline

Find closest parent tile of the given tile that has ready data.

Parameters
tileId
Returns

◆ getBaseTileProjector()

std::shared_ptr< RasterProjector > Maria::TileCache::getBaseTileProjector ( ) const
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.

◆ getIntersectingTileIds()

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.

◆ getName()

const std::string & Maria::TileCache::getName ( ) const
inline

Get display name for the tile cache. If no display name has been specified, map signature is used.

◆ GetReadyOrParentTile() [1/2]

std::shared_ptr< Maria::TileData > Maria::TileCache::GetReadyOrParentTile ( const TileId tileId)
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.

Parameters
tileIdID of the tile to get data for
Returns

◆ GetReadyOrParentTile() [2/2]

std::shared_ptr< Maria::TileData > Maria::TileCache::GetReadyOrParentTile ( TileId  tileId,
int  numParentLevels 
)
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.

Parameters
tileIdID of the tile to get data for
numParentLevelsNumber of parent levels to check
Returns

◆ getResolution()

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.

◆ getTileQueueOverflow()

int Maria::TileCache::getTileQueueOverflow ( ) const
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.

◆ GetTileResolution()

std::shared_ptr< Maria::TileData > Maria::TileCache::GetTileResolution ( const BasicGeoTypes::GeoPos pos,
double  resolution 
)
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.

◆ IntersectsBounds()

bool TileCache::IntersectsBounds ( const RasterProjector rp)

Check if the given viewport intersects any of the ResolutionAreas of this dataset.

◆ load()

std::shared_ptr< TileData > TileCache::load ( Maria::TileId  tileId,
long  timeout_ms = 0 
)

Load the given tile ID

Note
This will load the tile immediately on the calling thread.
Returns
A TileData object for the requested tile ID.

◆ loadAsync() [1/2]

void Maria::TileCache::loadAsync ( const std::shared_ptr< Maria::TileData > &  tile)
inline

Request async loading of the given tile tile.

Note
The tile may not be requested, due to full request queues. Check the actual state of the tile data object after calling.

◆ loadAsync() [2/2]

std::shared_ptr< Maria::TileData > Maria::TileCache::loadAsync ( Maria::TileId  tileId)
inline

Request async loading of the given tile ID.

Note
The tile may not be requested, due to full request queues. Check the actual state of the tile data object after calling.
Returns
A TileData object for the requested tile ID.

◆ waitForTile()

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.

◆ waitForTiles()

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.


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