SAGA API Version 9.13
Loading...
Searching...
No Matches
grid_io.cpp
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// grid_io.cpp //
15// //
16// Copyright (C) 2005 by Olaf Conrad //
17// //
18//-------------------------------------------------------//
19// //
20// This file is part of 'SAGA - System for Automated //
21// Geoscientific Analyses'. //
22// //
23// This library is free software; you can redistribute //
24// it and/or modify it under the terms of the GNU Lesser //
25// General Public License as published by the Free //
26// Software Foundation, either version 2.1 of the //
27// License, or (at your option) any later version. //
28// //
29// This library is distributed in the hope that it will //
30// be useful, but WITHOUT ANY WARRANTY; without even the //
31// implied warranty of MERCHANTABILITY or FITNESS FOR A //
32// PARTICULAR PURPOSE. See the GNU Lesser General Public //
33// License for more details. //
34// //
35// You should have received a copy of the GNU Lesser //
36// General Public License along with this program; if //
37// not, see <http://www.gnu.org/licenses/>. //
38// //
39//-------------------------------------------------------//
40// //
41// contact: Olaf Conrad //
42// Institute of Geography //
43// University of Hamburg //
44// Germany //
45// //
46// e-mail: oconrad@saga-gis.org //
47// //
49
50//---------------------------------------------------------
51#include <stdint.h>
52#include <string.h>
53
54#ifdef _SAGA_LINUX
55#include "config.h"
56#include <arpa/inet.h>
57#include <netinet/in.h>
58#else
59#include <WinSock2.h>
60#endif
61
62#include "grid.h"
63#include "data_manager.h"
64#include "tool_library.h"
65
66
68// //
69// //
70// //
72
73//---------------------------------------------------------
75{
76 return( Create(Get_File_Name(false)) );
77}
78
79//---------------------------------------------------------
81{
82 CSG_String File = Get_File_Name(true);
83
84 SG_File_Set_Extension(File, "sg-grd-z"); SG_File_Delete(File);
85 SG_File_Set_Extension(File, "sg-grd" ); SG_File_Delete(File);
86 SG_File_Set_Extension(File, "sgrd" ); SG_File_Delete(File);
87 SG_File_Set_Extension(File, "sdat" ); SG_File_Delete(File); SG_File_Delete(File + ".aux.xml");
88 SG_File_Set_Extension(File, "mgrd" ); SG_File_Delete(File);
89 SG_File_Set_Extension(File, "dgm" ); SG_File_Delete(File);
90 SG_File_Set_Extension(File, "dat" ); SG_File_Delete(File);
91
92 return( true );
93}
94
95
97// //
98// //
99// //
101
102//---------------------------------------------------------
104{
105 switch( Format )
106 {
107 case GRID_FILE_FORMAT_Binary_old: return( "sgrd" );
108 case GRID_FILE_FORMAT_Binary : return( "sg-grd" ); default:
109 case GRID_FILE_FORMAT_Compressed: return( "sg-grd-z" );
110 case GRID_FILE_FORMAT_ASCII : return( "asc" );
111 case GRID_FILE_FORMAT_GeoTIFF : return( "tif" );
112 }
113}
114
115//---------------------------------------------------------
117
118//---------------------------------------------------------
120{
121 switch( Format )
122 {
128 return( true );
129 }
130
131 return( false );
132}
133
134//---------------------------------------------------------
139
140//---------------------------------------------------------
145
146
148// //
150
151//---------------------------------------------------------
152bool CSG_Grid::Save(const CSG_String &File, int Format)
153{
154 if( File.is_Empty() )
155 {
156 return( *Get_File_Name(false) ? Save(Get_File_Name(false), Format) : false );
157 }
158
159 if( Format == GRID_FILE_FORMAT_Undefined )
160 {
161 if( SG_File_Cmp_Extension(File, "sdat" ) ) { return( Save(SG_File_Make_Path("", File, "sgrd"), Format) ); }
162
164
165 if( SG_File_Cmp_Extension(File, "sg-grd-z") ) { Format = GRID_FILE_FORMAT_Compressed; }
166 if( SG_File_Cmp_Extension(File, "sg-grd" ) ) { Format = GRID_FILE_FORMAT_Binary ; }
167 if( SG_File_Cmp_Extension(File, "sgrd" ) ) { Format = GRID_FILE_FORMAT_Binary_old; }
168 if( SG_File_Cmp_Extension(File, "tif" ) ) { Format = GRID_FILE_FORMAT_GeoTIFF ; }
169 }
170
171 if( SG_File_Get_Extension(File).is_Empty() )
172 {
173 return( Save(File + "." + SG_Grid_Get_File_Extension(Format)) );
174 }
175
176 //-----------------------------------------------------
177 SG_UI_Msg_Add(CSG_String::Format("%s %s: %s...", _TL("Saving"), _TL("grid"), File.c_str()), true);
178
179 bool bResult = false;
180
181 switch( Format )
182 {
183 default:
184 bResult = _Save_Native(File, (TSG_Grid_File_Format)Format);
185 break;
186
188 bResult = _Save_Compressed(File);
189 break;
190
192 SG_UI_Msg_Lock(true);
193 SG_RUN_TOOL(bResult, "io_gdal", 2, // Export GeoTIFF
194 SG_TOOL_PARAMLIST_ADD("GRIDS" , this)
195 && SG_TOOL_PARAMETER_SET("FILE" , File)
196 && SG_TOOL_PARAMETER_SET("OPTIONS", SG_T("COMPRESS=LZW BIGTIFF=YES")) // enable bigtiff as the 'if needed' default setting is not available for compressed files
197 );
198 SG_UI_Msg_Lock(false);
199 break;
200 }
201
203
204 //-----------------------------------------------------
205 if( bResult )
206 {
207 Set_Modified(false);
208
209 Set_File_Name(File, true);
210
212
213 return( true );
214 }
215
216 SG_UI_Msg_Add(_TL("failed"), false, SG_UI_MSG_STYLE_FAILURE);
217
218 return( false );
219}
220
221
223// //
224// //
225// //
227
228//---------------------------------------------------------
229bool CSG_Grid::_Load_External(const CSG_String &File, bool bCached, bool bLoadData)
230{
231 bool bResult = false; CSG_Data_Manager Manager; CSG_Tool *pTool = NULL;
232
233 SG_UI_Msg_Lock(true);
234
235 //-----------------------------------------------------
236 // Image Import
237
238 if( (SG_File_Cmp_Extension(File, "bmp")
239 || SG_File_Cmp_Extension(File, "gif")
240 || SG_File_Cmp_Extension(File, "jpg")
241 || SG_File_Cmp_Extension(File, "png")
242 || SG_File_Cmp_Extension(File, "pcx") )
243 && !bResult && (pTool = SG_Get_Tool_Library_Manager().Create_Tool("io_grid_image", 1)) != NULL )
244 {
245 pTool->Settings_Push(&Manager);
246
247 bResult = pTool->Set_Parameter("FILE", File) && pTool->Execute();
248
250 }
251
252 //-----------------------------------------------------
253 // GDAL Import
254
255 if( !bResult && (pTool = SG_Get_Tool_Library_Manager().Create_Tool("io_gdal", 0)) != NULL )
256 {
257 pTool->Settings_Push(&Manager);
258
259 bResult = pTool->Set_Parameter("FILES" , File)
260 && pTool->Set_Parameter("MULTIPLE", 0 ) // output as single grid(s)
261 && pTool->Execute();
262
264 }
265
266 SG_UI_Msg_Lock(false);
267
268 //-----------------------------------------------------
269 if( bResult && Manager.Grid().Count() && Manager.Grid(0).is_Valid() )
270 {
271 CSG_Grid *pGrid = Manager.Grid(0).asGrid();
272
273 if( pGrid->is_Cached() )
274 {
275 return( Create(*pGrid) );
276 }
277
278 Set_File_Name(File, false);
279
280 Set_Name (pGrid->Get_Name());
282
283 m_System = pGrid->m_System;
284 m_Type = pGrid->m_Type;
285 m_Values = pGrid->m_Values; pGrid->m_Values = NULL; // take ownership of data array
286
287 m_zOffset = pGrid->m_zOffset;
288 m_zScale = pGrid->m_zScale;
289 m_Unit = pGrid->m_Unit;
290
291 m_nBytes_Value = pGrid->m_nBytes_Value;
292 m_nBytes_Line = pGrid->m_nBytes_Line;
293
294 Get_MetaData () = pGrid->Get_MetaData ();
295 Get_Projection() = pGrid->Get_Projection();
296
298
299 return( true );
300 }
301
302 return( false );
303}
304
305//---------------------------------------------------------
306bool CSG_Grid::_Load_PGSQL(const CSG_String &File, bool bCached, bool bLoadData)
307{
308 bool bResult = false;
309
310 if( File.BeforeFirst(':').Cmp("PGSQL") == 0 ) // database source
311 {
312 CSG_String s(File);
313
314 s = s.AfterFirst(':'); CSG_String Host (s.BeforeFirst(':'));
315 s = s.AfterFirst(':'); CSG_String Port (s.BeforeFirst(':'));
316 s = s.AfterFirst(':'); CSG_String DBase(s.BeforeFirst(':'));
317 s = s.AfterFirst(':'); CSG_String Table(s.BeforeFirst(':'));
318 s = s.AfterFirst(':'); CSG_String rid (s.BeforeFirst(':').AfterFirst('='));
319
320 CSG_Tool *pTool = SG_Get_Tool_Library_Manager().Create_Tool("db_pgsql", 33); // CPGIS_Raster_Load_Band
321
322 if( pTool )
323 {
325
326 CSG_String Connection(DBase + " [" + Host + ":" + Port + "]");
327
328 bResult = pTool->Set_Manager(NULL) && pTool->On_Before_Execution()
329 && pTool->Set_Parameter("CONNECTION", Connection)
330 && pTool->Set_Parameter("DB_TABLE" , Table )
331 && pTool->Set_Parameter("RID" , rid )
332 && pTool->Set_Parameter("GRID" , this )
333 && pTool->Execute();
334
336
338 }
339 }
340
341 return( bResult );
342}
343
344
346// //
347// Native //
348// //
350
351//---------------------------------------------------------
352bool CSG_Grid::_Load_Native(const CSG_String &File, bool bCached, bool bLoadData)
353{
354 CSG_Grid_File_Info Info;
355
356 if( !Info.Create(File) )
357 {
358 return( false );
359 }
360
361 Set_File_Name(File, true);
362
363 Set_Name (Info.m_Name);
365 Set_Unit (Info.m_Unit);
366
367 Set_NoData_Value_Range(Info.m_NoData[0], Info.m_NoData[1]);
368
369 m_System = Info.m_System;
370 m_Type = Info.m_Type;
371 m_zScale = Info.m_zScale;
372 m_zOffset = Info.m_zOffset;
373
374 m_nBytes_Value = SG_Data_Type_Get_Size(m_Type);
375 m_nBytes_Line = m_Type == SG_DATATYPE_Bit ? 1 + Get_NX() / 8 : Get_NX() * m_nBytes_Value;
376
377 Get_Projection().Load(SG_File_Make_Path("", File, "prj"));
378
379 if( !bLoadData )
380 {
381 return( _Memory_Create(bCached) );
382 }
383
384 Load_MetaData(File);
385
386 //-----------------------------------------------------
387 CSG_File Stream;
388
389 if( !SG_Data_Type_is_Numeric(m_Type) ) // ASCII...
390 {
391 if( Stream.Open(Info.m_Data_File , SG_FILE_R, false)
392 || Stream.Open(SG_File_Make_Path("", File, "dat"), SG_FILE_R, false)
393 || Stream.Open(SG_File_Make_Path("", File, "sdat"), SG_FILE_R, false) )
394 {
395 Stream.Seek(Info.m_Offset);
396
397 return( _Load_ASCII(Stream, bCached, Info.m_bFlip) );
398 }
399 }
400
401 //-----------------------------------------------------
402 else // Binary...
403 {
404 if( bCached || _Cache_Check() )
405 {
406 if( _Cache_Create(Info.m_Data_File , m_Type, Info.m_Offset, Info.m_bSwapBytes, Info.m_bFlip)
407 || _Cache_Create(SG_File_Make_Path("", File, "dat"), m_Type, Info.m_Offset, Info.m_bSwapBytes, Info.m_bFlip)
408 || _Cache_Create(SG_File_Make_Path("", File, "sdat"), m_Type, Info.m_Offset, Info.m_bSwapBytes, Info.m_bFlip) )
409 {
410 return( true );
411 }
412 }
413
414 m_Cache_File = Info.m_Data_File ;
415 m_Cache_Offset = Info.m_Offset ;
416 m_Cache_bSwap = Info.m_bSwapBytes;
417 m_Cache_bFlip = Info.m_bFlip ;
418
419 if( _Memory_Create(bCached) )
420 {
421 if( Stream.Open(Info.m_Data_File , SG_FILE_R, true)
422 || Stream.Open(SG_File_Make_Path("", File, "dat"), SG_FILE_R, true)
423 || Stream.Open(SG_File_Make_Path("", File, "sdat"), SG_FILE_R, true) )
424 {
425 Stream.Seek(Info.m_Offset);
426
427 return( _Load_Binary(Stream, m_Type, Info.m_bFlip, Info.m_bSwapBytes) );
428 }
429 }
430 }
431
432 return( false );
433}
434
435//---------------------------------------------------------
436bool CSG_Grid::_Save_Native(const CSG_String &_File, TSG_Grid_File_Format Format)
437{
438#ifdef WORDS_BIGENDIAN
439 bool bBigEndian = true;
440#else
441 bool bBigEndian = false;
442#endif
443
444 CSG_String File(_File);
445
446 bool bBinary;
447
448 if( Format == GRID_FILE_FORMAT_ASCII )
449 {
450 bBinary = false;
451 }
452 else if( Format == GRID_FILE_FORMAT_Binary_old )
453 {
454 bBinary = true; SG_File_Set_Extension(File, "sgrd");
455 }
456 else
457 {
458 bBinary = true; SG_File_Set_Extension(File, "sg-grd");
459 }
460
461 CSG_Grid_File_Info Info(*this);
462
463 if( Info.Save(File, bBinary) )
464 {
465 CSG_File Stream(SG_File_Make_Path("", File, "sdat"), SG_FILE_W, true);
466
467 if( bBinary ? _Save_Binary(Stream, m_Type, false, bBigEndian) : _Save_ASCII (Stream) )
468 {
469 Save_MetaData(File);
470
471 Get_Projection().Save(SG_File_Make_Path("", File, "prj"));
472
473 Info.Save_AUX_XML(SG_File_Make_Path("", File, "sdat"));
474
475 return( true );
476 }
477 }
478
479 return( false );
480}
481
482
484// //
485// Compressed //
486// //
488
489//---------------------------------------------------------
490bool CSG_Grid::_Load_Compressed(const CSG_String &_File, bool bCached, bool bLoadData)
491{
492 Set_File_Name(_File, true);
493
494 CSG_Archive Stream(_File, SG_FILE_R);
495
496 if( !Stream.is_Reading() )
497 {
498 return( false );
499 }
500
501 //-----------------------------------------------------
502 CSG_String File(SG_File_Get_Name(_File, false) + ".");
503
504 if( !Stream.Get_File(File + "sgrd" )
505 && !Stream.Get_File(File + "sg-grd") )
506 {
507 File.Clear();
508
509 for(size_t i=0; i<Stream.Get_File_Count(); i++)
510 {
511 if( SG_File_Cmp_Extension(Stream.Get_File_Name(i), "sgrd" )
512 || SG_File_Cmp_Extension(Stream.Get_File_Name(i), "sg-grd") )
513 {
514 File = SG_File_Get_Name(Stream.Get_File_Name(i), false) + ".";
515 Stream.Get_File(Stream.Get_File_Name(i));
516 break;
517 }
518 }
519
520 if( File.is_Empty() )
521 {
522 return( false );
523 }
524 }
525
526 //-----------------------------------------------------
527 CSG_Grid_File_Info Info;
528
529 if( !Info.Create(Stream) )
530 {
531 return( false );
532 }
533
534 Set_Name (Info.m_Name);
536 Set_Unit (Info.m_Unit);
537
538 Set_NoData_Value_Range(Info.m_NoData[0], Info.m_NoData[1]);
539
540 m_System = Info.m_System;
541 m_Type = Info.m_Type;
542 m_zScale = Info.m_zScale;
543 m_zOffset = Info.m_zOffset;
544
545 m_nBytes_Value = SG_Data_Type_Get_Size(m_Type);
546 m_nBytes_Line = m_Type == SG_DATATYPE_Bit ? 1 + Get_NX() / 8 : Get_NX() * m_nBytes_Value;
547
548 if( Stream.Get_File(File + "prj") )
549 {
550 Get_Projection().Load(Stream);
551 }
552
553 if( !bLoadData )
554 {
555 return( _Memory_Create(bCached) );
556 }
557
558 if( Stream.Get_File(File + "mgrd") )
559 {
560 Load_MetaData(Stream);
561 }
562
563 //-----------------------------------------------------
564 if( _Cache_Check() )
565 {
566 bCached = true;
567 }
568
569 return( Stream.Get_File(File + "sdat") && _Memory_Create(bCached)
570 && _Load_Binary(Stream, m_Type, Info.m_bFlip, Info.m_bSwapBytes)
571 );
572}
573
574//---------------------------------------------------------
575bool CSG_Grid::_Save_Compressed(const CSG_String &_File)
576{
577#ifdef WORDS_BIGENDIAN
578 bool bBigEndian = true;
579#else
580 bool bBigEndian = false;
581#endif
582
583 CSG_Archive Stream(_File, SG_FILE_W);
584
585 if( Stream.is_Writing() )
586 {
587 CSG_String File(SG_File_Get_Name(_File, false) + ".");
588
589 CSG_Grid_File_Info Info(*this);
590
591 if( Stream.Add_File(File + "sgrd") && Info.Save(Stream, true)
592 && Stream.Add_File(File + "sdat") && _Save_Binary(Stream, m_Type, false, bBigEndian) )
593 {
594 Stream.Add_File(File + "mgrd" ); Save_MetaData(Stream);
595 Stream.Add_File(File + "prj" ); Get_Projection().Save(Stream);
596 Stream.Add_File(File + "sdat.aux.xml"); Info.Save_AUX_XML(Stream);
597
598 return( true );
599 }
600 }
601
602 return( false );
603}
604
605
607// //
608// Binary //
609// //
611
612//---------------------------------------------------------
613void CSG_Grid::_Swap_Bytes(char *Bytes, int nBytes) const
614{
615 if( nBytes == 2 )
616 {
617 uint16_t val, valSwapped;
618 memcpy(&val, Bytes, nBytes);
619 valSwapped = ntohs(val);
620 memcpy(Bytes, &valSwapped, nBytes);
621 }
622 else if( nBytes == 4 )
623 {
624 uint32_t val, valSwapped;
625 memcpy(&val, Bytes, nBytes);
626 valSwapped = ntohl(val);
627 memcpy(Bytes, &valSwapped, nBytes);
628 }
629}
630
631//---------------------------------------------------------
632bool CSG_Grid::_Load_Binary(CSG_File &Stream, TSG_Data_Type File_Type, bool bFlip, bool bSwapBytes)
633{
634 if( !Stream.is_Open() || !is_Valid() )
635 {
636 return( false );
637 }
638
640
641 //-----------------------------------------------------
642 if( File_Type == SG_DATATYPE_Bit )
643 {
644 int nLineBytes = Get_NX() / 8 + 1;
645
646 if( m_Type == File_Type && !is_Cached() )
647 {
648 for(int y=0; y<Get_NY() && !Stream.is_EOF() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
649 {
650 Stream.Read(m_Values[bFlip ? Get_NY() - y - 1 : y], sizeof(char), nLineBytes);
651 }
652 }
653 else
654 {
655 CSG_Array Line(1, nLineBytes);
656
657 for(int y=0; y<Get_NY() && !Stream.is_EOF() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
658 {
659 Stream.Read(Line.Get_Array(), nLineBytes);
660
661 char *pValue = (char *)Line.Get_Array();
662
663 for(int x=0, yy=bFlip ? Get_NY()-y-1 : y; x<Get_NX(); pValue++)
664 {
665 for(int i=0; i<8 && x<Get_NX(); i++, x++)
666 {
667 Set_Value(x, yy, (*pValue & m_Bitmask[i]) == 0 ? 0.0 : 1.0);
668 }
669 }
670 }
671 }
672 }
673
674 //-----------------------------------------------------
675 else
676 {
677 int nValueBytes = (int)SG_Data_Type_Get_Size(File_Type);
678 int nLineBytes = Get_NX() * nValueBytes;
679
680 if( m_Type == File_Type && !is_Cached() && !bSwapBytes )
681 {
682 for(int y=0; y<Get_NY() && !Stream.is_EOF() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
683 {
684 Stream.Read(m_Values[bFlip ? Get_NY() - y - 1 : y], nLineBytes);
685 }
686 }
687 else
688 {
689 CSG_Array Line(1, nLineBytes);
690
691 for(int y=0; y<Get_NY() && !Stream.is_EOF() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
692 {
693 Stream.Read(Line.Get_Array(), nLineBytes);
694
695 char *pValue = (char *)Line.Get_Array();
696
697 for(int x=0, yy=bFlip ? Get_NY()-y-1 : y; x<Get_NX(); x++, pValue+=nValueBytes)
698 {
699 if( bSwapBytes )
700 {
701 _Swap_Bytes(pValue, nValueBytes);
702 }
703
704 switch( File_Type )
705 {
706 case SG_DATATYPE_Byte : Set_Value(x, yy, *(BYTE *)pValue, false); break;
707 case SG_DATATYPE_Char : Set_Value(x, yy, *(char *)pValue, false); break;
708 case SG_DATATYPE_Word : Set_Value(x, yy, *(WORD *)pValue, false); break;
709 case SG_DATATYPE_Short : Set_Value(x, yy, *(short *)pValue, false); break;
710 case SG_DATATYPE_DWord : Set_Value(x, yy, *(DWORD *)pValue, false); break;
711 case SG_DATATYPE_Int : Set_Value(x, yy, *(int *)pValue, false); break;
712 case SG_DATATYPE_Float : Set_Value(x, yy, *(float *)pValue, false); break;
713 case SG_DATATYPE_Double: Set_Value(x, yy, *(double *)pValue, false); break;
714 default: break;
715 }
716 }
717 }
718 }
719 }
720
721 //-----------------------------------------------------
722 return( true );
723}
724
725//---------------------------------------------------------
726bool CSG_Grid::_Save_Binary(CSG_File &Stream, TSG_Data_Type File_Type, bool bFlip, bool bSwapBytes)
727{
728 //-----------------------------------------------------
729 if( !Stream.is_Writing() || !is_Valid() )
730 {
731 return( false );
732 }
733
735
736 //-----------------------------------------------------
737 if( File_Type == SG_DATATYPE_Bit )
738 {
739 int nLineBytes = Get_NX() / 8 + 1;
740
741 if( m_Type == File_Type && !is_Cached() )
742 {
743 for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
744 {
745 Stream.Write((char *)m_Values[bFlip ? Get_NY() - y - 1 : y], sizeof(char), nLineBytes);
746 }
747 }
748 else
749 {
750 CSG_Array Line(1, nLineBytes);
751
752 for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
753 {
754 char *pValue = (char *)Line.Get_Array();
755
756 for(int x=0, yy=bFlip ? Get_NY()-y-1 : y; x<Get_NX(); pValue++)
757 {
758 for(int i=0; i<8 && x<Get_NX(); i++, x++)
759 {
760 *pValue = asChar(x, yy) != 0.0 ? *pValue | m_Bitmask[i] : *pValue & (~m_Bitmask[i]);
761 }
762 }
763
764 Stream.Write(Line.Get_Array(), nLineBytes);
765 }
766 }
767 }
768
769 //-----------------------------------------------------
770 else
771 {
772 int nValueBytes = (int)SG_Data_Type_Get_Size(File_Type);
773 int nLineBytes = Get_NX() * nValueBytes;
774
775 if( m_Type == File_Type && !is_Cached() && !bSwapBytes )
776 {
777 for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
778 {
779 Stream.Write((char *)m_Values[bFlip ? Get_NY() - y - 1 : y], nLineBytes);
780 }
781 }
782 else
783 {
784 CSG_Array Line(1, nLineBytes);
785
786 for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
787 {
788 char *pValue = (char *)Line.Get_Array();
789
790 for(int x=0, yy=bFlip ? Get_NY()-y-1 : y; x<Get_NX(); x++, pValue+=nValueBytes)
791 {
792 switch( File_Type )
793 {
794 case SG_DATATYPE_Byte : *(BYTE *)pValue = asByte (x, yy, false); break;
795 case SG_DATATYPE_Char : *(char *)pValue = asChar (x, yy, false); break;
796 case SG_DATATYPE_Word : *(WORD *)pValue = asShort (x, yy, false); break;
797 case SG_DATATYPE_Short : *(short *)pValue = asShort (x, yy, false); break;
798 case SG_DATATYPE_DWord : *(DWORD *)pValue = asInt (x, yy, false); break;
799 case SG_DATATYPE_Int : *(int *)pValue = asInt (x, yy, false); break;
800 case SG_DATATYPE_Float : *(float *)pValue = asFloat (x, yy, false); break;
801 case SG_DATATYPE_Double: *(double *)pValue = asDouble(x, yy, false); break;
802 default: break;
803 }
804
805 if( bSwapBytes )
806 {
807 _Swap_Bytes(pValue, nValueBytes);
808 }
809 }
810
811 Stream.Write(Line.Get_Array(), nLineBytes);
812 }
813 }
814 }
815
816 //-----------------------------------------------------
817 return( true );
818}
819
820
822// //
823// ASCII //
824// //
826
827//---------------------------------------------------------
828bool CSG_Grid::_Load_ASCII(CSG_File &Stream, bool bCached, bool bFlip)
829{
830 if( !Stream.is_Reading() || !_Memory_Create(bCached) )
831 {
832 return( false );
833 }
834
836
837 for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
838 {
839 for(int x=0, yy=bFlip ? Get_NY()-y-1 : y; x<Get_NX(); x++)
840 {
841 Set_Value(x, yy, Stream.Scan_Double());
842 }
843 }
844
845 return( true );
846}
847
848//---------------------------------------------------------
849bool CSG_Grid::_Save_ASCII(CSG_File &Stream, bool bFlip)
850{
851 if( !Stream.is_Writing() || !is_Valid() )
852 {
853 return( false );
854 }
855
857
858 for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
859 {
860 for(int x=0, yy=bFlip ? Get_NY()-y-1 : y; x<Get_NX(); x++)
861 {
862 Stream.Printf("%lf ", asDouble(x, yy));
863 }
864
865 Stream.Printf("\n");
866 }
867
868 return( true );
869}
870
871
873// //
875
876//---------------------------------------------------------
877bool CSG_Grid::_Load_Surfer(const CSG_String &File, bool bCached, bool bLoadData)
878{
879 const float NoData = 1.70141e38f;
880
881 if( !SG_File_Cmp_Extension(File, "grd") )
882 {
883 return( false );
884 }
885
886 //-----------------------------------------------------
887 CSG_File Stream;
888
889 if( !Stream.Open(File, SG_FILE_R, true) )
890 {
891 return( false );
892 }
893
894 char Identifier[4]; Stream.Read(Identifier, sizeof(char), 4);
895
896 //-----------------------------------------------------
897 if( !strncmp(Identifier, "DSBB", 4) ) // Binary...
898 {
899 short nx, ny; double d; CSG_Rect r;
900
901 Stream.Read(&nx , sizeof(short ));
902 Stream.Read(&ny , sizeof(short ));
903 Stream.Read(&r.xMin, sizeof(double));
904 Stream.Read(&r.xMax, sizeof(double));
905 Stream.Read(&r.yMin, sizeof(double));
906 Stream.Read(&r.yMax, sizeof(double));
907 Stream.Read(&d , sizeof(double)); // zMin, we ignore...
908 Stream.Read(&d , sizeof(double)); // zMax, we ignore...
909
910 d = (r.xMax - r.xMin) / (nx - 1.);
911 // d = (r.yMax - r.yMin) / (ny - 1.); // we could proof for equal cellsize in direction of y...
912
913 //-------------------------------------------------
914 if( !Create(SG_DATATYPE_Float, nx, ny, d, r.xMin, r.yMin, bCached) || Stream.is_EOF() )
915 {
916 return( false );
917 }
918
919 //-------------------------------------------------
920 if( bLoadData )
921 {
922 CSG_Array Line(sizeof(float), Get_NX()); float *Values = (float *)Line.Get_Array();
923
924 for(int y=0; y<Get_NY() && !Stream.is_EOF() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
925 {
926 Stream.Read(Values, sizeof(float), Get_NX());
927
928 for(int x=0; x<Get_NX(); x++)
929 {
930 if( Values[x] == NoData )
931 {
932 Set_NoData(x, y);
933 }
934 else
935 {
936 Set_Value(x, y, Values[x]);
937 }
938 }
939 }
940 }
941
942 Get_MetaData().Add_Child("SURFER_GRID", "Surfer Grid (Binary)");
943 }
944
945 //-----------------------------------------------------
946 else if( !strncmp(Identifier, "DSAA", 4) ) // ASCII...
947 {
948 int nx = Stream.Scan_Int ();
949 int ny = Stream.Scan_Int ();
950 double xMin = Stream.Scan_Double();
951 double xMax = Stream.Scan_Double();
952 double yMin = Stream.Scan_Double(); Stream.Scan_Double();
953 // double yMax = Stream.Scan_Double();
954 double dx = Stream.Scan_Double(); Stream.Scan_Double();
955 // double dy = Stream.Scan_Double();
956
957 dx = (xMax - xMin) / (nx - 1.);
958 // dy = (yMax - yMin) / (ny - 1.); // we could proof for equal cellsize in direction of y...
959
960 //-------------------------------------------------
961 if( !Create(SG_DATATYPE_Float, nx, ny, dx, xMin, yMin, bCached) || Stream.is_EOF() )
962 {
963 return( false );
964 }
965
966 //-------------------------------------------------
967 if( bLoadData )
968 {
969 for(int y=0; y<Get_NY() && !Stream.is_EOF() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
970 {
971 for(int x=0; x<Get_NX(); x++)
972 {
973 double Value;
974
975 if( Stream.Scan(Value) && Value != NoData )
976 {
977 Set_Value(x, y, Value);
978 }
979 else
980 {
981 Set_NoData(x, y);
982 }
983 }
984 }
985 }
986
987 Get_MetaData().Add_Child("SURFER_GRID", "Surfer Grid (ASCII)");
988 }
989
990 //-------------------------------------------------
991 else // no Surfer Grid File (does not start with 'DSBB' or 'DSAA' sequence)!
992 {
993 return( false );
994 }
995
997
998 Set_File_Name(File);
999 Load_MetaData(File);
1000
1001 return( true );
1002}
1003
1004
1006// //
1007// //
1008// //
1010
1011//---------------------------------------------------------
1013{
1014 _On_Construction();
1015}
1016
1017void CSG_Grid_File_Info::_On_Construction(void)
1018{
1019 m_Name .Clear();
1021 m_Unit .Clear();
1022 m_System .Assign(0.0, 0.0, 0.0, 0, 0);
1023 m_Type = SG_DATATYPE_Float; // defaults to float
1024 m_zScale = 1.0;
1025 m_zOffset = 0;
1026 m_NoData[0] = -99999.0;
1027 m_NoData[1] = -99999.0;
1028 m_Data_File .Clear();
1029 m_bFlip = false;
1030 m_bSwapBytes = false;
1031 m_Offset = 0;
1033}
1034
1035//---------------------------------------------------------
1040
1042{
1043 m_Name = Info.m_Name;
1045 m_Unit = Info.m_Unit;
1046 m_System = Info.m_System;
1047 m_Type = Info.m_Type;
1048 m_zScale = Info.m_zScale;
1049 m_zOffset = Info.m_zOffset;
1050 m_NoData[0] = Info.m_NoData[0];
1051 m_NoData[1] = Info.m_NoData[1];
1052 m_Data_File = Info.m_Data_File;
1053 m_bFlip = Info.m_bFlip;
1055 m_Offset = Info.m_Offset;
1057
1058 return( true );
1059}
1060
1061//---------------------------------------------------------
1063{
1064 Create(Grid);
1065}
1066
1068{
1069 m_Name = Grid.Get_Name();
1071 m_Unit = Grid.Get_Unit();
1072 m_System = Grid.Get_System();
1073 m_Type = Grid.Get_Type();
1074 m_zScale = Grid.Get_Scaling();
1075 m_zOffset = Grid.Get_Offset();
1076 m_NoData[0] = Grid.Get_NoData_Value();
1077 m_NoData[1] = Grid.Get_NoData_Value(true);
1078 m_Data_File .Clear();
1079 m_bFlip = false;
1080 m_bSwapBytes = false;
1081 m_Offset = 0;
1083
1084 return( true );
1085}
1086
1087//---------------------------------------------------------
1089{
1090 Create(File);
1091}
1092
1094{
1095 if( !SG_File_Cmp_Extension(File, "sg-grd-z") )
1096 {
1097 if( SG_File_Cmp_Extension(File, "sgrd")
1098 || SG_File_Cmp_Extension(File, "sg-grd") )
1099 {
1100 CSG_File Stream(File, SG_FILE_R, false);
1101
1102 return( Create(Stream) );
1103 }
1104
1105 return( false );
1106 }
1107
1108 //-----------------------------------------------------
1109 CSG_Archive Stream(File, SG_FILE_R);
1110
1111 if( Stream.is_Reading() )
1112 {
1113 CSG_String Archive_File(SG_File_Get_Name(File, false) + ".");
1114
1115 if( !Stream.Get_File(Archive_File + "sgrd" )
1116 && !Stream.Get_File(Archive_File + "sg-grd") )
1117 {
1118 for(size_t i=0; i<Stream.Get_File_Count(); i++)
1119 {
1120 if( SG_File_Cmp_Extension(Stream.Get_File_Name(i), "sgrd" )
1121 || SG_File_Cmp_Extension(Stream.Get_File_Name(i), "sg-grd") )
1122 {
1123 Stream.Get_File(Stream.Get_File_Name(i));
1124 break;
1125 }
1126 }
1127 }
1128
1129 return( Create(Stream) );
1130 }
1131
1132 //-----------------------------------------------------
1133 return( false );
1134}
1135
1136//---------------------------------------------------------
1138{
1139 Create(Stream);
1140}
1141
1143{
1144 _On_Construction();
1145
1146 //-----------------------------------------------------
1147 if( !Stream.is_Reading() )
1148 {
1149 return( false );
1150 }
1151
1152 //-----------------------------------------------------
1153 sLong NX = 0, NY = 0;
1154 double Cellsize = 0.0, xMin = 0.0, yMin = 0.0;
1155
1156 do
1157 {
1158 CSG_String Value;
1159
1160 switch( _Get_Key(Stream, Value) )
1161 {
1162 case GRID_FILE_KEY_NAME : m_Name = Value; break;
1163 case GRID_FILE_KEY_DESCRIPTION : m_Description = Value; break;
1164 case GRID_FILE_KEY_UNITNAME : m_Unit = Value; break;
1165
1166 case GRID_FILE_KEY_CELLCOUNT_X : NX = Value.asInt (); break;
1167 case GRID_FILE_KEY_CELLCOUNT_Y : NY = Value.asInt (); break;
1168 case GRID_FILE_KEY_POSITION_XMIN : xMin = Value.asDouble(); break;
1169 case GRID_FILE_KEY_POSITION_YMIN : yMin = Value.asDouble(); break;
1170 case GRID_FILE_KEY_CELLSIZE : Cellsize = Value.asDouble(); break;
1171
1172 case GRID_FILE_KEY_Z_FACTOR : m_zScale = Value.asDouble(); break;
1173 case GRID_FILE_KEY_Z_OFFSET : m_zOffset = Value.asDouble(); break;
1174 case GRID_FILE_KEY_NODATA_VALUE : m_NoData[0] = Value.asDouble();
1175 Value = Value.AfterFirst(';'); m_NoData[1] = Value.is_Empty() ? m_NoData[0] : Value.asDouble(); break;
1176
1177 case GRID_FILE_KEY_DATAFILE_OFFSET: m_Offset = Value.asInt (); break;
1179 case GRID_FILE_KEY_TOPTOBOTTOM : m_bFlip = Value.Find(GRID_FILE_KEY_TRUE) >= 0; break;
1180
1182 if( SG_File_Get_Path(Value).Length() > 0 )
1183 {
1184 m_Data_File = Value;
1185 }
1186 else
1187 {
1189 }
1190 break;
1191
1193 {
1194 for(int i=0; i<SG_DATATYPE_Undefined; i++)
1195 {
1196 if( Value.Find(gSG_Data_Type_Identifier[i]) >= 0 )
1197 {
1198 m_Type = (TSG_Data_Type)i;
1199
1200 break;
1201 }
1202 }
1203 }
1204 break;
1205 }
1206 }
1207 while( !Stream.is_EOF() );
1208
1209 //-----------------------------------------------------
1210 return( m_System.Assign(Cellsize, xMin, yMin, (int)NX, (int)NY) );
1211}
1212
1213//---------------------------------------------------------
1214int CSG_Grid_File_Info::_Get_Key(CSG_File &Stream, CSG_String &Value)
1215{
1216 int i;
1217 CSG_String sLine;
1218
1219 if( Stream.Read_Line(sLine) && (i = sLine.Find('=')) > 0 )
1220 {
1221 Value = sLine.AfterFirst('=');
1222 Value.Trim();
1223
1224 sLine.Remove(i);
1225
1226 for(i=0; i<GRID_FILE_KEY_Count; i++)
1227 {
1229
1230 if( s.Find(sLine.Left(s.Length())) >= 0 )
1231 {
1232 return( i );
1233 }
1234 }
1235 }
1236
1237 return( -1 );
1238}
1239
1240
1242// //
1244
1245//---------------------------------------------------------
1246bool CSG_Grid_File_Info::Save(const CSG_String &File, bool bBinary)
1247{
1248 return( Save(CSG_File(File, SG_FILE_W, false), bBinary) );
1249}
1250
1251//---------------------------------------------------------
1252bool CSG_Grid_File_Info::Save(const CSG_File &Stream, bool bBinary)
1253{
1254 if( !Stream.is_Writing() )
1255 {
1256 return( false );
1257 }
1258
1259#define GRID_FILE_PRINT(Key, Val) { CSG_String s(gSG_Grid_File_Key_Names[Key]); s += "\t= " + Val + "\n"; Stream.Write(s); }
1260
1266#ifdef WORDS_BIGENDIAN
1268#else
1270#endif
1280
1281 return( true );
1282}
1283
1284//---------------------------------------------------------
1285bool CSG_Grid_File_Info::Save(const CSG_String &File, const CSG_Grid &Grid, bool bBinary)
1286{
1287 CSG_Grid_File_Info Info(Grid);
1288
1289 return( Info.Save(File, bBinary) );
1290}
1291
1292//---------------------------------------------------------
1293bool CSG_Grid_File_Info::Save(const CSG_File &Stream, const CSG_Grid &Grid, bool bBinary)
1294{
1295 CSG_Grid_File_Info Info(Grid);
1296
1297 return( Info.Save(Stream, bBinary) );
1298}
1299
1300
1302// //
1304
1305//---------------------------------------------------------
1307{
1308 CSG_File Stream;
1309
1310 return( m_Projection.is_Okay() && Stream.Open(File + ".aux.xml", SG_FILE_W, false) && Save_AUX_XML(Stream) );
1311}
1312
1313//---------------------------------------------------------
1315{
1316 if( m_Projection.is_Okay() && Stream.is_Writing() ) // store srs information that is recognized by ArcGIS
1317 {
1318 Stream.Write("<PAMDataset>\n<SRS>");
1319 Stream.Write(m_Projection.Get_WKT());
1320 Stream.Write("</SRS>\n</PAMDataset>\n");
1321
1322 return( true );
1323 }
1324
1325 return( false );
1326}
1327
1328
1330// //
1331// //
1332// //
1334
1335//---------------------------------------------------------
void SG_UI_Msg_Add(const char *Message, bool bNewLine, TSG_UI_MSG_STYLE Style)
bool SG_UI_Process_Set_Ready(void)
bool SG_UI_Process_Set_Progress(int Position, int Range)
int SG_UI_Msg_Lock(bool bOn)
void SG_UI_ProgressAndMsg_Lock(bool bOn)
bool SG_Data_Type_is_Numeric(TSG_Data_Type Type)
Definition api_core.cpp:198
@ SG_UI_MSG_STYLE_FAILURE
Definition api_core.h:1635
@ SG_UI_MSG_STYLE_SUCCESS
Definition api_core.h:1634
SAGA_API_DLL_EXPORT bool SG_File_Cmp_Extension(const CSG_String &File, const CSG_String &Extension)
signed long long sLong
Definition api_core.h:158
#define SG_T(s)
Definition api_core.h:537
SAGA_API_DLL_EXPORT CSG_String SG_File_Get_Path(const CSG_String &full_Path)
SAGA_API_DLL_EXPORT CSG_String SG_File_Make_Path(const CSG_String &Directory, const CSG_String &Name)
SAGA_API_DLL_EXPORT bool SG_File_Delete(const CSG_String &FileName)
SAGA_API_DLL_EXPORT CSG_String SG_File_Get_Name(const CSG_String &full_Path, bool bExtension)
const char gSG_Data_Type_Identifier[][32]
Definition api_core.h:1089
SAGA_API_DLL_EXPORT bool SG_File_Set_Extension(CSG_String &File, const CSG_String &Extension)
TSG_Data_Type
Definition api_core.h:1043
@ SG_DATATYPE_Byte
Definition api_core.h:1045
@ SG_DATATYPE_Bit
Definition api_core.h:1044
@ SG_DATATYPE_Short
Definition api_core.h:1048
@ SG_DATATYPE_Word
Definition api_core.h:1047
@ SG_DATATYPE_Float
Definition api_core.h:1053
@ SG_DATATYPE_Undefined
Definition api_core.h:1059
@ SG_DATATYPE_Double
Definition api_core.h:1054
@ SG_DATATYPE_Int
Definition api_core.h:1050
@ SG_DATATYPE_Char
Definition api_core.h:1046
@ SG_DATATYPE_DWord
Definition api_core.h:1049
#define _TL(s)
Definition api_core.h:1618
size_t SG_Data_Type_Get_Size(TSG_Data_Type Type)
Definition api_core.h:1110
SAGA_API_DLL_EXPORT CSG_String SG_File_Get_Extension(const CSG_String &File)
@ SG_FILE_W
Definition api_core.h:1161
@ SG_FILE_R
Definition api_core.h:1160
virtual CSG_String Get_File_Name(size_t Index)
Definition api_file.cpp:792
size_t Get_File_Count(void)
Definition api_core.h:1271
bool Get_File(const SG_Char *Name)
Definition api_file.cpp:775
size_t Count(void) const
CSG_Data_Collection & Grid(void) const
const SG_Char * Get_Name(void) const
void Set_Name(const CSG_String &Name)
bool Save_MetaData(const CSG_String &FileName)
double Get_NoData_Value(bool bUpper=false) const
Definition dataobject.h:256
CSG_MetaData & Get_MetaData(void) const
Definition dataobject.h:237
virtual bool Set_NoData_Value_Range(double Lower, double Upper)
const SG_Char * Get_File_Name(bool bNative=true) const
bool Load_MetaData(const CSG_String &FileName)
void Set_Description(const CSG_String &Description)
void Set_File_Type(int Type)
Definition dataobject.h:278
const SG_Char * Get_Description(void) const
CSG_Projection & Get_Projection(void)
void Set_File_Name(const CSG_String &FileName)
bool Seek(sLong Offset, int Origin=SG_FILE_START) const
Definition api_file.cpp:242
virtual bool Open(const SG_Char *FileName, int Mode=SG_FILE_R, bool bBinary=true, int Encoding=SG_FILE_ENCODING_ANSI)
Definition api_file.cpp:113
virtual const CSG_String & Get_File_Name(void) const
Definition api_core.h:1186
bool is_Open(void) const
Definition api_core.h:1195
bool Read_Line(CSG_String &Line) const
Definition api_file.cpp:409
size_t Write(void *Buffer, size_t Size, size_t Count=1) const
Definition api_file.cpp:382
int Scan_Int(void) const
Definition api_file.cpp:567
size_t Read(void *Buffer, size_t Size, size_t Count=1) const
Definition api_file.cpp:338
int Printf(const char *Format,...)
Definition api_file.cpp:287
bool is_EOF(void) const
Definition api_file.cpp:236
bool is_Writing(void) const
Definition api_core.h:1197
bool is_Reading(void) const
Definition api_core.h:1196
bool Scan(int &Value) const
Definition api_file.cpp:505
double Scan_Double(void) const
Definition api_file.cpp:572
CSG_String m_Name
Definition grid.h:473
CSG_Grid_System m_System
Definition grid.h:475
bool m_bSwapBytes
Definition grid.h:465
TSG_Data_Type m_Type
Definition grid.h:471
bool Save(const CSG_String &File, bool bBinary=true)
Definition grid_io.cpp:1246
CSG_Projection m_Projection
Definition grid.h:477
double m_zScale
Definition grid.h:469
CSG_String m_Unit
Definition grid.h:473
CSG_String m_Data_File
Definition grid.h:473
bool Save_AUX_XML(const CSG_String &File)
Definition grid_io.cpp:1306
CSG_String m_Description
Definition grid.h:473
bool Create(const CSG_Grid_File_Info &Info)
Definition grid_io.cpp:1041
double m_zOffset
Definition grid.h:469
double m_NoData[2]
Definition grid.h:469
bool Assign(const CSG_Grid_System &System)
static int Get_Precision(void)
int Get_NY(void) const
Definition grid.h:564
virtual bool On_Reload(void)
Definition grid_io.cpp:74
virtual int asInt(sLong i, bool bScaled=true) const
Definition grid.h:785
bool is_Cached(void) const
Definition grid.h:633
double Get_Offset(void) const
Definition grid.cpp:428
virtual void Set_NoData(int x, int y)
Definition grid.h:730
double Get_Scaling(void) const
Definition grid.cpp:422
virtual void Set_Modified(bool bModified=true)
Definition grid.h:664
virtual float asFloat(sLong i, bool bScaled=true) const
Definition grid.h:788
virtual short asShort(sLong i, bool bScaled=true) const
Definition grid.h:783
CSG_Grid(void)
Definition grid.cpp:136
virtual bool is_Valid(void) const
Definition grid.cpp:441
const CSG_String & Get_Unit(void) const
Definition grid.h:553
virtual double asDouble(sLong i, bool bScaled=true) const
Definition grid.h:789
virtual void Set_Value(sLong i, BYTE Value, bool bScaled=true)
Definition grid.h:846
virtual BYTE asByte(sLong i, bool bScaled=true) const
Definition grid.h:780
virtual bool Save(const char *File, int Format=0)
Definition grid.h:535
bool Create(const CSG_Grid &Grid)
Definition grid.cpp:235
const CSG_Grid_System & Get_System(void) const
Definition grid.h:559
virtual bool On_Delete(void)
Definition grid_io.cpp:80
void Set_Unit(const CSG_String &Unit)
Definition grid.cpp:400
int Get_NX(void) const
Definition grid.h:563
virtual char asChar(sLong i, bool bScaled=true) const
Definition grid.h:781
TSG_Data_Type Get_Type(void) const
Definition grid.h:547
CSG_MetaData * Add_Child(void)
Definition metadata.cpp:166
void Destroy(void)
bool Save(const CSG_String &File, ESG_CRS_Format Format=ESG_CRS_Format::WKT) const
bool Load(const CSG_String &File)
CSG_String AfterFirst(char Character) const
bool asInt(int &Value) const
CSG_String & Remove(size_t pos)
int Cmp(const CSG_String &String) const
void Clear(void)
CSG_String BeforeFirst(char Character) const
static CSG_String Format(const char *Format,...)
int Trim(bool fromRight=false)
int Find(char Character, bool fromEnd=false) const
bool asDouble(double &Value) const
const SG_Char * c_str(void) const
bool is_Empty(void) const
CSG_String Left(size_t count) const
bool Delete_Tool(CSG_Tool *pTool) const
CSG_Tool * Create_Tool(const CSG_String &Library, int Index, bool bWithGUI=false, bool bWithCMD=true) const
bool Set_Manager(class CSG_Data_Manager *pManager)
Definition tool.cpp:874
bool Settings_Push(class CSG_Data_Manager *pManager=NULL)
Definition tool.cpp:925
bool Set_Parameter(const CSG_String &ID, CSG_Parameter *pValue)
Definition tool.cpp:1584
virtual bool On_Before_Execution(void)
Definition tool.h:239
bool Execute(bool bAddHistory=false)
Definition tool.cpp:560
#define GRID_FILE_KEY_TRUE
Definition grid.h:144
SAGA_API_DLL_EXPORT CSG_String SG_Grid_Get_File_Extension(int Format)
Definition grid_io.cpp:103
@ GRID_FILE_KEY_DATAFORMAT
Definition grid.h:107
@ GRID_FILE_KEY_Count
Definition grid.h:118
@ GRID_FILE_KEY_CELLCOUNT_Y
Definition grid.h:112
@ GRID_FILE_KEY_DESCRIPTION
Definition grid.h:103
@ GRID_FILE_KEY_POSITION_YMIN
Definition grid.h:110
@ GRID_FILE_KEY_DATAFILE_OFFSET
Definition grid.h:106
@ GRID_FILE_KEY_NODATA_VALUE
Definition grid.h:116
@ GRID_FILE_KEY_UNITNAME
Definition grid.h:104
@ GRID_FILE_KEY_BYTEORDER_BIG
Definition grid.h:108
@ GRID_FILE_KEY_CELLSIZE
Definition grid.h:113
@ GRID_FILE_KEY_Z_FACTOR
Definition grid.h:114
@ GRID_FILE_KEY_Z_OFFSET
Definition grid.h:115
@ GRID_FILE_KEY_POSITION_XMIN
Definition grid.h:109
@ GRID_FILE_KEY_DATAFILE_NAME
Definition grid.h:105
@ GRID_FILE_KEY_CELLCOUNT_X
Definition grid.h:111
@ GRID_FILE_KEY_TOPTOBOTTOM
Definition grid.h:117
@ GRID_FILE_KEY_NAME
Definition grid.h:102
TSG_Grid_File_Format
Definition grid.h:89
@ GRID_FILE_FORMAT_ASCII
Definition grid.h:93
@ GRID_FILE_FORMAT_Compressed
Definition grid.h:94
@ GRID_FILE_FORMAT_Binary_old
Definition grid.h:91
@ GRID_FILE_FORMAT_GeoTIFF
Definition grid.h:95
@ GRID_FILE_FORMAT_Binary
Definition grid.h:92
@ GRID_FILE_FORMAT_Undefined
Definition grid.h:90
const SG_Char gSG_Grid_File_Key_Names[GRID_FILE_KEY_Count][32]
Definition grid.h:123
#define GRID_FILE_KEY_FALSE
Definition grid.h:145
#define GRID_FILE_PRINT(Key, Val)
bool SG_Grid_Set_File_Format_Default(int Format)
Definition grid_io.cpp:119
CSG_String SG_Grid_Get_File_Extension_Default(void)
Definition grid_io.cpp:141
CSG_String SG_Grid_Get_File_Extension(int Format)
Definition grid_io.cpp:103
TSG_Grid_File_Format SG_Grid_Get_File_Format_Default(void)
Definition grid_io.cpp:135
static TSG_Grid_File_Format gSG_Grid_File_Format_Default
Definition grid_io.cpp:116
double xMin
Definition geo_tools.h:468
double xMax
Definition geo_tools.h:468
double yMin
Definition geo_tools.h:468
double yMax
Definition geo_tools.h:468
CSG_Tool_Library_Manager & SG_Get_Tool_Library_Manager(void)
#define SG_TOOL_PARAMETER_SET(IDENTIFIER, VALUE)
#define SG_TOOL_PARAMLIST_ADD(IDENTIFIER, VALUE)
#define SG_RUN_TOOL(bRetVal, LIBRARY, TOOL, CONDITION)