13#ifndef GDAL_RAT_H_INCLUDED
14#define GDAL_RAT_H_INCLUDED
16#if !defined(GDAL_COMPILATION) && \
17 !defined(GDAL_RAT_SKIP_OTHER_GDAL_HEADERS) && !defined(GDAL_4_0_COMPAT)
38#define RAT_MAX_ELEM_FOR_CLONE 1000000
244 size_t &nWKBSize)
const = 0;
359 size_t nWKBSize) = 0;
393 int iLength,
double *pdfData);
395 int iLength,
int *pnData);
397 int iLength,
char **papszStrList);
399 int iLength,
bool *pbData);
403 int iLength,
GByte **ppabyWKB,
size_t *pnWKBSize);
405 virtual void SetRowCount(
int iCount);
406 virtual int GetRowOfValue(
double dfValue)
const;
407 virtual int GetRowOfValue(
int nValue)
const;
409 virtual CPLErr CreateColumn(
const char *pszFieldName,
412 virtual CPLErr SetLinearBinning(
double dfRow0Min,
double dfBinSize);
413 virtual int GetLinearBinning(
double *pdfRow0Min,
double *pdfBinSize)
const;
422 virtual void *SerializeJSON()
const;
426 virtual GDALColorTable *TranslateToColorTable(
int nEntryCount = -1);
428 virtual void DumpReadable(FILE * =
nullptr);
454 static bool StringToDateTime(
const char *pszStr,
457 static std::string WKBGeometryToWKT(
const void *pabyWKB,
size_t nWKBSize);
458 static std::vector<GByte> WKTGeometryToWKB(
const char *pszWKT);
471 int iStartRow,
int iLength,
bool *pbData);
473 int iStartRow,
int iLength,
476 int iStartRow,
int iLength,
491 struct GDALRasterAttributeField
499 std::vector<GInt32> anValues{};
500 std::vector<double> adfValues{};
501 std::vector<CPLString> aosValues{};
502 std::vector<bool> abValues{};
503 std::vector<GDALRATDateTime> asDateTimeValues{};
504 std::vector<std::vector<GByte>> aabyWKBGeometryValues{};
507 std::vector<GDALRasterAttributeField> aoFields{};
509 int bLinearBinning =
false;
510 double dfRow0Min = -0.5;
511 double dfBinSize = 1.0;
515 void AnalyseColumns();
516 int bColumnsAnalysed =
false;
523 mutable std::vector<GByte> m_abyWKB{};
542 int GetColumnCount()
const override;
544 const char *GetNameOfCol(
int)
const override;
550 int GetRowCount()
const override;
552 const char *GetValueAsString(
int iRow,
int iField)
const override;
553 int GetValueAsInt(
int iRow,
int iField)
const override;
554 double GetValueAsDouble(
int iRow,
int iField)
const override;
555 bool GetValueAsBoolean(
int iRow,
int iField)
const override;
556 GDALRATDateTime GetValueAsDateTime(
int iRow,
int iField)
const override;
557 const GByte *GetValueAsWKBGeometry(
int iRow,
int iField,
558 size_t &nWKBSize)
const override;
560 CPLErr SetValue(
int iRow,
int iField,
const char *pszValue)
override;
561 CPLErr SetValue(
int iRow,
int iField,
double dfValue)
override;
562 CPLErr SetValue(
int iRow,
int iField,
int nValue)
override;
563 CPLErr SetValue(
int iRow,
int iField,
bool bValue)
override;
564 CPLErr SetValue(
int iRow,
int iField,
566 CPLErr SetValue(
int iRow,
int iField,
const void *pabyWKB,
567 size_t nWKBSize)
override;
569 int ChangesAreWrittenToFile()
override;
570 void SetRowCount(
int iCount)
override;
572 int GetRowOfValue(
double dfValue)
const override;
573 int GetRowOfValue(
int nValue)
const override;
577 CPLErr SetLinearBinning(
double dfRow0Min,
double dfBinSize)
override;
578 int GetLinearBinning(
double *pdfRow0Min,
double *pdfBinSize)
const override;
583 void RemoveStatistics()
override;
586std::unique_ptr<GDALRasterAttributeTable>
587 CPL_DLL GDALLoadVATDBF(
const char *pszFilename);
Convenient string class based on std::string.
Definition cpl_string.h:320
A color table / palette.
Definition gdal_colortable.h:32
Raster Attribute Table container.
Definition gdal_rat.h:489
GDALDefaultRasterAttributeTable()
Construct empty table.
The GDALRasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute ...
Definition gdal_rat.h:48
virtual CPLErr SetValue(int iRow, int iField, bool bValue)=0
Set field value from boolean.
virtual const char * GetValueAsString(int iRow, int iField) const =0
Fetch field value as a string.
virtual double GetValueAsDouble(int iRow, int iField) const =0
Fetch field value as a double.
static GDALRasterAttributeTableH ToHandle(GDALRasterAttributeTable *poRAT)
Convert a GDALRasterAttributeTable* to a GDALRasterAttributeTableH.
Definition gdal_rat.h:433
virtual void RemoveStatistics()=0
Remove statistics from the RAT.
virtual bool GetValueAsBoolean(int iRow, int iField) const =0
Fetch field value as a boolean.
virtual int GetRowCount() const =0
Fetch row count.
virtual GDALRATDateTime GetValueAsDateTime(int iRow, int iField) const =0
Fetch field value as a datetime.
virtual int ChangesAreWrittenToFile()=0
Determine whether changes made to this RAT are reflected directly in the dataset.
virtual CPLErr SetTableType(const GDALRATTableType eInTableType)=0
Set the RAT table type.
virtual CPLErr SetValue(int iRow, int iField, double dfValue)=0
Set field value from double.
static GDALRasterAttributeTable * FromHandle(GDALRasterAttributeTableH hRAT)
Convert a GDALRasterAttributeTableH to a GDALRasterAttributeTable*.
Definition gdal_rat.h:441
virtual int GetColumnCount() const =0
Fetch table column count.
virtual CPLErr SetValue(int iRow, int iField, const GDALRATDateTime &sDateTime)=0
Set field value from datetime.
virtual GDALRATFieldUsage GetUsageOfCol(int iCol) const =0
Fetch column usage value.
virtual CPLErr SetValue(int iRow, int iField, int nValue)=0
Set field value from integer.
virtual GDALRasterAttributeTable * Clone() const =0
Copy Raster Attribute Table.
virtual CPLErr SetValue(int iRow, int iField, const void *pabyWKB, size_t nWKBSize)=0
Set field value from a WKB geometry.
virtual GDALRATTableType GetTableType() const =0
Get the RAT table type.
virtual const char * GetNameOfCol(int iCol) const =0
Fetch name of indicated column.
virtual int GetValueAsInt(int iRow, int iField) const =0
Fetch field value as a integer.
virtual const GByte * GetValueAsWKBGeometry(int iRow, int iField, size_t &nWKBSize) const =0
Fetch field value as a WKB geometry.
virtual int GetColOfUsage(GDALRATFieldUsage eUsage) const =0
Fetch column index for given usage.
virtual CPLErr SetValue(int iRow, int iField, const char *pszValue)=0
Set field value from string.
virtual GDALRATFieldType GetTypeOfCol(int iCol) const =0
Fetch column type.
CPL error handling services.
CPLErr
Error category.
Definition cpl_error.h:37
Definitions for CPL mini XML Parser/Serializer.
Core portability definitions for CPL.
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:175
Various convenience functions for working with strings and string lists.
Public (C callable) GDAL entry points.
GDALRATTableType
RAT table type (thematic or athematic)
Definition gdal.h:2263
@ GRTT_THEMATIC
Definition gdal.h:2264
GDALRATFieldUsage
Field usage of raster attribute table.
Definition gdal.h:2238
@ GFU_Generic
Definition gdal.h:2239
GDALRATFieldType
Field type of raster attribute table.
Definition gdal.h:2224
@ GFT_Integer
Definition gdal.h:2225
GDALRWFlag
Definition gdal.h:125
void * GDALRasterAttributeTableH
Opaque type used for the C bindings of the C++ GDALRasterAttributeTable class.
Definition gdal_fwd.h:58
This file is legacy since GDAL 3.12, but will be kept at least in the whole GDAL 3....
Document node structure.
Definition cpl_minixml.h:54
Structure encoding a DateTime field for a GDAL Raster Attribute Table.
Definition gdal.h:2309