SAGA API  v9.6
shapes_ogis.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 // shapes_ogis.cpp //
15 // //
16 // Copyright (C) 2010 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 "shapes.h"
52 
53 
55 // //
56 // //
57 // //
59 
60 //---------------------------------------------------------
62 {
63  switch( Type )
64  {
65  case SG_OGIS_TYPE_Point : return( "Point" );
66  case SG_OGIS_TYPE_LineString : return( "LineString" );
67  case SG_OGIS_TYPE_Polygon : return( "Polygon" );
68  case SG_OGIS_TYPE_MultiPoint : return( "MultiPoint" );
69  case SG_OGIS_TYPE_MultiLineString : return( "MultiLineString" );
70  case SG_OGIS_TYPE_MultiPolygon : return( "MultiPolygon" );
71  case SG_OGIS_TYPE_GeometryCollection : return( "GeometryCollection" );
72  case SG_OGIS_TYPE_PolyhedralSurface : return( "PolyhedralSurface" );
73  case SG_OGIS_TYPE_TIN : return( "TIN" );
74  case SG_OGIS_TYPE_Triangle : return( "Triangle" );
75 
76  case SG_OGIS_TYPE_PointZ : return( "PointZ" );
77  case SG_OGIS_TYPE_LineStringZ : return( "LineStringZ" );
78  case SG_OGIS_TYPE_PolygonZ : return( "PolygonZ" );
79  case SG_OGIS_TYPE_MultiPointZ : return( "MultiPointZ" );
80  case SG_OGIS_TYPE_MultiLineStringZ : return( "MultiLineStringZ" );
81  case SG_OGIS_TYPE_MultiPolygonZ : return( "MultiPolygonZ" );
82  case SG_OGIS_TYPE_GeometryCollectionZ : return( "GeometryCollectionZ" );
83  case SG_OGIS_TYPE_PolyhedralSurfaceZ : return( "PolyhedralSurfaceZ" );
84  case SG_OGIS_TYPE_TINZ : return( "TINZ" );
85  case SG_OGIS_TYPE_TriangleZ : return( "TriangleZ" );
86 
87  case SG_OGIS_TYPE_PointM : return( "PointM" );
88  case SG_OGIS_TYPE_LineStringM : return( "LineStringM" );
89  case SG_OGIS_TYPE_PolygonM : return( "PolygonM" );
90  case SG_OGIS_TYPE_MultiPointM : return( "MultiPointM" );
91  case SG_OGIS_TYPE_MultiLineStringM : return( "MultiLineStringM" );
92  case SG_OGIS_TYPE_MultiPolygonM : return( "MultiPolygonM" );
93  case SG_OGIS_TYPE_GeometryCollectionM : return( "GeometryCollectionM" );
94  case SG_OGIS_TYPE_PolyhedralSurfaceM : return( "PolyhedralSurfaceM" );
95  case SG_OGIS_TYPE_TINM : return( "TINM" );
96  case SG_OGIS_TYPE_TriangleM : return( "TriangleM" );
97 
98  case SG_OGIS_TYPE_PointZM : return( "PointZM" );
99  case SG_OGIS_TYPE_LineStringZM : return( "LineStringZM" );
100  case SG_OGIS_TYPE_PolygonZM : return( "PolygonZM" );
101  case SG_OGIS_TYPE_MultiPointZM : return( "MultiPointZM" );
102  case SG_OGIS_TYPE_MultiLineStringZM : return( "MultiLineStringZM" );
103  case SG_OGIS_TYPE_MultiPolygonZM : return( "MultiPolygonZM" );
104  case SG_OGIS_TYPE_GeometryCollectionZM : return( "GeometryCollectionZM" );
105  case SG_OGIS_TYPE_PolyhedralSurfaceZM : return( "PolyhedralSurfaceZM" );
106  case SG_OGIS_TYPE_TINZM : return( "TINZM" );
107  case SG_OGIS_TYPE_TriangleZM : return( "TriangleZM" );
108  }
109 
110  return( "" );
111 }
112 
113 //---------------------------------------------------------
115 {
116  #define TYPE_AS_WKB(t) if( !Type.CmpNoCase(Type_asWKText(t)) ) return( t );
117 
128 
139 
150 
161 
162  return( SG_OGIS_TYPE_Undefined );
163 }
164 
165 
167 // //
168 // //
169 // //
171 
172 //---------------------------------------------------------
173 inline bool CSG_Shapes_OGIS_Converter::_WKT_Read_Point(const CSG_String &Text, CSG_Shape *pShape, int iPart)
174 {
175  double x, y, z, m;
176 
177  switch( pShape->Get_Vertex_Type() )
178  {
179  case SG_VERTEX_TYPE_XY:
180  if( SG_SSCANF(Text.c_str(), SG_T("%lf %lf"), &x, &y) == 2 )
181  {
182  pShape->Add_Point(x, y, iPart);
183 
184  return( true );
185  }
186  break;
187 
188  case SG_VERTEX_TYPE_XYZ:
189  if( SG_SSCANF(Text.c_str(), SG_T("%lf %lf %lf"), &x, &y, &z) == 3 )
190  {
191  pShape->Add_Point(x, y, iPart);
192  pShape->Set_Z (z, pShape->Get_Point_Count(iPart) - 1, iPart);
193 
194  return( true );
195  }
196  break;
197 
198  case SG_VERTEX_TYPE_XYZM:
199  if( SG_SSCANF(Text.c_str(), SG_T("%lf %lf %lf %lf"), &x, &y, &z, &m) == 4 )
200  {
201  pShape->Add_Point(x, y, iPart);
202  pShape->Set_Z (z, pShape->Get_Point_Count(iPart) - 1, iPart);
203  pShape->Set_M (m, pShape->Get_Point_Count(iPart) - 1, iPart);
204 
205  return( true );
206  }
207  break;
208  }
209 
210  return( false );
211 }
212 
213 //---------------------------------------------------------
214 bool CSG_Shapes_OGIS_Converter::_WKT_Read_Points(const CSG_String &Text, CSG_Shape *pShape)
215 {
216  CSG_String s(Text.AfterFirst('(').BeforeFirst(')')); int iPart = pShape->Get_Part_Count();
217 
218  while( s.Length() > 0 )
219  {
220  if( !_WKT_Read_Point(s, pShape, iPart) )
221  {
222  return( false );
223  }
224 
225  s = s.AfterFirst(',');
226  }
227 
228  return( pShape->Get_Point_Count(iPart) > 0 );
229 }
230 
231 //---------------------------------------------------------
232 bool CSG_Shapes_OGIS_Converter::_WKT_Read_Parts(const CSG_String &Text, CSG_Shape *pShape)
233 {
234  CSG_String s(Text.AfterFirst('(').BeforeLast(')'));
235 
236  while( s.Length() > 0 )
237  {
238  _WKT_Read_Points(s, pShape);
239 
240  s = s.AfterFirst(',');
241  }
242 
243  return( pShape->Get_Part_Count() > 0 );
244 }
245 
246 //---------------------------------------------------------
247 bool CSG_Shapes_OGIS_Converter::_WKT_Read_Polygon(const CSG_String &Text, CSG_Shape *pShape)
248 {
249  CSG_String Part;
250 
251  for(int i=0, Level=-2; i<(int)Text.Length(); i++)
252  {
253  if( Text[i] == '(' )
254  {
255  Level++;
256  }
257  else if( Text[i] == ')' )
258  {
259  if( Level == 0 )
260  {
261  Part += Text[i];
262  _WKT_Read_Parts(Part, pShape);
263  Part.Clear();
264  }
265 
266  Level--;
267  }
268 
269  if( Level >= 0 )
270  {
271  Part += Text[i];
272  }
273  }
274 
275  return( pShape->Get_Part_Count() > 0 );
276 }
277 
278 //---------------------------------------------------------
280 {
281  pShape->Del_Parts();
282 
283  CSG_String Type(Text.BeforeFirst('(')); Type.Trim_Both();
284 
285  if( pShape->Get_Type() == to_ShapeType(Type) )
286  {
287  switch( Type_asWKBinary(Type) )
288  {
289  case SG_OGIS_TYPE_Point :
290  case SG_OGIS_TYPE_PointZ :
291  case SG_OGIS_TYPE_PointM :
292  case SG_OGIS_TYPE_PointZM : return( _WKT_Read_Point(Text.AfterFirst('(').BeforeFirst(')'), pShape, 0) );
293 
297  case SG_OGIS_TYPE_MultiPointZM : return( _WKT_Read_Points (Text, pShape) );
298 
302  case SG_OGIS_TYPE_LineStringZM : return( _WKT_Read_Points (Text, pShape) );
303 
308  return( _WKT_Read_Parts (Text, pShape) );
309 
310  case SG_OGIS_TYPE_Polygon :
311  case SG_OGIS_TYPE_PolygonZ :
312  case SG_OGIS_TYPE_PolygonM :
313  case SG_OGIS_TYPE_PolygonZM : return( _WKT_Read_Parts (Text, pShape) );
314 
318  case SG_OGIS_TYPE_MultiPolygonZM : return( _WKT_Read_Polygon(Text, pShape) );
319  }
320  }
321 
322  return( false );
323 }
324 
325 
327 // //
329 
330 //---------------------------------------------------------
331 inline bool CSG_Shapes_OGIS_Converter::_WKT_Write_Point(CSG_String &Text, CSG_Shape *pShape, int iPoint, int iPart)
332 {
333  TSG_Point Point = pShape->Get_Point(iPoint, iPart);
334 
335  switch( ((CSG_Shapes *)pShape->Get_Table())->Get_Vertex_Type() )
336  {
337  case SG_VERTEX_TYPE_XY:
338  Text += CSG_String::Format("%f %f" , Point.x, Point.y);
339  break;
340 
341  case SG_VERTEX_TYPE_XYZ:
342  Text += CSG_String::Format("%f %f %f" , Point.x, Point.y, pShape->Get_Z(iPoint, iPart));
343  break;
344 
345  case SG_VERTEX_TYPE_XYZM:
346  Text += CSG_String::Format("%f %f %f %f", Point.x, Point.y, pShape->Get_Z(iPoint, iPart), pShape->Get_M(iPoint, iPart));
347  break;
348  }
349 
350  return( false );
351 }
352 
353 //---------------------------------------------------------
354 inline bool CSG_Shapes_OGIS_Converter::_WKT_Write_Points(CSG_String &Text, CSG_Shape *pShape, int iPart)
355 {
356  Text += "(";
357 
358  for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
359  {
360  if( iPoint > 0 )
361  {
362  Text += ", ";
363  }
364 
365  _WKT_Write_Point(Text, pShape, iPoint, iPart);
366  }
367 
368  if( pShape->Get_Type() == SHAPE_TYPE_Polygon && CSG_Point(pShape->Get_Point(0, iPart)) != pShape->Get_Point(pShape->Get_Point_Count(iPart) -1, iPart) )
369  {
370  Text += ", ";
371 
372  _WKT_Write_Point(Text, pShape, 0, iPart);
373  }
374 
375  Text += ")";
376 
377  return( true );
378 }
379 
380 //---------------------------------------------------------
381 inline bool CSG_Shapes_OGIS_Converter::_WKT_Write_Parts(CSG_String &Text, CSG_Shape *pShape)
382 {
383  Text += "(";
384 
385  for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
386  {
387  if( iPart > 0 )
388  {
389  Text += ", ";
390  }
391 
392  _WKT_Write_Points(Text, pShape, iPart);
393  }
394 
395  Text += ")";
396 
397  return( true );
398 }
399 
400 //---------------------------------------------------------
401 inline bool CSG_Shapes_OGIS_Converter::_WKT_Write_Polygon(CSG_String &Text, CSG_Shape *pShape)
402 {
403  Text += "(";
404 
405  for(int iPart=0, nIslands=0; iPart<pShape->Get_Part_Count(); iPart++)
406  {
407  if( ((CSG_Shape_Polygon *)pShape)->is_Lake(iPart) == false )
408  {
409  if( nIslands++ > 0 )
410  {
411  Text += ", ";
412  }
413 
414  Text += "(";
415 
416  _WKT_Write_Points(Text, pShape, iPart);
417 
418  for(int jPart=0; jPart<pShape->Get_Part_Count(); jPart++)
419  {
420  if( ((CSG_Shape_Polygon *)pShape)->is_Lake(jPart) && ((CSG_Shape_Polygon *)pShape)->Contains(pShape->Get_Point(0, jPart), iPart) )
421  {
422  Text += ", ";
423 
424  _WKT_Write_Points(Text, pShape, jPart);
425  }
426  }
427 
428  Text += ")";
429  }
430  }
431 
432  Text += ")";
433 
434  return( true );
435 }
436 
437 //---------------------------------------------------------
439 {
440  switch( pShape->Get_Type() )
441  {
442  case SHAPE_TYPE_Point : _WKT_Write_Points (Text = from_ShapeType(pShape->Get_Type(), pShape->Get_Vertex_Type()), pShape, 0); break;
443  case SHAPE_TYPE_Points : _WKT_Write_Parts (Text = from_ShapeType(pShape->Get_Type(), pShape->Get_Vertex_Type()), pShape ); break;
444  case SHAPE_TYPE_Line : _WKT_Write_Parts (Text = from_ShapeType(pShape->Get_Type(), pShape->Get_Vertex_Type()), pShape ); break;
445  case SHAPE_TYPE_Polygon: _WKT_Write_Polygon(Text = from_ShapeType(pShape->Get_Type(), pShape->Get_Vertex_Type()), pShape ); break;
446 
447  default:
448  return( false );
449  }
450 
451  return( true );
452 }
453 
454 
456 // //
458 
459 //---------------------------------------------------------
460 inline bool CSG_Shapes_OGIS_Converter::_WKB_Read_Point(CSG_Bytes &Bytes, bool bSwapBytes, TSG_Vertex_Type Vertex, CSG_Shape *pShape, int iPart)
461 {
462  if( !Bytes.is_EOF() )
463  {
464  double x = Bytes.Read_Double(bSwapBytes);
465  double y = Bytes.Read_Double(bSwapBytes);
466 
467  pShape->Add_Point(x, y, iPart);
468 
469  switch( Vertex )
470  {
471  default:
472  break;
473 
474  case SG_VERTEX_TYPE_XYZ:
475  pShape->Set_Z(Bytes.Read_Double(bSwapBytes), pShape->Get_Point_Count(iPart) - 1, iPart);
476  break;
477 
478  case SG_VERTEX_TYPE_XYZM:
479  pShape->Set_Z(Bytes.Read_Double(bSwapBytes), pShape->Get_Point_Count(iPart) - 1, iPart);
480  pShape->Set_M(Bytes.Read_Double(bSwapBytes), pShape->Get_Point_Count(iPart) - 1, iPart);
481  break;
482  }
483 
484  return( true );
485  }
486 
487  return( false );
488 }
489 
490 //---------------------------------------------------------
491 bool CSG_Shapes_OGIS_Converter::_WKB_Read_Points(CSG_Bytes &Bytes, bool bSwapBytes, TSG_Vertex_Type Vertex, CSG_Shape *pShape)
492 {
493  DWORD nPoints = Bytes.Read_DWord(bSwapBytes), iPart = pShape->Get_Part_Count();
494 
495  for(DWORD iPoint=0; iPoint<nPoints; iPoint++)
496  {
497  if( !_WKB_Read_Point(Bytes, bSwapBytes, Vertex, pShape, iPart) )
498  {
499  return( false );
500  }
501  }
502 
503  return( pShape->Get_Point_Count(iPart) > 0 );
504 }
505 
506 //---------------------------------------------------------
507 bool CSG_Shapes_OGIS_Converter::_WKB_Read_Polygon(CSG_Bytes &Bytes, bool bSwapBytes, TSG_Vertex_Type Vertex, CSG_Shape *pShape)
508 {
509  int nParts = (int)Bytes.Read_DWord(bSwapBytes);
510 
511  for(int iPart=0; iPart<nParts; iPart++)
512  {
513  if( !_WKB_Read_Points(Bytes, bSwapBytes, Vertex, pShape) )
514  {
515  return( false );
516  }
517  }
518 
519  return( pShape->Get_Part_Count() > 0 );
520 }
521 
522 //---------------------------------------------------------
523 bool CSG_Shapes_OGIS_Converter::_WKB_Read_MultiPoint(CSG_Bytes &Bytes, bool bSwapBytes, TSG_Vertex_Type Vertex, CSG_Shape *pShape)
524 {
525  DWORD nPoints = Bytes.Read_DWord(bSwapBytes), iPart = pShape->Get_Part_Count();
526 
527  for(DWORD iPoint=0; iPoint<nPoints; iPoint++)
528  {
529  bSwapBytes = Bytes.Read_Byte() != SG_OGIS_BYTEORDER_NDR;
530 
531  TSG_Shape_Type Geometry; TSG_Vertex_Type _Vertex; to_ShapeType(Bytes.Read_DWord(bSwapBytes), Geometry, _Vertex);
532 
533  if( Geometry != SHAPE_TYPE_Point || Vertex != _Vertex || !_WKB_Read_Point(Bytes, bSwapBytes, Vertex, pShape, iPart) )
534  {
535  return( false );
536  }
537  }
538 
539  return( pShape->Get_Point_Count(iPart) > 0 );
540 }
541 
542 //---------------------------------------------------------
543 bool CSG_Shapes_OGIS_Converter::_WKB_Read_MultiLine(CSG_Bytes &Bytes, bool bSwapBytes, TSG_Vertex_Type Vertex, CSG_Shape *pShape)
544 {
545  DWORD nLines = Bytes.Read_DWord(bSwapBytes);
546 
547  for(DWORD iLine=0; iLine<nLines; iLine++)
548  {
549  bSwapBytes = Bytes.Read_Byte() != SG_OGIS_BYTEORDER_NDR;
550 
551  TSG_Shape_Type Geometry; TSG_Vertex_Type _Vertex; to_ShapeType(Bytes.Read_DWord(bSwapBytes), Geometry, _Vertex);
552 
553  if( Geometry != SHAPE_TYPE_Line || Vertex != _Vertex || !_WKB_Read_Points(Bytes, bSwapBytes, Vertex, pShape) )
554  {
555  return( false );
556  }
557  }
558 
559  return( pShape->Get_Part_Count() > 0 );
560 }
561 
562 //---------------------------------------------------------
563 bool CSG_Shapes_OGIS_Converter::_WKB_Read_MultiPolygon(CSG_Bytes &Bytes, bool bSwapBytes, TSG_Vertex_Type Vertex, CSG_Shape *pShape)
564 {
565  DWORD nPolygons = Bytes.Read_DWord(bSwapBytes);
566 
567  for(DWORD iPolygon=0; iPolygon<nPolygons; iPolygon++)
568  {
569  bSwapBytes = Bytes.Read_Byte() != SG_OGIS_BYTEORDER_NDR;
570 
571  TSG_Shape_Type Geometry; TSG_Vertex_Type _Vertex; to_ShapeType(Bytes.Read_DWord(bSwapBytes), Geometry, _Vertex);
572 
573  if( Geometry != SHAPE_TYPE_Polygon || Vertex != _Vertex || !_WKB_Read_Polygon(Bytes, bSwapBytes, Vertex, pShape) )
574  {
575  return( false );
576  }
577  }
578 
579  return( pShape->Get_Part_Count() > 0 );
580 }
581 
582 //---------------------------------------------------------
584 {
585  pShape->Del_Parts();
586 
587  if( Bytes.Get_Count() >= 4 )
588  {
589  Bytes.Rewind();
590 
591  bool bSwapBytes = Bytes.Read_Byte() != SG_OGIS_BYTEORDER_NDR;
592 
593  DWORD Type = Bytes.Read_DWord();
594 
595  if( pShape->Get_Type() == to_ShapeType(Type) )
596  {
597  switch( Type )
598  {
599  case SG_OGIS_TYPE_Point : return( _WKB_Read_Point (Bytes, bSwapBytes, SG_VERTEX_TYPE_XY , pShape, 0) );
600  case SG_OGIS_TYPE_PointZ : return( _WKB_Read_Point (Bytes, bSwapBytes, SG_VERTEX_TYPE_XYZ , pShape, 0) );
601  case SG_OGIS_TYPE_PointM : return( _WKB_Read_Point (Bytes, bSwapBytes, SG_VERTEX_TYPE_XYZ , pShape, 0) );
602  case SG_OGIS_TYPE_PointZM : return( _WKB_Read_Point (Bytes, bSwapBytes, SG_VERTEX_TYPE_XYZM, pShape, 0) );
603 
604  case SG_OGIS_TYPE_MultiPoint : return( _WKB_Read_MultiPoint (Bytes, bSwapBytes, SG_VERTEX_TYPE_XY , pShape ) );
605  case SG_OGIS_TYPE_MultiPointZ : return( _WKB_Read_MultiPoint (Bytes, bSwapBytes, SG_VERTEX_TYPE_XYZ , pShape ) );
606  case SG_OGIS_TYPE_MultiPointM : return( _WKB_Read_MultiPoint (Bytes, bSwapBytes, SG_VERTEX_TYPE_XYZ , pShape ) );
607  case SG_OGIS_TYPE_MultiPointZM : return( _WKB_Read_MultiPoint (Bytes, bSwapBytes, SG_VERTEX_TYPE_XYZM, pShape ) );
608 
609  case SG_OGIS_TYPE_LineString : return( _WKB_Read_Points (Bytes, bSwapBytes, SG_VERTEX_TYPE_XY , pShape ) );
610  case SG_OGIS_TYPE_LineStringZ : return( _WKB_Read_Points (Bytes, bSwapBytes, SG_VERTEX_TYPE_XYZ , pShape ) );
611  case SG_OGIS_TYPE_LineStringM : return( _WKB_Read_Points (Bytes, bSwapBytes, SG_VERTEX_TYPE_XYZ , pShape ) );
612  case SG_OGIS_TYPE_LineStringZM : return( _WKB_Read_Points (Bytes, bSwapBytes, SG_VERTEX_TYPE_XYZM, pShape ) );
613 
614  case SG_OGIS_TYPE_MultiLineString : return( _WKB_Read_MultiLine (Bytes, bSwapBytes, SG_VERTEX_TYPE_XY , pShape ) );
615  case SG_OGIS_TYPE_MultiLineStringZ : return( _WKB_Read_MultiLine (Bytes, bSwapBytes, SG_VERTEX_TYPE_XYZ , pShape ) );
616  case SG_OGIS_TYPE_MultiLineStringM : return( _WKB_Read_MultiLine (Bytes, bSwapBytes, SG_VERTEX_TYPE_XYZ , pShape ) );
617  case SG_OGIS_TYPE_MultiLineStringZM: return( _WKB_Read_MultiLine (Bytes, bSwapBytes, SG_VERTEX_TYPE_XYZM, pShape ) );
618 
619  case SG_OGIS_TYPE_Polygon : return( _WKB_Read_Polygon (Bytes, bSwapBytes, SG_VERTEX_TYPE_XY , pShape ) );
620  case SG_OGIS_TYPE_PolygonZ : return( _WKB_Read_Polygon (Bytes, bSwapBytes, SG_VERTEX_TYPE_XYZ , pShape ) );
621  case SG_OGIS_TYPE_PolygonM : return( _WKB_Read_Polygon (Bytes, bSwapBytes, SG_VERTEX_TYPE_XYZ , pShape ) );
622  case SG_OGIS_TYPE_PolygonZM : return( _WKB_Read_Polygon (Bytes, bSwapBytes, SG_VERTEX_TYPE_XYZM, pShape ) );
623 
624  case SG_OGIS_TYPE_MultiPolygon : return( _WKB_Read_MultiPolygon(Bytes, bSwapBytes, SG_VERTEX_TYPE_XY , pShape ) );
625  case SG_OGIS_TYPE_MultiPolygonZ : return( _WKB_Read_MultiPolygon(Bytes, bSwapBytes, SG_VERTEX_TYPE_XYZ , pShape ) );
626  case SG_OGIS_TYPE_MultiPolygonM : return( _WKB_Read_MultiPolygon(Bytes, bSwapBytes, SG_VERTEX_TYPE_XYZ , pShape ) );
627  case SG_OGIS_TYPE_MultiPolygonZM : return( _WKB_Read_MultiPolygon(Bytes, bSwapBytes, SG_VERTEX_TYPE_XYZM, pShape ) );
628  }
629  }
630  }
631 
632  return( false );
633 }
634 
635 
637 // //
639 
640 //---------------------------------------------------------
641 inline bool CSG_Shapes_OGIS_Converter::_WKB_Write_Point(CSG_Bytes &Bytes, CSG_Shape *pShape, int iPoint, int iPart)
642 {
643  TSG_Point Point = pShape->Get_Point(iPoint, iPart);
644 
645  Bytes += Point.x;
646  Bytes += Point.y;
647 
648  switch( pShape->Get_Vertex_Type() )
649  {
650  case SG_VERTEX_TYPE_XY:
651  break;
652 
653  case SG_VERTEX_TYPE_XYZ:
654  Bytes += pShape->Get_Z(iPoint, iPart);
655  break;
656 
657  case SG_VERTEX_TYPE_XYZM:
658  Bytes += pShape->Get_Z(iPoint, iPart);
659  Bytes += pShape->Get_M(iPoint, iPart);
660  break;
661  }
662 
663  return( true );
664 }
665 
666 //---------------------------------------------------------
667 bool CSG_Shapes_OGIS_Converter::_WKB_Write_Points(CSG_Bytes &Bytes, CSG_Shape *pShape, int iPart)
668 {
669  bool bFirstTwice = pShape->Get_Type() == SHAPE_TYPE_Polygon && CSG_Point(pShape->Get_Point(0, iPart)) != pShape->Get_Point(0, iPart, false);
670 
671  Bytes += (DWORD)(pShape->Get_Point_Count(iPart) + (bFirstTwice ? 1 : 0));
672 
673  for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
674  {
675  _WKB_Write_Point(Bytes, pShape, iPoint, iPart);
676  }
677 
678  if( bFirstTwice )
679  {
680  _WKB_Write_Point(Bytes, pShape, 0, iPart);
681  }
682 
683  return( true );
684 }
685 
686 //---------------------------------------------------------
687 bool CSG_Shapes_OGIS_Converter::_WKB_Write_MultiPoint(CSG_Bytes &Bytes, CSG_Shape *pShape)
688 {
689  Bytes += (DWORD)pShape->Get_Point_Count(); // total number of points
690 
691  for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
692  {
693  for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
694  {
695  Bytes += (BYTE)SG_OGIS_BYTEORDER_NDR;
696 
697  switch( pShape->Get_Vertex_Type() )
698  {
699  case SG_VERTEX_TYPE_XY : Bytes += (DWORD)SG_OGIS_TYPE_Point ; break;
700  case SG_VERTEX_TYPE_XYZ : Bytes += (DWORD)SG_OGIS_TYPE_PointZ ; break;
701  case SG_VERTEX_TYPE_XYZM: Bytes += (DWORD)SG_OGIS_TYPE_PointZM; break;
702  }
703 
704  if( !_WKB_Write_Point(Bytes, pShape, iPoint, iPart) )
705  {
706  return( false );
707  }
708  }
709  }
710 
711  return( true );
712 }
713 
714 //---------------------------------------------------------
715 bool CSG_Shapes_OGIS_Converter::_WKB_Write_MultiLine(CSG_Bytes &Bytes, CSG_Shape *pShape)
716 {
717  Bytes += (DWORD)pShape->Get_Part_Count();
718 
719  for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
720  {
721  Bytes += (BYTE)SG_OGIS_BYTEORDER_NDR;
722 
723  switch( pShape->Get_Vertex_Type() )
724  {
725  case SG_VERTEX_TYPE_XY : Bytes += (DWORD)SG_OGIS_TYPE_LineString ; break;
726  case SG_VERTEX_TYPE_XYZ : Bytes += (DWORD)SG_OGIS_TYPE_LineStringZ ; break;
727  case SG_VERTEX_TYPE_XYZM: Bytes += (DWORD)SG_OGIS_TYPE_LineStringZM; break;
728  }
729 
730  if( !_WKB_Write_Points(Bytes, pShape, iPart) )
731  {
732  return( false );
733  }
734  }
735 
736  return( true );
737 }
738 
739 //---------------------------------------------------------
740 bool CSG_Shapes_OGIS_Converter::_WKB_Write_MultiPolygon(CSG_Bytes &Bytes, CSG_Shape *pShape)
741 {
742  int nPolygons = 0; CSG_Array_Int nRings(pShape->Get_Part_Count()), iPolygon(pShape->Get_Part_Count());
743 
744  for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
745  {
746  nRings[iPart] = 0;
747 
748  if( ((CSG_Shape_Polygon *)pShape)->is_Lake(iPart) == false )
749  {
750  nPolygons ++;
751  nRings [iPart] ++;
752  iPolygon[iPart] = iPart;
753 
754  for(int jPart=0; jPart<pShape->Get_Part_Count(); jPart++)
755  {
756  if( ((CSG_Shape_Polygon *)pShape)->is_Lake(jPart) && ((CSG_Shape_Polygon *)pShape)->Contains(pShape->Get_Point(0, jPart), iPart) )
757  {
758  nRings [iPart] ++;
759  iPolygon[jPart] = iPart;
760  }
761  }
762  }
763  }
764 
765  Bytes += (DWORD)nPolygons;
766 
767  for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
768  {
769  if( nRings[iPart] > 0 )
770  {
771  Bytes += (BYTE)SG_OGIS_BYTEORDER_NDR;
772 
773  switch( pShape->Get_Vertex_Type() )
774  {
775  case SG_VERTEX_TYPE_XY : Bytes += (DWORD)SG_OGIS_TYPE_Polygon ; break;
776  case SG_VERTEX_TYPE_XYZ : Bytes += (DWORD)SG_OGIS_TYPE_PolygonZ ; break;
777  case SG_VERTEX_TYPE_XYZM: Bytes += (DWORD)SG_OGIS_TYPE_PolygonZM; break;
778  }
779 
780  Bytes += (DWORD)nRings[iPart];
781 
782  for(int jPart=0; jPart<pShape->Get_Part_Count(); jPart++)
783  {
784  if( iPolygon[jPart] == iPart )
785  {
786  if( !_WKB_Write_Points(Bytes, pShape, jPart) )
787  {
788  return( false );
789  }
790  }
791  }
792  }
793  }
794 
795  return( nPolygons > 0 );
796 }
797 
798 //---------------------------------------------------------
800 {
801  DWORD Type;
802 
803  if( from_ShapeType(Type, pShape->Get_Type(), pShape->Get_Vertex_Type()) )
804  {
805  Bytes.Destroy();
806 
807  Bytes += (BYTE)SG_OGIS_BYTEORDER_NDR;
808  Bytes += Type;
809 
810  switch( pShape->Get_Type() )
811  {
812  case SHAPE_TYPE_Point : return( _WKB_Write_Point (Bytes, pShape, 0, 0) );
813  case SHAPE_TYPE_Points : return( _WKB_Write_MultiPoint (Bytes, pShape ) );
814  case SHAPE_TYPE_Line : return( _WKB_Write_MultiLine (Bytes, pShape ) );
815  case SHAPE_TYPE_Polygon: return( _WKB_Write_MultiPolygon(Bytes, pShape ) );
816  default: break;
817  }
818  }
819 
820  return( false );
821 }
822 
823 
825 // //
826 // //
827 // //
829 
830 //---------------------------------------------------------
832 {
833  switch( Vertex )
834  {
835  case SG_VERTEX_TYPE_XY:
836  switch( Shape )
837  {
838  case SHAPE_TYPE_Point : Type = Type_asWKText(SG_OGIS_TYPE_Point ); return( true );
839  case SHAPE_TYPE_Points : Type = Type_asWKText(SG_OGIS_TYPE_MultiPoint ); return( true );
840  case SHAPE_TYPE_Line : Type = Type_asWKText(SG_OGIS_TYPE_MultiLineString ); return( true );
841  case SHAPE_TYPE_Polygon: Type = Type_asWKText(SG_OGIS_TYPE_MultiPolygon ); return( true );
842  default: break;
843  }
844  break;
845 
846  case SG_VERTEX_TYPE_XYZ:
847  switch( Shape )
848  {
849  case SHAPE_TYPE_Point : Type = Type_asWKText(SG_OGIS_TYPE_PointZ ); return( true );
850  case SHAPE_TYPE_Points : Type = Type_asWKText(SG_OGIS_TYPE_MultiPointZ ); return( true );
851  case SHAPE_TYPE_Line : Type = Type_asWKText(SG_OGIS_TYPE_MultiLineStringZ ); return( true );
852  case SHAPE_TYPE_Polygon: Type = Type_asWKText(SG_OGIS_TYPE_MultiPolygonZ ); return( true );
853  default: break;
854  }
855  break;
856 
857  case SG_VERTEX_TYPE_XYZM:
858  switch( Shape )
859  {
860  case SHAPE_TYPE_Point : Type = Type_asWKText(SG_OGIS_TYPE_PointZM ); return( true );
861  case SHAPE_TYPE_Points : Type = Type_asWKText(SG_OGIS_TYPE_MultiPointZM ); return( true );
862  case SHAPE_TYPE_Line : Type = Type_asWKText(SG_OGIS_TYPE_MultiLineStringZM); return( true );
863  case SHAPE_TYPE_Polygon: Type = Type_asWKText(SG_OGIS_TYPE_MultiPolygonZM ); return( true );
864  default: break;
865  }
866  break;
867  }
868 
869  return( false );
870 }
871 
872 //---------------------------------------------------------
874 {
875  switch( Vertex )
876  {
877  case SG_VERTEX_TYPE_XY:
878  switch( Shape )
879  {
880  case SHAPE_TYPE_Point : Type = SG_OGIS_TYPE_Point ; return( true );
881  case SHAPE_TYPE_Points : Type = SG_OGIS_TYPE_MultiPoint ; return( true );
882  case SHAPE_TYPE_Line : Type = SG_OGIS_TYPE_MultiLineString; return( true );
883  case SHAPE_TYPE_Polygon: Type = SG_OGIS_TYPE_MultiPolygon ; return( true );
884  default: break;
885  }
886  break;
887 
888  case SG_VERTEX_TYPE_XYZ:
889  switch( Shape )
890  {
891  case SHAPE_TYPE_Point : Type = SG_OGIS_TYPE_PointZ ; return( true );
892  case SHAPE_TYPE_Points : Type = SG_OGIS_TYPE_MultiPointZ ; return( true );
893  case SHAPE_TYPE_Line : Type = SG_OGIS_TYPE_MultiLineStringZ; return( true );
894  case SHAPE_TYPE_Polygon: Type = SG_OGIS_TYPE_MultiPolygonZ ; return( true );
895  default: break;
896  }
897  break;
898 
899  case SG_VERTEX_TYPE_XYZM:
900  switch( Shape )
901  {
902  case SHAPE_TYPE_Point : Type = SG_OGIS_TYPE_PointZM ; return( true );
903  case SHAPE_TYPE_Points : Type = SG_OGIS_TYPE_MultiPointZM ; return( true );
904  case SHAPE_TYPE_Line : Type = SG_OGIS_TYPE_MultiLineStringZM; return( true );
905  case SHAPE_TYPE_Polygon: Type = SG_OGIS_TYPE_MultiPolygonZM ; return( true );
906  default: break;
907  }
908  break;
909  }
910 
911  return( false );
912 }
913 
914 //---------------------------------------------------------
916 {
917  CSG_String Type;
918 
919  from_ShapeType(Type, Shape, Vertex);
920 
921  return( Type );
922 }
923 
924 //---------------------------------------------------------
926 {
927  switch( Type_asWKBinary(Type) )
928  {
929  case SG_OGIS_TYPE_Point : Shape = SHAPE_TYPE_Point ; Vertex = SG_VERTEX_TYPE_XY ; return( true );
930  case SG_OGIS_TYPE_MultiPoint : Shape = SHAPE_TYPE_Points ; Vertex = SG_VERTEX_TYPE_XY ; return( true );
931  case SG_OGIS_TYPE_LineString : Shape = SHAPE_TYPE_Line ; Vertex = SG_VERTEX_TYPE_XY ; return( true );
932  case SG_OGIS_TYPE_MultiLineString : Shape = SHAPE_TYPE_Line ; Vertex = SG_VERTEX_TYPE_XY ; return( true );
933  case SG_OGIS_TYPE_Polygon : Shape = SHAPE_TYPE_Polygon; Vertex = SG_VERTEX_TYPE_XY ; return( true );
934  case SG_OGIS_TYPE_MultiPolygon : Shape = SHAPE_TYPE_Polygon; Vertex = SG_VERTEX_TYPE_XY ; return( true );
935 
936  case SG_OGIS_TYPE_PointZ : Shape = SHAPE_TYPE_Point ; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
937  case SG_OGIS_TYPE_MultiPointZ : Shape = SHAPE_TYPE_Points ; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
938  case SG_OGIS_TYPE_LineStringZ : Shape = SHAPE_TYPE_Line ; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
939  case SG_OGIS_TYPE_MultiLineStringZ : Shape = SHAPE_TYPE_Line ; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
940  case SG_OGIS_TYPE_PolygonZ : Shape = SHAPE_TYPE_Polygon; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
941  case SG_OGIS_TYPE_MultiPolygonZ : Shape = SHAPE_TYPE_Polygon; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
942 
943  case SG_OGIS_TYPE_PointM : Shape = SHAPE_TYPE_Point ; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
944  case SG_OGIS_TYPE_MultiPointM : Shape = SHAPE_TYPE_Points ; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
945  case SG_OGIS_TYPE_LineStringM : Shape = SHAPE_TYPE_Line ; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
946  case SG_OGIS_TYPE_MultiLineStringM : Shape = SHAPE_TYPE_Line ; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
947  case SG_OGIS_TYPE_PolygonM : Shape = SHAPE_TYPE_Polygon; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
948  case SG_OGIS_TYPE_MultiPolygonM : Shape = SHAPE_TYPE_Polygon; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
949 
950  case SG_OGIS_TYPE_PointZM : Shape = SHAPE_TYPE_Point ; Vertex = SG_VERTEX_TYPE_XYZM; return( true );
951  case SG_OGIS_TYPE_MultiPointZM : Shape = SHAPE_TYPE_Points ; Vertex = SG_VERTEX_TYPE_XYZM; return( true );
952  case SG_OGIS_TYPE_LineStringZM : Shape = SHAPE_TYPE_Line ; Vertex = SG_VERTEX_TYPE_XYZM; return( true );
953  case SG_OGIS_TYPE_MultiLineStringZM : Shape = SHAPE_TYPE_Line ; Vertex = SG_VERTEX_TYPE_XYZM; return( true );
954  case SG_OGIS_TYPE_PolygonZM : Shape = SHAPE_TYPE_Polygon; Vertex = SG_VERTEX_TYPE_XYZM; return( true );
955  case SG_OGIS_TYPE_MultiPolygonZM : Shape = SHAPE_TYPE_Polygon; Vertex = SG_VERTEX_TYPE_XYZM; return( true );
956  }
957 
958  Shape = SHAPE_TYPE_Undefined; Vertex = SG_VERTEX_TYPE_XY;
959 
960  return( false );
961 }
962 
963 //---------------------------------------------------------
965 {
966  switch( Type )
967  {
968  case SG_OGIS_TYPE_Point : Shape = SHAPE_TYPE_Point ; Vertex = SG_VERTEX_TYPE_XY ; return( true );
969  case SG_OGIS_TYPE_MultiPoint : Shape = SHAPE_TYPE_Points ; Vertex = SG_VERTEX_TYPE_XY ; return( true );
970  case SG_OGIS_TYPE_LineString : Shape = SHAPE_TYPE_Line ; Vertex = SG_VERTEX_TYPE_XY ; return( true );
971  case SG_OGIS_TYPE_MultiLineString : Shape = SHAPE_TYPE_Line ; Vertex = SG_VERTEX_TYPE_XY ; return( true );
972  case SG_OGIS_TYPE_Polygon : Shape = SHAPE_TYPE_Polygon; Vertex = SG_VERTEX_TYPE_XY ; return( true );
973  case SG_OGIS_TYPE_MultiPolygon : Shape = SHAPE_TYPE_Polygon; Vertex = SG_VERTEX_TYPE_XY ; return( true );
974 
975  case SG_OGIS_TYPE_PointZ : Shape = SHAPE_TYPE_Point ; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
976  case SG_OGIS_TYPE_MultiPointZ : Shape = SHAPE_TYPE_Points ; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
977  case SG_OGIS_TYPE_LineStringZ : Shape = SHAPE_TYPE_Line ; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
978  case SG_OGIS_TYPE_MultiLineStringZ : Shape = SHAPE_TYPE_Line ; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
979  case SG_OGIS_TYPE_PolygonZ : Shape = SHAPE_TYPE_Polygon; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
980  case SG_OGIS_TYPE_MultiPolygonZ : Shape = SHAPE_TYPE_Polygon; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
981 
982  case SG_OGIS_TYPE_PointM : Shape = SHAPE_TYPE_Point ; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
983  case SG_OGIS_TYPE_MultiPointM : Shape = SHAPE_TYPE_Points ; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
984  case SG_OGIS_TYPE_LineStringM : Shape = SHAPE_TYPE_Line ; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
985  case SG_OGIS_TYPE_MultiLineStringM : Shape = SHAPE_TYPE_Line ; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
986  case SG_OGIS_TYPE_PolygonM : Shape = SHAPE_TYPE_Polygon; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
987  case SG_OGIS_TYPE_MultiPolygonM : Shape = SHAPE_TYPE_Polygon; Vertex = SG_VERTEX_TYPE_XYZ ; return( true );
988 
989  case SG_OGIS_TYPE_PointZM : Shape = SHAPE_TYPE_Point ; Vertex = SG_VERTEX_TYPE_XYZM; return( true );
990  case SG_OGIS_TYPE_MultiPointZM : Shape = SHAPE_TYPE_Points ; Vertex = SG_VERTEX_TYPE_XYZM; return( true );
991  case SG_OGIS_TYPE_LineStringZM : Shape = SHAPE_TYPE_Line ; Vertex = SG_VERTEX_TYPE_XYZM; return( true );
992  case SG_OGIS_TYPE_MultiLineStringZM : Shape = SHAPE_TYPE_Line ; Vertex = SG_VERTEX_TYPE_XYZM; return( true );
993  case SG_OGIS_TYPE_PolygonZM : Shape = SHAPE_TYPE_Polygon; Vertex = SG_VERTEX_TYPE_XYZM; return( true );
994  case SG_OGIS_TYPE_MultiPolygonZM : Shape = SHAPE_TYPE_Polygon; Vertex = SG_VERTEX_TYPE_XYZM; return( true );
995  }
996 
997  Shape = SHAPE_TYPE_Undefined; Vertex = SG_VERTEX_TYPE_XY;
998 
999  return( false );
1000 }
1001 
1002 //---------------------------------------------------------
1004 {
1005  TSG_Shape_Type Geometry; TSG_Vertex_Type Vertex; to_ShapeType(Type, Geometry, Vertex);
1006 
1007  return( Geometry );
1008 }
1009 
1010 //---------------------------------------------------------
1012 {
1013  TSG_Shape_Type Geometry; TSG_Vertex_Type Vertex; to_ShapeType(Type, Geometry, Vertex);
1014 
1015  return( Geometry );
1016 }
1017 
1018 //---------------------------------------------------------
1020 {
1021  TSG_Shape_Type Geometry; TSG_Vertex_Type Vertex; to_ShapeType(Type, Geometry, Vertex);
1022 
1023  return( Vertex );
1024 }
1025 
1026 //---------------------------------------------------------
1028 {
1029  TSG_Shape_Type Geometry; TSG_Vertex_Type Vertex; to_ShapeType(Type, Geometry, Vertex);
1030 
1031  return( Vertex );
1032 }
1033 
1034 
1036 // //
1037 // //
1038 // //
1040 
1041 //---------------------------------------------------------
1042 // Basic Type definitions
1043 // byte : 1 byte
1044 // uint16 : 16 bit unsigned integer (2 bytes)
1045 // uint32 : 32 bit unsigned integer (4 bytes)
1046 // float64 : double precision floating point number (8 bytes)
1047 //
1048 // +------------------------------------------------------------+
1049 // | RASTER |
1050 // +---------------+-------------+------------------------------+
1051 // | - name - | - type - | - meaning - |
1052 // +---------------+-------------+------------------------------+
1053 // | endianness | byte | 1:ndr/little endian |
1054 // | | | 0:xdr/big endian |
1055 // +---------------+-------------+------------------------------+
1056 // | version | uint16 | format version (0 for this |
1057 // | | | structure) |
1058 // +---------------+-------------+------------------------------+
1059 // | nBands | uint16 | Number of bands |
1060 // +---------------+-------------+------------------------------+
1061 // | scaleX | float64 | pixel width |
1062 // | | | in geographical units |
1063 // +---------------+-------------+------------------------------+
1064 // | scaleY | float64 | pixel height |
1065 // | | | in geographical units |
1066 // +---------------+-------------+------------------------------+
1067 // | ipX | float64 | X ordinate of upper-left |
1068 // | | | pixel's upper-left corner |
1069 // | | | in geographical units |
1070 // +---------------+-------------+------------------------------+
1071 // | ipY | float64 | Y ordinate of upper-left |
1072 // | | | pixel's upper-left corner |
1073 // | | | in geographical units |
1074 // +---------------+-------------+------------------------------+
1075 // | skewX | float64 | rotation about Y-axis |
1076 // +---------------+-------------+------------------------------+
1077 // | skewY | float64 | rotation about X-axis |
1078 // +---------------+-------------+------------------------------+
1079 // | srid | int32 | Spatial reference id |
1080 // +---------------+-------------+------------------------------+
1081 // | width | uint16 | number of pixel columns |
1082 // +---------------+-------------+------------------------------+
1083 // | height | uint16 | number of pixel rows |
1084 // +---------------+-------------+------------------------------+
1085 // | bands[nBands] | RASTERBAND | Bands data |
1086 // +---------------+-------------+------------------------------+
1087 
1089 // //
1091 
1092 //---------------------------------------------------------
1093 #include "grid.h"
1094 
1095 
1097 // //
1099 
1100 //---------------------------------------------------------
1102 {
1103  Bytes.Rewind();
1104 
1105  //-----------------------------------------------------
1106  // Raster System
1107 
1108  bool bSwap = Bytes.Read_Byte () == 0; // endiannes: 1=ndr/little endian, 0=xdr/big endian
1109  short version = Bytes.Read_Short (bSwap); // version
1110  short nBands = Bytes.Read_Short (bSwap); // number of bands
1111  double dx = Bytes.Read_Double(bSwap); // scaleX
1112  double dy = Bytes.Read_Double(bSwap); // scaleY
1113  double xMin = Bytes.Read_Double(bSwap); // ipX
1114  double yMax = Bytes.Read_Double(bSwap); // ipY
1115  double skewX = Bytes.Read_Double(bSwap); // skewX
1116  double skewY = Bytes.Read_Double(bSwap); // skewY
1117  int SRID = Bytes.Read_Int (bSwap); // srid
1118  short NX = Bytes.Read_Short (bSwap); // width
1119  short NY = Bytes.Read_Short (bSwap); // height
1120 
1121  //-----------------------------------------------------
1122  // Band
1123 
1124  TSG_Data_Type Type; BYTE Flags = Bytes.Read_Byte();
1125 
1126  switch( Flags & 0x0F )
1127  {
1128  case 0: Type = SG_DATATYPE_Bit ; break; // 0: 1-bit boolean
1129  case 1: Type = SG_DATATYPE_Char ; break; // 1: 2-bit unsigned integer
1130  case 2: Type = SG_DATATYPE_Char ; break; // 2: 4-bit unsigned integer
1131  case 3: Type = SG_DATATYPE_Char ; break; // 3: 8-bit signed integer
1132  case 4: Type = SG_DATATYPE_Byte ; break; // 4: 8-bit unsigned integer
1133  case 5: Type = SG_DATATYPE_Short ; break; // 5: 16-bit signed integer
1134  case 6: Type = SG_DATATYPE_Word ; break; // 6: 16-bit unsigned integer
1135  case 7: Type = SG_DATATYPE_Int ; break; // 7: 32-bit signed integer
1136  case 8: Type = SG_DATATYPE_DWord ; break; // 8: 32-bit unsigned integer
1137  case 10: Type = SG_DATATYPE_Float ; break; // 10: 32-bit float
1138  case 11: Type = SG_DATATYPE_Double; break; // 11: 64-bit float
1139  }
1140 
1141 // Flags |= 0x80; // isOffline: no, never here!
1142  Flags |= 0x40; // hasNodataValue
1143 // Flags |= 0x20; // isNoDataValue: no, never here!
1144 // Flags |= 0x10; // reserved (unused)
1145 
1146  if( !pGrid->Create(Type, NX, NY, dx, xMin + 0.5 * dx, yMax - (NY - 0.5) * dx) )
1147  {
1148  return( false );
1149  }
1150 
1151  pGrid->Get_Projection().Create(SRID);
1152 
1153  double noData;
1154 
1155  switch( pGrid->Get_Type() )
1156  {
1157  case SG_DATATYPE_Bit : noData = Bytes.Read_Byte ( ); break; // 0: 1-bit boolean
1158  case SG_DATATYPE_Char : noData = Bytes.Read_Char ( ); break; // 3: 8-bit signed integer
1159  case SG_DATATYPE_Byte : noData = Bytes.Read_Byte ( ); break; // 4: 8-bit unsigned integer
1160  case SG_DATATYPE_Short : noData = Bytes.Read_Short (bSwap); break; // 5: 16-bit signed integer
1161  case SG_DATATYPE_Word : noData = Bytes.Read_Word (bSwap); break; // 6: 16-bit unsigned integer
1162  case SG_DATATYPE_Int : noData = Bytes.Read_Int (bSwap); break; // 7: 32-bit signed integer
1163  case SG_DATATYPE_DWord : noData = Bytes.Read_DWord (bSwap); break; // 8: 32-bit unsigned integer
1164  case SG_DATATYPE_Float : noData = Bytes.Read_Float (bSwap); break; // 9: 32-bit float
1165  case SG_DATATYPE_Double: noData = Bytes.Read_Double(bSwap); break; // 10: 64-bit float
1166  default:
1167  break;
1168  }
1169 
1170  pGrid->Set_NoData_Value(noData);
1171 
1172  for(int y=0; y<pGrid->Get_NY() && SG_UI_Process_Set_Progress(y, pGrid->Get_NY()); y++)
1173  {
1174  for(int x=0; x<pGrid->Get_NX(); x++)
1175  {
1176  switch( pGrid->Get_Type() )
1177  {
1178  case SG_DATATYPE_Bit : pGrid->Set_Value(x, y, Bytes.Read_Byte ( )); break; // 0: 1-bit boolean
1179  case SG_DATATYPE_Char : pGrid->Set_Value(x, y, Bytes.Read_Char ( )); break; // 3: 8-bit signed integer
1180  case SG_DATATYPE_Byte : pGrid->Set_Value(x, y, Bytes.Read_Byte ( )); break; // 4: 8-bit unsigned integer
1181  case SG_DATATYPE_Short : pGrid->Set_Value(x, y, Bytes.Read_Short (bSwap)); break; // 5: 16-bit signed integer
1182  case SG_DATATYPE_Word : pGrid->Set_Value(x, y, Bytes.Read_Word (bSwap)); break; // 6: 16-bit unsigned integer
1183  case SG_DATATYPE_Int : pGrid->Set_Value(x, y, Bytes.Read_Int (bSwap)); break; // 7: 32-bit signed integer
1184  case SG_DATATYPE_DWord : pGrid->Set_Value(x, y, Bytes.Read_DWord (bSwap)); break; // 8: 32-bit unsigned integer
1185  case SG_DATATYPE_Float : pGrid->Set_Value(x, y, Bytes.Read_Float (bSwap)); break; // 9: 32-bit float
1186  case SG_DATATYPE_Double: pGrid->Set_Value(x, y, Bytes.Read_Double(bSwap)); break; // 10: 64-bit float
1187  default:
1188  break;
1189  }
1190  }
1191  }
1192 
1193  return( true );
1194 }
1195 
1196 //---------------------------------------------------------
1197 bool CSG_Grid_OGIS_Converter::to_WKBinary(CSG_Bytes &Bytes, class CSG_Grid *pGrid, int SRID)
1198 {
1199  Bytes.Clear();
1200 
1201  //-----------------------------------------------------
1202  // Raster System
1203 
1204  if( pGrid->Get_Projection().Get_EPSG() > 0 )
1205  {
1206  SRID = pGrid->Get_Projection().Get_EPSG();
1207  }
1208 
1209  Bytes += (BYTE )1 ; // endiannes
1210  Bytes += (short )0 ; // version
1211  Bytes += (short )1 ; // number of bands
1212  Bytes += (double)pGrid->Get_Cellsize(); // scaleX
1213  Bytes += (double)pGrid->Get_Cellsize(); // scaleY
1214  Bytes += (double)pGrid->Get_XMin(true); // ipX
1215  Bytes += (double)pGrid->Get_YMax(true); // ipY
1216  Bytes += (double)0. ; // skewX
1217  Bytes += (double)0. ; // skewY
1218  Bytes += (int )SRID ; // srid
1219  Bytes += (short )pGrid->Get_NX() ; // width
1220  Bytes += (short )pGrid->Get_NY() ; // height
1221 
1222  //-----------------------------------------------------
1223  // Band
1224 
1225  BYTE Flags;
1226 
1227  switch( pGrid->Get_Type() )
1228  {
1229  case SG_DATATYPE_Bit : Flags = 0; break; // 0: 1-bit boolean
1230 // case SG_DATATYPE_ : Flags = 1; break; // 1: 2-bit unsigned integer
1231 // case SG_DATATYPE_ : Flags = 2; break; // 2: 4-bit unsigned integer
1232  case SG_DATATYPE_Char : Flags = 3; break; // 3: 8-bit signed integer
1233  case SG_DATATYPE_Byte : Flags = 4; break; // 4: 8-bit unsigned integer
1234  case SG_DATATYPE_Short : Flags = 5; break; // 5: 16-bit signed integer
1235  case SG_DATATYPE_Word : Flags = 6; break; // 6: 16-bit unsigned integer
1236  case SG_DATATYPE_Int : Flags = 7; break; // 7: 32-bit signed integer
1237  case SG_DATATYPE_DWord : Flags = 8; break; // 8: 32-bit unsigned integer
1238  default : Flags = 10; break; // 10: 32-bit float
1239  case SG_DATATYPE_Double: Flags = 11; break; // 11: 64-bit float
1240  }
1241 
1242 // Flags |= 0x80; // isOffline: no, never here!
1243  Flags |= 0x40; // hasNodataValue
1244 // Flags |= 0x20; // isNoDataValue: no, never here!
1245 // Flags |= 0x10; // reserved (unused)
1246 
1247  Bytes += Flags;
1248 
1249  switch( pGrid->Get_Type() )
1250  {
1251  case SG_DATATYPE_Bit : Bytes += (BYTE )0 ; break; // 0: 1-bit boolean
1252  case SG_DATATYPE_Char : Bytes += (char )pGrid->Get_NoData_Value(); break; // 3: 8-bit signed integer
1253  case SG_DATATYPE_Byte : Bytes += (BYTE )pGrid->Get_NoData_Value(); break; // 4: 8-bit unsigned integer
1254  case SG_DATATYPE_Short : Bytes += (short )pGrid->Get_NoData_Value(); break; // 5: 16-bit signed integer
1255  case SG_DATATYPE_Word : Bytes += (WORD )pGrid->Get_NoData_Value(); break; // 6: 16-bit unsigned integer
1256  case SG_DATATYPE_Int : Bytes += (int )pGrid->Get_NoData_Value(); break; // 7: 32-bit signed integer
1257  case SG_DATATYPE_DWord : Bytes += (DWORD )pGrid->Get_NoData_Value(); break; // 8: 32-bit unsigned integer
1258  default : Bytes += (float )pGrid->Get_NoData_Value(); break; // 9: 32-bit float
1259  case SG_DATATYPE_Double: Bytes += (double)pGrid->Get_NoData_Value(); break; // 10: 64-bit float
1260  }
1261 
1262  for(int y=0; y<pGrid->Get_NY() && SG_UI_Process_Set_Progress(y, pGrid->Get_NY()); y++)
1263  {
1264  for(int x=0; x<pGrid->Get_NX(); x++)
1265  {
1266  double Value = pGrid->is_NoData(x, y) ? pGrid->Get_NoData_Value() : pGrid->asDouble(x, y);
1267 
1268  switch( pGrid->Get_Type() )
1269  {
1270  case SG_DATATYPE_Bit : Bytes += (BYTE )Value; break; // 0: 1-bit boolean
1271  case SG_DATATYPE_Char : Bytes += (char )Value; break; // 3: 8-bit signed integer
1272  case SG_DATATYPE_Byte : Bytes += (BYTE )Value; break; // 4: 8-bit unsigned integer
1273  case SG_DATATYPE_Short : Bytes += (short )Value; break; // 5: 16-bit signed integer
1274  case SG_DATATYPE_Word : Bytes += (WORD )Value; break; // 6: 16-bit unsigned integer
1275  case SG_DATATYPE_Int : Bytes += (int )Value; break; // 7: 32-bit signed integer
1276  case SG_DATATYPE_DWord : Bytes += (DWORD )Value; break; // 8: 32-bit unsigned integer
1277  default : Bytes += (float )Value; break; // 9: 32-bit float
1278  case SG_DATATYPE_Double: Bytes += (double)Value; break; // 10: 64-bit float
1279  }
1280  }
1281  }
1282 
1283  return( true );
1284 }
1285 
1286 
1288 // //
1289 // //
1290 // //
1292 
1293 //---------------------------------------------------------
CSG_Grid::Get_Type
TSG_Data_Type Get_Type(void) const
Definition: grid.h:521
CSG_String::BeforeFirst
CSG_String BeforeFirst(char Character) const
Definition: api_string.cpp:666
SG_DATATYPE_Int
@ SG_DATATYPE_Int
Definition: api_core.h:1000
SG_OGIS_TYPE_TriangleM
@ SG_OGIS_TYPE_TriangleM
Definition: shapes.h:1500
CSG_Bytes::Read_DWord
DWORD Read_DWord(bool bSwapBytes=false)
Definition: api_core.h:879
CSG_Shapes_OGIS_Converter::from_WKText
static bool from_WKText(const CSG_String &Text, CSG_Shape *pShape)
Definition: shapes_ogis.cpp:279
SG_T
#define SG_T(s)
Definition: api_core.h:537
SG_OGIS_TYPE_TINZ
@ SG_OGIS_TYPE_TINZ
Definition: shapes.h:1488
SG_DATATYPE_DWord
@ SG_DATATYPE_DWord
Definition: api_core.h:999
CSG_Bytes::Read_Int
int Read_Int(bool bSwapBytes=false)
Definition: api_core.h:878
CSG_String::Length
size_t Length(void) const
Definition: api_string.cpp:172
SG_OGIS_TYPE_PolygonZ
@ SG_OGIS_TYPE_PolygonZ
Definition: shapes.h:1482
CSG_Bytes::Destroy
bool Destroy(void)
Definition: api_memory.cpp:829
CSG_Shape::Get_Z
virtual double Get_Z(int iPoint=0, int iPart=0, bool bAscending=true) const
Definition: shapes.h:195
CSG_Shape::Del_Parts
virtual int Del_Parts(void)
Definition: shapes.h:171
CSG_Data_Object::Get_NoData_Value
double Get_NoData_Value(bool bUpper=false) const
Definition: dataobject.h:253
TSG_Shape_Type
TSG_Shape_Type
Definition: shapes.h:100
CSG_Grid::Create
bool Create(const CSG_Grid &Grid)
Definition: grid.cpp:230
CSG_Bytes::Get_Count
int Get_Count(void) const
Definition: api_core.h:831
CSG_Bytes::Read_Word
WORD Read_Word(bool bSwapBytes=false)
Definition: api_core.h:877
SHAPE_TYPE_Polygon
@ SHAPE_TYPE_Polygon
Definition: shapes.h:105
CSG_Shapes_OGIS_Converter::to_WKBinary
static bool to_WKBinary(CSG_Shape *pShape, CSG_Bytes &Bytes)
Definition: shapes_ogis.cpp:799
SG_DATATYPE_Byte
@ SG_DATATYPE_Byte
Definition: api_core.h:995
grid.h
SG_SSCANF
#define SG_SSCANF
Definition: api_core.h:540
CSG_Grid_OGIS_Converter::to_WKBinary
static bool to_WKBinary(CSG_Bytes &Bytes, class CSG_Grid *pGrid, int SRID=-1)
Definition: shapes_ogis.cpp:1197
SG_OGIS_TYPE_PolyhedralSurfaceZM
@ SG_OGIS_TYPE_PolyhedralSurfaceZM
Definition: shapes.h:1509
SG_OGIS_TYPE_MultiPolygon
@ SG_OGIS_TYPE_MultiPolygon
Definition: shapes.h:1474
SG_OGIS_TYPE_PointM
@ SG_OGIS_TYPE_PointM
Definition: shapes.h:1491
SG_OGIS_TYPE_PointZ
@ SG_OGIS_TYPE_PointZ
Definition: shapes.h:1480
TYPE_AS_WKB
#define TYPE_AS_WKB(t)
SG_OGIS_TYPE_MultiPoint
@ SG_OGIS_TYPE_MultiPoint
Definition: shapes.h:1472
SG_OGIS_TYPE_MultiLineString
@ SG_OGIS_TYPE_MultiLineString
Definition: shapes.h:1473
SSG_Point
Definition: geo_tools.h:128
CSG_Table_Record::Get_Table
class CSG_Table * Get_Table(void)
Definition: table.h:135
CSG_Projection::Get_EPSG
int Get_EPSG(void) const
Definition: geo_tools.h:893
CSG_Shape::Get_Type
TSG_Shape_Type Get_Type(void) const
Definition: shape.cpp:88
CSG_Shapes_OGIS_Converter::to_ShapeType
static bool to_ShapeType(const CSG_String &Type, TSG_Shape_Type &Shape, TSG_Vertex_Type &Vertex)
Definition: shapes_ogis.cpp:925
CSG_Shapes_OGIS_Converter::from_WKBinary
static bool from_WKBinary(CSG_Bytes &Bytes, CSG_Shape *pShape)
Definition: shapes_ogis.cpp:583
SG_OGIS_TYPE_MultiPolygonZM
@ SG_OGIS_TYPE_MultiPolygonZM
Definition: shapes.h:1507
CSG_Shape_Points::Get_Point
virtual TSG_Point Get_Point(int iPoint=0) const
Definition: shape_points.cpp:294
CSG_Shape::Get_Point
virtual TSG_Point Get_Point(int iPoint=0) const =0
SG_VERTEX_TYPE_XY
@ SG_VERTEX_TYPE_XY
Definition: shapes.h:92
SG_OGIS_TYPE_PolygonM
@ SG_OGIS_TYPE_PolygonM
Definition: shapes.h:1493
SG_OGIS_TYPE_Undefined
@ SG_OGIS_TYPE_Undefined
Definition: shapes.h:1467
CSG_String::BeforeLast
CSG_String BeforeLast(char Character) const
Definition: api_string.cpp:677
SG_OGIS_BYTEORDER_NDR
@ SG_OGIS_BYTEORDER_NDR
Definition: shapes.h:1461
CSG_Bytes::Clear
bool Clear(void)
Definition: api_memory.cpp:844
CSG_Shape::Get_Part_Count
virtual int Get_Part_Count(void) const =0
CSG_Shapes_OGIS_Converter::Type_asWKBinary
static DWORD Type_asWKBinary(const CSG_String &Type)
Definition: shapes_ogis.cpp:114
CSG_Bytes::Rewind
void Rewind(void)
Definition: api_core.h:828
CSG_Grid::Get_Cellsize
double Get_Cellsize(void) const
Definition: grid.h:541
SG_OGIS_TYPE_LineString
@ SG_OGIS_TYPE_LineString
Definition: shapes.h:1470
CSG_Point
Definition: geo_tools.h:135
SG_VERTEX_TYPE_XYZM
@ SG_VERTEX_TYPE_XYZM
Definition: shapes.h:94
CSG_Shapes_OGIS_Converter::to_VertexType
static TSG_Vertex_Type to_VertexType(const CSG_String &Type)
Definition: shapes_ogis.cpp:1019
SG_OGIS_TYPE_GeometryCollectionZM
@ SG_OGIS_TYPE_GeometryCollectionZM
Definition: shapes.h:1508
SG_OGIS_TYPE_TINM
@ SG_OGIS_TYPE_TINM
Definition: shapes.h:1499
CSG_Bytes::Read_Byte
BYTE Read_Byte(void)
Definition: api_core.h:874
CSG_Shape::Get_Vertex_Type
TSG_Vertex_Type Get_Vertex_Type(void) const
Definition: shape.cpp:94
CSG_Grid::Set_Value
virtual void Set_Value(sLong i, double Value, bool bScaled=true)
Definition: grid.h:817
SG_OGIS_TYPE_TINZM
@ SG_OGIS_TYPE_TINZM
Definition: shapes.h:1510
SG_OGIS_TYPE_PolyhedralSurface
@ SG_OGIS_TYPE_PolyhedralSurface
Definition: shapes.h:1476
CSG_Grid::Get_NY
int Get_NY(void) const
Definition: grid.h:538
CSG_String::Trim_Both
int Trim_Both(void)
Definition: api_string.cpp:600
SG_OGIS_TYPE_Point
@ SG_OGIS_TYPE_Point
Definition: shapes.h:1469
SG_DATATYPE_Float
@ SG_DATATYPE_Float
Definition: api_core.h:1003
SG_OGIS_TYPE_PolyhedralSurfaceZ
@ SG_OGIS_TYPE_PolyhedralSurfaceZ
Definition: shapes.h:1487
CSG_Grid::Get_XMin
double Get_XMin(bool bCells=false) const
Definition: grid.h:546
CSG_Array_Int
Definition: api_core.h:423
SG_OGIS_TYPE_TriangleZ
@ SG_OGIS_TYPE_TriangleZ
Definition: shapes.h:1489
SG_OGIS_TYPE_GeometryCollectionZ
@ SG_OGIS_TYPE_GeometryCollectionZ
Definition: shapes.h:1486
SG_OGIS_TYPE_LineStringZM
@ SG_OGIS_TYPE_LineStringZM
Definition: shapes.h:1503
CSG_Shape::Get_M
virtual double Get_M(int iPoint=0, int iPart=0, bool bAscending=true) const
Definition: shapes.h:211
CSG_Shapes_OGIS_Converter::to_WKText
static bool to_WKText(CSG_Shape *pShape, CSG_String &Text)
Definition: shapes_ogis.cpp:438
SG_OGIS_TYPE_GeometryCollection
@ SG_OGIS_TYPE_GeometryCollection
Definition: shapes.h:1475
CSG_Shape::Add_Point
virtual int Add_Point(double x, double y, int iPart=0)=0
CSG_Shapes_OGIS_Converter::from_ShapeType
static bool from_ShapeType(CSG_String &Type, TSG_Shape_Type Shape, TSG_Vertex_Type Vertex=SG_VERTEX_TYPE_XY)
Definition: shapes_ogis.cpp:831
SG_DATATYPE_Word
@ SG_DATATYPE_Word
Definition: api_core.h:997
SG_OGIS_TYPE_TIN
@ SG_OGIS_TYPE_TIN
Definition: shapes.h:1477
CSG_Bytes
Definition: api_core.h:812
CSG_String::Format
static CSG_String Format(const char *Format,...)
Definition: api_string.cpp:270
SG_OGIS_TYPE_PolyhedralSurfaceM
@ SG_OGIS_TYPE_PolyhedralSurfaceM
Definition: shapes.h:1498
SHAPE_TYPE_Line
@ SHAPE_TYPE_Line
Definition: shapes.h:104
SG_OGIS_TYPE_GeometryCollectionM
@ SG_OGIS_TYPE_GeometryCollectionM
Definition: shapes.h:1497
SG_OGIS_TYPE_TriangleZM
@ SG_OGIS_TYPE_TriangleZM
Definition: shapes.h:1511
CSG_String::AfterFirst
CSG_String AfterFirst(char Character) const
Definition: api_string.cpp:644
CSG_String::Clear
void Clear(void)
Definition: api_string.cpp:259
CSG_Shape::Get_Point_Count
virtual int Get_Point_Count(void) const =0
TSG_Vertex_Type
TSG_Vertex_Type
Definition: shapes.h:91
shapes.h
SG_OGIS_TYPE_Triangle
@ SG_OGIS_TYPE_Triangle
Definition: shapes.h:1478
CSG_String
Definition: api_core.h:563
CSG_Grid_OGIS_Converter::from_WKBinary
static bool from_WKBinary(CSG_Bytes &Bytes, class CSG_Grid *pGrid)
Definition: shapes_ogis.cpp:1101
SHAPE_TYPE_Point
@ SHAPE_TYPE_Point
Definition: shapes.h:102
CSG_Grid::asDouble
virtual double asDouble(sLong i, bool bScaled=true) const
Definition: grid.h:767
CSG_Grid::Get_NX
int Get_NX(void) const
Definition: grid.h:537
SG_OGIS_TYPE_PointZM
@ SG_OGIS_TYPE_PointZM
Definition: shapes.h:1502
CSG_Shapes_OGIS_Converter::Type_asWKText
static CSG_String Type_asWKText(DWORD Type)
Definition: shapes_ogis.cpp:61
SG_UI_Process_Set_Progress
bool SG_UI_Process_Set_Progress(int Position, int Range)
Definition: api_callback.cpp:255
SSG_Point::x
double x
Definition: geo_tools.h:129
SG_OGIS_TYPE_MultiPolygonM
@ SG_OGIS_TYPE_MultiPolygonM
Definition: shapes.h:1496
CSG_Bytes::Read_Char
char Read_Char(void)
Definition: api_core.h:875
SG_DATATYPE_Short
@ SG_DATATYPE_Short
Definition: api_core.h:998
SG_OGIS_TYPE_MultiPointZM
@ SG_OGIS_TYPE_MultiPointZM
Definition: shapes.h:1505
CSG_Bytes::Read_Float
float Read_Float(bool bSwapBytes=false)
Definition: api_core.h:880
SSG_Point::y
double y
Definition: geo_tools.h:129
CSG_Grid
Definition: grid.h:475
SG_DATATYPE_Bit
@ SG_DATATYPE_Bit
Definition: api_core.h:994
CSG_Data_Object::Set_NoData_Value
virtual bool Set_NoData_Value(double Value)
Definition: dataobject.cpp:572
SG_OGIS_TYPE_MultiPointZ
@ SG_OGIS_TYPE_MultiPointZ
Definition: shapes.h:1483
SG_OGIS_TYPE_PolygonZM
@ SG_OGIS_TYPE_PolygonZM
Definition: shapes.h:1504
CSG_Shape::Set_Z
virtual void Set_Z(double z, int iPoint=0, int iPart=0)
Definition: shapes.h:194
CSG_Shapes
Definition: shapes.h:775
CSG_String::c_str
const SG_Char * c_str(void) const
Definition: api_string.cpp:236
SHAPE_TYPE_Points
@ SHAPE_TYPE_Points
Definition: shapes.h:103
CSG_Bytes::Read_Short
short Read_Short(bool bSwapBytes=false)
Definition: api_core.h:876
SG_OGIS_TYPE_Polygon
@ SG_OGIS_TYPE_Polygon
Definition: shapes.h:1471
SG_OGIS_TYPE_LineStringZ
@ SG_OGIS_TYPE_LineStringZ
Definition: shapes.h:1481
SG_OGIS_TYPE_MultiPointM
@ SG_OGIS_TYPE_MultiPointM
Definition: shapes.h:1494
CSG_Bytes::is_EOF
bool is_EOF(void)
Definition: api_core.h:829
TSG_Data_Type
TSG_Data_Type
Definition: api_core.h:993
SG_OGIS_TYPE_MultiLineStringZM
@ SG_OGIS_TYPE_MultiLineStringZM
Definition: shapes.h:1506
CSG_Shape_Points::Get_Part_Count
virtual int Get_Part_Count(void) const
Definition: shapes.h:498
CSG_Grid::is_NoData
virtual bool is_NoData(int x, int y) const
Definition: grid.h:701
CSG_Shape_Polygon
Definition: shapes.h:701
CSG_Projection::Create
bool Create(const CSG_Projection &Projection)
Definition: projections.cpp:96
CSG_Bytes::Read_Double
double Read_Double(bool bSwapBytes=false)
Definition: api_core.h:881
CSG_Shape::Set_M
virtual void Set_M(double m, int iPoint=0, int iPart=0)
Definition: shapes.h:210
SG_OGIS_TYPE_MultiPolygonZ
@ SG_OGIS_TYPE_MultiPolygonZ
Definition: shapes.h:1485
CSG_Shape
Definition: shapes.h:141
SG_DATATYPE_Char
@ SG_DATATYPE_Char
Definition: api_core.h:996
CSG_Data_Object::Get_Projection
CSG_Projection & Get_Projection(void)
Definition: dataobject.cpp:637
SG_VERTEX_TYPE_XYZ
@ SG_VERTEX_TYPE_XYZ
Definition: shapes.h:93
SHAPE_TYPE_Undefined
@ SHAPE_TYPE_Undefined
Definition: shapes.h:101
SG_OGIS_TYPE_MultiLineStringM
@ SG_OGIS_TYPE_MultiLineStringM
Definition: shapes.h:1495
SG_OGIS_TYPE_MultiLineStringZ
@ SG_OGIS_TYPE_MultiLineStringZ
Definition: shapes.h:1484
SG_OGIS_TYPE_LineStringM
@ SG_OGIS_TYPE_LineStringM
Definition: shapes.h:1492
CSG_Grid::Get_YMax
double Get_YMax(bool bCells=false) const
Definition: grid.h:551
SG_DATATYPE_Double
@ SG_DATATYPE_Double
Definition: api_core.h:1004