SpatiaLite
3.0.0-stable
|
00001 /* 00002 gg_structs.h -- Gaia common support for geometries: structures 00003 00004 version 3.0, 2011 July 20 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 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 #ifdef __cplusplus 00059 extern "C" 00060 { 00061 #endif 00062 00066 typedef struct gaiaPointStruct 00067 { 00068 /* an OpenGis POINT */ 00070 double X; /* X,Y coordinates */ 00072 double Y; 00074 double Z; /* Z coordinate */ 00076 double M; /* M measure */ 00078 int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */ 00080 struct gaiaPointStruct *Next; /* for double-linked list */ 00082 struct gaiaPointStruct *Prev; /* for double-linked list */ 00083 } gaiaPoint; 00089 typedef gaiaPoint *gaiaPointPtr; 00090 00094 typedef struct gaiaDynamicLineStruct 00095 { 00096 /* a generic DYNAMIC LINE object */ 00098 int Error; 00100 int Srid; 00102 gaiaPointPtr First; /* Points linked list - first */ 00104 gaiaPointPtr Last; /* Points linked list - last */ 00105 } gaiaDynamicLine; 00111 typedef gaiaDynamicLine *gaiaDynamicLinePtr; 00112 00116 typedef struct gaiaLinestringStruct 00117 { 00118 /* an OpenGis LINESTRING */ 00120 int Points; /* number of vertices */ 00122 double *Coords; /* X,Y [vertices] array */ 00124 double MinX; /* MBR - BBOX */ 00126 double MinY; /* MBR - BBOX */ 00128 double MaxX; /* MBR - BBOX */ 00130 double MaxY; /* MBR - BBOX */ 00132 int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */ 00134 struct gaiaLinestringStruct *Next; /* for linked list */ 00135 } gaiaLinestring; 00141 typedef gaiaLinestring *gaiaLinestringPtr; 00142 00146 typedef struct gaiaRingStruct 00147 { 00148 /* a GIS ring - OpenGis LINESTRING, closed */ 00150 int Points; /* number of vertices */ 00152 double *Coords; /* X,Y [vertices] array */ 00154 int Clockwise; /* clockwise / counterclockwise */ 00156 double MinX; /* MBR - BBOX */ 00158 double MinY; /* MBR - BBOX */ 00160 double MaxX; /* MBR - BBOX */ 00162 double MaxY; /* MBR - BBOX */ 00164 int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */ 00166 struct gaiaRingStruct *Next; /* for linked list */ 00168 struct gaiaPolygonStruct *Link; /* polygon reference */ 00169 } gaiaRing; 00175 typedef gaiaRing *gaiaRingPtr; 00176 00180 typedef struct gaiaPolygonStruct 00181 { 00182 /* an OpenGis POLYGON */ 00184 gaiaRingPtr Exterior; /* exterior ring */ 00186 int NumInteriors; /* number of interior rings */ 00188 gaiaRingPtr Interiors; /* interior rings array */ 00190 int NextInterior; /* first free interior ring */ 00192 double MinX; /* MBR - BBOX */ 00194 double MinY; /* MBR - BBOX */ 00196 double MaxX; /* MBR - BBOX */ 00198 double MaxY; /* MBR - BBOX */ 00200 int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */ 00202 struct gaiaPolygonStruct *Next; /* for linked list */ 00203 } gaiaPolygon; 00209 typedef gaiaPolygon *gaiaPolygonPtr; 00210 00214 typedef struct gaiaGeomCollStruct 00215 { 00216 /* OpenGis GEOMETRYCOLLECTION */ 00218 int Srid; /* the SRID value for this GEOMETRY */ 00220 char endian_arch; /* littleEndian - bigEndian arch for target CPU */ 00222 char endian; /* littleEndian - bigEndian */ 00224 const unsigned char *blob; /* WKB encoded buffer */ 00226 unsigned long size; /* buffer size */ 00228 unsigned long offset; /* current offset [for parsing] */ 00230 gaiaPointPtr FirstPoint; /* Points linked list - first */ 00232 gaiaPointPtr LastPoint; /* Points linked list - last */ 00234 gaiaLinestringPtr FirstLinestring; /* Linestrings linked list - first */ 00236 gaiaLinestringPtr LastLinestring; /* Linestrings linked list - last */ 00238 gaiaPolygonPtr FirstPolygon; /* Polygons linked list - first */ 00240 gaiaPolygonPtr LastPolygon; /* Polygons linked list - last */ 00242 double MinX; /* MBR - BBOX */ 00244 double MinY; /* MBR - BBOX */ 00246 double MaxX; /* MBR - BBOX */ 00248 double MaxY; /* MBR - BBOX */ 00250 int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */ 00252 int DeclaredType; /* the declared TYPE for this Geometry */ 00254 struct gaiaGeomCollStruct *Next; /* Vanuatu - used for linked list */ 00255 } gaiaGeomColl; 00261 typedef gaiaGeomColl *gaiaGeomCollPtr; 00262 00266 typedef struct gaiaPreRingStruct 00267 { 00268 /* a LINESTRING used to build rings */ 00270 gaiaLinestringPtr Line; /* a LINESTRING pointer */ 00272 int AlreadyUsed; /* a switch to mark an already used line element */ 00274 struct gaiaPreRingStruct *Next; /* for linked list */ 00275 } gaiaPreRing; 00281 typedef gaiaPreRing *gaiaPreRingPtr; 00282 00286 typedef struct gaiaValueStruct 00287 { 00288 /* a DBF field multitype value */ 00290 short Type; /* the type */ 00292 char *TxtValue; /* the text value */ 00294 sqlite3_int64 IntValue; /* the integer value */ 00296 double DblValue; /* the double value */ 00297 } gaiaValue; 00301 typedef gaiaValue *gaiaValuePtr; 00302 00306 typedef struct gaiaDbfFieldStruct 00307 { 00308 /* a DBF field definition - shapefile attribute */ 00310 char *Name; /* field name */ 00312 unsigned char Type; /* field type */ 00314 int Offset; /* buffer offset [this field begins at *buffer+offset* and extends for *length* bytes */ 00316 unsigned char Length; /* field total length [in bytes] */ 00318 unsigned char Decimals; /* decimal positions */ 00320 gaiaValuePtr Value; /* the current multitype value for this attribute */ 00322 struct gaiaDbfFieldStruct *Next; /* pointer to next element in linked list */ 00323 } gaiaDbfField; 00327 typedef gaiaDbfField *gaiaDbfFieldPtr; 00328 00332 typedef struct gaiaDbfListStruct 00333 { 00334 /* a linked list to contain the DBF fields definitions - shapefile attributes */ 00336 int RowId; /* the current RowId */ 00338 gaiaGeomCollPtr Geometry; /* geometry for current entity */ 00340 gaiaDbfFieldPtr First; /* pointer to first element in linked list */ 00342 gaiaDbfFieldPtr Last; /* pointer to last element in linker list */ 00343 } gaiaDbfList; 00349 typedef gaiaDbfList *gaiaDbfListPtr; 00350 00354 typedef struct gaiaDbfStruct 00355 { 00356 /* DBF TYPE */ 00358 int endian_arch; 00360 int Valid; /* 1 = ready to process */ 00362 char *Path; /* the DBF path */ 00364 FILE *flDbf; /* the DBF file handle */ 00366 gaiaDbfListPtr Dbf; /* the DBF attributes list */ 00368 unsigned char *BufDbf; /* the DBF I/O buffer */ 00370 int DbfHdsz; /* the DBF header length */ 00372 int DbfReclen; /* the DBF record length */ 00374 int DbfSize; /* current DBF size */ 00376 int DbfRecno; /* current DBF record number */ 00378 void *IconvObj; /* opaque reference to ICONV converter */ 00380 char *LastError; /* last error message */ 00381 } gaiaDbf; 00387 typedef gaiaDbf *gaiaDbfPtr; 00388 00392 typedef struct gaiaShapefileStruct 00393 { 00394 /* SHAPEFILE TYPE */ 00396 int endian_arch; 00398 int Valid; /* 1 = ready to process */ 00400 int ReadOnly; /* read or write mode */ 00402 char *Path; /* the shapefile abstract path [no suffixes] */ 00404 FILE *flShx; /* the SHX file handle */ 00406 FILE *flShp; /* the SHP file handle */ 00408 FILE *flDbf; /* the DBF file handle */ 00410 int Shape; /* the SHAPE code for the whole shapefile */ 00412 gaiaDbfListPtr Dbf; /* the DBF attributes list */ 00414 unsigned char *BufDbf; /* the DBF I/O buffer */ 00416 int DbfHdsz; /* the DBF header length */ 00418 int DbfReclen; /* the DBF record length */ 00420 int DbfSize; /* current DBF size */ 00422 int DbfRecno; /* current DBF record number */ 00424 unsigned char *BufShp; /* the SHP I/O buffer */ 00426 int ShpBfsz; /* the SHP buffer current size */ 00428 int ShpSize; /* current SHP size */ 00430 int ShxSize; /* current SHX size */ 00432 double MinX; /* the MBR/BBOX for the whole shapefile */ 00434 double MinY; 00436 double MaxX; 00438 double MaxY; 00440 void *IconvObj; /* opaque reference to ICONV converter */ 00442 char *LastError; /* last error message */ 00444 int EffectiveType; /* the effective Geometry-type, as determined by gaiaShpAnalyze() */ 00446 int EffectiveDims; /* the effective Dimensions [XY, XYZ, XYM, XYZM], as determined by gaiaShpAnalyze() */ 00447 } gaiaShapefile; 00453 typedef gaiaShapefile *gaiaShapefilePtr; 00454 00458 typedef struct gaiaOutBufferStruct 00459 { 00460 /* a struct handling a dynamically growing output buffer */ 00462 char *Buffer; 00464 int WriteOffset; 00466 int BufferSize; 00468 int Error; 00469 } gaiaOutBuffer; 00475 typedef gaiaOutBuffer *gaiaOutBufferPtr; 00476 00477 #ifndef OMIT_ICONV /* ICONV enabled: supporting text reader */ 00478 00480 #define VRTTXT_FIELDS_MAX 65535 00481 00482 #define VRTTXT_BLOCK_MAX 65535 00483 00485 #define VRTTXT_TEXT 1 00486 00487 #define VRTTXT_INTEGER 2 00488 00489 #define VRTTXT_DOUBLE 3 00490 00491 #define VRTTXT_NULL 4 00492 00496 struct vrttxt_line 00497 { 00498 /* a struct representing a full LINE (aka Record) */ 00500 off_t offset; 00502 int len; 00504 int field_offsets[VRTTXT_FIELDS_MAX]; 00506 int num_fields; 00508 int error; 00509 }; 00510 00514 struct vrttxt_row 00515 { 00516 /* a struct storing Row offsets */ 00518 int line_no; 00520 off_t offset; 00522 int len; 00524 int num_fields; 00525 }; 00526 00530 struct vrttxt_row_block 00531 { 00532 /* 00533 / for efficiency sake, individual Row offsets 00534 / are grouped in reasonably sized blocks 00535 */ 00537 struct vrttxt_row rows[VRTTXT_BLOCK_MAX]; 00539 int num_rows; 00541 int min_line_no; 00543 int max_line_no; 00545 struct vrttxt_row_block *next; 00546 }; 00547 00551 struct vrttxt_column_header 00552 { 00553 /* a struct representing a Column (aka Field) header */ 00555 char *name; 00557 int type; 00558 }; 00559 00563 typedef struct vrttxt_reader 00564 { 00565 /* the main TXT-Reader struct */ 00567 struct vrttxt_column_header columns[VRTTXT_FIELDS_MAX]; 00569 FILE *text_file; 00571 void *toUtf8; /* the UTF-8 ICONV converter */ 00573 char field_separator; 00575 char text_separator; 00577 char decimal_separator; 00579 int first_line_titles; 00581 int error; 00583 struct vrttxt_row_block *first; 00585 struct vrttxt_row_block *last; 00587 struct vrttxt_row **rows; 00589 int num_rows; 00591 int line_no; 00593 int max_fields; 00595 int current_buf_sz; 00597 int current_buf_off; 00599 char *line_buffer; 00601 char *field_buffer; 00603 int field_offsets[VRTTXT_FIELDS_MAX]; 00605 int field_lens[VRTTXT_FIELDS_MAX]; 00607 int max_current_field; 00609 int current_line_ready; 00610 } gaiaTextReader; 00616 typedef gaiaTextReader *gaiaTextReaderPtr; 00617 00618 #endif /* end ICONV (text reader) */ 00619 00620 #ifdef __cplusplus 00621 } 00622 #endif 00623 00624 #endif /* _GG_STRUCTS_H */