33#include "Design/Headers/ElevationService.h"
34#include "TIFImageHandler/Headers/GeoTiffFactory.h"
35#include "Base/Headers/Dictionary.h"
36#include "Base/Headers/File.h"
37#include "Base/Headers/RWLock.h"
40typedef struct tiff TIFF;
52 bool operator==(
const TileKey& other)
const
58 return !operator==(other);
67 size_t operator()(
const TileKey& key)
const
69 return hash<int>()(key.
lat) ^ (hash<int>()(key.
lon) << 16);
The equivelent of std::vector but with a bit more control.
A hash-based key-value store, useful for quick associative lookups.
For a given coordinate, determines the elevation at that coordinate.
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
void processRequest(ElevationRequest request)
Processes an elevation request by loading or downloading required tiles.
void downloadTile(const TileKey &key, LogPtr &log)
Initiates downloading of a tile from the remote source.
static void Initialize()
Registers this service as an available elevation provider.
Dictionary< UUID, Buffer< TileKey > > m_request_tiles
Tiles required per request.
void onTileDownloadedSlot(const TileKey &key)
Called when a tile download completes successfully.
fltp08 sampleElevation(CachedTile &tile, fltp08 lat, fltp08 lon)
Samples the elevation value from a cached tile at a geographic coordinate.
RWLock m_lock
Read-write lock for thread-safe tile access.
Dictionary< TileKey, ItemDownloader * > m_active_downloads
Active tile downloads in progress.
Dictionary< TileKey, Buffer< UUID > > m_pending_tile_downloads
Requests waiting on specific tile downloads.
Buffer< TileKey > requiredTiles(const ElevationRequest &request)
Determines which tiles are needed to fulfill an elevation request.
static TileKey TileKeyForCoord(fltp08 lat, fltp08 lon)
Computes the tile key for a given geographic coordinate.
void onTileDownloadFailedSlot(const TileKey &key)
Called when a tile download fails.
void resolveRequest(ElevationRequest &request)
Resolves an elevation request by sampling loaded tiles.
void checkAndResolve(const UUID &request_id)
Checks if all tiles for a request are available and resolves it if so.
Dictionary< TileKey, bool > m_unavailable_tiles
Tiles that failed to download or are missing.
~GeoTiffElevationService()
Destroys the service and releases cached tile resources.
String tileName(const TileKey &key) const
Returns the human-readable name for a given tile.
Dictionary< TileKey, CachedTile > m_loaded_tiles
Tiles that have been loaded into memory.
File m_cache_dir
Local directory for cached tile files.
bool loadTileFromDisk(const TileKey &key)
Attempts to load a tile from the local disk cache.
GeoTiffElevationService()
Constructs a GeoTiffElevationService.
File tileCachePath(const TileKey &key) const
Returns the local cache file path for a given tile.
Dictionary< UUID, ElevationRequest > m_pending_requests
Pending elevation requests by UUID.
String tileUrl(const TileKey &key) const
Returns the download URL for a given tile.
virtual void postRequest(const ElevationRequest &request) override
Submits an elevation request for asynchronous processing.
Used for Downloading resources from a network.
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
A readers-writer lock allowing concurrent reads or exclusive writes.
The core String class for the NDEVR API.
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
The primary namespace for the NDEVR SDK.
constexpr bool operator!=(const Vector< t_dims, t_type > &vec_a, const Vector< t_dims, t_type > &vec_b)
Inequality operator.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
int32_t sint04
-Defines an alias representing a 4 byte, signed integer.
Stores a cached GeoTIFF tile with precomputed layout information for fast elevation sampling.
uint04 scanline_bytes
The number of bytes per scanline for strip-based TIFFs.
uint04 tile_height
The height of each TIFF tile in pixels.
GeoTiffInfo info
The GeoTIFF metadata for this tile.
uint04 band_index
The raster band index used for elevation data.
uint04 cached_scanline_row
The currently cached scanline row index.
uint04 cached_tile_ox
X origin of the currently cached tile.
uint04 cached_tile_oy
Y origin of the currently cached tile.
uint04 tile_width
The width of each TIFF tile in pixels.
TIFF * tif_handle
The open TIFF file handle.
File file_path
The file path to the cached tile on disk.
Buffer< uint01 > read_buf
Reusable read buffer sized to tile or scanline size.
bool is_tiled
Whether the TIFF is stored in tiles (vs. strips).
Stores options and receives data for determining the elevation at given coordinates.
Stores parsed GeoTIFF metadata including projection, tiepoints, and raster dimensions.
A key identifying a geographic tile by integer latitude and longitude.
sint04 lon
The integer longitude of the tile.
sint04 lat
The integer latitude of the tile.