SAGA API Version 9.12
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 {
162
163 if( SG_File_Cmp_Extension(File, "sg-grd-z") ) { Format = GRID_FILE_FORMAT_Compressed; }
164 if( SG_File_Cmp_Extension(File, "sg-grd" ) ) { Format = GRID_FILE_FORMAT_Binary ; }
165 if( SG_File_Cmp_Extension(File, "sgrd" ) ) { Format = GRID_FILE_FORMAT_Binary_old; }
166 if( SG_File_Cmp_Extension(File, "tif" ) ) { Format = GRID_FILE_FORMAT_GeoTIFF ; }
167 }
168
169 if( SG_File_Get_Extension(File).is_Empty() )
170 {
171 return( Save(File + "." + SG_Grid_Get_File_Extension(Format)) );
172 }
173
174 //-----------------------------------------------------
175 SG_UI_Msg_Add(CSG_String::Format("%s %s: %s...", _TL("Saving"), _TL("grid"), File.c_str()), true);
176
177 bool bResult = false;
178
179 switch( Format )
180 {
181 default:
182 bResult = _Save_Native(File, (TSG_Grid_File_Format)Format);
183 break;
184
186 bResult = _Save_Compressed(File);
187 break;
188
190 SG_UI_Msg_Lock(true);
191 SG_RUN_TOOL(bResult, "io_gdal", 2, // Export GeoTIFF
192 SG_TOOL_PARAMLIST_ADD("GRIDS" , this)
193 && SG_TOOL_PARAMETER_SET("FILE" , File)
194 && 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
195 );
196 SG_UI_Msg_Lock(false);
197 break;
198 }
199
201
202 //-----------------------------------------------------
203 if( bResult )
204 {
205 Set_Modified(false);
206
207 Set_File_Name(File, true);
208
210
211 return( true );
212 }
213
214 SG_UI_Msg_Add(_TL("failed"), false, SG_UI_MSG_STYLE_FAILURE);
215
216 return( false );
217}
218
219
221// //
222// //
223// //
225
226//---------------------------------------------------------
227bool CSG_Grid::_Load_External(const CSG_String &File, bool bCached, bool bLoadData)
228{
229 bool bResult = false; CSG_Data_Manager Manager; CSG_Tool *pTool = NULL;
230
231 SG_UI_Msg_Lock(true);
232
233 //-----------------------------------------------------
234 // Image Import
235
236 if( (SG_File_Cmp_Extension(File, "bmp")
237 || SG_File_Cmp_Extension(File, "gif")
238 || SG_File_Cmp_Extension(File, "jpg")
239 || SG_File_Cmp_Extension(File, "png")
240 || SG_File_Cmp_Extension(File, "pcx") )
241 && !bResult && (pTool = SG_Get_Tool_Library_Manager().Create_Tool("io_grid_image", 1)) != NULL )
242 {
243 pTool->Settings_Push(&Manager);
244
245 bResult = pTool->Set_Parameter("FILE", File) && pTool->Execute();
246
248 }
249
250 //-----------------------------------------------------
251 // GDAL Import
252
253 if( !bResult && (pTool = SG_Get_Tool_Library_Manager().Create_Tool("io_gdal", 0)) != NULL )
254 {
255 pTool->Settings_Push(&Manager);
256
257 bResult = pTool->Set_Parameter("FILES" , File)
258 && pTool->Set_Parameter("MULTIPLE", 0 ) // output as single grid(s)
259 && pTool->Execute();
260
262 }
263
264 SG_UI_Msg_Lock(false);
265
266 //-----------------------------------------------------
267 if( bResult && Manager.Grid().Count() && Manager.Grid(0).is_Valid() )
268 {
269 CSG_Grid *pGrid = Manager.Grid(0).asGrid();
270
271 if( pGrid->is_Cached() )
272 {
273 return( Create(*pGrid) );
274 }
275
276 Set_File_Name(File, false);
277
278 Set_Name (pGrid->Get_Name());
280
281 m_System = pGrid->m_System;
282 m_Type = pGrid->m_Type;
283 m_Values = pGrid->m_Values; pGrid->m_Values = NULL; // take ownership of data array
284
285 m_zOffset = pGrid->m_zOffset;
286 m_zScale = pGrid->m_zScale;
287 m_Unit = pGrid->m_Unit;
288
289 m_nBytes_Value = pGrid->m_nBytes_Value;
290 m_nBytes_Line = pGrid->m_nBytes_Line;
291
292 Get_MetaData () = pGrid->Get_MetaData ();
293 Get_Projection() = pGrid->Get_Projection();
294
296
297 return( true );
298 }
299
300 return( false );
301}
302
303//---------------------------------------------------------
304bool CSG_Grid::_Load_PGSQL(const CSG_String &File, bool bCached, bool bLoadData)
305{
306 bool bResult = false;
307
308 if( File.BeforeFirst(':').Cmp("PGSQL") == 0 ) // database source
309 {
310 CSG_String s(File);
311
312 s = s.AfterFirst(':'); CSG_String Host (s.BeforeFirst(':'));
313 s = s.AfterFirst(':'); CSG_String Port (s.BeforeFirst(':'));
314 s = s.AfterFirst(':'); CSG_String DBase(s.BeforeFirst(':'));
315 s = s.AfterFirst(':'); CSG_String Table(s.BeforeFirst(':'));
316 s = s.AfterFirst(':'); CSG_String rid (s.BeforeFirst(':').AfterFirst('='));
317
318 CSG_Tool *pTool = SG_Get_Tool_Library_Manager().Create_Tool("db_pgsql", 33); // CPGIS_Raster_Load_Band
319
320 if( pTool )
321 {
323
324 CSG_String Connection(DBase + " [" + Host + ":" + Port + "]");
325
326 bResult = pTool->Set_Manager(NULL) && pTool->On_Before_Execution()
327 && pTool->Set_Parameter("CONNECTION", Connection)
328 && pTool->Set_Parameter("DB_TABLE" , Table )
329 && pTool->Set_Parameter("RID" , rid )
330 && pTool->Set_Parameter("GRID" , this )
331 && pTool->Execute();
332
334
336 }
337 }
338
339 return( bResult );
340}
341
342
344// //
345// Native //
346// //
348
349//---------------------------------------------------------
350bool CSG_Grid::_Load_Native(const CSG_String &File, bool bCached, bool bLoadData)
351{
352 CSG_Grid_File_Info Info;
353
354 if( !Info.Create(File) )
355 {
356 return( false );
357 }
358
359 Set_File_Name(File, true);
360
361 Set_Name (Info.m_Name);
363 Set_Unit (Info.m_Unit);
364
365 Set_NoData_Value_Range(Info.m_NoData[0], Info.m_NoData[1]);
366
367 m_System = Info.m_System;
368 m_Type = Info.m_Type;
369 m_zScale = Info.m_zScale;
370 m_zOffset = Info.m_zOffset;
371
372 m_nBytes_Value = SG_Data_Type_Get_Size(m_Type);
373 m_nBytes_Line = m_Type == SG_DATATYPE_Bit ? 1 + Get_NX() / 8 : Get_NX() * m_nBytes_Value;
374
375 Get_Projection().Load(SG_File_Make_Path("", File, "prj"));
376
377 if( !bLoadData )
378 {
379 return( _Memory_Create(bCached) );
380 }
381
382 Load_MetaData(File);
383
384 //-----------------------------------------------------
385 CSG_File Stream;
386
387 if( !SG_Data_Type_is_Numeric(m_Type) ) // ASCII...
388 {
389 if( Stream.Open(Info.m_Data_File , SG_FILE_R, false)
390 || Stream.Open(SG_File_Make_Path("", File, "dat"), SG_FILE_R, false)
391 || Stream.Open(SG_File_Make_Path("", File, "sdat"), SG_FILE_R, false) )
392 {
393 Stream.Seek(Info.m_Offset);
394
395 return( _Load_ASCII(Stream, bCached, Info.m_bFlip) );
396 }
397 }
398
399 //-----------------------------------------------------
400 else // Binary...
401 {
402 if( bCached || _Cache_Check() )
403 {
404 if( _Cache_Create(Info.m_Data_File , m_Type, Info.m_Offset, Info.m_bSwapBytes, Info.m_bFlip)
405 || _Cache_Create(SG_File_Make_Path("", File, "dat"), m_Type, Info.m_Offset, Info.m_bSwapBytes, Info.m_bFlip)
406 || _Cache_Create(SG_File_Make_Path("", File, "sdat"), m_Type, Info.m_Offset, Info.m_bSwapBytes, Info.m_bFlip) )
407 {
408 return( true );
409 }
410 }
411
412 m_Cache_File = Info.m_Data_File ;
413 m_Cache_Offset = Info.m_Offset ;
414 m_Cache_bSwap = Info.m_bSwapBytes;
415 m_Cache_bFlip = Info.m_bFlip ;
416
417 if( _Memory_Create(bCached) )
418 {
419 if( Stream.Open(Info.m_Data_File , SG_FILE_R, true)
420 || Stream.Open(SG_File_Make_Path("", File, "dat"), SG_FILE_R, true)
421 || Stream.Open(SG_File_Make_Path("", File, "sdat"), SG_FILE_R, true) )
422 {
423 Stream.Seek(Info.m_Offset);
424
425 return( _Load_Binary(Stream, m_Type, Info.m_bFlip, Info.m_bSwapBytes) );
426 }
427 }
428 }
429
430 return( false );
431}
432
433//---------------------------------------------------------
434bool CSG_Grid::_Save_Native(const CSG_String &_File, TSG_Grid_File_Format Format)
435{
436#ifdef WORDS_BIGENDIAN
437 bool bBigEndian = true;
438#else
439 bool bBigEndian = false;
440#endif
441
442 CSG_String File(_File);
443
444 bool bBinary;
445
446 if( Format == GRID_FILE_FORMAT_ASCII )
447 {
448 bBinary = false;
449 }
450 else if( Format == GRID_FILE_FORMAT_Binary_old )
451 {
452 bBinary = true; SG_File_Set_Extension(File, "sgrd");
453 }
454 else
455 {
456 bBinary = true; SG_File_Set_Extension(File, "sg-grd");
457 }
458
459 CSG_Grid_File_Info Info(*this);
460
461 if( Info.Save(File, bBinary) )
462 {
463 CSG_File Stream(SG_File_Make_Path("", File, "sdat"), SG_FILE_W, true);
464
465 if( bBinary ? _Save_Binary(Stream, m_Type, false, bBigEndian) : _Save_ASCII (Stream) )
466 {
467 Save_MetaData(File);
468
469 Get_Projection().Save(SG_File_Make_Path("", File, "prj"));
470
471 Info.Save_AUX_XML(SG_File_Make_Path("", File, "sdat"));
472
473 return( true );
474 }
475 }
476
477 return( false );
478}
479
480
482// //
483// Compressed //
484// //
486
487//---------------------------------------------------------
488bool CSG_Grid::_Load_Compressed(const CSG_String &_File, bool bCached, bool bLoadData)
489{
490 Set_File_Name(_File, true);
491
492 CSG_Archive Stream(_File, SG_FILE_R);
493
494 if( !Stream.is_Reading() )
495 {
496 return( false );
497 }
498
499 //-----------------------------------------------------
500 CSG_String File(SG_File_Get_Name(_File, false) + ".");
501
502 if( !Stream.Get_File(File + "sgrd" )
503 && !Stream.Get_File(File + "sg-grd") )
504 {
505 File.Clear();
506
507 for(size_t i=0; i<Stream.Get_File_Count(); i++)
508 {
509 if( SG_File_Cmp_Extension(Stream.Get_File_Name(i), "sgrd" )
510 || SG_File_Cmp_Extension(Stream.Get_File_Name(i), "sg-grd") )
511 {
512 File = SG_File_Get_Name(Stream.Get_File_Name(i), false) + ".";
513 Stream.Get_File(Stream.Get_File_Name(i));
514 break;
515 }
516 }
517
518 if( File.is_Empty() )
519 {
520 return( false );
521 }
522 }
523
524 //-----------------------------------------------------
525 CSG_Grid_File_Info Info;
526
527 if( !Info.Create(Stream) )
528 {
529 return( false );
530 }
531
532 Set_Name (Info.m_Name);
534 Set_Unit (Info.m_Unit);
535
536 Set_NoData_Value_Range(Info.m_NoData[0], Info.m_NoData[1]);
537
538 m_System = Info.m_System;
539 m_Type = Info.m_Type;
540 m_zScale = Info.m_zScale;
541 m_zOffset = Info.m_zOffset;
542
543 m_nBytes_Value = SG_Data_Type_Get_Size(m_Type);
544 m_nBytes_Line = m_Type == SG_DATATYPE_Bit ? 1 + Get_NX() / 8 : Get_NX() * m_nBytes_Value;
545
546 if( Stream.Get_File(File + "prj") )
547 {
548 Get_Projection().Load(Stream);
549 }
550
551 if( !bLoadData )
552 {
553 return( _Memory_Create(bCached) );
554 }
555
556 if( Stream.Get_File(File + "mgrd") )
557 {
558 Load_MetaData(Stream);
559 }
560
561 //-----------------------------------------------------
562 if( _Cache_Check() )
563 {
564 bCached = true;
565 }
566
567 return( Stream.Get_File(File + "sdat") && _Memory_Create(bCached)
568 && _Load_Binary(Stream, m_Type, Info.m_bFlip, Info.m_bSwapBytes)
569 );
570}
571
572//---------------------------------------------------------
573bool CSG_Grid::_Save_Compressed(const CSG_String &_File)
574{
575#ifdef WORDS_BIGENDIAN
576 bool bBigEndian = true;
577#else
578 bool bBigEndian = false;
579#endif
580
581 CSG_Archive Stream(_File, SG_FILE_W);
582
583 if( Stream.is_Writing() )
584 {
585 CSG_String File(SG_File_Get_Name(_File, false) + ".");
586
587 CSG_Grid_File_Info Info(*this);
588
589 if( Stream.Add_File(File + "sgrd") && Info.Save(Stream, true)
590 && Stream.Add_File(File + "sdat") && _Save_Binary(Stream, m_Type, false, bBigEndian) )
591 {
592 Stream.Add_File(File + "mgrd" ); Save_MetaData(Stream);
593 Stream.Add_File(File + "prj" ); Get_Projection().Save(Stream);
594 Stream.Add_File(File + "sdat.aux.xml"); Info.Save_AUX_XML(Stream);
595
596 return( true );
597 }
598 }
599
600 return( false );
601}
602
603
605// //
606// Binary //
607// //
609
610//---------------------------------------------------------
611void CSG_Grid::_Swap_Bytes(char *Bytes, int nBytes) const
612{
613 if( nBytes == 2 )
614 {
615 uint16_t val, valSwapped;
616 memcpy(&val, Bytes, nBytes);
617 valSwapped = ntohs(val);
618 memcpy(Bytes, &valSwapped, nBytes);
619 }
620 else if( nBytes == 4 )
621 {
622 uint32_t val, valSwapped;
623 memcpy(&val, Bytes, nBytes);
624 valSwapped = ntohl(val);
625 memcpy(Bytes, &valSwapped, nBytes);
626 }
627}
628
629//---------------------------------------------------------
630bool CSG_Grid::_Load_Binary(CSG_File &Stream, TSG_Data_Type File_Type, bool bFlip, bool bSwapBytes)
631{
632 if( !Stream.is_Open() || !is_Valid() )
633 {
634 return( false );
635 }
636
638
639 //-----------------------------------------------------
640 if( File_Type == SG_DATATYPE_Bit )
641 {
642 int nLineBytes = Get_NX() / 8 + 1;
643
644 if( m_Type == File_Type && !is_Cached() )
645 {
646 for(int y=0; y<Get_NY() && !Stream.is_EOF() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
647 {
648 Stream.Read(m_Values[bFlip ? Get_NY() - y - 1 : y], sizeof(char), nLineBytes);
649 }
650 }
651 else
652 {
653 CSG_Array Line(1, nLineBytes);
654
655 for(int y=0; y<Get_NY() && !Stream.is_EOF() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
656 {
657 Stream.Read(Line.Get_Array(), nLineBytes);
658
659 char *pValue = (char *)Line.Get_Array();
660
661 for(int x=0, yy=bFlip ? Get_NY()-y-1 : y; x<Get_NX(); pValue++)
662 {
663 for(int i=0; i<8 && x<Get_NX(); i++, x++)
664 {
665 Set_Value(x, yy, (*pValue & m_Bitmask[i]) == 0 ? 0.0 : 1.0);
666 }
667 }
668 }
669 }
670 }
671
672 //-----------------------------------------------------
673 else
674 {
675 int nValueBytes = (int)SG_Data_Type_Get_Size(File_Type);
676 int nLineBytes = Get_NX() * nValueBytes;
677
678 if( m_Type == File_Type && !is_Cached() && !bSwapBytes )
679 {
680 for(int y=0; y<Get_NY() && !Stream.is_EOF() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
681 {
682 Stream.Read(m_Values[bFlip ? Get_NY() - y - 1 : y], nLineBytes);
683 }
684 }
685 else
686 {
687 CSG_Array Line(1, nLineBytes);
688
689 for(int y=0; y<Get_NY() && !Stream.is_EOF() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
690 {
691 Stream.Read(Line.Get_Array(), nLineBytes);
692
693 char *pValue = (char *)Line.Get_Array();
694
695 for(int x=0, yy=bFlip ? Get_NY()-y-1 : y; x<Get_NX(); x++, pValue+=nValueBytes)
696 {
697 if( bSwapBytes )
698 {
699 _Swap_Bytes(pValue, nValueBytes);
700 }
701
702 switch( File_Type )
703 {
704 case SG_DATATYPE_Byte : Set_Value(x, yy, *(BYTE *)pValue, false); break;
705 case SG_DATATYPE_Char : Set_Value(x, yy, *(char *)pValue, false); break;
706 case SG_DATATYPE_Word : Set_Value(x, yy, *(WORD *)pValue, false); break;
707 case SG_DATATYPE_Short : Set_Value(x, yy, *(short *)pValue, false); break;
708 case SG_DATATYPE_DWord : Set_Value(x, yy, *(DWORD *)pValue, false); break;
709 case SG_DATATYPE_Int : Set_Value(x, yy, *(int *)pValue, false); break;
710 case SG_DATATYPE_Float : Set_Value(x, yy, *(float *)pValue, false); break;
711 case SG_DATATYPE_Double: Set_Value(x, yy, *(double *)pValue, false); break;
712 default: break;
713 }
714 }
715 }
716 }
717 }
718
719 //-----------------------------------------------------
720 return( true );
721}
722
723//---------------------------------------------------------
724bool CSG_Grid::_Save_Binary(CSG_File &Stream, TSG_Data_Type File_Type, bool bFlip, bool bSwapBytes)
725{
726 //-----------------------------------------------------
727 if( !Stream.is_Writing() || !is_Valid() )
728 {
729 return( false );
730 }
731
733
734 //-----------------------------------------------------
735 if( File_Type == SG_DATATYPE_Bit )
736 {
737 int nLineBytes = Get_NX() / 8 + 1;
738
739 if( m_Type == File_Type && !is_Cached() )
740 {
741 for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
742 {
743 Stream.Write((char *)m_Values[bFlip ? Get_NY() - y - 1 : y], sizeof(char), nLineBytes);
744 }
745 }
746 else
747 {
748 CSG_Array Line(1, nLineBytes);
749
750 for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
751 {
752 char *pValue = (char *)Line.Get_Array();
753
754 for(int x=0, yy=bFlip ? Get_NY()-y-1 : y; x<Get_NX(); pValue++)
755 {
756 for(int i=0; i<8 && x<Get_NX(); i++, x++)
757 {
758 *pValue = asChar(x, yy) != 0.0 ? *pValue | m_Bitmask[i] : *pValue & (~m_Bitmask[i]);
759 }
760 }
761
762 Stream.Write(Line.Get_Array(), nLineBytes);
763 }
764 }
765 }
766
767 //-----------------------------------------------------
768 else
769 {
770 int nValueBytes = (int)SG_Data_Type_Get_Size(File_Type);
771 int nLineBytes = Get_NX() * nValueBytes;
772
773 if( m_Type == File_Type && !is_Cached() && !bSwapBytes )
774 {
775 for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
776 {
777 Stream.Write((char *)m_Values[bFlip ? Get_NY() - y - 1 : y], nLineBytes);
778 }
779 }
780 else
781 {
782 CSG_Array Line(1, nLineBytes);
783
784 for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
785 {
786 char *pValue = (char *)Line.Get_Array();
787
788 for(int x=0, yy=bFlip ? Get_NY()-y-1 : y; x<Get_NX(); x++, pValue+=nValueBytes)
789 {
790 switch( File_Type )
791 {
792 case SG_DATATYPE_Byte : *(BYTE *)pValue = asByte (x, yy, false); break;
793 case SG_DATATYPE_Char : *(char *)pValue = asChar (x, yy, false); break;
794 case SG_DATATYPE_Word : *(WORD *)pValue = asShort (x, yy, false); break;
795 case SG_DATATYPE_Short : *(short *)pValue = asShort (x, yy, false); break;
796 case SG_DATATYPE_DWord : *(DWORD *)pValue = asInt (x, yy, false); break;
797 case SG_DATATYPE_Int : *(int *)pValue = asInt (x, yy, false); break;
798 case SG_DATATYPE_Float : *(float *)pValue = asFloat (x, yy, false); break;
799 case SG_DATATYPE_Double: *(double *)pValue = asDouble(x, yy, false); break;
800 default: break;
801 }
802
803 if( bSwapBytes )
804 {
805 _Swap_Bytes(pValue, nValueBytes);
806 }
807 }
808
809 Stream.Write(Line.Get_Array(), nLineBytes);
810 }
811 }
812 }
813
814 //-----------------------------------------------------
815 return( true );
816}
817
818
820// //
821// ASCII //
822// //
824
825//---------------------------------------------------------
826bool CSG_Grid::_Load_ASCII(CSG_File &Stream, bool bCached, bool bFlip)
827{
828 if( !Stream.is_Reading() || !_Memory_Create(bCached) )
829 {
830 return( false );
831 }
832
834
835 for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
836 {
837 for(int x=0, yy=bFlip ? Get_NY()-y-1 : y; x<Get_NX(); x++)
838 {
839 Set_Value(x, yy, Stream.Scan_Double());
840 }
841 }
842
843 return( true );
844}
845
846//---------------------------------------------------------
847bool CSG_Grid::_Save_ASCII(CSG_File &Stream, bool bFlip)
848{
849 if( !Stream.is_Writing() || !is_Valid() )
850 {
851 return( false );
852 }
853
855
856 for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
857 {
858 for(int x=0, yy=bFlip ? Get_NY()-y-1 : y; x<Get_NX(); x++)
859 {
860 Stream.Printf("%lf ", asDouble(x, yy));
861 }
862
863 Stream.Printf("\n");
864 }
865
866 return( true );
867}
868
869
871// //
873
874//---------------------------------------------------------
875bool CSG_Grid::_Load_Surfer(const CSG_String &File, bool bCached, bool bLoadData)
876{
877 const float NoData = 1.70141e38f;
878
879 if( !SG_File_Cmp_Extension(File, "grd") )
880 {
881 return( false );
882 }
883
884 //-----------------------------------------------------
885 CSG_File Stream;
886
887 if( !Stream.Open(File, SG_FILE_R, true) )
888 {
889 return( false );
890 }
891
892 char Identifier[4]; Stream.Read(Identifier, sizeof(char), 4);
893
894 //-----------------------------------------------------
895 if( !strncmp(Identifier, "DSBB", 4) ) // Binary...
896 {
897 short nx, ny; double d; CSG_Rect r;
898
899 Stream.Read(&nx , sizeof(short ));
900 Stream.Read(&ny , sizeof(short ));
901 Stream.Read(&r.xMin, sizeof(double));
902 Stream.Read(&r.xMax, sizeof(double));
903 Stream.Read(&r.yMin, sizeof(double));
904 Stream.Read(&r.yMax, sizeof(double));
905 Stream.Read(&d , sizeof(double)); // zMin, we ignore...
906 Stream.Read(&d , sizeof(double)); // zMax, we ignore...
907
908 d = (r.xMax - r.xMin) / (nx - 1.);
909 // d = (r.yMax - r.yMin) / (ny - 1.); // we could proof for equal cellsize in direction of y...
910
911 //-------------------------------------------------
912 if( !Create(SG_DATATYPE_Float, nx, ny, d, r.xMin, r.yMin, bCached) || Stream.is_EOF() )
913 {
914 return( false );
915 }
916
917 //-------------------------------------------------
918 if( bLoadData )
919 {
920 CSG_Array Line(sizeof(float), Get_NX()); float *Values = (float *)Line.Get_Array();
921
922 for(int y=0; y<Get_NY() && !Stream.is_EOF() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
923 {
924 Stream.Read(Values, sizeof(float), Get_NX());
925
926 for(int x=0; x<Get_NX(); x++)
927 {
928 if( Values[x] == NoData )
929 {
930 Set_NoData(x, y);
931 }
932 else
933 {
934 Set_Value(x, y, Values[x]);
935 }
936 }
937 }
938 }
939
940 Get_MetaData().Add_Child("SURFER_GRID", "Surfer Grid (Binary)");
941 }
942
943 //-----------------------------------------------------
944 else if( !strncmp(Identifier, "DSAA", 4) ) // ASCII...
945 {
946 int nx = Stream.Scan_Int ();
947 int ny = Stream.Scan_Int ();
948 double xMin = Stream.Scan_Double();
949 double xMax = Stream.Scan_Double();
950 double yMin = Stream.Scan_Double(); Stream.Scan_Double();
951 // double yMax = Stream.Scan_Double();
952 double dx = Stream.Scan_Double(); Stream.Scan_Double();
953 // double dy = Stream.Scan_Double();
954
955 dx = (xMax - xMin) / (nx - 1.);
956 // dy = (yMax - yMin) / (ny - 1.); // we could proof for equal cellsize in direction of y...
957
958 //-------------------------------------------------
959 if( !Create(SG_DATATYPE_Float, nx, ny, dx, xMin, yMin, bCached) || Stream.is_EOF() )
960 {
961 return( false );
962 }
963
964 //-------------------------------------------------
965 if( bLoadData )
966 {
967 for(int y=0; y<Get_NY() && !Stream.is_EOF() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
968 {
969 for(int x=0; x<Get_NX(); x++)
970 {
971 double Value;
972
973 if( Stream.Scan(Value) && Value != NoData )
974 {
975 Set_Value(x, y, Value);
976 }
977 else
978 {
979 Set_NoData(x, y);
980 }
981 }
982 }
983 }
984
985 Get_MetaData().Add_Child("SURFER_GRID", "Surfer Grid (ASCII)");
986 }
987
988 //-------------------------------------------------
989 else // no Surfer Grid File (does not start with 'DSBB' or 'DSAA' sequence)!
990 {
991 return( false );
992 }
993
995
996 Set_File_Name(File);
997 Load_MetaData(File);
998
999 return( true );
1000}
1001
1002
1004// //
1005// //
1006// //
1008
1009//---------------------------------------------------------
1011{
1012 _On_Construction();
1013}
1014
1015void CSG_Grid_File_Info::_On_Construction(void)
1016{
1017 m_Name .Clear();
1019 m_Unit .Clear();
1020 m_System .Assign(0.0, 0.0, 0.0, 0, 0);
1021 m_Type = SG_DATATYPE_Float; // defaults to float
1022 m_zScale = 1.0;
1023 m_zOffset = 0;
1024 m_NoData[0] = -99999.0;
1025 m_NoData[1] = -99999.0;
1026 m_Data_File .Clear();
1027 m_bFlip = false;
1028 m_bSwapBytes = false;
1029 m_Offset = 0;
1031}
1032
1033//---------------------------------------------------------
1038
1040{
1041 m_Name = Info.m_Name;
1043 m_Unit = Info.m_Unit;
1044 m_System = Info.m_System;
1045 m_Type = Info.m_Type;
1046 m_zScale = Info.m_zScale;
1047 m_zOffset = Info.m_zOffset;
1048 m_NoData[0] = Info.m_NoData[0];
1049 m_NoData[1] = Info.m_NoData[1];
1050 m_Data_File = Info.m_Data_File;
1051 m_bFlip = Info.m_bFlip;
1053 m_Offset = Info.m_Offset;
1055
1056 return( true );
1057}
1058
1059//---------------------------------------------------------
1061{
1062 Create(Grid);
1063}
1064
1066{
1067 m_Name = Grid.Get_Name();
1069 m_Unit = Grid.Get_Unit();
1070 m_System = Grid.Get_System();
1071 m_Type = Grid.Get_Type();
1072 m_zScale = Grid.Get_Scaling();
1073 m_zOffset = Grid.Get_Offset();
1074 m_NoData[0] = Grid.Get_NoData_Value();
1075 m_NoData[1] = Grid.Get_NoData_Value(true);
1076 m_Data_File .Clear();
1077 m_bFlip = false;
1078 m_bSwapBytes = false;
1079 m_Offset = 0;
1081
1082 return( true );
1083}
1084
1085//---------------------------------------------------------
1087{
1088 Create(File);
1089}
1090
1092{
1093 if( !SG_File_Cmp_Extension(File, "sg-grd-z") )
1094 {
1095 if( SG_File_Cmp_Extension(File, "sgrd")
1096 || SG_File_Cmp_Extension(File, "sg-grd") )
1097 {
1098 CSG_File Stream(File, SG_FILE_R, false);
1099
1100 return( Create(Stream) );
1101 }
1102
1103 return( false );
1104 }
1105
1106 //-----------------------------------------------------
1107 CSG_Archive Stream(File, SG_FILE_R);
1108
1109 if( Stream.is_Reading() )
1110 {
1111 CSG_String Archive_File(SG_File_Get_Name(File, false) + ".");
1112
1113 if( !Stream.Get_File(Archive_File + "sgrd" )
1114 && !Stream.Get_File(Archive_File + "sg-grd") )
1115 {
1116 for(size_t i=0; i<Stream.Get_File_Count(); i++)
1117 {
1118 if( SG_File_Cmp_Extension(Stream.Get_File_Name(i), "sgrd" )
1119 || SG_File_Cmp_Extension(Stream.Get_File_Name(i), "sg-grd") )
1120 {
1121 Stream.Get_File(Stream.Get_File_Name(i));
1122 break;
1123 }
1124 }
1125 }
1126
1127 return( Create(Stream) );
1128 }
1129
1130 //-----------------------------------------------------
1131 return( false );
1132}
1133
1134//---------------------------------------------------------
1136{
1137 Create(Stream);
1138}
1139
1141{
1142 _On_Construction();
1143
1144 //-----------------------------------------------------
1145 if( !Stream.is_Reading() )
1146 {
1147 return( false );
1148 }
1149
1150 //-----------------------------------------------------
1151 sLong NX = 0, NY = 0;
1152 double Cellsize = 0.0, xMin = 0.0, yMin = 0.0;
1153
1154 do
1155 {
1156 CSG_String Value;
1157
1158 switch( _Get_Key(Stream, Value) )
1159 {
1160 case GRID_FILE_KEY_NAME : m_Name = Value; break;
1161 case GRID_FILE_KEY_DESCRIPTION : m_Description = Value; break;
1162 case GRID_FILE_KEY_UNITNAME : m_Unit = Value; break;
1163
1164 case GRID_FILE_KEY_CELLCOUNT_X : NX = Value.asInt (); break;
1165 case GRID_FILE_KEY_CELLCOUNT_Y : NY = Value.asInt (); break;
1166 case GRID_FILE_KEY_POSITION_XMIN : xMin = Value.asDouble(); break;
1167 case GRID_FILE_KEY_POSITION_YMIN : yMin = Value.asDouble(); break;
1168 case GRID_FILE_KEY_CELLSIZE : Cellsize = Value.asDouble(); break;
1169
1170 case GRID_FILE_KEY_Z_FACTOR : m_zScale = Value.asDouble(); break;
1171 case GRID_FILE_KEY_Z_OFFSET : m_zOffset = Value.asDouble(); break;
1172 case GRID_FILE_KEY_NODATA_VALUE : m_NoData[0] = Value.asDouble();
1173 Value = Value.AfterFirst(';'); m_NoData[1] = Value.is_Empty() ? m_NoData[0] : Value.asDouble(); break;
1174
1175 case GRID_FILE_KEY_DATAFILE_OFFSET: m_Offset = Value.asInt (); break;
1177 case GRID_FILE_KEY_TOPTOBOTTOM : m_bFlip = Value.Find(GRID_FILE_KEY_TRUE) >= 0; break;
1178
1180 if( SG_File_Get_Path(Value).Length() > 0 )
1181 {
1182 m_Data_File = Value;
1183 }
1184 else
1185 {
1187 }
1188 break;
1189
1191 {
1192 for(int i=0; i<SG_DATATYPE_Undefined; i++)
1193 {
1194 if( Value.Find(gSG_Data_Type_Identifier[i]) >= 0 )
1195 {
1196 m_Type = (TSG_Data_Type)i;
1197
1198 break;
1199 }
1200 }
1201 }
1202 break;
1203 }
1204 }
1205 while( !Stream.is_EOF() );
1206
1207 //-----------------------------------------------------
1208 return( m_System.Assign(Cellsize, xMin, yMin, (int)NX, (int)NY) );
1209}
1210
1211//---------------------------------------------------------
1212int CSG_Grid_File_Info::_Get_Key(CSG_File &Stream, CSG_String &Value)
1213{
1214 int i;
1215 CSG_String sLine;
1216
1217 if( Stream.Read_Line(sLine) && (i = sLine.Find('=')) > 0 )
1218 {
1219 Value = sLine.AfterFirst('=');
1220 Value.Trim();
1221
1222 sLine.Remove(i);
1223
1224 for(i=0; i<GRID_FILE_KEY_Count; i++)
1225 {
1227
1228 if( s.Find(sLine.Left(s.Length())) >= 0 )
1229 {
1230 return( i );
1231 }
1232 }
1233 }
1234
1235 return( -1 );
1236}
1237
1238
1240// //
1242
1243//---------------------------------------------------------
1244bool CSG_Grid_File_Info::Save(const CSG_String &File, bool bBinary)
1245{
1246 return( Save(CSG_File(File, SG_FILE_W, false), bBinary) );
1247}
1248
1249//---------------------------------------------------------
1250bool CSG_Grid_File_Info::Save(const CSG_File &Stream, bool bBinary)
1251{
1252 if( !Stream.is_Writing() )
1253 {
1254 return( false );
1255 }
1256
1257#define GRID_FILE_PRINT(Key, Val) { CSG_String s(gSG_Grid_File_Key_Names[Key]); s += "\t= " + Val + "\n"; Stream.Write(s); }
1258
1264#ifdef WORDS_BIGENDIAN
1266#else
1268#endif
1278
1279 return( true );
1280}
1281
1282//---------------------------------------------------------
1283bool CSG_Grid_File_Info::Save(const CSG_String &File, const CSG_Grid &Grid, bool bBinary)
1284{
1285 CSG_Grid_File_Info Info(Grid);
1286
1287 return( Info.Save(File, bBinary) );
1288}
1289
1290//---------------------------------------------------------
1291bool CSG_Grid_File_Info::Save(const CSG_File &Stream, const CSG_Grid &Grid, bool bBinary)
1292{
1293 CSG_Grid_File_Info Info(Grid);
1294
1295 return( Info.Save(Stream, bBinary) );
1296}
1297
1298
1300// //
1302
1303//---------------------------------------------------------
1305{
1306 CSG_File Stream;
1307
1308 return( m_Projection.is_Okay() && Stream.Open(File + ".aux.xml", SG_FILE_W, false) && Save_AUX_XML(Stream) );
1309}
1310
1311//---------------------------------------------------------
1313{
1314 if( m_Projection.is_Okay() && Stream.is_Writing() ) // store srs information that is recognized by ArcGIS
1315 {
1316 Stream.Write("<PAMDataset>\n<SRS>");
1317 Stream.Write(m_Projection.Get_WKT());
1318 Stream.Write("</SRS>\n</PAMDataset>\n");
1319
1320 return( true );
1321 }
1322
1323 return( false );
1324}
1325
1326
1328// //
1329// //
1330// //
1332
1333//---------------------------------------------------------
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:1627
@ SG_UI_MSG_STYLE_SUCCESS
Definition api_core.h:1626
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:1082
SAGA_API_DLL_EXPORT bool SG_File_Set_Extension(CSG_String &File, const CSG_String &Extension)
TSG_Data_Type
Definition api_core.h:1036
@ SG_DATATYPE_Byte
Definition api_core.h:1038
@ SG_DATATYPE_Bit
Definition api_core.h:1037
@ SG_DATATYPE_Short
Definition api_core.h:1041
@ SG_DATATYPE_Word
Definition api_core.h:1040
@ SG_DATATYPE_Float
Definition api_core.h:1046
@ SG_DATATYPE_Undefined
Definition api_core.h:1052
@ SG_DATATYPE_Double
Definition api_core.h:1047
@ SG_DATATYPE_Int
Definition api_core.h:1043
@ SG_DATATYPE_Char
Definition api_core.h:1039
@ SG_DATATYPE_DWord
Definition api_core.h:1042
#define _TL(s)
Definition api_core.h:1610
size_t SG_Data_Type_Get_Size(TSG_Data_Type Type)
Definition api_core.h:1103
SAGA_API_DLL_EXPORT CSG_String SG_File_Get_Extension(const CSG_String &File)
@ SG_FILE_W
Definition api_core.h:1154
@ SG_FILE_R
Definition api_core.h:1153
virtual CSG_String Get_File_Name(size_t Index)
Definition api_file.cpp:792
size_t Get_File_Count(void)
Definition api_core.h:1264
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:1179
bool is_Open(void) const
Definition api_core.h:1188
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:1190
bool is_Reading(void) const
Definition api_core.h:1189
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:1244
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:1304
CSG_String m_Description
Definition grid.h:473
bool Create(const CSG_Grid_File_Info &Info)
Definition grid_io.cpp:1039
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
bool is_Cached(void) const
Definition grid.h:633
double Get_Offset(void) const
Definition grid.cpp:428
virtual int asInt(int x, int y, bool bScaled=true) const
Definition grid.h:785
virtual void Set_NoData(int x, int y)
Definition grid.h:730
virtual char asChar(int x, int y, bool bScaled=true) const
Definition grid.h:781
double Get_Scaling(void) const
Definition grid.cpp:422
virtual short asShort(int x, int y, bool bScaled=true) const
Definition grid.h:783
virtual void Set_Modified(bool bModified=true)
Definition grid.h:664
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:793
virtual BYTE asByte(int x, int y, bool bScaled=true) const
Definition grid.h:779
virtual bool Save(const char *File, int Format=0)
Definition grid.h:535
virtual float asFloat(int x, int y, bool bScaled=true) const
Definition grid.h:789
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 void Set_Value(sLong i, double Value, bool bScaled=true)
Definition grid.h:843
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
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
int asInt(void) const
const SG_Char * c_str(void) const
bool is_Empty(void) const
CSG_String Left(size_t count) const
double asDouble(void) 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:1607
virtual bool On_Before_Execution(void)
Definition tool.h:239
bool Execute(bool bAddHistory=false)
Definition tool.cpp:562
#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)