Class Tile

Nested Relationships

Nested Types

Class Documentation

class Tile

This class represents a valid GDAL tile.

Public Functions

Tile(const std::string &filename)

Constructor.

Parameters

filename – the Gdal file path

void scan_tile() const

Scan the whole dataset tile to store in the cache.

bool is_valid() const

Check whether the tile has a valid file.

Returns

Whether raster tile is associated with valid file.

bool is_rotated() const

Check if the tile is rotated in map space.

Returns

Whether the tile is rotated.

bool is_cached() const

Check if a tile is currently cached.

Returns

Cached state of the tile.

double lookup_datum(const Coordinate &map_coords) const

Gets the elevation from a GDAL tile.

Parameters

map_coords – coordinate in map space.

Returns

found elevation. Note that this function does not perform a bounds check, as the GdalSource confirms that the coordinates are in bounds before trying to look up the datum. If an out of bound map coordinate is provided, it will return the closest elevation contained in the tile. If data is missing from the nearest pixels in the tile, it will return NAN.

Vector lookup_data(const Coordinates &map_coords) const

Gets the elevations from a GDAL tile.

Parameters

map_coords – batch of coordinates in map space.

Returns

A vector of elevations.

bool contains(const Coordinate &map_coords) const

Check if the given coordinates are in the bounds of this tile.

Parameters

map_coords – coordinates in map space

Returns

true if the given coordinates are in the tile.

std::vector<size_t> contains(const Coordinates &map_coords, const std::vector<bool> &search_mask = {}) const

Check if the given set of coordinates are in the bounds of this tile.

Parameters
  • map_coords – batch of N coordinates in map space.

  • search_mask – optional mask of length N, where indices of coordinates to look for are true. If an index is false, contains will ignore that index, even if it is contained in the tile. This parameter exists to improve performance by avoiding unnecessary checks when a coordinate may have already been found in another Tile. This is faster than passing in only the set of Coordinates to search for, which would require substantial memory re-allocation.

Returns

indices of coordinates in map_coords contained in tile.

void unload() const

Remove the tile data from memory, if cached.

std::string get_filename() const

Return a human-readable name for this object.

Returns

The file name.

size_t get_width() const

Returns the total number of pixels in each line.

Returns

The number of pixels in the line.

size_t get_height() const

Returns the total number of lines in the dataset object (i.e.

in the file).

Returns

The number of lines.

std::unique_ptr<OGRCoordinateTransformation, detail::TransformDelete> wgs84_to_map_transform() const

Get transformation from wgs84 to map for this tile.

Returns

pointer to transformation

std::unique_ptr<OGRCoordinateTransformation, detail::TransformDelete> map_to_wgs84_transform() const

Get transformation from map to wgs84 for this tile.

Returns

pointer to transformation

Coordinate map_to_pixel(const Coordinate &map_coords) const

Transform coordinates in map space into the pixel space of this particular tile.

Parameters

map_coords – coordinates in map space

Returns

the projected pixel coordinates for this tile

Coordinates map_to_pixel(const Coordinates &map_coords) const

Transform a batch of coordinates in map space into the pixel space of this particular tile.

Parameters

map_coords – a batch of coordinates in map space

Returns

the projected batch of pixel coordinates for this tile

Coordinate pixel_to_map(const Coordinate &pixel_coords) const

Transform coordinates in the pixel space of this particular tile into map space.

Parameters

pixel_coords – coordinates in the pixel space of this tile

Returns

the projected map coordinates

Coordinates pixel_to_map(const Coordinates &pixel_coords) const

Transform a batch of coordinates in the pixel space of this particular tile into map space.

Parameters

pixel_coords – a batch of coordinates in the pixel space of this tile

Returns

the projected batch of map coordinates

Friends

friend const std::ostream &operator<<(std::ostream &os, Tile &tile)

Overload insertion operator to print the tile’s data.

Parameters
  • os – the ostream object

  • tile – the tile to print

Returns

The output stream os.