Class GdalRaster

Inheritance Relationships

Base Type

Class Documentation

class GdalRaster : public navtk::geospatial::Raster

Interface to an GDAL File made up of a rectangular grid of pixels.

Each pixel represents a post; thus, pixel and post can be considered synonymous

Public Functions

GdalRaster(const std::string &filename, const std::string &undulation_path = "WW15MGH.GRD")

Constructor.

Parameters
  • filename – the file path

  • undulation_path – the path to the geoid undulation file for converting between HAE and MSL. The default path of this variable requires setting the NAVTK_DATA_DIR environment variable to the folder containing the undulation file.

~GdalRaster() = default

Destructor.

void scan_tile()

Scan the whole dataset tile to store in the cache.

bool is_valid() const
Returns

Whether raster tile is associated with valid file.

virtual int get_width() const override

Returns the total number of elements in each line.

Returns

The number of elements in the line.

virtual int get_height() const override

Returns the total number of lines available.

Returns

The number of lines.

virtual std::pair<double, double> wgs84_to_pixel(double latitude, double longitude) const override

Transform the coordinates from wgs84 (lat/lon) to pixel offset.

Parameters
  • latitude – Latitude in degrees

  • longitude – Longitude in degrees

Returns

The converted coordinates as a pixel offset from the top left of the tile.

std::pair<double, double> pixel_to_wgs84(double x_pixel, double y_pixel) const

Transform the coordinates from pixel offset to wgs84 (lat/lon).

This is the reverse of wgs84_to_pixel().

Parameters
  • x_pixel – column offset from top left of tile

  • y_pixel – row offset from top left of tile

Returns

The converted coordinates in the form {latitude, longitude}.

virtual double read_pixel(size_t idx_x, size_t idx_y) override

Returns a single double representing the elevation at the given pixel index.

Parameters
  • idx_x – index of pixel in the line, value should be between 0 and get_width().

  • idx_y – index of line to read, value should be between 0 and get_height().

Returns

The elevation at the pixel index, or no_data_value if the requested index is unavailable in the dataset or is out of bounds.

virtual std::string get_name() const override

Return a human-readable name for this object.

Returns

The file name.

virtual bool is_valid_data(double data) const override

Compare the given elevation to the raster’s no data value (a unique value used by the dataset to denote invalid or missing data inside of a tile).

Parameters

data – The elevation to evaluate.

Returns

true if the elevation is valid and false if not.

virtual void unload() override

Remove data from memory, if cached.