Program Listing for File Tile.hpp
↰ Return to documentation for file (optional/gdal/src/navtk/geospatial/Tile.hpp)
#pragma once
#include <memory>
#include <ostream>
#ifndef GDAL_INCLUDE_IN_SUBFOLDER
# include <gdal_priv.h>
# include <ogr_spatialref.h>
#else
# include <gdal/gdal_priv.h>
# include <gdal/ogr_spatialref.h>
#endif
#include <navtk/geospatial/Coordinates.hpp>
#include <navtk/geospatial/detail/custom_deleters.hpp>
#include <navtk/geospatial/detail/transformations.hpp>
namespace navtk {
namespace geospatial {
class Tile {
public:
Tile(const std::string& filename);
void scan_tile() const;
bool is_valid() const;
bool is_rotated() const;
bool is_cached() const;
double lookup_datum(const Coordinate& map_coords) const;
Vector lookup_data(const Coordinates& map_coords) const;
bool contains(const Coordinate& map_coords) const;
std::vector<size_t> contains(const Coordinates& map_coords,
const std::vector<bool>& search_mask = {}) const;
void unload() const;
std::string get_filename() const;
size_t get_width() const;
size_t get_height() const;
std::unique_ptr<OGRCoordinateTransformation, detail::TransformDelete> wgs84_to_map_transform()
const;
std::unique_ptr<OGRCoordinateTransformation, detail::TransformDelete> map_to_wgs84_transform()
const;
Coordinate map_to_pixel(const Coordinate& map_coords) const;
Coordinates map_to_pixel(const Coordinates& map_coords) const;
Coordinate pixel_to_map(const Coordinate& pixel_coords) const;
Coordinates pixel_to_map(const Coordinates& pixel_coords) const;
friend const std::ostream& operator<<(std::ostream& os, Tile& tile);
private:
struct Bounds {
Coordinate down_left;
Coordinate down_right;
Coordinate up_left;
Coordinate up_right;
};
Bounds get_bounds(std::array<Coordinate, 4> corners);
std::string filename;
double no_data_value;
bool valid = false;
std::unique_ptr<GDALDataset, detail::DatasetDelete> dataset;
size_t size_x, size_y;
Bounds bounds;
mutable std::vector<double> cached_tile;
mutable bool cached = false;
double map_offset_x;
double map_offset_y;
double pixel_width;
double pixel_height;
double row_rotation;
double column_rotation;
double read_pixel(const Pixel& idx) const;
Vector read_pixels(const Pixels& idx) const;
};
} // namespace geospatial
} // namespace navtk