 |
SAGA API
v9.7
|
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)
290 if( DBase.Open_Read(
SG_File_Make_Path(
"", File_Name,
"dbf"),
this,
false) && DBase.Get_Field_Count() < 1 )
297 if( DBase.is_Open() )
321 if( Stream.
Read(File_Header.Get_Data(),
sizeof(
char), 100) != 100 )
328 if( File_Header.asInt( 0,
true) != 9994 )
335 if( File_Header.asInt(28,
false) != 1000 )
342 int Type = File_Header.asInt(32);
374 if( Stream.
Read(Record_Header.Get_Data(0),
sizeof(
int), 2) != 2 )
381 if( Record_Header.asInt(0,
true) != iShape + 1 )
388 size_t nBytes = 2 * (size_t)Record_Header.asInt(4,
true);
390 if( !Content.
Set_Size(nBytes,
false) )
397 if( Stream.
Read(Content.
Get_Data(),
sizeof(
char), nBytes) != nBytes )
404 if( DBase.is_Open() && DBase.isDeleted() )
409 if( Content.
asInt(0) != Type )
411 if( Content.
asInt(0) == 0 )
449 nPoints = Content.
asInt(36);
457 pZ = 56 + nPoints * 24 <= (int)Length ? (
double *)Content.
Get_Data(56 + nPoints * 16) : NULL;
461 pZ = 56 + nPoints * 24 <= (int)Length ? (
double *)Content.
Get_Data(56 + nPoints * 16) : NULL;
462 pM = 72 + nPoints * 32 <= (int)Length ? (
double *)Content.
Get_Data(72 + nPoints * 24) : NULL;
467 for(
int iPoint=0; iPoint<nPoints; iPoint++, pPoint++)
471 if( pZ ) { pShape->
Set_Z(*(pZ++), iPoint); }
472 if( pM ) { pShape->
Set_M(*(pM++), iPoint); }
481 nParts = Content.
asInt(36);
482 nPoints = Content.
asInt(40);
483 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;
501 for(
int iPoint=0, iPart=0, Offset=0; iPoint<nPoints; iPoint++, pPoint++, Offset++)
503 if( iPart < nParts - 1 && iPoint >= Parts[iPart + 1] )
508 pShape->
Add_Point(pPoint->x, pPoint->y, iPart);
510 if( pZ ) { pShape->
Set_Z(*(pZ++), Offset, iPart); }
511 if( pM ) { pShape->
Set_M(*(pM++), Offset, iPart); }
521 if( DBase.is_Open() )
525 switch( DBase.Get_Field_Type(iField) )
528 pShape->
Set_Value(iField, DBase.asString(iField));
535 if( DBase.asDouble(iField, Value) )
586 #define Set_Content_Length(n) Record_Header.Set_Value(4, (int)(n), true);\
587 fSHP.Write(Record_Header.Get_Data(), sizeof(int), 2);\
588 fSHX.Write_Int(fSHP_Size, true);\
589 fSHX.Write_Int((n) , true);\
590 fSHP_Size += 4 + (n);\
594 bool CSG_Shapes::_Save_ESRI(
const CSG_String &File_Name)
607 default:
return(
false );
612 switch( Vertex_Type )
617 default:
return(
false );
708 Record_Header.
Set_Value(0, (
int)iShape + 1,
true);
718 switch( Vertex_Type )
732 switch( Vertex_Type )
752 switch( Vertex_Type )
double asDouble(int Field) const
@ 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)
void Set_Value(int Offset, char Value, bool bBigEndian=false)
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)
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)
virtual bool Open(const SG_Char *FileName, int Mode=SG_FILE_R, bool bBinary=true, int Encoding=SG_FILE_ENCODING_ANSI)
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)
virtual bool Add_Field(const CSG_String &Name, TSG_Data_Type Type, int Position=-1)
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)
bool Read_Line(CSG_String &Line) const
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)