|
SAGA API
v9.6
|
Go to the documentation of this file.
52 #ifndef HEADER_INCLUDED__SAGA_API__grids_H
53 #define HEADER_INCLUDED__SAGA_API__grids_H
100 #define SG_GRIDS_NAME_OWNER 0x01
101 #define SG_GRIDS_NAME_INDEX 0x02
102 #define SG_GRIDS_NAME_VALUE 0x04
103 #define SG_GRIDS_NAME_GRID 0x08
128 virtual bool Create (
const CSG_Grids &Grids);
131 virtual bool Create (
const CSG_Grids *pGrids,
bool bCopyData =
false);
133 CSG_Grids (
const char *FileName,
bool bLoadData =
true);
134 virtual bool Create (
const char *FileName,
bool bLoadData =
true);
135 CSG_Grids (
const wchar_t *FileName,
bool bLoadData =
true);
136 virtual bool Create (
const wchar_t *FileName,
bool bLoadData =
true);
138 virtual bool Create (
const CSG_String &FileName,
bool bLoadData =
true);
147 virtual bool Create (
int NX,
int NY,
int NZ = 0,
double Cellsize = 0.,
double xMin = 0.,
double yMin = 0.,
double zMin = 0.,
TSG_Data_Type Type =
SG_DATATYPE_Undefined);
153 virtual bool Load (
const CSG_String &File,
bool bLoadData =
true);
157 virtual bool Save (
const wchar_t *File,
int Format = 0) {
return(
Save(
CSG_String(File), Format) ); }
185 int Get_NX (
void)
const {
return( m_pGrids[0]->Get_System().
Get_NX() ); }
186 int Get_NY (
void)
const {
return( m_pGrids[0]->Get_System().
Get_NY() ); }
187 int Get_NZ (
void)
const {
return( (
int)m_Attributes.Get_Count() ); }
189 sLong Get_Data_Count (
void);
190 sLong Get_NoData_Count (
void);
197 double Get_XMin (
bool bCells =
false)
const {
return( m_pGrids[0]->Get_System().Get_XMin (bCells) ); }
198 double Get_XMax (
bool bCells =
false)
const {
return( m_pGrids[0]->Get_System().Get_XMax (bCells) ); }
201 double Get_YMin (
bool bCells =
false)
const {
return( m_pGrids[0]->Get_System().Get_YMin (bCells) ); }
202 double Get_YMax (
bool bCells =
false)
const {
return( m_pGrids[0]->Get_System().Get_YMax (bCells) ); }
205 double Get_ZMin (
bool bCells =
false)
const {
return( m_Attributes.Get_Minimum(m_Z_Attribute) ); }
206 double Get_ZMax (
bool bCells =
false)
const {
return( m_Attributes.Get_Maximum(m_Z_Attribute) ); }
207 double Get_ZRange (
bool bCells =
false)
const {
return( m_Attributes.Get_Range (m_Z_Attribute) ); }
213 bool Set_Z_Attribute (
int Field);
216 bool Set_Z_Name_Field (
int Field);
217 int Get_Z_Name_Field (
void)
const;
219 bool Add_Attribute (
const char *Name,
TSG_Data_Type Type,
int Insert = -1);
220 bool Add_Attribute (
const wchar_t *Name,
TSG_Data_Type Type,
int Insert = -1);
222 bool Del_Attribute (
int Field);
229 bool Set_Attribute (
int i,
int Field,
const CSG_String &Value);
231 bool Set_Attribute (
int i,
const wchar_t *Field,
const wchar_t *Value);
232 bool Set_Attribute (
int i,
const char *Field,
const char *Value);
234 bool Set_Attribute (
int i,
int Field,
double Value);
235 bool Set_Attribute (
int i,
const CSG_String &Field,
double Value);
236 bool Set_Attribute (
int i,
const wchar_t *Field,
double Value);
237 bool Set_Attribute (
int i,
const char *Field,
double Value);
239 bool Set_Z (
int i,
double Value);
240 double Get_Z (
int i)
const {
return( m_Attributes[i].asDouble(m_Z_Attribute) ); }
242 bool Update_Z_Order (
void);
248 bool Set_Grid_Count (
int Count);
251 bool Add_Grid (
double Z);
252 bool Add_Grid (
double Z,
CSG_Grid *pGrid,
bool bAttach =
false);
256 bool Del_Grid (
int i,
bool bDetach =
false);
257 bool Del_Grids (
bool bDetach =
false);
261 CSG_String Get_Grid_Name (
int i,
int Style = 0)
const;
269 void Set_Scaling (
double Scale = 1.,
double Offset = 0.);
271 double Get_Offset (
void)
const {
return( m_pGrids[0]->Get_Offset () ); }
272 bool is_Scaled (
void)
const {
return( m_pGrids[0]->is_Scaled () ); }
274 double Get_Mean (
void);
275 double Get_Min (
void);
276 double Get_Max (
void);
277 double Get_Range (
void);
278 double Get_StdDev (
void);
279 double Get_Variance (
void);
280 double Get_Quantile (
double Quantile,
bool bFromHistogram =
true);
281 double Get_Percentile (
double Percentile,
bool bFromHistogram =
true);
301 bool is_Compatible (
CSG_Grid *pGrid )
const;
302 bool is_Compatible (
CSG_Grids *pGrids)
const;
304 bool is_Compatible (
int NX,
int NY,
double Cellsize,
double xMin,
double yMin)
const;
306 bool is_InGrid (
int x,
int y,
int z,
bool bCheckNoData =
true)
const {
return( Get_System().
is_InGrid(x, y) && z >= 0 && z < Get_NZ() && (!bCheckNoData || !is_NoData(x, y, z)) ); }
307 bool is_InGrid_byPos (
double x,
double y,
double z,
bool bCheckNoData =
true)
const {
return(
Get_Extent(
true).Contains(x, y) && z >= Get_ZMin() && z <= Get_ZMax() && (!bCheckNoData || !is_NoData(Get_System().Get_xWorld_to_Grid(x), Get_System().Get_yWorld_to_Grid(y), (
int)z)) ); }
318 m_Attributes.Set_Modified(bModified);
335 void Assign_NoData (
void);
337 virtual bool Assign (
double Value = 0.);
346 virtual CSG_Grids & operator = (
double Value );
348 virtual CSG_Grids & operator += (
double Value );
351 virtual CSG_Grids & operator -= (
double Value );
352 virtual CSG_Grids & Subtract (
double Value );
354 virtual CSG_Grids & operator *= (
double Value );
355 virtual CSG_Grids & Multiply (
double Value );
357 virtual CSG_Grids & operator /= (
double Value );
358 virtual CSG_Grids & Divide (
double Value );
360 virtual double operator () (
int x,
int y,
int z)
const {
return( asDouble(x, y, z) ); }
362 virtual CSG_Grid & operator [] (
int i) {
return( *m_pGrids[i] ); }
385 virtual BYTE
asByte (
int x,
int y,
int z,
bool bScaled =
true)
const {
return(
SG_ROUND_TO_BYTE (asDouble(x, y, z, bScaled)) ); }
387 virtual char asChar (
int x,
int y,
int z,
bool bScaled =
true)
const {
return(
SG_ROUND_TO_CHAR (asDouble(x, y, z, bScaled)) ); }
389 virtual short asShort (
int x,
int y,
int z,
bool bScaled =
true)
const {
return(
SG_ROUND_TO_SHORT(asDouble(x, y, z, bScaled)) ); }
391 virtual int asInt (
int x,
int y,
int z,
bool bScaled =
true)
const {
return(
SG_ROUND_TO_INT (asDouble(x, y, z, bScaled)) ); }
395 virtual float asFloat (
int x,
int y,
int z,
bool bScaled =
true)
const {
return( (
float) (asDouble(x, y, z, bScaled)) ); }
396 virtual float asFloat (
sLong i,
bool bScaled =
true)
const {
return( (
float) (asDouble( i, bScaled)) ); }
401 int z = (int)(i / m_pGrids[0]->Get_NCells());
403 return( m_pGrids[z]->asDouble((
sLong)(i % m_pGrids[0]->Get_NCells()), bScaled) );
406 virtual double asDouble(
int x,
int y,
int z,
bool bScaled =
true)
const
408 return( m_pGrids[z]->asDouble(x, y, bScaled) );
415 virtual void Add_Value(
int x,
int y,
int z,
double Value) { Set_Value(x, y, z, asDouble(x, y, z) + Value ); }
416 virtual void Add_Value(
sLong i,
double Value) { Set_Value( i, asDouble( i) + Value ); }
418 virtual void Mul_Value(
int x,
int y,
int z,
double Value) { Set_Value(x, y, z, asDouble(x, y, z) * Value ); }
419 virtual void Mul_Value(
sLong i,
double Value) { Set_Value( i, asDouble( i) * Value ); }
424 int z = (int)(i / m_pGrids[0]->Get_NCells());
426 m_pGrids[z]->Set_Value((
sLong)(i % m_pGrids[0]->Get_NCells()), Value, bScaled);
429 virtual void Set_Value(
int x,
int y,
int z,
double Value,
bool bScaled =
true)
431 m_pGrids[z]->Set_Value(x, y, Value, bScaled);
447 return( _Get_Index() );
452 if( Position >= 0 && Position < Get_NCells() && _Get_Index() )
454 Position = m_Index[bDown ? Get_NCells() - Position - 1 : Position];
456 if( !bCheckNoData || !is_NoData(Position) )
467 return( (i = Get_Sorted(Position, bDown, bCheckNoData)) >= 0 );
470 bool Get_Sorted (
sLong Position,
int &x,
int &y,
int &z,
bool bDown =
true,
bool bCheckNoData =
true)
472 if( (Position = Get_Sorted(Position, bDown, bCheckNoData)) >= 0 )
474 z = (int)(Position / m_pGrids[0]->Get_NCells());
476 Position = Position % m_pGrids[0]->Get_NCells();
478 x = (int)(Position % Get_NX());
479 y = (int)(Position / Get_NX());
499 int m_Z_Attribute, m_Z_Name;
515 void _On_Construction (
void);
517 void _Synchronize (
CSG_Grid *pGrid);
520 bool _Get_Z (
double Value,
int &iz,
double &dz)
const;
523 bool _Set_Index (
void);
524 bool _Get_Index (
void)
531 return( m_Index || _Set_Index() );
535 bool _Load_External (
const CSG_String &FileName);
536 bool _Load_PGSQL (
const CSG_String &FileName);
538 bool _Load_Normal (
const CSG_String &FileName);
539 bool _Save_Normal (
const CSG_String &FileName);
541 bool _Load_Compressed (
const CSG_String &FileName);
542 bool _Save_Compressed (
const CSG_String &FileName);
544 bool _Load_Header (
CSG_File &Stream);
545 bool _Save_Header (
CSG_File &Stream);
547 bool _Load_Attributes (
CSG_File &Stream);
548 bool _Save_Attributes (
CSG_File &Stream);
555 bool _Assign_MeanValue (
CSG_Grids *pSource,
bool bVolumeProportional);
556 bool _Assign_ExtremeValue (
CSG_Grids *pSource,
bool bMaximum);
557 bool _Assign_Majority (
CSG_Grids *pSource);
573 #define SG_GRIDS_PTR_SAFE_SET_NODATA(g, x, y, z) { if( g && g->is_InGrid(x, y, z, false) ) { g->Set_NoData(x, y, z ); } }
574 #define SG_GRIDS_PTR_SAFE_SET_VALUE(g, x, y, z, v) { if( g && g->is_InGrid(x, y, z, false) ) { g->Set_Value (x, y, z, v); } }
610 #endif // #ifndef HEADER_INCLUDED__SAGA_API__grids_H
virtual char asChar(sLong i, bool bScaled=true) const
bool is_InGrid(int x, int y, int z, bool bCheckNoData=true) const
@ GRIDS_FILE_FORMAT_Normal
TSG_Intersection is_Intersecting(const CSG_Rect &Extent) const
virtual bool Assign(CSG_Data_Object *pObject)
#define SG_FREE_SAFE(PTR)
virtual void Set_NoData(int x, int y, int z)
virtual int asInt(int x, int y, int z, bool bScaled=true) const
double Get_ZRange(bool bCells=false) const
virtual bool is_NoData(sLong i) const
virtual void Mul_Value(sLong i, double Value)
sLong Get_Sorted(sLong Position, bool bDown=true, bool bCheckNoData=true)
double Get_Offset(void) const
virtual bool On_Reload(void)=0
virtual bool On_Delete(void)=0
virtual void Set_Value(sLong i, double Value, bool bScaled=true)
bool Update(bool bForce=false)
TSG_Intersection is_Intersecting(double xMin, double yMin, double xMax, double yMax) const
double Get_Scaling(void) const
double Get_NoData_Value(bool bUpper=false) const
const CSG_Table & Get_Attributes(void) const
double Get_YRange(bool bCells=false) const
CSG_Table_Record & Get_Attributes(int i) const
int Get_Grid_Count(void) const
bool is_NoData_Value(double Value) const
@ GRID_RESAMPLING_Undefined
virtual const CSG_Rect & Get_Extent(void)
bool is_InGrid_byPos(double x, double y, double z, bool bCheckNoData=true) const
virtual bool Save(const CSG_String &File, int Format=0)=0
virtual void Add_Value(sLong i, double Value)
virtual BYTE asByte(int x, int y, int z, bool bScaled=true) const
sLong Get_NCells(void) const
@ SG_DATAOBJECT_TYPE_Grids
TSG_Data_Type Get_Type(void) const
int Get_Z_Attribute(void) const
bool is_Scaled(void) const
virtual bool Set_Max_Samples(sLong Max_Samples)
void Set_Update_Flag(bool bOn=true)
virtual double asDouble(int x, int y, int z, bool bScaled=true) const
@ GRIDS_FILE_FORMAT_Undefined
double Get_YMax(bool bCells=false) const
const SG_Char * Get_Unit(void) const
bool Get_Sorted(sLong Position, int &x, int &y, int &z, bool bDown=true, bool bCheckNoData=true)
virtual sLong asLong(sLong i, bool bScaled=true) const
virtual short asShort(sLong i, bool bScaled=true) const
const CSG_Grid_System & Get_System(void) const
int Get_nLineBytes(void) const
double Get_YMin(bool bCells=false) const
virtual sLong asLong(int x, int y, int z, bool bScaled=true) const
virtual BYTE asByte(sLong i, bool bScaled=true) const
double Get_XRange(bool bCells=false) const
virtual void Add_Value(int x, int y, int z, double Value)
virtual const CSG_Rect & Get_Extent(void)=0
const CSG_Rect & Get_Extent(bool bCells=false) const
virtual bool is_NoData(int x, int y, int z) const
virtual short asShort(int x, int y, int z, bool bScaled=true) const
virtual bool On_Update(void)
CSG_Grid * Get_Grid_Ptr(int i) const
@ GRIDS_FILE_FORMAT_Compressed
virtual bool is_Modified(void) const
bool is_InGrid_byPos(const TSG_Point_3D &p, bool bCheckNoData=true) const
#define SAGA_API_DLL_EXPORT
@ GRID_RESAMPLING_BSpline
virtual void Set_Modified(bool bOn=true)
double Get_XMax(bool bCells=false) const
bool Set_Index(bool bOn=true)
sLong Get_Memory_Size(void) const
double Get_ZMax(bool bCells=false) const
double Get_XMin(bool bCells=false) const
bool Get_Update_Flag(void)
virtual bool Save(const char *File, int Format=0)
virtual float asFloat(int x, int y, int z, bool bScaled=true) const
virtual double asDouble(sLong i, bool bScaled=true) const
double Get_Z(int i) const
virtual float asFloat(sLong i, bool bScaled=true) const
virtual char asChar(int x, int y, int z, bool bScaled=true) const
virtual bool Save(const wchar_t *File, int Format=0)
double Get_Cellarea(void) const
double Get_Cellsize(void) const
virtual bool is_Modified(void) const
TSG_Intersection is_Intersecting(const TSG_Rect &Extent) const
SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids(void)
virtual void Set_Modified(bool bModified=true)
virtual void Set_NoData(sLong i)
virtual void Set_Value(int x, int y, int z, double Value, bool bScaled=true)
double Get_ZMin(bool bCells=false) const
virtual int asInt(sLong i, bool bScaled=true) const
virtual void Mul_Value(int x, int y, int z, double Value)
int Get_nValueBytes(void) const
CSG_Table * Get_Attributes_Ptr(void)
virtual bool Set_NoData_Value_Range(double Lower, double Upper)
virtual bool Destroy(void)
virtual bool is_Valid(void) const =0
const CSG_Grid & Get_Grid(int i) const
bool Get_Sorted(sLong Position, sLong &i, bool bDown=true, bool bCheckNoData=true)
virtual TSG_Data_Object_Type Get_ObjectType(void) const
@ GRIDS_FILE_FORMAT_GeoTIFF