SpatiaLite  4.1.0
 All Data Structures Files Functions Variables Typedefs Macros Pages
gg_structs.h
Go to the documentation of this file.
1 /*
2  gg_structs.h -- Gaia common support for geometries: structures
3 
4  version 4.1, 2013 May 8
5 
6  Author: Sandro Furieri a.furieri@lqt.it
7 
8  ------------------------------------------------------------------------------
9 
10  Version: MPL 1.1/GPL 2.0/LGPL 2.1
11 
12  The contents of this file are subject to the Mozilla Public License Version
13  1.1 (the "License"); you may not use this file except in compliance with
14  the License. You may obtain a copy of the License at
15  http://www.mozilla.org/MPL/
16 
17 Software distributed under the License is distributed on an "AS IS" basis,
18 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
19 for the specific language governing rights and limitations under the
20 License.
21 
22 The Original Code is the SpatiaLite library
23 
24 The Initial Developer of the Original Code is Alessandro Furieri
25 
26 Portions created by the Initial Developer are Copyright (C) 2008-2013
27 the Initial Developer. All Rights Reserved.
28 
29 Contributor(s):
30 
31 
32 Alternatively, the contents of this file may be used under the terms of
33 either the GNU General Public License Version 2 or later (the "GPL"), or
34 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
35 in which case the provisions of the GPL or the LGPL are applicable instead
36 of those above. If you wish to allow use of your version of this file only
37 under the terms of either the GPL or the LGPL, and not to allow others to
38 use your version of this file under the terms of the MPL, indicate your
39 decision by deleting the provisions above and replace them with the notice
40 and other provisions required by the GPL or the LGPL. If you do not delete
41 the provisions above, a recipient may use your version of this file under
42 the terms of any one of the MPL, the GPL or the LGPL.
43 
44 */
45 
46 
53 #ifndef _GG_STRUCTS_H
54 #ifndef DOXYGEN_SHOULD_SKIP_THIS
55 #define _GG_STRUCTS_H
56 #endif
57 
58 #include <sys/types.h>
59 
60 #ifdef __cplusplus
61 extern "C"
62 {
63 #endif
64 
68  typedef struct gaiaPointStruct
69  {
70 /* an OpenGis POINT */
72  double X; /* X,Y coordinates */
74  double Y;
76  double Z; /* Z coordinate */
78  double M; /* M measure */
80  int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */
82  struct gaiaPointStruct *Next; /* for double-linked list */
84  struct gaiaPointStruct *Prev; /* for double-linked list */
85  } gaiaPoint;
92 
96  typedef struct gaiaDynamicLineStruct
97  {
98 /* a generic DYNAMIC LINE object */
100  int Error;
102  int Srid;
104  gaiaPointPtr First; /* Points linked list - first */
106  gaiaPointPtr Last; /* Points linked list - last */
107  } gaiaDynamicLine;
114 
118  typedef struct gaiaLinestringStruct
119  {
120 /* an OpenGis LINESTRING */
122  int Points; /* number of vertices */
124  double *Coords; /* X,Y [vertices] array */
126  double MinX; /* MBR - BBOX */
128  double MinY; /* MBR - BBOX */
130  double MaxX; /* MBR - BBOX */
132  double MaxY; /* MBR - BBOX */
134  int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */
136  struct gaiaLinestringStruct *Next; /* for linked list */
137  } gaiaLinestring;
144 
148  typedef struct gaiaRingStruct
149  {
150 /* a GIS ring - OpenGis LINESTRING, closed */
152  int Points; /* number of vertices */
154  double *Coords; /* X,Y [vertices] array */
156  int Clockwise; /* clockwise / counterclockwise */
158  double MinX; /* MBR - BBOX */
160  double MinY; /* MBR - BBOX */
162  double MaxX; /* MBR - BBOX */
164  double MaxY; /* MBR - BBOX */
166  int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */
168  struct gaiaRingStruct *Next; /* for linked list */
170  struct gaiaPolygonStruct *Link; /* polygon reference */
171  } gaiaRing;
178 
182  typedef struct gaiaPolygonStruct
183  {
184 /* an OpenGis POLYGON */
186  gaiaRingPtr Exterior; /* exterior ring */
188  int NumInteriors; /* number of interior rings */
190  gaiaRingPtr Interiors; /* interior rings array */
192  int NextInterior; /* first free interior ring */
194  double MinX; /* MBR - BBOX */
196  double MinY; /* MBR - BBOX */
198  double MaxX; /* MBR - BBOX */
200  double MaxY; /* MBR - BBOX */
202  int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */
204  struct gaiaPolygonStruct *Next; /* for linked list */
205  } gaiaPolygon;
212 
216  typedef struct gaiaGeomCollStruct
217  {
218 /* OpenGis GEOMETRYCOLLECTION */
220  int Srid; /* the SRID value for this GEOMETRY */
222  char endian_arch; /* littleEndian - bigEndian arch for target CPU */
224  char endian; /* littleEndian - bigEndian */
226  const unsigned char *blob; /* WKB encoded buffer */
228  unsigned long size; /* buffer size */
230  unsigned long offset; /* current offset [for parsing] */
232  gaiaPointPtr FirstPoint; /* Points linked list - first */
234  gaiaPointPtr LastPoint; /* Points linked list - last */
236  gaiaLinestringPtr FirstLinestring; /* Linestrings linked list - first */
238  gaiaLinestringPtr LastLinestring; /* Linestrings linked list - last */
240  gaiaPolygonPtr FirstPolygon; /* Polygons linked list - first */
242  gaiaPolygonPtr LastPolygon; /* Polygons linked list - last */
244  double MinX; /* MBR - BBOX */
246  double MinY; /* MBR - BBOX */
248  double MaxX; /* MBR - BBOX */
250  double MaxY; /* MBR - BBOX */
252  int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */
254  int DeclaredType; /* the declared TYPE for this Geometry */
256  struct gaiaGeomCollStruct *Next; /* Vanuatu - used for linked list */
257  } gaiaGeomColl;
264 
268  typedef struct gaiaPreRingStruct
269  {
270 /* a LINESTRING used to build rings */
272  gaiaLinestringPtr Line; /* a LINESTRING pointer */
274  int AlreadyUsed; /* a switch to mark an already used line element */
276  struct gaiaPreRingStruct *Next; /* for linked list */
277  } gaiaPreRing;
284 
288  typedef struct gaiaValueStruct
289  {
290 /* a DBF field multitype value */
292  short Type; /* the type */
294  char *TxtValue; /* the text value */
296  sqlite3_int64 IntValue; /* the integer value */
298  double DblValue; /* the double value */
299  } gaiaValue;
304 
308  typedef struct gaiaDbfFieldStruct
309  {
310 /* a DBF field definition - shapefile attribute */
312  char *Name; /* field name */
314  unsigned char Type; /* field type */
316  int Offset; /* buffer offset [this field begins at *buffer+offset* and extends for *length* bytes */
318  unsigned char Length; /* field total length [in bytes] */
320  unsigned char Decimals; /* decimal positions */
322  gaiaValuePtr Value; /* the current multitype value for this attribute */
324  struct gaiaDbfFieldStruct *Next; /* pointer to next element in linked list */
325  } gaiaDbfField;
330 
334  typedef struct gaiaDbfListStruct
335  {
336 /* a linked list to contain the DBF fields definitions - shapefile attributes */
338  int RowId; /* the current RowId */
340  gaiaGeomCollPtr Geometry; /* geometry for current entity */
342  gaiaDbfFieldPtr First; /* pointer to first element in linked list */
344  gaiaDbfFieldPtr Last; /* pointer to last element in linker list */
345  } gaiaDbfList;
352 
356  typedef struct gaiaDbfStruct
357  {
358 /* DBF TYPE */
362  int Valid; /* 1 = ready to process */
364  char *Path; /* the DBF path */
366  FILE *flDbf; /* the DBF file handle */
368  gaiaDbfListPtr Dbf; /* the DBF attributes list */
370  unsigned char *BufDbf; /* the DBF I/O buffer */
372  int DbfHdsz; /* the DBF header length */
374  int DbfReclen; /* the DBF record length */
376  int DbfSize; /* current DBF size */
378  int DbfRecno; /* current DBF record number */
380  void *IconvObj; /* opaque reference to ICONV converter */
382  char *LastError; /* last error message */
383  } gaiaDbf;
389  typedef gaiaDbf *gaiaDbfPtr;
390 
394  typedef struct gaiaShapefileStruct
395  {
396 /* SHAPEFILE TYPE */
400  int Valid; /* 1 = ready to process */
402  int ReadOnly; /* read or write mode */
404  char *Path; /* the shapefile abstract path [no suffixes] */
406  FILE *flShx; /* the SHX file handle */
408  FILE *flShp; /* the SHP file handle */
410  FILE *flDbf; /* the DBF file handle */
412  int Shape; /* the SHAPE code for the whole shapefile */
414  gaiaDbfListPtr Dbf; /* the DBF attributes list */
416  unsigned char *BufDbf; /* the DBF I/O buffer */
418  int DbfHdsz; /* the DBF header length */
420  int DbfReclen; /* the DBF record length */
422  int DbfSize; /* current DBF size */
424  int DbfRecno; /* current DBF record number */
426  unsigned char *BufShp; /* the SHP I/O buffer */
428  int ShpBfsz; /* the SHP buffer current size */
430  int ShpSize; /* current SHP size */
432  int ShxSize; /* current SHX size */
434  double MinX; /* the MBR/BBOX for the whole shapefile */
436  double MinY;
438  double MaxX;
440  double MaxY;
442  void *IconvObj; /* opaque reference to ICONV converter */
444  char *LastError; /* last error message */
446  int EffectiveType; /* the effective Geometry-type, as determined by gaiaShpAnalyze() */
448  int EffectiveDims; /* the effective Dimensions [XY, XYZ, XYM, XYZM], as determined by gaiaShpAnalyze() */
449  } gaiaShapefile;
456 
460  typedef struct gaiaOutBufferStruct
461  {
462 /* a struct handling a dynamically growing output buffer */
464  char *Buffer;
470  int Error;
471  } gaiaOutBuffer;
478 
479 #ifndef OMIT_ICONV /* ICONV enabled: supporting text reader */
480 
482 #define VRTTXT_FIELDS_MAX 65535
483 
484 #define VRTTXT_BLOCK_MAX 65535
485 
487 #define VRTTXT_TEXT 1
488 
489 #define VRTTXT_INTEGER 2
490 
491 #define VRTTXT_DOUBLE 3
492 
493 #define VRTTXT_NULL 4
494 
498  struct vrttxt_line
499  {
500 /* a struct representing a full LINE (aka Record) */
502  off_t offset;
504  int len;
510  int error;
511  };
512 
516  struct vrttxt_row
517  {
518 /* a struct storing Row offsets */
520  int line_no;
522  off_t offset;
524  int len;
527  };
528 
533  {
534 /*
535 / for efficiency sake, individual Row offsets
536 / are grouped in reasonably sized blocks
537 */
541  int num_rows;
548  };
549 
554  {
555 /* a struct representing a Column (aka Field) header */
557  char *name;
559  int type;
560  };
561 
565  typedef struct vrttxt_reader
566  {
567 /* the main TXT-Reader struct */
571  FILE *text_file;
573  void *toUtf8; /* the UTF-8 ICONV converter */
583  int error;
589  struct vrttxt_row **rows;
591  int num_rows;
593  int line_no;
601  char *line_buffer;
612  } gaiaTextReader;
619 
620 #endif /* end ICONV (text reader) */
621 
625  typedef struct gaiaLayerExtentInfos
626  {
628  int Count;
630  double MinX; /* MBR - BBOX */
632  double MinY; /* MBR - BBOX */
634  double MaxX; /* MBR - BBOX */
636  double MaxY; /* MBR - BBOX */
637  } gaiaLayerExtent;
638 
645 
649  typedef struct gaiaLayerAuthInfos
650  {
654  int IsHidden;
655  } gaiaLayerAuth;
656 
663 
668  {
670  int MaxSize;
672 
679 
684  {
686  sqlite3_int64 MinValue;
688  sqlite3_int64 MaxValue;
690 
697 
702  {
704  double MinValue;
706  double MaxValue;
708 
715 
720  {
722  int Ordinal;
736  gaiaAttributeFieldMaxSizePtr MaxSize;
738  gaiaAttributeFieldIntRangePtr IntRange;
740  gaiaAttributeFieldDoubleRangePtr DoubleRange;
744 
751 
755  typedef struct gaiaVectorLayerItem
756  {
761  char *TableName;
765  int Srid;
778  gaiaLayerExtentPtr ExtentInfos;
780  gaiaLayerAuthPtr AuthInfos;
782  gaiaLayerAttributeFieldPtr First;
784  gaiaLayerAttributeFieldPtr Last;
787  } gaiaVectorLayer;
788 
795 
799  typedef struct gaiaVectorLayersListStr
800  {
802  gaiaVectorLayerPtr First;
804  gaiaVectorLayerPtr Last;
806  gaiaVectorLayerPtr Current;
808 
815 
816 #ifdef __cplusplus
817 }
818 #endif
819 
820 #endif /* _GG_STRUCTS_H */