NDEVR
API Documentation
GeoTiffFactory.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2020, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: TIFImageHandler
28File: GeoTiffFactory
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/IOFactory.h>
35#include <NDEVR/Matrix.h>
36
37struct tiff;
38typedef struct tiff TIFF;
39
40namespace NDEVR
41{
45 struct TIF_IMAGE_HANDLER_API GeoTiffInfo
46 {
48 bool has_pixel_scale = false;
49
52 bool has_tiepoints = false;
53
55 bool has_transformation = false;
56
57 uint04 projected_cs_type = Constant<uint04>::Invalid;
58 uint04 geographic_type = Constant<uint04>::Invalid;
59 uint04 model_type = Constant<uint04>::Invalid;
60 uint04 raster_type = Constant<uint04>::Invalid;
61
64 uint16_t samples_per_pixel = 0;
65 uint16_t bits_per_sample = 0;
66 uint16_t sample_format = 0;
68
69 uint02 elevation_band_index = Constant<uint02>::Invalid;
71
72 // Set by readFile when CRS is geographic (degrees) -- holds the UTM projection
73 // used for converting degree coordinates to meters
74 UUID source_projection = Constant<UUID>::Invalid;
75
78 bool isOrthophoto() const;
81 bool isMultispectral() const;
82
95 };
96
101 class TIF_IMAGE_HANDLER_API GeoTiffFactory : public IOFactory
102 {
103 private:
105 GeoTiffFactory();
106 public:
110 void getSupportedFormats(Buffer<FileFormat>& formats, bool is_read) override;
114 bool canRead(const File& file) override;
118 bool canRead(const FactoryParameters& file) override;
122 bool readFile(FactoryParameters& file) override;
126 bool writeFile(FactoryParameters& file) override;
135 FactoryFeatures factoryFeatures(const FactoryParameters& file, bool is_read) const override;
138 static GeoTiffFactory* DefaultFactory();
141 static constexpr StringView FactoryID() { return "GeoTIFF Factory"; }
142
145 virtual bool isAutoEnabled() const;
149 static bool HasGeoTiffTags(TIFF* tif);
153 static GeoTiffInfo ParseGeoTiffTags(TIFF* tif);
157 static UUID ResolveProjection(const GeoTiffInfo& info);
158 private:
164 bool readOrthophoto(FactoryParameters& params, TIFF* tif, const GeoTiffInfo& info);
170 bool readMultispectral(FactoryParameters& params, TIFF* tif, const GeoTiffInfo& info);
171
174 static constexpr StringView CustomOptionsLabel() { return "geotiff_options"; }
177 static constexpr StringView CustomOptionsImportMode() { return "import_mode"; }
180 static constexpr StringView CustomOptionsDecimation() { return "decimation_stride"; }
183 static constexpr StringView CustomOptionsDrapeMode() { return "drape_mode"; }
186 static constexpr StringView CustomOptionsUseProjection() { return "use_projection"; }
187 };
188}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Allows IOFactories to report what features they support to make the import/export dialogs easier to s...
User-defined options that define preferences for importing and exporting using IOFactory objects.
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
bool writeFile(FactoryParameters &file) override
Writes design data to a GeoTIFF file.
virtual bool isAutoEnabled() const
Checks whether this factory is automatically enabled.
FactoryFeatures factoryFeatures(const FactoryParameters &file, bool is_read) const override
Returns the supported factory features for the given file.
static GeoTiffFactory * DefaultFactory()
Returns the singleton GeoTiffFactory instance.
bool canRead(const FactoryParameters &file) override
Checks whether the given factory parameters describe a readable GeoTIFF.
static UUID ResolveProjection(const GeoTiffInfo &info)
Resolves the coordinate reference system projection from GeoTIFF info.
void getSupportedFormats(Buffer< FileFormat > &formats, bool is_read) override
Populates the list of supported GeoTIFF file formats.
static bool HasGeoTiffTags(TIFF *tif)
Checks whether the given TIFF handle contains GeoTIFF tags.
FactoryOptions defaultReadOptions(const FactoryParameters &file) const override
Returns the default read options for GeoTIFF files.
static constexpr StringView FactoryID()
Returns the unique identifier string for this factory.
bool canRead(const File &file) override
Checks whether the given file can be read as a GeoTIFF.
static GeoTiffInfo ParseGeoTiffTags(TIFF *tif)
Parses GeoTIFF tags from a TIFF handle.
bool readFile(FactoryParameters &file) override
Reads a GeoTIFF file into the design model.
IOFactory(const StringView &factory_name)
Constructs an IOFactory with the given factory name.
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
The core String View class for the NDEVR API.
Definition StringView.h:58
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
A point in N-dimensional space, used primarily for spatial location information.
Definition Vertex.hpp:44
The primary namespace for the NDEVR SDK.
uint16_t uint02
-Defines an alias representing a 2 byte, unsigned integer -Can represent exact integer values 0 throu...
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.
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
A container of input information that is to be filled with output information by an IOFactory.
Definition IOFactory.h:105
Stores parsed GeoTIFF metadata including projection, tiepoints, and raster dimensions.
bool has_pixel_scale
Whether pixel scale tags were present.
bool isOrthophoto() const
Checks whether this GeoTIFF represents an orthophoto.
UUID source_projection
The UTM projection UUID for geographic CRS conversion.
Vector< 3, fltp08 > pixel_scale
The pixel scale in X, Y, Z.
uint04 model_type
The GeoTIFF model type (projected, geographic, or geocentric).
uint04 height
The image height in pixels.
Vertex< 3, fltp08 > pixelToMeters(fltp08 col, fltp08 row, fltp08 z=0.0) const
Converts pixel coordinates to meters, handling geographic CRS via UTM.
Buffer< Vertex< 3, fltp08 > > model_tiepoints
Model-space tiepoint coordinates.
uint04 projected_cs_type
The projected coordinate system EPSG code.
uint02 elevation_band_index
The band index containing elevation data.
bool isMultispectral() const
Checks whether this GeoTIFF contains multispectral data.
uint04 geographic_type
The geographic coordinate system EPSG code.
bool has_tiepoints
Whether tiepoint tags were present.
uint16_t samples_per_pixel
The number of samples (bands) per pixel.
fltp08 invalid_val
The no-data or invalid value for elevation data.
uint16_t bits_per_sample
The number of bits per sample.
Vertex< 3, fltp08 > pixelToCoord(fltp08 col, fltp08 row, fltp08 z=0.0) const
Converts pixel coordinates to geographic or projected coordinates.
Buffer< String > band_descriptions
Descriptive names for each band.
uint04 raster_type
The raster type (pixel-is-area or pixel-is-point).
uint16_t sample_format
The sample data format (unsigned, signed, float).
bool has_transformation
Whether a transformation matrix tag was present.
Buffer< Vertex< 3, fltp08 > > raster_tiepoints
Raster-space tiepoint coordinates.
Matrix< fltp08 > model_transformation
The full 4x4 model transformation matrix.
uint04 width
The image width in pixels.