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