 |
SAGA API
v9.2
|
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) ); }
214 bool Del_Attribute (
int iField);
221 bool Set_Z_Attribute (
int i);
224 bool Set_Z_Name_Field (
int i);
225 int Get_Z_Name_Field (
void)
const;
227 bool Set_Z (
int i,
double Value);
228 double Get_Z (
int i)
const {
return( m_Attributes[i].asDouble(m_Z_Attribute) ); }
230 bool Update_Z_Order (
void);
236 bool Set_Grid_Count (
int Count);
239 bool Add_Grid (
double Z);
240 bool Add_Grid (
double Z,
CSG_Grid *pGrid,
bool bAttach =
false);
244 bool Del_Grid (
int i,
bool bDetach =
false);
245 bool Del_Grids (
bool bDetach =
false);
249 CSG_String Get_Grid_Name (
int i,
int Style = 0)
const;
257 void Set_Scaling (
double Scale = 1.,
double Offset = 0.);
259 double Get_Offset (
void)
const {
return( m_pGrids[0]->Get_Offset () ); }
260 bool is_Scaled (
void)
const {
return( m_pGrids[0]->is_Scaled () ); }
262 double Get_Mean (
void);
263 double Get_Min (
void);
264 double Get_Max (
void);
265 double Get_Range (
void);
266 double Get_StdDev (
void);
267 double Get_Variance (
void);
268 double Get_Quantile (
double Quantile,
bool bFromHistogram =
true);
269 double Get_Percentile (
double Percentile,
bool bFromHistogram =
true);
289 bool is_Compatible (
CSG_Grid *pGrid )
const;
290 bool is_Compatible (
CSG_Grids *pGrids)
const;
292 bool is_Compatible (
int NX,
int NY,
double Cellsize,
double xMin,
double yMin)
const;
294 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)) ); }
295 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)) ); }
306 m_Attributes.Set_Modified(bModified);
323 void Assign_NoData (
void);
325 virtual bool Assign (
double Value = 0.);
334 virtual CSG_Grids & operator = (
double Value );
336 virtual CSG_Grids & operator += (
double Value );
339 virtual CSG_Grids & operator -= (
double Value );
340 virtual CSG_Grids & Subtract (
double Value );
342 virtual CSG_Grids & operator *= (
double Value );
343 virtual CSG_Grids & Multiply (
double Value );
345 virtual CSG_Grids & operator /= (
double Value );
346 virtual CSG_Grids & Divide (
double Value );
348 virtual double operator () (
int x,
int y,
int z)
const {
return( asDouble(x, y, z) ); }
350 virtual CSG_Grid & operator [] (
int i) {
return( *m_pGrids[i] ); }
373 virtual BYTE
asByte (
int x,
int y,
int z,
bool bScaled =
true)
const {
return(
SG_ROUND_TO_BYTE (asDouble(x, y, z, bScaled)) ); }
375 virtual char asChar (
int x,
int y,
int z,
bool bScaled =
true)
const {
return(
SG_ROUND_TO_CHAR (asDouble(x, y, z, bScaled)) ); }
377 virtual short asShort (
int x,
int y,
int z,
bool bScaled =
true)
const {
return(
SG_ROUND_TO_SHORT(asDouble(x, y, z, bScaled)) ); }
379 virtual int asInt (
int x,
int y,
int z,
bool bScaled =
true)
const {
return(
SG_ROUND_TO_INT (asDouble(x, y, z, bScaled)) ); }
383 virtual float asFloat (
int x,
int y,
int z,
bool bScaled =
true)
const {
return( (
float) (asDouble(x, y, z, bScaled)) ); }
384 virtual float asFloat (
sLong i,
bool bScaled =
true)
const {
return( (
float) (asDouble( i, bScaled)) ); }
389 int z = (int)(i / m_pGrids[0]->Get_NCells());
391 return( m_pGrids[z]->asDouble((
sLong)(i % m_pGrids[0]->Get_NCells()), bScaled) );
394 virtual double asDouble(
int x,
int y,
int z,
bool bScaled =
true)
const
396 return( m_pGrids[z]->asDouble(x, y, bScaled) );
403 virtual void Add_Value(
int x,
int y,
int z,
double Value) { Set_Value(x, y, z, asDouble(x, y, z) + Value ); }
404 virtual void Add_Value(
sLong i,
double Value) { Set_Value( i, asDouble( i) + Value ); }
406 virtual void Mul_Value(
int x,
int y,
int z,
double Value) { Set_Value(x, y, z, asDouble(x, y, z) * Value ); }
407 virtual void Mul_Value(
sLong i,
double Value) { Set_Value( i, asDouble( i) * Value ); }
412 int z = (int)(i / m_pGrids[0]->Get_NCells());
414 m_pGrids[z]->Set_Value((
sLong)(i % m_pGrids[0]->Get_NCells()), Value, bScaled);
417 virtual void Set_Value(
int x,
int y,
int z,
double Value,
bool bScaled =
true)
419 m_pGrids[z]->Set_Value(x, y, Value, bScaled);
435 return( _Get_Index() );
440 if( Position >= 0 && Position < Get_NCells() && _Get_Index() )
442 Position = m_Index[bDown ? Get_NCells() - Position - 1 : Position];
444 if( !bCheckNoData || !is_NoData(Position) )
455 return( (i = Get_Sorted(Position, bDown, bCheckNoData)) >= 0 );
458 bool Get_Sorted (
sLong Position,
int &x,
int &y,
int &z,
bool bDown =
true,
bool bCheckNoData =
true)
460 if( (Position = Get_Sorted(Position, bDown, bCheckNoData)) >= 0 )
462 z = (int)(Position / m_pGrids[0]->Get_NCells());
464 Position = Position % m_pGrids[0]->Get_NCells();
466 x = (int)(Position % Get_NX());
467 y = (int)(Position / Get_NX());
487 int m_Z_Attribute, m_Z_Name;
503 void _On_Construction (
void);
505 void _Synchronize (
CSG_Grid *pGrid);
508 bool _Get_Z (
double Value,
int &iz,
double &dz)
const;
511 bool _Set_Index (
void);
512 bool _Get_Index (
void)
519 return( m_Index || _Set_Index() );
523 bool _Load_External (
const CSG_String &FileName);
524 bool _Load_PGSQL (
const CSG_String &FileName);
526 bool _Load_Normal (
const CSG_String &FileName);
527 bool _Save_Normal (
const CSG_String &FileName);
529 bool _Load_Compressed (
const CSG_String &FileName);
530 bool _Save_Compressed (
const CSG_String &FileName);
532 bool _Load_Header (
CSG_File &Stream);
533 bool _Save_Header (
CSG_File &Stream);
535 bool _Load_Attributes (
CSG_File &Stream);
536 bool _Save_Attributes (
CSG_File &Stream);
543 bool _Assign_MeanValue (
CSG_Grids *pSource,
bool bVolumeProportional);
544 bool _Assign_ExtremeValue (
CSG_Grids *pSource,
bool bMaximum);
545 bool _Assign_Majority (
CSG_Grids *pSource);
561 #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 ); } }
562 #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); } }
598 #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