|
SpatiaLite 4.3.0a
|
00001 /* 00002 gg_structs.h -- Gaia common support for geometries: structures 00003 00004 version 4.3, 2015 June 29 00005 00006 Author: Sandro Furieri a.furieri@lqt.it 00007 00008 ------------------------------------------------------------------------------ 00009 00010 Version: MPL 1.1/GPL 2.0/LGPL 2.1 00011 00012 The contents of this file are subject to the Mozilla Public License Version 00013 1.1 (the "License"); you may not use this file except in compliance with 00014 the License. You may obtain a copy of the License at 00015 http://www.mozilla.org/MPL/ 00016 00017 Software distributed under the License is distributed on an "AS IS" basis, 00018 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 00019 for the specific language governing rights and limitations under the 00020 License. 00021 00022 The Original Code is the SpatiaLite library 00023 00024 The Initial Developer of the Original Code is Alessandro Furieri 00025 00026 Portions created by the Initial Developer are Copyright (C) 2008-2015 00027 the Initial Developer. All Rights Reserved. 00028 00029 Contributor(s): 00030 00031 00032 Alternatively, the contents of this file may be used under the terms of 00033 either the GNU General Public License Version 2 or later (the "GPL"), or 00034 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 00035 in which case the provisions of the GPL or the LGPL are applicable instead 00036 of those above. If you wish to allow use of your version of this file only 00037 under the terms of either the GPL or the LGPL, and not to allow others to 00038 use your version of this file under the terms of the MPL, indicate your 00039 decision by deleting the provisions above and replace them with the notice 00040 and other provisions required by the GPL or the LGPL. If you do not delete 00041 the provisions above, a recipient may use your version of this file under 00042 the terms of any one of the MPL, the GPL or the LGPL. 00043 00044 */ 00045 00046 00053 #ifndef _GG_STRUCTS_H 00054 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00055 #define _GG_STRUCTS_H 00056 #endif 00057 00058 #include <sys/types.h> 00059 00060 #ifdef __cplusplus 00061 extern "C" 00062 { 00063 #endif 00064 00068 typedef struct gaiaPointStruct 00069 { 00070 /* an OpenGis POINT */ 00072 double X; /* X,Y coordinates */ 00074 double Y; 00076 double Z; /* Z coordinate */ 00078 double M; /* M measure */ 00080 int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */ 00082 struct gaiaPointStruct *Next; /* for double-linked list */ 00084 struct gaiaPointStruct *Prev; /* for double-linked list */ 00085 } gaiaPoint; 00091 typedef gaiaPoint *gaiaPointPtr; 00092 00096 typedef struct gaiaDynamicLineStruct 00097 { 00098 /* a generic DYNAMIC LINE object */ 00100 int Error; 00102 int Srid; 00104 gaiaPointPtr First; /* Points linked list - first */ 00106 gaiaPointPtr Last; /* Points linked list - last */ 00107 } gaiaDynamicLine; 00113 typedef gaiaDynamicLine *gaiaDynamicLinePtr; 00114 00118 typedef struct gaiaLinestringStruct 00119 { 00120 /* an OpenGis LINESTRING */ 00122 int Points; /* number of vertices */ 00124 double *Coords; /* X,Y [vertices] array */ 00126 double MinX; /* MBR - BBOX */ 00128 double MinY; /* MBR - BBOX */ 00130 double MaxX; /* MBR - BBOX */ 00132 double MaxY; /* MBR - BBOX */ 00134 int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */ 00136 struct gaiaLinestringStruct *Next; /* for linked list */ 00137 } gaiaLinestring; 00143 typedef gaiaLinestring *gaiaLinestringPtr; 00144 00148 typedef struct gaiaRingStruct 00149 { 00150 /* a GIS ring - OpenGis LINESTRING, closed */ 00152 int Points; /* number of vertices */ 00154 double *Coords; /* X,Y [vertices] array */ 00156 int Clockwise; /* clockwise / counterclockwise */ 00158 double MinX; /* MBR - BBOX */ 00160 double MinY; /* MBR - BBOX */ 00162 double MaxX; /* MBR - BBOX */ 00164 double MaxY; /* MBR - BBOX */ 00166 int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */ 00168 struct gaiaRingStruct *Next; /* for linked list */ 00170 struct gaiaPolygonStruct *Link; /* polygon reference */ 00171 } gaiaRing; 00177 typedef gaiaRing *gaiaRingPtr; 00178 00182 typedef struct gaiaPolygonStruct 00183 { 00184 /* an OpenGis POLYGON */ 00186 gaiaRingPtr Exterior; /* exterior ring */ 00188 int NumInteriors; /* number of interior rings */ 00190 gaiaRingPtr Interiors; /* interior rings array */ 00192 int NextInterior; /* first free interior ring */ 00194 double MinX; /* MBR - BBOX */ 00196 double MinY; /* MBR - BBOX */ 00198 double MaxX; /* MBR - BBOX */ 00200 double MaxY; /* MBR - BBOX */ 00202 int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */ 00204 struct gaiaPolygonStruct *Next; /* for linked list */ 00205 } gaiaPolygon; 00211 typedef gaiaPolygon *gaiaPolygonPtr; 00212 00216 typedef struct gaiaGeomCollStruct 00217 { 00218 /* OpenGis GEOMETRYCOLLECTION */ 00220 int Srid; /* the SRID value for this GEOMETRY */ 00222 char endian_arch; /* littleEndian - bigEndian arch for target CPU */ 00224 char endian; /* littleEndian - bigEndian */ 00226 const unsigned char *blob; /* WKB encoded buffer */ 00228 unsigned long size; /* buffer size */ 00230 unsigned long offset; /* current offset [for parsing] */ 00232 gaiaPointPtr FirstPoint; /* Points linked list - first */ 00234 gaiaPointPtr LastPoint; /* Points linked list - last */ 00236 gaiaLinestringPtr FirstLinestring; /* Linestrings linked list - first */ 00238 gaiaLinestringPtr LastLinestring; /* Linestrings linked list - last */ 00240 gaiaPolygonPtr FirstPolygon; /* Polygons linked list - first */ 00242 gaiaPolygonPtr LastPolygon; /* Polygons linked list - last */ 00244 double MinX; /* MBR - BBOX */ 00246 double MinY; /* MBR - BBOX */ 00248 double MaxX; /* MBR - BBOX */ 00250 double MaxY; /* MBR - BBOX */ 00252 int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */ 00254 int DeclaredType; /* the declared TYPE for this Geometry */ 00256 struct gaiaGeomCollStruct *Next; /* Vanuatu - used for linked list */ 00257 } gaiaGeomColl; 00263 typedef gaiaGeomColl *gaiaGeomCollPtr; 00264 00268 typedef struct gaiaPreRingStruct 00269 { 00270 /* a LINESTRING used to build rings */ 00272 gaiaLinestringPtr Line; /* a LINESTRING pointer */ 00274 int AlreadyUsed; /* a switch to mark an already used line element */ 00276 struct gaiaPreRingStruct *Next; /* for linked list */ 00277 } gaiaPreRing; 00283 typedef gaiaPreRing *gaiaPreRingPtr; 00284 00288 typedef struct gaiaValueStruct 00289 { 00290 /* a DBF field multitype value */ 00292 short Type; /* the type */ 00294 char *TxtValue; /* the text value */ 00296 sqlite3_int64 IntValue; /* the integer value */ 00298 double DblValue; /* the double value */ 00299 } gaiaValue; 00303 typedef gaiaValue *gaiaValuePtr; 00304 00308 typedef struct gaiaDbfFieldStruct 00309 { 00310 /* a DBF field definition - shapefile attribute */ 00312 char *Name; /* field name */ 00314 unsigned char Type; /* field type */ 00316 int Offset; /* buffer offset [this field begins at *buffer+offset* and extends for *length* bytes */ 00318 unsigned char Length; /* field total length [in bytes] */ 00320 unsigned char Decimals; /* decimal positions */ 00322 gaiaValuePtr Value; /* the current multitype value for this attribute */ 00324 struct gaiaDbfFieldStruct *Next; /* pointer to next element in linked list */ 00325 } gaiaDbfField; 00329 typedef gaiaDbfField *gaiaDbfFieldPtr; 00330 00334 typedef struct gaiaDbfListStruct 00335 { 00336 /* a linked list to contain the DBF fields definitions - shapefile attributes */ 00338 int RowId; /* the current RowId */ 00340 gaiaGeomCollPtr Geometry; /* geometry for current entity */ 00342 gaiaDbfFieldPtr First; /* pointer to first element in linked list */ 00344 gaiaDbfFieldPtr Last; /* pointer to last element in linker list */ 00345 } gaiaDbfList; 00351 typedef gaiaDbfList *gaiaDbfListPtr; 00352 00356 typedef struct gaiaDbfStruct 00357 { 00358 /* DBF TYPE */ 00360 int endian_arch; 00362 int Valid; /* 1 = ready to process */ 00364 char *Path; /* the DBF path */ 00366 FILE *flDbf; /* the DBF file handle */ 00368 gaiaDbfListPtr Dbf; /* the DBF attributes list */ 00370 unsigned char *BufDbf; /* the DBF I/O buffer */ 00372 int DbfHdsz; /* the DBF header length */ 00374 int DbfReclen; /* the DBF record length */ 00376 int DbfSize; /* current DBF size */ 00378 int DbfRecno; /* current DBF record number */ 00380 void *IconvObj; /* opaque reference to ICONV converter */ 00382 char *LastError; /* last error message */ 00383 } gaiaDbf; 00389 typedef gaiaDbf *gaiaDbfPtr; 00390 00394 typedef struct gaiaShapefileStruct 00395 { 00396 /* SHAPEFILE TYPE */ 00398 int endian_arch; 00400 int Valid; /* 1 = ready to process */ 00402 int ReadOnly; /* read or write mode */ 00404 char *Path; /* the shapefile abstract path [no suffixes] */ 00406 FILE *flShx; /* the SHX file handle */ 00408 FILE *flShp; /* the SHP file handle */ 00410 FILE *flDbf; /* the DBF file handle */ 00412 int Shape; /* the SHAPE code for the whole shapefile */ 00414 gaiaDbfListPtr Dbf; /* the DBF attributes list */ 00416 unsigned char *BufDbf; /* the DBF I/O buffer */ 00418 int DbfHdsz; /* the DBF header length */ 00420 int DbfReclen; /* the DBF record length */ 00422 int DbfSize; /* current DBF size */ 00424 int DbfRecno; /* current DBF record number */ 00426 unsigned char *BufShp; /* the SHP I/O buffer */ 00428 int ShpBfsz; /* the SHP buffer current size */ 00430 int ShpSize; /* current SHP size */ 00432 int ShxSize; /* current SHX size */ 00434 double MinX; /* the MBR/BBOX for the whole shapefile */ 00436 double MinY; 00438 double MaxX; 00440 double MaxY; 00442 void *IconvObj; /* opaque reference to ICONV converter */ 00444 char *LastError; /* last error message */ 00446 int EffectiveType; /* the effective Geometry-type, as determined by gaiaShpAnalyze() */ 00448 int EffectiveDims; /* the effective Dimensions [XY, XYZ, XYM, XYZM], as determined by gaiaShpAnalyze() */ 00449 } gaiaShapefile; 00455 typedef gaiaShapefile *gaiaShapefilePtr; 00456 00460 typedef struct gaiaOutBufferStruct 00461 { 00462 /* a struct handling a dynamically growing output buffer */ 00464 char *Buffer; 00466 int WriteOffset; 00468 int BufferSize; 00470 int Error; 00471 } gaiaOutBuffer; 00477 typedef gaiaOutBuffer *gaiaOutBufferPtr; 00478 00479 #ifndef OMIT_ICONV /* ICONV enabled: supporting text reader */ 00480 00482 #define VRTTXT_FIELDS_MAX 65535 00483 00484 #define VRTTXT_BLOCK_MAX 65535 00485 00487 #define VRTTXT_TEXT 1 00488 00489 #define VRTTXT_INTEGER 2 00490 00491 #define VRTTXT_DOUBLE 3 00492 00493 #define VRTTXT_NULL 4 00494 00498 struct vrttxt_line 00499 { 00500 /* a struct representing a full LINE (aka Record) */ 00502 off_t offset; 00504 int len; 00506 int field_offsets[VRTTXT_FIELDS_MAX]; 00508 int num_fields; 00510 int error; 00511 }; 00512 00516 struct vrttxt_row 00517 { 00518 /* a struct storing Row offsets */ 00520 int line_no; 00522 off_t offset; 00524 int len; 00526 int num_fields; 00527 }; 00528 00532 struct vrttxt_row_block 00533 { 00534 /* 00535 / for efficiency sake, individual Row offsets 00536 / are grouped in reasonably sized blocks 00537 */ 00539 struct vrttxt_row rows[VRTTXT_BLOCK_MAX]; 00541 int num_rows; 00543 int min_line_no; 00545 int max_line_no; 00547 struct vrttxt_row_block *next; 00548 }; 00549 00553 struct vrttxt_column_header 00554 { 00555 /* a struct representing a Column (aka Field) header */ 00557 char *name; 00559 int type; 00560 }; 00561 00565 typedef struct vrttxt_reader 00566 { 00567 /* the main TXT-Reader struct */ 00569 struct vrttxt_column_header columns[VRTTXT_FIELDS_MAX]; 00571 FILE *text_file; 00573 void *toUtf8; /* the UTF-8 ICONV converter */ 00575 char field_separator; 00577 char text_separator; 00579 char decimal_separator; 00581 int first_line_titles; 00583 int error; 00585 struct vrttxt_row_block *first; 00587 struct vrttxt_row_block *last; 00589 struct vrttxt_row **rows; 00591 int num_rows; 00593 int line_no; 00595 int max_fields; 00597 int current_buf_sz; 00599 int current_buf_off; 00601 char *line_buffer; 00603 char *field_buffer; 00605 int field_offsets[VRTTXT_FIELDS_MAX]; 00607 int field_lens[VRTTXT_FIELDS_MAX]; 00609 int max_current_field; 00611 int current_line_ready; 00612 } gaiaTextReader; 00618 typedef gaiaTextReader *gaiaTextReaderPtr; 00619 00620 #endif /* end ICONV (text reader) */ 00621 00625 typedef struct gaiaLayerExtentInfos 00626 { 00628 int Count; 00630 double MinX; /* MBR - BBOX */ 00632 double MinY; /* MBR - BBOX */ 00634 double MaxX; /* MBR - BBOX */ 00636 double MaxY; /* MBR - BBOX */ 00637 } gaiaLayerExtent; 00638 00644 typedef gaiaLayerExtent *gaiaLayerExtentPtr; 00645 00649 typedef struct gaiaLayerAuthInfos 00650 { 00652 int IsReadOnly; 00654 int IsHidden; 00655 } gaiaLayerAuth; 00656 00662 typedef gaiaLayerAuth *gaiaLayerAuthPtr; 00663 00667 typedef struct gaiaAttributeFieldMaxSizeInfos 00668 { 00670 int MaxSize; 00671 } gaiaAttributeFieldMaxSize; 00672 00678 typedef gaiaAttributeFieldMaxSize *gaiaAttributeFieldMaxSizePtr; 00679 00683 typedef struct gaiaAttributeFieldIntRangeInfos 00684 { 00686 sqlite3_int64 MinValue; 00688 sqlite3_int64 MaxValue; 00689 } gaiaAttributeFieldIntRange; 00690 00696 typedef gaiaAttributeFieldIntRange *gaiaAttributeFieldIntRangePtr; 00697 00701 typedef struct gaiaAttributeFieldDoubleRangeInfos 00702 { 00704 double MinValue; 00706 double MaxValue; 00707 } gaiaAttributeFieldDoubleRange; 00708 00714 typedef gaiaAttributeFieldDoubleRange *gaiaAttributeFieldDoubleRangePtr; 00715 00719 typedef struct gaiaLayerAttributeFieldInfos 00720 { 00722 int Ordinal; 00724 char *AttributeFieldName; 00726 int NullValuesCount; 00728 int IntegerValuesCount; 00730 int DoubleValuesCount; 00732 int TextValuesCount; 00734 int BlobValuesCount; 00736 gaiaAttributeFieldMaxSizePtr MaxSize; 00738 gaiaAttributeFieldIntRangePtr IntRange; 00740 gaiaAttributeFieldDoubleRangePtr DoubleRange; 00742 struct gaiaLayerAttributeFieldInfos *Next; 00743 } gaiaLayerAttributeField; 00744 00750 typedef gaiaLayerAttributeField *gaiaLayerAttributeFieldPtr; 00751 00755 typedef struct gaiaVectorLayerItem 00756 { 00759 int LayerType; 00761 char *TableName; 00763 char *GeometryName; 00765 int Srid; 00770 int GeometryType; 00772 int Dimensions; 00776 int SpatialIndex; 00778 gaiaLayerExtentPtr ExtentInfos; 00780 gaiaLayerAuthPtr AuthInfos; 00782 gaiaLayerAttributeFieldPtr First; 00784 gaiaLayerAttributeFieldPtr Last; 00786 struct gaiaVectorLayerItem *Next; 00787 } gaiaVectorLayer; 00788 00794 typedef gaiaVectorLayer *gaiaVectorLayerPtr; 00795 00799 typedef struct gaiaVectorLayersListStr 00800 { 00802 gaiaVectorLayerPtr First; 00804 gaiaVectorLayerPtr Last; 00806 gaiaVectorLayerPtr Current; 00807 } gaiaVectorLayersList; 00808 00814 typedef gaiaVectorLayersList *gaiaVectorLayersListPtr; 00815 00816 #ifdef __cplusplus 00817 } 00818 #endif 00819 00820 #endif /* _GG_STRUCTS_H */
1.7.3