SAGA API Version 9.14
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 if( SG_File_Cmp_Extension(File, "sg-grd") || SG_File_Cmp_Extension(File, "sgrd") )
359 {
360 SG_UI_Msg_Add_Error(CSG_String::Format("%s: %s", _TL("header file error"), File.c_str()));
361 }
362
363 return( false );
364 }
365
366 Set_File_Name(File, true);
367
368 Set_Name (Info.m_Name);
370 Set_Unit (Info.m_Unit);
371
372 Set_NoData_Value_Range(Info.m_NoData[0], Info.m_NoData[1]);
373
374 m_System = Info.m_System;
375 m_Type = Info.m_Type;
376 m_zScale = Info.m_zScale;
377 m_zOffset = Info.m_zOffset;
378
379 m_nBytes_Value = SG_Data_Type_Get_Size(m_Type);
380 m_nBytes_Line = m_Type == SG_DATATYPE_Bit ? 1 + Get_NX() / 8 : Get_NX() * m_nBytes_Value;
381
382 Get_Projection().Load(SG_File_Make_Path("", File, "prj"));
383
384 if( !bLoadData )
385 {
386 return( _Memory_Create(bCached) );
387 }
388
389 Load_MetaData(File);
390
391 //-----------------------------------------------------
392 CSG_File Stream;
393
394 if( !SG_Data_Type_is_Numeric(m_Type) ) // ASCII...
395 {
396 if( Stream.Open(Info.m_Data_File , SG_FILE_R, false)
397 || Stream.Open(SG_File_Make_Path("", File, "dat"), SG_FILE_R, false)
398 || Stream.Open(SG_File_Make_Path("", File, "sdat"), SG_FILE_R, false) )
399 {
400 Stream.Seek(Info.m_Offset);
401
402 return( _Load_ASCII(Stream, bCached, Info.m_bFlip) );
403 }
404 }
405
406 //-----------------------------------------------------
407 else // Binary...
408 {
409 if( bCached || _Cache_Check() )
410 {
411 if( _Cache_Create(Info.m_Data_File , m_Type, Info.m_Offset, Info.m_bSwapBytes, Info.m_bFlip)
412 || _Cache_Create(SG_File_Make_Path("", File, "dat"), m_Type, Info.m_Offset, Info.m_bSwapBytes, Info.m_bFlip)
413 || _Cache_Create(SG_File_Make_Path("", File, "sdat"), m_Type, Info.m_Offset, Info.m_bSwapBytes, Info.m_bFlip) )
414 {
415 return( true );
416 }
417 }
418
419 m_Cache_File = Info.m_Data_File ;
420 m_Cache_Offset = Info.m_Offset ;
421 m_Cache_bSwap = Info.m_bSwapBytes;
422 m_Cache_bFlip = Info.m_bFlip ;
423
424 if( _Memory_Create(bCached) )
425 {
426 if( Stream.Open(Info.m_Data_File , SG_FILE_R, true)
427 || Stream.Open(SG_File_Make_Path("", File, "dat"), SG_FILE_R, true)
428 || Stream.Open(SG_File_Make_Path("", File, "sdat"), SG_FILE_R, true) )
429 {
430 Stream.Seek(Info.m_Offset);
431
432 return( _Load_Binary(Stream, m_Type, Info.m_bFlip, Info.m_bSwapBytes) );
433 }
434 }
435 }
436
437 return( false );
438}
439
440//---------------------------------------------------------
441bool CSG_Grid::_Save_Native(const CSG_String &_File, TSG_Grid_File_Format Format)
442{
443#ifdef WORDS_BIGENDIAN
444 bool bBigEndian = true;
445#else
446 bool bBigEndian = false;
447#endif
448
449 CSG_String File(_File);
450
451 bool bBinary;
452
453 if( Format == GRID_FILE_FORMAT_ASCII )
454 {
455 bBinary = false;
456 }
457 else if( Format == GRID_FILE_FORMAT_Binary_old )
458 {
459 bBinary = true; SG_File_Set_Extension(File, "sgrd");
460 }
461 else
462 {
463 bBinary = true; SG_File_Set_Extension(File, "sg-grd");
464 }
465
466 CSG_Grid_File_Info Info(*this);
467
468 if( Info.Save(File, bBinary) )
469 {
470 CSG_File Stream(SG_File_Make_Path("", File, "sdat"), SG_FILE_W, true);
471
472 if( bBinary ? _Save_Binary(Stream, m_Type, false, bBigEndian) : _Save_ASCII (Stream) )
473 {
474 Save_MetaData(File);
475
476 Get_Projection().Save(SG_File_Make_Path("", File, "prj"));
477
478 Info.Save_AUX_XML(SG_File_Make_Path("", File, "sdat"));
479
480 return( true );
481 }
482 }
483
484 return( false );
485}
486
487
489// //
490// Compressed //
491// //
493
494//---------------------------------------------------------
495bool CSG_Grid::_Load_Compressed(const CSG_String &_File, bool bCached, bool bLoadData)
496{
497 Set_File_Name(_File, true);
498
499 CSG_Archive Stream(_File, SG_FILE_R);
500
501 if( !Stream.is_Reading() )
502 {
503 return( false );
504 }
505
506 //-----------------------------------------------------
507 CSG_String File(SG_File_Get_Name(_File, false) + ".");
508
509 if( !Stream.Get_File(File + "sgrd" )
510 && !Stream.Get_File(File + "sg-grd") )
511 {
512 File.Clear();
513
514 for(size_t i=0; i<Stream.Get_File_Count(); i++)
515 {
516 if( SG_File_Cmp_Extension(Stream.Get_File_Name(i), "sgrd" )
517 || SG_File_Cmp_Extension(Stream.Get_File_Name(i), "sg-grd") )
518 {
519 File = SG_File_Get_Name(Stream.Get_File_Name(i), false) + ".";
520 Stream.Get_File(Stream.Get_File_Name(i));
521 break;
522 }
523 }
524
525 if( File.is_Empty() )
526 {
527 return( false );
528 }
529 }
530
531 //-----------------------------------------------------
532 CSG_Grid_File_Info Info;
533
534 if( !Info.Create(Stream) )
535 {
536 return( false );
537 }
538
539 Set_Name (Info.m_Name);
541 Set_Unit (Info.m_Unit);
542
543 Set_NoData_Value_Range(Info.m_NoData[0], Info.m_NoData[1]);
544
545 m_System = Info.m_System;
546 m_Type = Info.m_Type;
547 m_zScale = Info.m_zScale;
548 m_zOffset = Info.m_zOffset;
549
550 m_nBytes_Value = SG_Data_Type_Get_Size(m_Type);
551 m_nBytes_Line = m_Type == SG_DATATYPE_Bit ? 1 + Get_NX() / 8 : Get_NX() * m_nBytes_Value;
552
553 if( Stream.Get_File(File + "prj") )
554 {
555 Get_Projection().Load(Stream);
556 }
557
558 if( !bLoadData )
559 {
560 return( _Memory_Create(bCached) );
561 }
562
563 if( Stream.Get_File(File + "mgrd") )
564 {
565 Load_MetaData(Stream);
566 }
567
568 //-----------------------------------------------------
569 if( _Cache_Check() )
570 {
571 bCached = true;
572 }
573
574 return( Stream.Get_File(File + "sdat") && _Memory_Create(bCached)
575 && _Load_Binary(Stream, m_Type, Info.m_bFlip, Info.m_bSwapBytes)
576 );
577}
578
579//---------------------------------------------------------
580bool CSG_Grid::_Save_Compressed(const CSG_String &_File)
581{
582#ifdef WORDS_BIGENDIAN
583 bool bBigEndian = true;
584#else
585 bool bBigEndian = false;
586#endif
587
588 CSG_Archive Stream(_File, SG_FILE_W);
589
590 if( Stream.is_Writing() )
591 {
592 CSG_String File(SG_File_Get_Name(_File, false) + ".");
593
594 CSG_Grid_File_Info Info(*this);
595
596 if( Stream.Add_File(File + "sgrd") && Info.Save(Stream, true)
597 && Stream.Add_File(File + "sdat") && _Save_Binary(Stream, m_Type, false, bBigEndian) )
598 {
599 Stream.Add_File(File + "mgrd" ); Save_MetaData(Stream);
600 Stream.Add_File(File + "prj" ); Get_Projection().Save(Stream);
601 Stream.Add_File(File + "sdat.aux.xml"); Info.Save_AUX_XML(Stream);
602
603 return( true );
604 }
605 }
606
607 return( false );
608}
609
610
612// //
613// Binary //
614// //
616
617//---------------------------------------------------------
618void CSG_Grid::_Swap_Bytes(char *Bytes, int nBytes) const
619{
620 if( nBytes == 2 )
621 {
622 uint16_t val, valSwapped;
623 memcpy(&val, Bytes, nBytes);
624 valSwapped = ntohs(val);
625 memcpy(Bytes, &valSwapped, nBytes);
626 }
627 else if( nBytes == 4 )
628 {
629 uint32_t val, valSwapped;
630 memcpy(&val, Bytes, nBytes);
631 valSwapped = ntohl(val);
632 memcpy(Bytes, &valSwapped, nBytes);
633 }
634}
635
636//---------------------------------------------------------
637bool CSG_Grid::_Load_Binary(CSG_File &Stream, TSG_Data_Type File_Type, bool bFlip, bool bSwapBytes)
638{
639 if( !Stream.is_Open() || !is_Valid() )
640 {
641 return( false );
642 }
643
645
646 //-----------------------------------------------------
647 if( File_Type == SG_DATATYPE_Bit )
648 {
649 int nLineBytes = Get_NX() / 8 + 1;
650
651 if( m_Type == File_Type && !is_Cached() )
652 {
653 for(int y=0; y<Get_NY() && !Stream.is_EOF() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
654 {
655 Stream.Read(m_Values[bFlip ? Get_NY() - y - 1 : y], sizeof(char), nLineBytes);
656 }
657 }
658 else
659 {
660 CSG_Array Line(1, nLineBytes);
661
662 for(int y=0; y<Get_NY() && !Stream.is_EOF() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
663 {
664 Stream.Read(Line.Get_Array(), nLineBytes);
665
666 char *pValue = (char *)Line.Get_Array();
667
668 for(int x=0, yy=bFlip ? Get_NY()-y-1 : y; x<Get_NX(); pValue++)
669 {
670 for(int i=0; i<8 && x<Get_NX(); i++, x++)
671 {
672 Set_Value(x, yy, (*pValue & m_Bitmask[i]) == 0 ? 0.0 : 1.0);
673 }
674 }
675 }
676 }
677 }
678
679 //-----------------------------------------------------
680 else
681 {
682 int nValueBytes = (int)SG_Data_Type_Get_Size(File_Type);
683 int nLineBytes = Get_NX() * nValueBytes;
684
685 if( m_Type == File_Type && !is_Cached() && !bSwapBytes )
686 {
687 for(int y=0; y<Get_NY() && !Stream.is_EOF() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
688 {
689 Stream.Read(m_Values[bFlip ? Get_NY() - y - 1 : y], nLineBytes);
690 }
691 }
692 else
693 {
694 CSG_Array Line(1, nLineBytes);
695
696 for(int y=0; y<Get_NY() && !Stream.is_EOF() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
697 {
698 Stream.Read(Line.Get_Array(), nLineBytes);
699
700 char *pValue = (char *)Line.Get_Array();
701
702 for(int x=0, yy=bFlip ? Get_NY()-y-1 : y; x<Get_NX(); x++, pValue+=nValueBytes)
703 {
704 if( bSwapBytes )
705 {
706 _Swap_Bytes(pValue, nValueBytes);
707 }
708
709 switch( File_Type )
710 {
711 case SG_DATATYPE_Byte : Set_Value(x, yy, *(BYTE *)pValue, false); break;
712 case SG_DATATYPE_Char : Set_Value(x, yy, *(char *)pValue, false); break;
713 case SG_DATATYPE_Word : Set_Value(x, yy, *(WORD *)pValue, false); break;
714 case SG_DATATYPE_Short : Set_Value(x, yy, *(short *)pValue, false); break;
715 case SG_DATATYPE_DWord : Set_Value(x, yy, *(DWORD *)pValue, false); break;
716 case SG_DATATYPE_Int : Set_Value(x, yy, *(int *)pValue, false); break;
717 case SG_DATATYPE_Float : Set_Value(x, yy, *(float *)pValue, false); break;
718 case SG_DATATYPE_Double: Set_Value(x, yy, *(double *)pValue, false); break;
719 default: break;
720 }
721 }
722 }
723 }
724 }
725
726 //-----------------------------------------------------
727 return( true );
728}
729
730//---------------------------------------------------------
731bool CSG_Grid::_Save_Binary(CSG_File &Stream, TSG_Data_Type File_Type, bool bFlip, bool bSwapBytes)
732{
733 //-----------------------------------------------------
734 if( !Stream.is_Writing() || !is_Valid() )
735 {
736 return( false );
737 }
738
740
741 //-----------------------------------------------------
742 if( File_Type == SG_DATATYPE_Bit )
743 {
744 int nLineBytes = Get_NX() / 8 + 1;
745
746 if( m_Type == File_Type && !is_Cached() )
747 {
748 for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
749 {
750 Stream.Write((char *)m_Values[bFlip ? Get_NY() - y - 1 : y], sizeof(char), nLineBytes);
751 }
752 }
753 else
754 {
755 CSG_Array Line(1, nLineBytes);
756
757 for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
758 {
759 char *pValue = (char *)Line.Get_Array();
760
761 for(int x=0, yy=bFlip ? Get_NY()-y-1 : y; x<Get_NX(); pValue++)
762 {
763 for(int i=0; i<8 && x<Get_NX(); i++, x++)
764 {
765 *pValue = asChar(x, yy) != 0.0 ? *pValue | m_Bitmask[i] : *pValue & (~m_Bitmask[i]);
766 }
767 }
768
769 Stream.Write(Line.Get_Array(), nLineBytes);
770 }
771 }
772 }
773
774 //-----------------------------------------------------
775 else
776 {
777 int nValueBytes = (int)SG_Data_Type_Get_Size(File_Type);
778 int nLineBytes = Get_NX() * nValueBytes;
779
780 if( m_Type == File_Type && !is_Cached() && !bSwapBytes )
781 {
782 for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
783 {
784 Stream.Write((char *)m_Values[bFlip ? Get_NY() - y - 1 : y], nLineBytes);
785 }
786 }
787 else
788 {
789 CSG_Array Line(1, nLineBytes);
790
791 for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
792 {
793 char *pValue = (char *)Line.Get_Array();
794
795 for(int x=0, yy=bFlip ? Get_NY()-y-1 : y; x<Get_NX(); x++, pValue+=nValueBytes)
796 {
797 switch( File_Type )
798 {
799 case SG_DATATYPE_Byte : *(BYTE *)pValue = asByte (x, yy, false); break;
800 case SG_DATATYPE_Char : *(char *)pValue = asChar (x, yy, false); break;
801 case SG_DATATYPE_Word : *(WORD *)pValue = asShort (x, yy, false); break;
802 case SG_DATATYPE_Short : *(short *)pValue = asShort (x, yy, false); break;
803 case SG_DATATYPE_DWord : *(DWORD *)pValue = asInt (x, yy, false); break;
804 case SG_DATATYPE_Int : *(int *)pValue = asInt (x, yy, false); break;
805 case SG_DATATYPE_Float : *(float *)pValue = asFloat (x, yy, false); break;
806 case SG_DATATYPE_Double: *(double *)pValue = asDouble(x, yy, false); break;
807 default: break;
808 }
809
810 if( bSwapBytes )
811 {
812 _Swap_Bytes(pValue, nValueBytes);
813 }
814 }
815
816 Stream.Write(Line.Get_Array(), nLineBytes);
817 }
818 }
819 }
820
821 //-----------------------------------------------------
822 return( true );
823}
824
825
827// //
828// ASCII //
829// //
831
832//---------------------------------------------------------
833bool CSG_Grid::_Load_ASCII(CSG_File &Stream, bool bCached, bool bFlip)
834{
835 if( !Stream.is_Reading() || !_Memory_Create(bCached) )
836 {
837 return( false );
838 }
839
841
842 for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
843 {
844 for(int x=0, yy=bFlip ? Get_NY()-y-1 : y; x<Get_NX(); x++)
845 {
846 Set_Value(x, yy, Stream.Scan_Double());
847 }
848 }
849
850 return( true );
851}
852
853//---------------------------------------------------------
854bool CSG_Grid::_Save_ASCII(CSG_File &Stream, bool bFlip)
855{
856 if( !Stream.is_Writing() || !is_Valid() )
857 {
858 return( false );
859 }
860
862
863 for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
864 {
865 for(int x=0, yy=bFlip ? Get_NY()-y-1 : y; x<Get_NX(); x++)
866 {
867 Stream.Printf("%lf ", asDouble(x, yy));
868 }
869
870 Stream.Printf("\n");
871 }
872
873 return( true );
874}
875
876
878// //
880
881//---------------------------------------------------------
882bool CSG_Grid::_Load_Surfer(const CSG_String &File, bool bCached, bool bLoadData)
883{
884 const float NoData = 1.70141e38f;
885
886 if( !SG_File_Cmp_Extension(File, "grd") )
887 {
888 return( false );
889 }
890
891 //-----------------------------------------------------
892 CSG_File Stream;
893
894 if( !Stream.Open(File, SG_FILE_R, true) )
895 {
896 return( false );
897 }
898
899 char Identifier[4]; Stream.Read(Identifier, sizeof(char), 4);
900
901 //-----------------------------------------------------
902 if( !strncmp(Identifier, "DSBB", 4) ) // Binary...
903 {
904 short nx, ny; double d; CSG_Rect r;
905
906 Stream.Read(&nx , sizeof(short ));
907 Stream.Read(&ny , sizeof(short ));
908 Stream.Read(&r.xMin, sizeof(double));
909 Stream.Read(&r.xMax, sizeof(double));
910 Stream.Read(&r.yMin, sizeof(double));
911 Stream.Read(&r.yMax, sizeof(double));
912 Stream.Read(&d , sizeof(double)); // zMin, we ignore...
913 Stream.Read(&d , sizeof(double)); // zMax, we ignore...
914
915 d = (r.xMax - r.xMin) / (nx - 1.);
916 // d = (r.yMax - r.yMin) / (ny - 1.); // we could proof for equal cellsize in direction of y...
917
918 //-------------------------------------------------
919 if( !Create(SG_DATATYPE_Float, nx, ny, d, r.xMin, r.yMin, bCached) || Stream.is_EOF() )
920 {
921 return( false );
922 }
923
924 //-------------------------------------------------
925 if( bLoadData )
926 {
927 CSG_Array Line(sizeof(float), Get_NX()); float *Values = (float *)Line.Get_Array();
928
929 for(int y=0; y<Get_NY() && !Stream.is_EOF() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
930 {
931 Stream.Read(Values, sizeof(float), Get_NX());
932
933 for(int x=0; x<Get_NX(); x++)
934 {
935 if( Values[x] == NoData )
936 {
937 Set_NoData(x, y);
938 }
939 else
940 {
941 Set_Value(x, y, Values[x]);
942 }
943 }
944 }
945 }
946
947 Get_MetaData().Add_Child("SURFER_GRID", "Surfer Grid (Binary)");
948 }
949
950 //-----------------------------------------------------
951 else if( !strncmp(Identifier, "DSAA", 4) ) // ASCII...
952 {
953 int nx = Stream.Scan_Int ();
954 int ny = Stream.Scan_Int ();
955 double xMin = Stream.Scan_Double();
956 double xMax = Stream.Scan_Double();
957 double yMin = Stream.Scan_Double(); Stream.Scan_Double();
958 // double yMax = Stream.Scan_Double();
959 double dx = Stream.Scan_Double(); Stream.Scan_Double();
960 // double dy = Stream.Scan_Double();
961
962 dx = (xMax - xMin) / (nx - 1.);
963 // dy = (yMax - yMin) / (ny - 1.); // we could proof for equal cellsize in direction of y...
964
965 //-------------------------------------------------
966 if( !Create(SG_DATATYPE_Float, nx, ny, dx, xMin, yMin, bCached) || Stream.is_EOF() )
967 {
968 return( false );
969 }
970
971 //-------------------------------------------------
972 if( bLoadData )
973 {
974 for(int y=0; y<Get_NY() && !Stream.is_EOF() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
975 {
976 for(int x=0; x<Get_NX(); x++)
977 {
978 double Value;
979
980 if( Stream.Scan(Value) && Value != NoData )
981 {
982 Set_Value(x, y, Value);
983 }
984 else
985 {
986 Set_NoData(x, y);
987 }
988 }
989 }
990 }
991
992 Get_MetaData().Add_Child("SURFER_GRID", "Surfer Grid (ASCII)");
993 }
994
995 //-------------------------------------------------
996 else // no Surfer Grid File (does not start with 'DSBB' or 'DSAA' sequence)!
997 {
998 return( false );
999 }
1000
1002
1003 Set_File_Name(File);
1004 Load_MetaData(File);
1005
1006 return( true );
1007}
1008
1009
1011// //
1012// //
1013// //
1015
1016//---------------------------------------------------------
1018{
1019 _On_Construction();
1020}
1021
1022void CSG_Grid_File_Info::_On_Construction(void)
1023{
1024 m_Name .Clear();
1026 m_Unit .Clear();
1027 m_System .Assign(0.0, 0.0, 0.0, 0, 0);
1028 m_Type = SG_DATATYPE_Float; // defaults to float
1029 m_zScale = 1.0;
1030 m_zOffset = 0;
1031 m_NoData[0] = -99999.0;
1032 m_NoData[1] = -99999.0;
1033 m_Data_File .Clear();
1034 m_bFlip = false;
1035 m_bSwapBytes = false;
1036 m_Offset = 0;
1038}
1039
1040//---------------------------------------------------------
1045
1047{
1048 m_Name = Info.m_Name;
1050 m_Unit = Info.m_Unit;
1051 m_System = Info.m_System;
1052 m_Type = Info.m_Type;
1053 m_zScale = Info.m_zScale;
1054 m_zOffset = Info.m_zOffset;
1055 m_NoData[0] = Info.m_NoData[0];
1056 m_NoData[1] = Info.m_NoData[1];
1057 m_Data_File = Info.m_Data_File;
1058 m_bFlip = Info.m_bFlip;
1060 m_Offset = Info.m_Offset;
1062
1063 return( true );
1064}
1065
1066//---------------------------------------------------------
1068{
1069 Create(Grid);
1070}
1071
1073{
1074 m_Name = Grid.Get_Name();
1076 m_Unit = Grid.Get_Unit();
1077 m_System = Grid.Get_System();
1078 m_Type = Grid.Get_Type();
1079 m_zScale = Grid.Get_Scaling();
1080 m_zOffset = Grid.Get_Offset();
1081 m_NoData[0] = Grid.Get_NoData_Value();
1082 m_NoData[1] = Grid.Get_NoData_Value(true);
1083 m_Data_File .Clear();
1084 m_bFlip = false;
1085 m_bSwapBytes = false;
1086 m_Offset = 0;
1088
1089 return( true );
1090}
1091
1092//---------------------------------------------------------
1094{
1095 Create(File);
1096}
1097
1099{
1100 if( !SG_File_Cmp_Extension(File, "sg-grd-z") )
1101 {
1102 if( SG_File_Cmp_Extension(File, "sgrd")
1103 || SG_File_Cmp_Extension(File, "sg-grd") )
1104 {
1105 CSG_File Stream(File, SG_FILE_R, false);
1106
1107 return( Create(Stream) );
1108 }
1109
1110 return( false );
1111 }
1112
1113 //-----------------------------------------------------
1114 CSG_Archive Stream(File, SG_FILE_R);
1115
1116 if( Stream.is_Reading() )
1117 {
1118 CSG_String Archive_File(SG_File_Get_Name(File, false) + ".");
1119
1120 if( !Stream.Get_File(Archive_File + "sgrd" )
1121 && !Stream.Get_File(Archive_File + "sg-grd") )
1122 {
1123 for(size_t i=0; i<Stream.Get_File_Count(); i++)
1124 {
1125 if( SG_File_Cmp_Extension(Stream.Get_File_Name(i), "sgrd" )
1126 || SG_File_Cmp_Extension(Stream.Get_File_Name(i), "sg-grd") )
1127 {
1128 Stream.Get_File(Stream.Get_File_Name(i));
1129 break;
1130 }
1131 }
1132 }
1133
1134 return( Create(Stream) );
1135 }
1136
1137 //-----------------------------------------------------
1138 return( false );
1139}
1140
1141//---------------------------------------------------------
1143{
1144 Create(Stream);
1145}
1146
1148{
1149 _On_Construction();
1150
1151 //-----------------------------------------------------
1152 if( !Stream.is_Reading() )
1153 {
1154 return( false );
1155 }
1156
1157 //-----------------------------------------------------
1158 sLong NX = 0, NY = 0; double Cellsize = 0., xMin = 0., yMin = 0.;
1159
1160 for(int i=0; i<256 && !Stream.is_EOF(); i++)
1161 {
1162 CSG_String Value;
1163
1164 switch( _Get_Key(Stream, Value) )
1165 {
1166 case GRID_FILE_KEY_NAME : m_Name = Value; break;
1167 case GRID_FILE_KEY_DESCRIPTION : m_Description = Value; break;
1168 case GRID_FILE_KEY_UNITNAME : m_Unit = Value; break;
1169
1170 case GRID_FILE_KEY_CELLCOUNT_X : NX = Value.asInt (); break;
1171 case GRID_FILE_KEY_CELLCOUNT_Y : NY = Value.asInt (); break;
1172 case GRID_FILE_KEY_POSITION_XMIN : xMin = Value.asDouble(); break;
1173 case GRID_FILE_KEY_POSITION_YMIN : yMin = Value.asDouble(); break;
1174 case GRID_FILE_KEY_CELLSIZE : Cellsize = Value.asDouble(); break;
1175
1176 case GRID_FILE_KEY_Z_FACTOR : m_zScale = Value.asDouble(); break;
1177 case GRID_FILE_KEY_Z_OFFSET : m_zOffset = Value.asDouble(); break;
1178 case GRID_FILE_KEY_NODATA_VALUE : m_NoData[0] = Value.asDouble();
1179 Value = Value.AfterFirst(';'); m_NoData[1] = Value.is_Empty() ? m_NoData[0] : Value.asDouble(); break;
1180
1181 case GRID_FILE_KEY_DATAFILE_OFFSET: m_Offset = Value.asInt (); break;
1183 case GRID_FILE_KEY_TOPTOBOTTOM : m_bFlip = Value.Find(GRID_FILE_KEY_TRUE) >= 0; break;
1184
1186 if( SG_File_Get_Path(Value).Length() > 0 )
1187 {
1188 m_Data_File = Value;
1189 }
1190 else
1191 {
1193 }
1194 break;
1195
1197 {
1198 for(int i=0; i<SG_DATATYPE_Undefined; i++)
1199 {
1200 if( Value.Find(gSG_Data_Type_Identifier[i]) >= 0 )
1201 {
1202 m_Type = (TSG_Data_Type)i;
1203
1204 break;
1205 }
1206 }
1207 }
1208 break;
1209 }
1210 }
1211
1212 //-----------------------------------------------------
1213 return( m_System.Assign(Cellsize, xMin, yMin, (int)NX, (int)NY) );
1214}
1215
1216//---------------------------------------------------------
1217int CSG_Grid_File_Info::_Get_Key(CSG_File &Stream, CSG_String &Value)
1218{
1219 CSG_String sLine; int i;
1220
1221 if( Stream.Read_Line(sLine) && (i = sLine.Find('=')) > 0 )
1222 {
1223 Value = sLine.AfterFirst('='); Value.Trim();
1224
1225 sLine.Remove(i);
1226
1227 for(i=0; i<GRID_FILE_KEY_Count; i++)
1228 {
1230
1231 if( s.Find(sLine.Left(s.Length())) >= 0 )
1232 {
1233 return( i );
1234 }
1235 }
1236 }
1237
1238 return( -1 );
1239}
1240
1241
1243// //
1245
1246//---------------------------------------------------------
1247bool CSG_Grid_File_Info::Save(const CSG_String &File, bool bBinary)
1248{
1249 return( Save(CSG_File(File, SG_FILE_W, false), bBinary) );
1250}
1251
1252//---------------------------------------------------------
1253bool CSG_Grid_File_Info::Save(const CSG_File &Stream, bool bBinary)
1254{
1255 if( !Stream.is_Writing() )
1256 {
1257 return( false );
1258 }
1259
1260#define GRID_FILE_PRINT(Key, Val) { CSG_String s(gSG_Grid_File_Key_Names[Key]); s += "\t= " + Val + "\n"; Stream.Write(s); }
1261
1267#ifdef WORDS_BIGENDIAN
1269#else
1271#endif
1281
1282 return( true );
1283}
1284
1285//---------------------------------------------------------
1286bool CSG_Grid_File_Info::Save(const CSG_String &File, const CSG_Grid &Grid, bool bBinary)
1287{
1288 CSG_Grid_File_Info Info(Grid);
1289
1290 return( Info.Save(File, bBinary) );
1291}
1292
1293//---------------------------------------------------------
1294bool CSG_Grid_File_Info::Save(const CSG_File &Stream, const CSG_Grid &Grid, bool bBinary)
1295{
1296 CSG_Grid_File_Info Info(Grid);
1297
1298 return( Info.Save(Stream, bBinary) );
1299}
1300
1301
1303// //
1305
1306//---------------------------------------------------------
1308{
1309 CSG_File Stream;
1310
1311 return( m_Projection.is_Okay() && Stream.Open(File + ".aux.xml", SG_FILE_W, false) && Save_AUX_XML(Stream) );
1312}
1313
1314//---------------------------------------------------------
1316{
1317 if( m_Projection.is_Okay() && Stream.is_Writing() ) // store srs information that is recognized by ArcGIS
1318 {
1319 Stream.Write("<PAMDataset>\n<SRS>");
1320 Stream.Write(m_Projection.Get_WKT());
1321 Stream.Write("</SRS>\n</PAMDataset>\n");
1322
1323 return( true );
1324 }
1325
1326 return( false );
1327}
1328
1329
1331// //
1332// //
1333// //
1335
1336//---------------------------------------------------------
void SG_UI_Msg_Add_Error(const char *Message)
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:199
@ SG_UI_MSG_STYLE_FAILURE
Definition api_core.h:1636
@ SG_UI_MSG_STYLE_SUCCESS
Definition api_core.h:1635
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:1619
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:1247
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:1307
CSG_String m_Description
Definition grid.h:473
bool Create(const CSG_Grid_File_Info &Info)
Definition grid_io.cpp:1046
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 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:169
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:1659
virtual bool On_Before_Execution(void)
Definition tool.h:242
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
#define asDouble(i)
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)