116 #define TYPE_AS_WKB(t) if( !Type.CmpNoCase(Type_asWKText(t)) ) return( t );
173 inline bool CSG_Shapes_OGIS_Converter::_WKT_Read_Point(
const CSG_String &Text,
CSG_Shape *pShape,
int iPart)
214 bool CSG_Shapes_OGIS_Converter::_WKT_Read_Points(
const CSG_String &Text,
CSG_Shape *pShape)
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(
',');
247 bool 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) );
331 inline bool CSG_Shapes_OGIS_Converter::_WKT_Write_Point(
CSG_String &Text,
CSG_Shape *pShape,
int iPoint,
int iPart)
354 inline 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);
381 inline bool CSG_Shapes_OGIS_Converter::_WKT_Write_Parts(
CSG_String &Text,
CSG_Shape *pShape)
392 _WKT_Write_Points(Text, pShape, iPart);
401 inline 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++)
416 _WKT_Write_Points(Text, pShape, 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) )
641 inline 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);
667 bool 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);
687 bool CSG_Shapes_OGIS_Converter::_WKB_Write_MultiPoint(
CSG_Bytes &Bytes,
CSG_Shape *pShape)
704 if( !_WKB_Write_Point(Bytes, pShape, iPoint, iPart) )
715 bool CSG_Shapes_OGIS_Converter::_WKB_Write_MultiLine(
CSG_Bytes &Bytes,
CSG_Shape *pShape)
730 if( !_WKB_Write_Points(Bytes, pShape, iPart) )
740 bool CSG_Shapes_OGIS_Converter::_WKB_Write_MultiPolygon(
CSG_Bytes &Bytes,
CSG_Shape *pShape)
752 iPolygon[iPart] = 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 )
1146 if( !pGrid->
Create(Type, NX, NY, dx, xMin + 0.5 * dx, yMax - (NY - 0.5) * dx) )
1174 for(
int x=0; x<pGrid->
Get_NX(); x++)
1210 Bytes += (short )0 ;
1211 Bytes += (short )1 ;
1214 Bytes += (double)pGrid->
Get_XMin(
true);
1215 Bytes += (double)pGrid->
Get_YMax(
true);
1216 Bytes += (double)0. ;
1217 Bytes += (double)0. ;
1218 Bytes += (int )SRID ;
1219 Bytes += (short )pGrid->
Get_NX() ;
1220 Bytes += (short )pGrid->
Get_NY() ;
1238 default : Flags = 10;
break;
1264 for(
int x=0; x<pGrid->
Get_NX(); x++)
1277 default : Bytes += (float )Value;
break;