|
NEP 2.7.0
NetCDF Extension Pack
|
GeoTIFF file format detection and operations. More...
#include "config.h"#include <assert.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <netcdf.h>#include "geotiffdispatch.h"#include "nep_nc4.h"Macros | |
| #define | GEOTIFF_KEY_DIRECTORY_TAG 34735 |
| #define | MAX_IFD_OFFSET 104857600 |
| #define | TIFF_IFD_ENTRY_SIZE 12 |
| #define | MAX_BUFFER_SIZE 1073741824 |
| #define | MAX_IFD_ENTRIES 4096 |
Functions | |
| static unsigned short | swap16 (unsigned short val) |
| static unsigned int | swap32 (unsigned int val) |
| static int | nc4_set_var_type (nc_type xtype, int endianness, size_t type_size, char *type_name, NC_TYPE_INFO_T **typep) |
| static int | nc4_var_list_add_full (NC_GRP_INFO_T *grp, const char *name, int ndims, nc_type xtype, int endianness, size_t type_size, char *type_name, void *fill_value, int contiguous, size_t *chunksizes, void *format_var_info, NC_VAR_INFO_T **var) |
| static int | read_tiff_header (FILE *fp, int *is_little_endian, int *is_bigtiff, unsigned int *ifd_offset) |
| static int | check_geotiff_tags (FILE *fp, unsigned int ifd_offset, int is_little_endian, int is_bigtiff, int *has_geotiff_tags) |
| int | NC_GEOTIFF_detect_format (const char *path, int *is_geotiff) |
GeoTIFF file format detection and operations.
This file implements GeoTIFF format detection for the NetCDF API. It validates TIFF magic numbers, headers, and GeoTIFF-specific tags to distinguish GeoTIFF files from regular TIFF files.
| #define GEOTIFF_KEY_DIRECTORY_TAG 34735 |
GeoTIFF key directory tag
| #define MAX_BUFFER_SIZE 1073741824 |
Maximum buffer size for reading (1 GB)
| #define MAX_IFD_ENTRIES 4096 |
Maximum number of IFD entries to process
| #define MAX_IFD_OFFSET 104857600 |
Maximum reasonable IFD offset (100 MB)
| #define TIFF_IFD_ENTRY_SIZE 12 |
TIFF IFD entry size
|
static |
Check if IFD contains GeoTIFF tags.
| fp | File pointer. |
| ifd_offset | IFD offset. |
| is_little_endian | 1 if little-endian, 0 if big-endian. |
| is_bigtiff | 1 if BigTIFF, 0 if classic TIFF. |
| has_geotiff_tags | Output: 1 if GeoTIFF tags found, 0 otherwise. |
|
static |
|
static |
| int NC_GEOTIFF_detect_format | ( | const char * | path, |
| int * | is_geotiff | ||
| ) |
|
static |
Read and validate TIFF header.
| fp | File pointer. |
| is_little_endian | Output: 1 if little-endian, 0 if big-endian. |
| is_bigtiff | Output: 1 if BigTIFF, 0 if classic TIFF. |
| ifd_offset | Output: IFD offset. |
|
static |
Byte-swap a 16-bit value.
| val | Value to swap. |
|
static |
Byte-swap a 32-bit value.
| val | Value to swap. |