116 #define TYPE_AS_WKB(t) if( !Type.CmpNoCase(Type_asWKText(t)) ) return( t );
173inline bool CSG_Shapes_OGIS_Converter::_WKT_Read_Point(
const CSG_String &Text,
CSG_Shape *pShape,
int iPart)
218 while( s.Length() > 0 )
220 if( !_WKT_Read_Point(s, pShape, iPart) )
225 s = s.AfterFirst(
',');
236 while( s.Length() > 0 )
238 _WKT_Read_Points(s, pShape);
240 s = s.AfterFirst(
',');
247bool CSG_Shapes_OGIS_Converter::_WKT_Read_Polygon(
const CSG_String &Text,
CSG_Shape *pShape)
251 for(
int i=0, Level=-2; i<(int)Text.
Length(); i++)
257 else if( Text[i] ==
')' )
262 _WKT_Read_Parts(Part, pShape);
308 return( _WKT_Read_Parts (Text, pShape) );
331inline bool CSG_Shapes_OGIS_Converter::_WKT_Write_Point(
CSG_String &Text,
CSG_Shape *pShape,
int iPoint,
int iPart)
354inline bool CSG_Shapes_OGIS_Converter::_WKT_Write_Points(
CSG_String &Text,
CSG_Shape *pShape,
int iPart)
365 _WKT_Write_Point(Text, pShape, iPoint, iPart);
372 _WKT_Write_Point(Text, pShape, 0, iPart);
381inline bool CSG_Shapes_OGIS_Converter::_WKT_Write_Parts(
CSG_String &Text,
CSG_Shape *pShape)
392 _WKT_Write_Points(Text, pShape, iPart);
401inline bool CSG_Shapes_OGIS_Converter::_WKT_Write_Polygon(
CSG_String &Text,
CSG_Shape *pShape)
405 for(
int iPart=0, nIslands=0; iPart<pShape->
Get_Part_Count(); iPart++)
407 if( ((CSG_Shape_Polygon *)pShape)->is_Lake(iPart) ==
false )
416 _WKT_Write_Points(Text, pShape, iPart);
420 if( ((CSG_Shape_Polygon *)pShape)->is_Lake(jPart) && ((CSG_Shape_Polygon *)pShape)->Contains(pShape->
Get_Point(0, jPart), iPart) )
424 _WKT_Write_Points(Text, pShape, jPart);
495 for(DWORD iPoint=0; iPoint<nPoints; iPoint++)
497 if( !_WKB_Read_Point(Bytes, bSwapBytes, Vertex, pShape, iPart) )
509 int nParts = (int)Bytes.
Read_DWord(bSwapBytes);
511 for(
int iPart=0; iPart<nParts; iPart++)
513 if( !_WKB_Read_Points(Bytes, bSwapBytes, Vertex, pShape) )
527 for(DWORD iPoint=0; iPoint<nPoints; iPoint++)
533 if( Geometry !=
SHAPE_TYPE_Point || Vertex != _Vertex || !_WKB_Read_Point(Bytes, bSwapBytes, Vertex, pShape, iPart) )
547 for(DWORD iLine=0; iLine<nLines; iLine++)
553 if( Geometry !=
SHAPE_TYPE_Line || Vertex != _Vertex || !_WKB_Read_Points(Bytes, bSwapBytes, Vertex, pShape) )
565 DWORD nPolygons = Bytes.
Read_DWord(bSwapBytes);
567 for(DWORD iPolygon=0; iPolygon<nPolygons; iPolygon++)
573 if( Geometry !=
SHAPE_TYPE_Polygon || Vertex != _Vertex || !_WKB_Read_Polygon(Bytes, bSwapBytes, Vertex, pShape) )
641inline bool CSG_Shapes_OGIS_Converter::_WKB_Write_Point(
CSG_Bytes &Bytes,
CSG_Shape *pShape,
int iPoint,
int iPart)
654 Bytes += pShape->
Get_Z(iPoint, iPart);
658 Bytes += pShape->
Get_Z(iPoint, iPart);
659 Bytes += pShape->
Get_M(iPoint, iPart);
667bool CSG_Shapes_OGIS_Converter::_WKB_Write_Points(
CSG_Bytes &Bytes,
CSG_Shape *pShape,
int iPart)
671 Bytes += (DWORD)(pShape->
Get_Point_Count(iPart) + (bFirstTwice ? 1 : 0));
675 _WKB_Write_Point(Bytes, pShape, iPoint, iPart);
680 _WKB_Write_Point(Bytes, pShape, 0, iPart);
687bool CSG_Shapes_OGIS_Converter::_WKB_Write_MultiPoint(
CSG_Bytes &Bytes,
CSG_Shape *pShape)
704 if( !_WKB_Write_Point(Bytes, pShape, iPoint, iPart) )
715bool CSG_Shapes_OGIS_Converter::_WKB_Write_MultiLine(
CSG_Bytes &Bytes,
CSG_Shape *pShape)
730 if( !_WKB_Write_Points(Bytes, pShape, iPart) )
740bool CSG_Shapes_OGIS_Converter::_WKB_Write_MultiPolygon(
CSG_Bytes &Bytes,
CSG_Shape *pShape)
748 if( ((CSG_Shape_Polygon *)pShape)->is_Lake(iPart) ==
false )
752 iPolygon[iPart] = iPart;
756 if( ((CSG_Shape_Polygon *)pShape)->is_Lake(jPart) && ((CSG_Shape_Polygon *)pShape)->Contains(pShape->
Get_Point(0, jPart), iPart) )
759 iPolygon[jPart] = iPart;
765 Bytes += (DWORD)nPolygons;
769 if( nRings[iPart] > 0 )
780 Bytes += (DWORD)nRings[iPart];
784 if( iPolygon[jPart] == iPart )
786 if( !_WKB_Write_Points(Bytes, pShape, jPart) )
795 return( nPolygons > 0 );
814 case SHAPE_TYPE_Line :
return( _WKB_Write_MultiLine (Bytes, pShape ) );
1126 switch( Flags & 0x0F )
1147 if( !pGrid->
Create(Type, NX, NY, dx, xMin + 0.5 * dx, yMax - (NY - 0.5) * dx) )
1167 default : noData = -99999. ;
break;
1174 for(
int x=0; x<pGrid->
Get_NX(); x++)
1209 Bytes += (short )0 ;
1210 Bytes += (short )1 ;
1213 Bytes += (double)pGrid->
Get_XMin(
true);
1214 Bytes += (double)pGrid->
Get_YMax(
true);
1215 Bytes += (double)0. ;
1216 Bytes += (double)0. ;
1217 Bytes += (int )SRID ;
1218 Bytes += (short )pGrid->
Get_NX() ;
1219 Bytes += (short )pGrid->
Get_NY() ;
1237 default : Flags = 10;
break;
1263 for(
int x=0; x<pGrid->
Get_NX(); x++)
1276 default : Bytes += (float )Value;
break;
bool SG_UI_Process_Set_Progress(int Position, int Range)
int Get_Count(void) const
DWORD Read_DWord(bool bSwapBytes=false)
double Read_Double(bool bSwapBytes=false)
WORD Read_Word(bool bSwapBytes=false)
int Read_Int(bool bSwapBytes=false)
short Read_Short(bool bSwapBytes=false)
float Read_Float(bool bSwapBytes=false)
double Get_NoData_Value(bool bUpper=false) const
virtual bool Set_NoData_Value(double Value)
CSG_Projection & Get_Projection(void)
static bool to_WKBinary(CSG_Bytes &Bytes, class CSG_Grid *pGrid, int SRID=-1)
static bool from_WKBinary(CSG_Bytes &Bytes, class CSG_Grid *pGrid)
double Get_YMax(bool bCells=false) const
double Get_XMin(bool bCells=false) const
double Get_Cellsize(void) const
virtual bool is_NoData(int x, int y) const
virtual double asDouble(sLong i, bool bScaled=true) const
bool Create(const CSG_Grid &Grid)
virtual void Set_Value(sLong i, double Value, bool bScaled=true)
TSG_Data_Type Get_Type(void) const
bool Create(const CSG_Projection &Projection)
virtual TSG_Point Get_Point(int iPoint=0) const
virtual int Get_Part_Count(void) const
virtual int Get_Point_Count(void) const =0
virtual void Set_M(double m, int iPoint=0, int iPart=0)
TSG_Shape_Type Get_Type(void) const
virtual int Add_Point(double x, double y, int iPart=0)=0
virtual int Get_Part_Count(void) const =0
virtual TSG_Point Get_Point(int iPoint=0) const =0
virtual int Del_Parts(void)
virtual double Get_Z(int iPoint=0, int iPart=0, bool bAscending=true) const
TSG_Vertex_Type Get_Vertex_Type(void) const
virtual double Get_M(int iPoint=0, int iPart=0, bool bAscending=true) const
virtual void Set_Z(double z, int iPoint=0, int iPart=0)
static bool from_WKText(const CSG_String &Text, CSG_Shape *pShape)
static TSG_Vertex_Type to_VertexType(const CSG_String &Type)
static bool from_ShapeType(CSG_String &Type, TSG_Shape_Type Shape, TSG_Vertex_Type Vertex=SG_VERTEX_TYPE_XY)
static CSG_String Type_asWKText(DWORD Type)
static bool from_WKBinary(CSG_Bytes &Bytes, CSG_Shape *pShape)
static bool to_WKBinary(CSG_Shape *pShape, CSG_Bytes &Bytes)
static bool to_ShapeType(const CSG_String &Type, TSG_Shape_Type &Shape, TSG_Vertex_Type &Vertex)
static bool to_WKText(CSG_Shape *pShape, CSG_String &Text)
static DWORD Type_asWKBinary(const CSG_String &Type)
size_t Length(void) const
CSG_String AfterFirst(char Character) const
CSG_String BeforeFirst(char Character) const
CSG_String BeforeLast(char Character) const
static CSG_String Format(const char *Format,...)
const SG_Char * c_str(void) const
class CSG_Table * Get_Table(void)
@ SG_OGIS_TYPE_PolyhedralSurfaceZ
@ SG_OGIS_TYPE_MultiPolygon
@ SG_OGIS_TYPE_GeometryCollectionM
@ SG_OGIS_TYPE_MultiPolygonZM
@ SG_OGIS_TYPE_MultiPoint
@ SG_OGIS_TYPE_MultiPolygonZ
@ SG_OGIS_TYPE_GeometryCollectionZM
@ SG_OGIS_TYPE_LineStringZ
@ SG_OGIS_TYPE_GeometryCollectionZ
@ SG_OGIS_TYPE_MultiLineStringM
@ SG_OGIS_TYPE_TriangleZM
@ SG_OGIS_TYPE_PolyhedralSurfaceM
@ SG_OGIS_TYPE_PolyhedralSurface
@ SG_OGIS_TYPE_LineString
@ SG_OGIS_TYPE_PolyhedralSurfaceZM
@ SG_OGIS_TYPE_LineStringZM
@ SG_OGIS_TYPE_MultiLineStringZ
@ SG_OGIS_TYPE_MultiPointM
@ SG_OGIS_TYPE_MultiPointZM
@ SG_OGIS_TYPE_MultiLineStringZM
@ SG_OGIS_TYPE_MultiPolygonM
@ SG_OGIS_TYPE_MultiPointZ
@ SG_OGIS_TYPE_MultiLineString
@ SG_OGIS_TYPE_LineStringM
@ SG_OGIS_TYPE_GeometryCollection