|
SAGA API
v9.6
|
Go to the documentation of this file.
157 bool bResult =
false;
195 bool CSG_Shapes::_Load_GDAL(
const CSG_String &File_Name)
216 if( !pShapes || !
Create(*pShapes) )
264 bool CSG_Shapes::_Load_ESRI(
const CSG_String &File_Name)
266 int Type, iField, iPart, nParts, *Parts, iPoint, nPoints, iOffset;
267 double *pZ = NULL, *pM = NULL;
269 CSG_Buffer File_Header(100), Record_Header(8), Content;
300 if( fDBF.Get_Field_Count() < 1 )
320 if( fSHP.
Read(File_Header.Get_Data(),
sizeof(
char), 100) != 100 )
327 if( File_Header.asInt( 0,
true) != 9994 )
334 if( File_Header.asInt(28,
false) != 1000 )
341 switch( Type = File_Header.asInt(32) )
370 if( fSHP.
Read(Record_Header.Get_Data(0),
sizeof(
int), 2) != 2 )
377 if( Record_Header.asInt(0,
true) != iShape + 1 )
384 size_t Length = 2 * Record_Header.asInt(4,
true);
386 if( !Content.
Set_Size(Length,
false) )
393 if( fSHP.
Read(Content.
Get_Data(),
sizeof(
char), Length) != Length )
400 if( fDBF.isDeleted() )
405 if( Content.
asInt(0) != Type )
407 if( Content.
asInt(0) == 0 )
447 nPoints = Content.
asInt(36);
456 pZ = 56 + nPoints * 24 <= (int)Length ? (
double *)Content.
Get_Data(56 + nPoints * 16) : NULL;
460 pZ = 56 + nPoints * 24 <= (int)Length ? (
double *)Content.
Get_Data(56 + nPoints * 16) : NULL;
461 pM = 72 + nPoints * 32 <= (int)Length ? (
double *)Content.
Get_Data(72 + nPoints * 24) : NULL;
466 for(iPoint=0; iPoint<nPoints; iPoint++, pPoint++)
470 if( pZ ) { pShape->
Set_Z(*(pZ++), iPoint); }
471 if( pM ) { pShape->
Set_M(*(pM++), iPoint); }
480 nParts = Content.
asInt(36);
481 nPoints = Content.
asInt(40);
482 Parts = (
int *)Content.
Get_Data(44);
491 pZ = 60 + nParts * 4 + nPoints * 24 <= (int)Length ? (
double *)Content.
Get_Data(60 + nParts * 4 + nPoints * 16) : NULL;
495 pZ = 60 + nParts * 4 + nPoints * 24 <= (int)Length ? (
double *)Content.
Get_Data(60 + nParts * 4 + nPoints * 16) : NULL;
496 pM = 76 + nParts * 4 + nPoints * 32 <= (int)Length ? (
double *)Content.
Get_Data(76 + nParts * 4 + nPoints * 24) : NULL;
503 for(iPoint=0, iPart=0; iPoint<nPoints; iPoint++, pPoint++)
505 if( iPart < nParts - 1 && iPoint >= Parts[iPart + 1] )
513 if( pZ ) { pShape->
Set_Z(*(pZ++), iOffset, iPart); }
514 if( pM ) { pShape->
Set_M(*(pM++), iOffset, iPart); }
525 switch( fDBF.Get_Field_Type(iField) )
528 pShape->
Set_Value(iField, fDBF.asString(iField));
536 if( fDBF.asDouble(iField, Value) )
583 #define Set_Content_Length(n) Record_Header.Set_Value(4, (int)(n), true);\
584 fSHP.Write(Record_Header.Get_Data(), sizeof(int), 2);\
585 fSHX.Write_Int(fSHP_Size, true);\
586 fSHX.Write_Int((n) , true);\
587 fSHP_Size += 4 + (n);\
591 bool CSG_Shapes::_Save_ESRI(
const CSG_String &File_Name)
593 int Type, fSHP_Size, fSHX_Size, iField, iPart, iPoint, nPoints;
595 CSG_Buffer File_Header(100), Record_Header(8), Content;
607 default:
return(
false );
612 switch( Vertex_Type )
617 default:
return(
false );
666 File_Header.Set_Value( 0, 9994 ,
true );
667 File_Header.Set_Value( 4, 0 ,
true );
668 File_Header.Set_Value( 8, 0 ,
true );
669 File_Header.Set_Value(12, 0 ,
true );
670 File_Header.Set_Value(16, 0 ,
true );
671 File_Header.Set_Value(20, 0 ,
true );
672 File_Header.Set_Value(24, 0 ,
true );
673 File_Header.Set_Value(28, 1000 ,
false);
674 File_Header.Set_Value(32, Type ,
false);
679 File_Header.Set_Value(68,
Get_ZMin() ,
false);
680 File_Header.Set_Value(76,
Get_ZMax() ,
false);
681 File_Header.Set_Value(84,
Get_MMin() ,
false);
682 File_Header.Set_Value(92,
Get_MMax() ,
false);
684 fSHP.
Write(File_Header.Get_Data(),
sizeof(
char), 100);
685 fSHX.
Write(File_Header.Get_Data(),
sizeof(
char), 100);
700 Record_Header.Set_Value(0, (
int)iShape + 1,
true);
715 switch( Vertex_Type )
729 switch( Vertex_Type )
749 switch( Vertex_Type )
double asDouble(int Field) const
virtual bool Open(const CSG_String &FileName, int Mode=SG_FILE_R, bool bBinary=true, int Encoding=SG_FILE_ENCODING_ANSI)
@ PARAMETER_TYPE_FilePath
virtual bool On_Delete(void)
bool Save(const CSG_String &File, ESG_CRS_Format Format=ESG_CRS_Format::WKT) const
void Set_File_Name(const CSG_String &FileName)
virtual CSG_Shape * Get_Shape(const CSG_Point &Point, double Epsilon=0.)
bool Update(bool bForce=false)
CSG_String SG_Shapes_Get_File_Extension_Default(void)
virtual bool On_Reload(void)
virtual double Get_Z(int iPoint=0, int iPart=0, bool bAscending=true) const
double Get_XMax(void) const
@ SG_UI_MSG_STYLE_SUCCESS
bool Seek(sLong Offset, int Origin=SG_FILE_START) const
SAGA_API_DLL_EXPORT bool SG_File_Cmp_Extension(const CSG_String &FileName, const CSG_String &Extension)
bool Save_MetaData(const CSG_String &FileName)
double asDouble(int Offset, bool bBigEndian=false) const
bool Open_Write(const SG_Char *FileName, class CSG_Table *pTable, bool bRecords_Save=true)
int Get_Field_Count(void) const
SAGA_API_DLL_EXPORT bool SG_File_Delete(const CSG_String &FileName)
CSG_Data_Collection & Shapes(void) const
bool Set_Size(size_t Size, bool bShrink=true)
size_t Read(void *Buffer, size_t Size, size_t Count=1) const
static TSG_Shape_File_Format gSG_Shape_File_Format_Default
bool is_NoData(int Field) const
virtual void Set_Modified(bool bModified=true)
bool SG_Shapes_Set_File_Format_Default(int Format)
#define Set_Content_Length(n)
virtual TSG_Point Get_Point(int iPoint=0) const =0
virtual CSG_Shape * Add_Shape(CSG_Table_Record *pCopy=NULL, TSG_ADD_Shape_Copy_Mode mCopy=SHAPE_COPY)
@ SG_UI_MSG_STYLE_FAILURE
virtual int Get_Part_Count(void) const =0
const SG_Char * asString(int Field, int Decimals=-99) const
int asInt(int Offset, bool bBigEndian=false) const
const SG_Char * Get_Field_Name(int iField) const
double Get_YMin(void) const
virtual bool Save(const CSG_String &File, int Format=0)
bool Read_Line(CSG_String &sLine) const
int SG_UI_Msg_Lock(bool bOn)
char Get_Field_Type(int iField)
virtual double Get_ZMax(void)
@ SHAPE_FILE_FORMAT_GeoPackage
virtual double Get_ZMin(void)
sLong Get_Count(void) const
TSG_Shape_File_Format SG_Shapes_Get_File_Format_Default(void)
const SG_Char * Get_File_Name(bool bNative=true) const
virtual double Get_M(int iPoint=0, int iPart=0, bool bAscending=true) const
virtual int Add_Point(double x, double y, int iPart=0)=0
bool Load(const CSG_String &File)
@ SHAPE_FILE_FORMAT_Undefined
virtual double Get_MMin(void)
char * Get_Data(int Offset=0) const
TSG_Vertex_Type m_Vertex_Type
static CSG_String Format(const char *Format,...)
int Find(char Character, bool fromEnd=false) const
bool Write_Double(double Value, bool bBigEndian=false)
bool Set_Field_Name(int iField, const SG_Char *Name)
const char gSG_Data_Type_Identifier[][32]
SAGA_API_DLL_EXPORT bool SG_File_Set_Extension(CSG_String &FileName, const CSG_String &Extension)
bool _Save_DBase(const CSG_String &File)
virtual int Get_Point_Count(void) const =0
@ SHAPE_FILE_FORMAT_GeoJSON
bool Set_Value(int iField, double Value)
CSG_MetaData & Get_MetaData_DB(void) const
int Printf(const char *Format,...)
virtual double Get_MMax(void)
bool SG_UI_Process_Set_Progress(int Position, int Range)
bool Write_Int(int Value, bool bBigEndian=false)
CSG_MetaData & Get_MetaData(void) const
bool Set_Value(int Field, const CSG_String &Value)
double Get_YMax(void) const
bool Load_MetaData(const CSG_String &FileName)
double Get_XMin(void) const
bool Set_NoData(int iField)
virtual const CSG_Rect & Get_Extent(void)=0
virtual void Set_Z(double z, int iPoint=0, int iPart=0)
SAGA_API_DLL_EXPORT CSG_String SG_File_Make_Path(const CSG_String &Directory, const CSG_String &Name)
const SG_Char * c_str(void) const
size_t Write(void *Buffer, size_t Size, size_t Count=1) const
bool SG_UI_Process_Set_Ready(void)
void SG_UI_Msg_Add_Error(const char *Message)
TSG_Data_Type Get_Field_Type(int iField) const
virtual void Set_M(double m, int iPoint=0, int iPart=0)
CSG_Projection & Get_Projection(void)
bool Set_NoData(int Field)
bool _Save_Text(const CSG_String &File, bool bHeadline, const SG_Char Separator)
void SG_UI_Msg_Add(const char *Message, bool bNewLine, TSG_UI_MSG_STYLE Style)