SAGA API Version 9.13
Loading...
Searching...
No Matches
grids.h
Go to the documentation of this file.
1
3// //
4// SAGA //
5// //
6// System for Automated Geoscientific Analyses //
7// //
8// Application Programming Interface //
9// //
10// Library: SAGA_API //
11// //
12//-------------------------------------------------------//
13// //
14// grids.h //
15// //
16// Copyright (C) 2017 by //
17// Olaf Conrad //
18// //
19//-------------------------------------------------------//
20// //
21// This file is part of 'SAGA - System for Automated //
22// Geoscientific Analyses'. //
23// //
24// This library is free software; you can redistribute //
25// it and/or modify it under the terms of the GNU Lesser //
26// General Public License as published by the Free //
27// Software Foundation, either version 2.1 of the //
28// License, or (at your option) any later version. //
29// //
30// This library is distributed in the hope that it will //
31// be useful, but WITHOUT ANY WARRANTY; without even the //
32// implied warranty of MERCHANTABILITY or FITNESS FOR A //
33// PARTICULAR PURPOSE. See the GNU Lesser General Public //
34// License for more details. //
35// //
36// You should have received a copy of the GNU Lesser //
37// General Public License along with this program; if //
38// not, see <http://www.gnu.org/licenses/>. //
39// //
40//-------------------------------------------------------//
41// //
42// e-mail: oconrad@saga-gis.org //
43// //
44// contact: Olaf Conrad //
45// Institute of Geography //
46// University of Hamburg //
47// Germany //
48// //
50
51//---------------------------------------------------------
52#ifndef HEADER_INCLUDED__SAGA_API__grids_H
53#define HEADER_INCLUDED__SAGA_API__grids_H
54
55
57// //
58// //
59// //
61
62//---------------------------------------------------------
71
72
74// //
75// //
76// //
78
79//---------------------------------------------------------
80#include "grid.h"
81
82
84// //
85// //
86// //
88
89//---------------------------------------------------------
98
99//---------------------------------------------------------
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
104
105
107// //
108// CSG_Grids //
109// //
111
112//---------------------------------------------------------
117//---------------------------------------------------------
119{
120//---------------------------------------------------------
121public:
122
123 //-----------------------------------------------------
124 CSG_Grids(void);
125 virtual ~CSG_Grids(void);
126
127 CSG_Grids (const CSG_Grids &Grids);
128 virtual bool Create (const CSG_Grids &Grids);
129
130 CSG_Grids (const CSG_Grids *pGrids, bool bCopyData = false);
131 virtual bool Create (const CSG_Grids *pGrids, bool bCopyData = false);
132
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);
137 CSG_Grids (const CSG_String &FileName, bool bLoadData = true);
138 virtual bool Create (const CSG_String &FileName, bool bLoadData = true);
139
140 CSG_Grids (const CSG_Grid_System &System, int NZ = 0, double zMin = 0., TSG_Data_Type Type = SG_DATATYPE_Undefined);
141 virtual bool Create (const CSG_Grid_System &System, int NZ = 0, double zMin = 0., TSG_Data_Type Type = SG_DATATYPE_Undefined);
142
143 CSG_Grids (const CSG_Grid_System &System, const CSG_Table &Attributes, int zAttribute = 0, TSG_Data_Type Type = SG_DATATYPE_Undefined, bool bCreateGrids = false);
144 virtual bool Create (const CSG_Grid_System &System, const CSG_Table &Attributes, int zAttribute = 0, TSG_Data_Type Type = SG_DATATYPE_Undefined, bool bCreateGrids = false);
145
146 CSG_Grids (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);
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);
148
149 CSG_Grids (const CSG_Table &Attributes, int zAttribute = 0);
150 virtual bool Create (const CSG_Table &Attributes, int zAttribute = 0);
151
152 virtual bool Destroy (void);
153
154
155 //-----------------------------------------------------
156 virtual bool Load (const CSG_String &File, bool bLoadData = true);
157
158 virtual bool Save (const CSG_String &File, int Format = 0);
159 virtual bool Save (const char *File, int Format = 0) { return( Save(CSG_String(File), Format) ); }
160 virtual bool Save (const wchar_t *File, int Format = 0) { return( Save(CSG_String(File), Format) ); }
161
162
163 //-----------------------------------------------------
167
168
169 //-----------------------------------------------------
170 // Data-Info...
171
172 TSG_Data_Type Get_Type (void) const { return( m_pGrids[0]->Get_Type() ); }
173
174 int Get_nValueBytes (void) const { return( m_pGrids[0]->Get_nValueBytes() ); }
175 int Get_nLineBytes (void) const { return( m_pGrids[0]->Get_nLineBytes () ); }
176
177 void Set_Unit (const CSG_String &Unit);
178 const SG_Char * Get_Unit (void) const { return( m_pGrids[0]->Get_Unit() ); }
179
180
181 //-----------------------------------------------------
182 // Georeference...
183
184 const CSG_Grid_System & Get_System (void) const { return( m_pGrids[0]->Get_System() ); }
185
186 virtual const CSG_Rect & Get_Extent (void) { return( Get_System().Get_Extent() ); }
187
188 int Get_NX (void) const { return( m_pGrids[0]->Get_System().Get_NX() ); }
189 int Get_NY (void) const { return( m_pGrids[0]->Get_System().Get_NY() ); }
190 int Get_NZ (void) const { return( (int)m_Attributes.Get_Count() ); }
191 sLong Get_NCells (void) const { return( Get_System().Get_NCells() * Get_NZ() ); }
192 sLong Get_Data_Count (void);
193 sLong Get_NoData_Count (void);
194
195 double Get_Cellsize (void) const { return( m_pGrids[0]->Get_System().Get_Cellsize() ); }
196 double Get_Cellarea (void) const { return( m_pGrids[0]->Get_System().Get_Cellarea() ); }
197
198 const CSG_Rect & Get_Extent (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_Extent(bCells) ); }
199
200 double Get_XMin (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_XMin (bCells) ); }
201 double Get_XMax (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_XMax (bCells) ); }
202 double Get_XRange (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_XRange(bCells) ); }
203
204 double Get_YMin (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_YMin (bCells) ); }
205 double Get_YMax (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_YMax (bCells) ); }
206 double Get_YRange (bool bCells = false) const { return( m_pGrids[0]->Get_System().Get_YRange(bCells) ); }
207
208 double Get_ZMin (bool bCells = false) const { return( m_Attributes.Get_Minimum(m_Z_Attribute) ); }
209 double Get_ZMax (bool bCells = false) const { return( m_Attributes.Get_Maximum(m_Z_Attribute) ); }
210 double Get_ZRange (bool bCells = false) const { return( m_Attributes.Get_Range (m_Z_Attribute) ); }
211
212
213 //-----------------------------------------------------
214 // Attributes...
215
216 bool Set_Z_Attribute (int Field, bool bSetNameField = false);
217 int Get_Z_Attribute (void) const { return( m_Z_Attribute ); }
218
219 bool Set_Z_Name_Field (int Field);
220 int Get_Z_Name_Field (void) const;
221
222 TSG_Data_Type Get_Z_Type (void) const { return( m_Attributes.Get_Field_Type(m_Z_Attribute) ); }
223
224 bool Add_Attribute (const char *Name, TSG_Data_Type Type, int Insert = -1);
225 bool Add_Attribute (const wchar_t *Name, TSG_Data_Type Type, int Insert = -1);
226 bool Add_Attribute (const CSG_String &Name, TSG_Data_Type Type, int Insert = -1);
227 bool Del_Attribute (int Field);
228
229 const CSG_Table & Get_Attributes (void) const { return( m_Attributes ); }
230 CSG_Table * Get_Attributes_Ptr (void) { return( &m_Attributes ); }
231
232 CSG_Table_Record & Get_Attributes (int i) const { return( m_Attributes[i] ); }
233
234 bool Set_Attribute (int i, int Field, const CSG_String &Value);
235 bool Set_Attribute (int i, const CSG_String &Field, const CSG_String &Value);
236 bool Set_Attribute (int i, const wchar_t *Field, const wchar_t *Value);
237 bool Set_Attribute (int i, const char *Field, const char *Value);
238
239 bool Set_Attribute (int i, int Field, double Value);
240 bool Set_Attribute (int i, const CSG_String &Field, double Value);
241 bool Set_Attribute (int i, const wchar_t *Field, double Value);
242 bool Set_Attribute (int i, const char *Field, double Value);
243
244 bool Set_Z (int i, double Value);
245 double Get_Z (int i) const { return( m_Attributes[i].asDouble(m_Z_Attribute) ); }
246
247 bool Update_Z_Order (void);
248
249
250 //-----------------------------------------------------
251 // Grids...
252
253 bool Set_Grid_Count (int Count);
254 int Get_Grid_Count (void) const { return( (int)m_Attributes.Get_Count() ); }
255
256 bool Add_Grid (double Z);
257 bool Add_Grid (double Z, CSG_Grid *pGrid, bool bAttach = false);
258 bool Add_Grid (CSG_Table_Record &Attributes);
259 bool Add_Grid (CSG_Table_Record &Attributes, CSG_Grid *pGrid, bool bAttach = false);
260
261 bool Del_Grid (int i, bool bDetach = false);
262 bool Del_Grids ( bool bDetach = false);
263
264 const CSG_Grid & Get_Grid (int i) const { return( *m_pGrids[i] ); }
265 CSG_Grid * Get_Grid_Ptr (int i) const { return( i >= 0 && i < Get_NZ() ? m_pGrids[i] : NULL ); }
266 CSG_String Get_Grid_Name (int i, int Style = 0) const;
267
268 sLong Get_Memory_Size (void) const { return( m_pGrids[0]->Get_Memory_Size() * Get_NZ() ); }
269
270
271 //-----------------------------------------------------
272 // Values...
273
274 void Set_Scaling (double Scale = 1., double Offset = 0.);
275 double Get_Scaling (void) const { return( m_pGrids[0]->Get_Scaling() ); }
276 double Get_Offset (void) const { return( m_pGrids[0]->Get_Offset () ); }
277 bool is_Scaled (void) const { return( m_pGrids[0]->is_Scaled () ); }
278
279 double Get_Mean (void);
280 double Get_Min (void);
281 double Get_Max (void);
282 double Get_Range (void);
283 double Get_StdDev (void);
284 double Get_Variance (void);
285 double Get_Quantile (double Quantile, bool bFromHistogram = true);
286 double Get_Percentile (double Percentile, bool bFromHistogram = true);
287
288 const CSG_Simple_Statistics & Get_Statistics (void);
289 bool Get_Statistics (const CSG_Rect &rWorld, CSG_Simple_Statistics &Statistics, bool bHoldValues = false) const;
290
291 const CSG_Histogram & Get_Histogram (size_t nClasses = 0);
292 bool Get_Histogram (const CSG_Rect &rWorld, CSG_Histogram &Histogram, size_t nClasses = 0) const;
293
294 virtual bool Set_Max_Samples (sLong Max_Samples);
295
296
297 //-----------------------------------------------------
298 // Checks...
299
300 virtual bool is_Valid (void) const;
301
302 TSG_Intersection is_Intersecting (const CSG_Rect &Extent) const { return( m_pGrids[0]->is_Intersecting(Extent) ); }
303 TSG_Intersection is_Intersecting (const TSG_Rect &Extent) const { return( m_pGrids[0]->is_Intersecting(Extent) ); }
304 TSG_Intersection is_Intersecting (double xMin, double yMin, double xMax, double yMax) const { return( m_pGrids[0]->is_Intersecting(xMin, yMin, xMax, yMax) ); }
305
306 bool is_Compatible (CSG_Grid *pGrid ) const;
307 bool is_Compatible (CSG_Grids *pGrids) const;
308 bool is_Compatible (const CSG_Grid_System &System) const;
309 bool is_Compatible (int NX, int NY, double Cellsize, double xMin, double yMin) const;
310
311 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)) ); }
312 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)) ); }
313 bool is_InGrid_byPos (const TSG_Point_3D &p, bool bCheckNoData = true) const { return( is_InGrid_byPos(p.x, p.y, p.z, bCheckNoData) ); }
314
315
316 //-----------------------------------------------------
317 // Set update flag when modified...
318
319 virtual void Set_Modified (bool bModified = true)
320 {
322
323 m_Attributes.Set_Modified(bModified);
324
325 if( bModified )
326 {
328 }
329 }
330
331 virtual bool is_Modified (void) const
332 {
333 return( CSG_Data_Object::is_Modified() || m_Attributes.is_Modified() );
334 }
335
336
337 //-----------------------------------------------------
338 // Operations...
339
340 void Assign_NoData (void);
341
342 virtual bool Assign (double Value = 0.);
343 virtual bool Assign (CSG_Data_Object *pObject , bool bProgress = false);
344 virtual bool Assign (CSG_Grids *pGrids, CSG_Grid_Resampling Interpolation, bool bProgress = false);
345
346
347 //-----------------------------------------------------
348 // Operators...
349
350 virtual CSG_Grids & operator = (const CSG_Grids &Grids);
351 virtual CSG_Grids & operator = (double Value );
352
353 virtual CSG_Grids & operator += (double Value );
354 virtual CSG_Grids & Add (double Value );
355
356 virtual CSG_Grids & operator -= (double Value );
357 virtual CSG_Grids & Subtract (double Value );
358
359 virtual CSG_Grids & operator *= (double Value );
360 virtual CSG_Grids & Multiply (double Value );
361
362 virtual CSG_Grids & operator /= (double Value );
363 virtual CSG_Grids & Divide (double Value );
364
365 virtual double operator () (int x, int y, int z) const { return( asDouble(x, y, z) ); }
366
367 virtual CSG_Grid & operator [] (int i) { return( *m_pGrids[i] ); }
368
369
370 //-----------------------------------------------------
371 // No Data Value...
372
373 virtual bool Set_NoData_Value_Range (double loValue, double hiValue);
374
375 virtual bool is_NoData (int x, int y, int z) const { return( is_NoData_Value(asDouble(x, y, z, false)) ); }
376 virtual bool is_NoData (sLong i) const { return( is_NoData_Value(asDouble( i, false)) ); }
377
378 virtual void Set_NoData (int x, int y, int z) { Set_Value(x, y, z, Get_NoData_Value(), false); }
379 virtual void Set_NoData (sLong i) { Set_Value( i, Get_NoData_Value(), false); }
380
381
382 //-----------------------------------------------------
383 // Get Value...
384
385 double Get_Value (double x, double y, double z, CSG_Grid_Resampling Resampling = CSG_Grid_Resampling::Bicubic_2, CSG_Grid_Resampling ZResampling = CSG_Grid_Resampling::Undefined) const;
387 bool Get_Value (double x, double y, double z, double &Value, CSG_Grid_Resampling Resampling = CSG_Grid_Resampling::Bicubic_2, CSG_Grid_Resampling ZResampling = CSG_Grid_Resampling::Undefined) const;
388 bool Get_Value (const TSG_Point_3D &p, double &Value, CSG_Grid_Resampling Resampling = CSG_Grid_Resampling::Bicubic_2, CSG_Grid_Resampling ZResampling = CSG_Grid_Resampling::Undefined) const;
389
390 virtual BYTE asByte (int x, int y, int z, bool bScaled = true) const { return( SG_ROUND_TO_BYTE (asDouble(x, y, z, bScaled)) ); }
391 virtual BYTE asByte (sLong i, bool bScaled = true) const { return( SG_ROUND_TO_BYTE (asDouble( i, bScaled)) ); }
392 virtual char asChar (int x, int y, int z, bool bScaled = true) const { return( SG_ROUND_TO_CHAR (asDouble(x, y, z, bScaled)) ); }
393 virtual char asChar (sLong i, bool bScaled = true) const { return( SG_ROUND_TO_CHAR (asDouble( i, bScaled)) ); }
394 virtual short asShort (int x, int y, int z, bool bScaled = true) const { return( SG_ROUND_TO_SHORT(asDouble(x, y, z, bScaled)) ); }
395 virtual short asShort (sLong i, bool bScaled = true) const { return( SG_ROUND_TO_SHORT(asDouble( i, bScaled)) ); }
396 virtual int asInt (int x, int y, int z, bool bScaled = true) const { return( SG_ROUND_TO_INT (asDouble(x, y, z, bScaled)) ); }
397 virtual int asInt (sLong i, bool bScaled = true) const { return( SG_ROUND_TO_INT (asDouble( i, bScaled)) ); }
398 virtual sLong asLong (int x, int y, int z, bool bScaled = true) const { return( SG_ROUND_TO_SLONG(asDouble(x, y, z, bScaled)) ); }
399 virtual sLong asLong (sLong i, bool bScaled = true) const { return( SG_ROUND_TO_SLONG(asDouble( i, bScaled)) ); }
400 virtual float asFloat (int x, int y, int z, bool bScaled = true) const { return( (float) (asDouble(x, y, z, bScaled)) ); }
401 virtual float asFloat (sLong i, bool bScaled = true) const { return( (float) (asDouble( i, bScaled)) ); }
402
403 //-----------------------------------------------------
404 virtual double asDouble(sLong i, bool bScaled = true) const
405 {
406 int z = (int)(i / m_pGrids[0]->Get_NCells());
407
408 return( m_pGrids[z]->asDouble((sLong)(i % m_pGrids[0]->Get_NCells()), bScaled) );
409 }
410
411 virtual double asDouble(int x, int y, int z, bool bScaled = true) const
412 {
413 return( m_pGrids[z]->asDouble(x, y, bScaled) );
414 }
415
416
417 //-----------------------------------------------------
418 // Set Value...
419
420 virtual void Add_Value(int x, int y, int z, double Value) { Set_Value(x, y, z, asDouble(x, y, z) + Value ); }
421 virtual void Add_Value(sLong i, double Value) { Set_Value( i, asDouble( i) + Value ); }
422
423 virtual void Mul_Value(int x, int y, int z, double Value) { Set_Value(x, y, z, asDouble(x, y, z) * Value ); }
424 virtual void Mul_Value(sLong i, double Value) { Set_Value( i, asDouble( i) * Value ); }
425
426 //-----------------------------------------------------
427 virtual void Set_Value(sLong i, double Value, bool bScaled = true)
428 {
429 int z = (int)(i / m_pGrids[0]->Get_NCells());
430
431 m_pGrids[z]->Set_Value((sLong)(i % m_pGrids[0]->Get_NCells()), Value, bScaled);
432 }
433
434 virtual void Set_Value(int x, int y, int z, double Value, bool bScaled = true)
435 {
436 m_pGrids[z]->Set_Value(x, y, Value, bScaled);
437 }
438
439
440 //-----------------------------------------------------
441 // Index...
442
443 bool Set_Index (bool bOn = true)
444 {
445 if( !bOn )
446 {
447 SG_FREE_SAFE(m_Index);
448
449 return( true );
450 }
451
452 return( _Get_Index() );
453 }
454
455 sLong Get_Sorted (sLong Position, bool bDown = true, bool bCheckNoData = true)
456 {
457 if( Position >= 0 && Position < Get_NCells() && _Get_Index() )
458 {
459 Position = m_Index[bDown ? Get_NCells() - Position - 1 : Position];
460
461 if( !bCheckNoData || !is_NoData(Position) )
462 {
463 return( Position );
464 }
465 }
466
467 return( -1 );
468 }
469
470 bool Get_Sorted (sLong Position, sLong &i, bool bDown = true, bool bCheckNoData = true)
471 {
472 return( (i = Get_Sorted(Position, bDown, bCheckNoData)) >= 0 );
473 }
474
475 bool Get_Sorted (sLong Position, int &x, int &y, int &z, bool bDown = true, bool bCheckNoData = true)
476 {
477 if( (Position = Get_Sorted(Position, bDown, bCheckNoData)) >= 0 )
478 {
479 z = (int)(Position / m_pGrids[0]->Get_NCells());
480
481 Position = Position % m_pGrids[0]->Get_NCells();
482
483 x = (int)(Position % Get_NX());
484 y = (int)(Position / Get_NX());
485
486 return( true );
487 }
488
489 return( false );
490 }
491
492
493//---------------------------------------------------------
494protected:
495
496 virtual bool On_Update (void);
497 virtual bool On_Reload (void);
498 virtual bool On_Delete (void);
499
500
501//---------------------------------------------------------
502private:
503
504 int m_Z_Attribute, m_Z_Name;
505
506 sLong *m_Index;
507
508 CSG_Table m_Attributes;
509
510 CSG_Array_Pointer m_Grids;
511
512 CSG_Grid **m_pGrids;
513
514 CSG_Simple_Statistics m_Statistics;
515
516 CSG_Histogram m_Histogram;
517
518
519 //-----------------------------------------------------
520 void _On_Construction (void);
521
522 void _Synchronize (CSG_Grid *pGrid);
523
524 //-----------------------------------------------------
525 bool _Get_Z (double Value, int &iz, double &dz) const;
526
527 //-----------------------------------------------------
528 bool _Set_Index (void);
529 bool _Get_Index (void)
530 {
531 if( Get_Update_Flag() )
532 {
533 Update();
534 }
535
536 return( m_Index || _Set_Index() );
537 }
538
539 //-----------------------------------------------------
540 bool _Load_External (const CSG_String &FileName);
541 bool _Load_PGSQL (const CSG_String &FileName);
542
543 bool _Load_Normal (const CSG_String &FileName);
544 bool _Save_Normal (const CSG_String &FileName);
545
546 bool _Load_Compressed (const CSG_String &FileName);
547 bool _Save_Compressed (const CSG_String &FileName);
548
549 bool _Load_Header (CSG_File &Stream);
550 bool _Save_Header (CSG_File &Stream);
551
552 bool _Load_Attributes (CSG_File &Stream);
553 bool _Save_Attributes (CSG_File &Stream);
554
555 bool _Load_Data (CSG_File &Stream, CSG_Grid *pGrid);
556 bool _Save_Data (CSG_File &Stream, CSG_Grid *pGrid);
557
558 //-----------------------------------------------------
559 bool _Assign_Interpolated (CSG_Grids *pSource, CSG_Grid_Resampling Interpolation);
560 bool _Assign_MeanValue (CSG_Grids *pSource, bool bVolumeProportional);
561 bool _Assign_ExtremeValue (CSG_Grids *pSource, bool bMaximum);
562 bool _Assign_Majority (CSG_Grids *pSource);
563
564 //-----------------------------------------------------
565 CSG_Grids & _Operation_Arithmetic (const CSG_Grids &Grids, TSG_Grid_Operation Operation);
566 CSG_Grids & _Operation_Arithmetic (double Value , TSG_Grid_Operation Operation);
567
568};
569
570
572// //
573// Functions //
574// //
576
577//---------------------------------------------------------
578#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 ); } }
579#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); } }
580
581//---------------------------------------------------------
584
587
589SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (const CSG_Grids *pGrids, bool bCopyData = false);
590
592SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (const char *FileName, bool bLoadData = true);
594SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (const wchar_t *FileName, bool bLoadData = true);
596SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (const CSG_String &FileName, bool bLoadData = true);
597
599SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (const CSG_Grid_System &System, int NZ = 0, double zMin = 0., TSG_Data_Type Type = SG_DATATYPE_Undefined);
600
602SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (const CSG_Grid_System &System, const CSG_Table &Attributes, int zAttribute = 0, TSG_Data_Type Type = SG_DATATYPE_Undefined, bool bCreateGrids = false);
603
605SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (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);
606
608SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids (const CSG_Table &Attributes, int zAttribute = 0);
609
610
612// //
613// //
614// //
616
617//---------------------------------------------------------
618#endif // #ifndef HEADER_INCLUDED__SAGA_API__grids_H
signed long long sLong
Definition api_core.h:158
#define SAGA_API_DLL_EXPORT
Definition api_core.h:94
#define SG_FREE_SAFE(PTR)
Definition api_core.h:205
TSG_Data_Type
Definition api_core.h:1043
@ SG_DATATYPE_Undefined
Definition api_core.h:1059
#define SG_Char
Definition api_core.h:536
virtual bool is_Modified(void) const
Definition dataobject.h:231
bool is_NoData_Value(double Value) const
Definition dataobject.h:258
virtual bool is_Valid(void) const =0
void Set_Update_Flag(bool bOn=true)
Definition dataobject.h:288
virtual bool Set_Max_Samples(sLong Max_Samples)
double Get_NoData_Value(bool bUpper=false) const
Definition dataobject.h:256
bool Get_Update_Flag(void)
Definition dataobject.h:289
virtual bool Set_NoData_Value_Range(double Lower, double Upper)
bool Update(bool bForce=false)
virtual bool Destroy(void)
virtual bool Save(const CSG_String &File, int Format=0)=0
virtual void Set_Modified(bool bOn=true)
Definition dataobject.h:230
virtual bool Assign(CSG_Data_Object *pObject, bool bProgress=false)
virtual bool On_Update(void)
Definition dataobject.h:290
virtual bool On_Delete(void)=0
virtual bool On_Reload(void)=0
virtual const CSG_Rect & Get_Extent(void)=0
TSG_Data_Type Get_Type(void) const
Definition grids.h:172
virtual void Set_NoData(int x, int y, int z)
Definition grids.h:378
virtual int asInt(sLong i, bool bScaled=true) const
Definition grids.h:397
virtual float asFloat(int x, int y, int z, bool bScaled=true) const
Definition grids.h:400
virtual void Mul_Value(sLong i, double Value)
Definition grids.h:424
double Get_ZMin(bool bCells=false) const
Definition grids.h:208
const CSG_Grid_System & Get_System(void) const
Definition grids.h:184
CSG_Table * Get_Attributes_Ptr(void)
Definition grids.h:230
int Get_NZ(void) const
Definition grids.h:190
const CSG_Grid & Get_Grid(int i) const
Definition grids.h:264
virtual BYTE asByte(sLong i, bool bScaled=true) const
Definition grids.h:391
virtual const CSG_Rect & Get_Extent(void)
Definition grids.h:186
virtual bool is_NoData(int x, int y, int z) const
Definition grids.h:375
virtual void Set_Modified(bool bModified=true)
Definition grids.h:319
virtual bool is_Modified(void) const
Definition grids.h:331
virtual void Set_NoData(sLong i)
Definition grids.h:379
virtual void Mul_Value(int x, int y, int z, double Value)
Definition grids.h:423
bool Get_Sorted(sLong Position, sLong &i, bool bDown=true, bool bCheckNoData=true)
Definition grids.h:470
sLong Get_NCells(void) const
Definition grids.h:191
double Get_Cellsize(void) const
Definition grids.h:195
virtual short asShort(sLong i, bool bScaled=true) const
Definition grids.h:395
double Get_XRange(bool bCells=false) const
Definition grids.h:202
virtual void Add_Value(sLong i, double Value)
Definition grids.h:421
double Get_YMax(bool bCells=false) const
Definition grids.h:205
virtual bool Create(const CSG_Grids &Grids)
Definition grids.cpp:319
virtual void Set_Value(sLong i, double Value, bool bScaled=true)
Definition grids.h:427
sLong Get_Sorted(sLong Position, bool bDown=true, bool bCheckNoData=true)
Definition grids.h:455
virtual bool is_NoData(sLong i) const
Definition grids.h:376
TSG_Intersection is_Intersecting(const CSG_Rect &Extent) const
Definition grids.h:302
TSG_Data_Type Get_Z_Type(void) const
Definition grids.h:222
sLong Get_Memory_Size(void) const
Definition grids.h:268
const SG_Char * Get_Unit(void) const
Definition grids.h:178
double Get_Cellarea(void) const
Definition grids.h:196
bool is_InGrid_byPos(double x, double y, double z, bool bCheckNoData=true) const
Definition grids.h:312
double Get_XMin(bool bCells=false) const
Definition grids.h:200
double Get_ZMax(bool bCells=false) const
Definition grids.h:209
double Get_Offset(void) const
Definition grids.h:276
double Get_Scaling(void) const
Definition grids.h:275
double Get_Z(int i) const
Definition grids.h:245
virtual bool Save(const wchar_t *File, int Format=0)
Definition grids.h:160
bool is_InGrid_byPos(const TSG_Point_3D &p, bool bCheckNoData=true) const
Definition grids.h:313
int Get_Grid_Count(void) const
Definition grids.h:254
int Get_Z_Attribute(void) const
Definition grids.h:217
bool Get_Sorted(sLong Position, int &x, int &y, int &z, bool bDown=true, bool bCheckNoData=true)
Definition grids.h:475
virtual short asShort(int x, int y, int z, bool bScaled=true) const
Definition grids.h:394
CSG_Grid * Get_Grid_Ptr(int i) const
Definition grids.h:265
virtual sLong asLong(sLong i, bool bScaled=true) const
Definition grids.h:399
virtual char asChar(sLong i, bool bScaled=true) const
Definition grids.h:393
double Get_YMin(bool bCells=false) const
Definition grids.h:204
virtual int asInt(int x, int y, int z, bool bScaled=true) const
Definition grids.h:396
bool Set_Index(bool bOn=true)
Definition grids.h:443
double Get_YRange(bool bCells=false) const
Definition grids.h:206
virtual void Add_Value(int x, int y, int z, double Value)
Definition grids.h:420
virtual bool Load(const CSG_String &File, bool bLoadData=true)
Definition grids.cpp:1765
int Get_NX(void) const
Definition grids.h:188
int Get_NY(void) const
Definition grids.h:189
virtual char asChar(int x, int y, int z, bool bScaled=true) const
Definition grids.h:392
virtual sLong asLong(int x, int y, int z, bool bScaled=true) const
Definition grids.h:398
const CSG_Rect & Get_Extent(bool bCells=false) const
Definition grids.h:198
const CSG_Table & Get_Attributes(void) const
Definition grids.h:229
double Get_XMax(bool bCells=false) const
Definition grids.h:201
TSG_Intersection is_Intersecting(const TSG_Rect &Extent) const
Definition grids.h:303
bool is_InGrid(int x, int y, int z, bool bCheckNoData=true) const
Definition grids.h:311
virtual TSG_Data_Object_Type Get_ObjectType(void) const
Definition grids.h:166
virtual double asDouble(sLong i, bool bScaled=true) const
Definition grids.h:404
virtual bool Save(const char *File, int Format=0)
Definition grids.h:159
virtual float asFloat(sLong i, bool bScaled=true) const
Definition grids.h:401
CSG_Grids(void)
Definition grids.cpp:168
virtual BYTE asByte(int x, int y, int z, bool bScaled=true) const
Definition grids.h:390
CSG_Table_Record & Get_Attributes(int i) const
Definition grids.h:232
double Get_ZRange(bool bCells=false) const
Definition grids.h:210
virtual double asDouble(int x, int y, int z, bool bScaled=true) const
Definition grids.h:411
int Get_nValueBytes(void) const
Definition grids.h:174
bool is_Scaled(void) const
Definition grids.h:277
TSG_Intersection is_Intersecting(double xMin, double yMin, double xMax, double yMax) const
Definition grids.h:304
virtual void Set_Value(int x, int y, int z, double Value, bool bScaled=true)
Definition grids.h:434
int Get_nLineBytes(void) const
Definition grids.h:175
TSG_Data_Object_Type
Definition dataobject.h:117
@ SG_DATAOBJECT_TYPE_Grids
Definition dataobject.h:119
struct SSG_Point_3D TSG_Point_3D
TSG_Intersection
Definition geo_tools.h:101
struct SSG_Rect TSG_Rect
TSG_Grid_Operation
Definition grid.h:194
CSG_Grid_Resampling
Definition grid.h:156
TSG_Grids_File_Format
Definition grids.h:91
@ GRIDS_FILE_FORMAT_GeoTIFF
Definition grids.h:95
@ GRIDS_FILE_FORMAT_Normal
Definition grids.h:93
@ GRIDS_FILE_FORMAT_Compressed
Definition grids.h:94
@ GRIDS_FILE_FORMAT_Undefined
Definition grids.h:92
SAGA_API_DLL_EXPORT CSG_Grids * SG_Create_Grids(void)
Definition grids.cpp:65
#define SG_ROUND_TO_INT(x)
Definition mat_tools.h:155
#define SG_ROUND_TO_CHAR(x)
Definition mat_tools.h:151
#define SG_ROUND_TO_BYTE(x)
Definition mat_tools.h:150
#define SG_ROUND_TO_SLONG(x)
Definition mat_tools.h:158
#define SG_ROUND_TO_SHORT(x)
Definition mat_tools.h:153