SpatiaLite 4.3.0a

src/headers/spatialite/gg_formats.h

Go to the documentation of this file.
00001 /*
00002  gg_formats.h -- Gaia common support for geometries: formats
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 Klaus Foerster klaus.foerster@svg.cc
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_FORMATS_H
00054 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00055 #define _GG_FORMATS_H
00056 #endif
00057 
00058 #ifdef __cplusplus
00059 extern "C"
00060 {
00061 #endif
00062 
00063 /* function prototypes */
00064 
00070     GAIAGEO_DECLARE int gaiaEndianArch (void);
00071 
00087     GAIAGEO_DECLARE short gaiaImport16 (const unsigned char *p,
00088                                         int little_endian,
00089                                         int little_endian_arch);
00090 
00106     GAIAGEO_DECLARE int gaiaImport32 (const unsigned char *p, int little_endian,
00107                                       int little_endian_arch);
00108 
00124     GAIAGEO_DECLARE unsigned int gaiaImportU32 (const unsigned char *p,
00125                                                 int little_endian,
00126                                                 int little_endian_arch);
00127 
00143     GAIAGEO_DECLARE float gaiaImportF32 (const unsigned char *p,
00144                                          int little_endian,
00145                                          int little_endian_arch);
00146 
00162     GAIAGEO_DECLARE double gaiaImport64 (const unsigned char *p,
00163                                          int little_endian,
00164                                          int little_endian_arch);
00165 
00181     GAIAGEO_DECLARE sqlite3_int64 gaiaImportI64 (const unsigned char *p,
00182                                                  int little_endian,
00183                                                  int little_endian_arch);
00184 
00199     GAIAGEO_DECLARE void gaiaExport16 (unsigned char *p, short value,
00200                                        int little_endian,
00201                                        int little_endian_arch);
00202 
00217     GAIAGEO_DECLARE void gaiaExport32 (unsigned char *p, int value,
00218                                        int little_endian,
00219                                        int little_endian_arch);
00220 
00235     GAIAGEO_DECLARE void gaiaExportU32 (unsigned char *p, unsigned int value,
00236                                         int little_endian,
00237                                         int little_endian_arch);
00238 
00253     GAIAGEO_DECLARE void gaiaExportF32 (unsigned char *p, float value,
00254                                         int little_endian,
00255                                         int little_endian_arch);
00256 
00271     GAIAGEO_DECLARE void gaiaExport64 (unsigned char *p, double value,
00272                                        int little_endian,
00273                                        int little_endian_arch);
00274 
00289     GAIAGEO_DECLARE void gaiaExportI64 (unsigned char *p, sqlite3_int64 value,
00290                                         int little_endian,
00291                                         int little_endian_arch);
00292 
00308     GAIAGEO_DECLARE void gaiaOutBufferInitialize (gaiaOutBufferPtr buf);
00309 
00321     GAIAGEO_DECLARE void gaiaOutBufferReset (gaiaOutBufferPtr buf);
00322 
00336     GAIAGEO_DECLARE void gaiaAppendToOutBuffer (gaiaOutBufferPtr buf,
00337                                                 const char *text);
00338 
00355     GAIAGEO_DECLARE void gaiaMakePoint (double x, double y, int srid,
00356                                         unsigned char **result, int *size);
00357 
00375     GAIAGEO_DECLARE void gaiaMakePointZ (double x, double y, double z, int srid,
00376                                          unsigned char **result, int *size);
00377 
00395     GAIAGEO_DECLARE void gaiaMakePointM (double x, double y, double m, int srid,
00396                                          unsigned char **result, int *size);
00397 
00416     GAIAGEO_DECLARE void gaiaMakePointZM (double x, double y, double z,
00417                                           double m, int srid,
00418                                           unsigned char **result, int *size);
00419 
00435     GAIAGEO_DECLARE void gaiaMakeLine (gaiaGeomCollPtr geom1,
00436                                        gaiaGeomCollPtr geom2,
00437                                        unsigned char **result, int *size);
00438 
00455     GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromSpatiaLiteBlobWkb (const unsigned
00456                                                                char *blob,
00457                                                                unsigned int
00458                                                                size);
00459 
00478     GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromSpatiaLiteBlobWkbEx (const unsigned
00479                                                                  char *blob,
00480                                                                  unsigned int
00481                                                                  size,
00482                                                                  int gpkg_mode,
00483                                                                  int
00484                                                                  gpkg_amphibious);
00485 
00500     GAIAGEO_DECLARE void gaiaToSpatiaLiteBlobWkb (gaiaGeomCollPtr geom,
00501                                                   unsigned char **result,
00502                                                   int *size);
00503 
00519     GAIAGEO_DECLARE void gaiaToSpatiaLiteBlobWkbEx (gaiaGeomCollPtr geom,
00520                                                     unsigned char **result,
00521                                                     int *size, int gpkg_mode);
00522 
00539     GAIAGEO_DECLARE void gaiaToCompressedBlobWkb (gaiaGeomCollPtr geom,
00540                                                   unsigned char **result,
00541                                                   int *size);
00542 
00558     GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromWkb (const unsigned char *blob,
00559                                                  unsigned int size);
00560 
00578     GAIAGEO_DECLARE void gaiaToWkb (gaiaGeomCollPtr geom,
00579                                     unsigned char **result, int *size);
00580 
00595     GAIAGEO_DECLARE char *gaiaToHexWkb (gaiaGeomCollPtr geom);
00596 
00608     GAIAGEO_DECLARE void gaiaToEWKB (gaiaOutBufferPtr out_buf,
00609                                      gaiaGeomCollPtr geom);
00610 
00626     GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromEWKB (const unsigned char
00627                                                   *in_buffer);
00628 
00643     GAIAGEO_DECLARE unsigned char *gaiaParseHexEWKB (const unsigned char
00644                                                      *blob_hex, int *blob_size);
00645 
00664     GAIAGEO_DECLARE int
00665         gaiaEwkbGetPoint (gaiaGeomCollPtr geom, unsigned char *blob,
00666                           int offset, int blob_size, int endian,
00667                           int endian_arch, int dims);
00668 
00687     GAIAGEO_DECLARE int
00688         gaiaEwkbGetLinestring (gaiaGeomCollPtr geom, unsigned char *blob,
00689                                int offset, int blob_size, int endian,
00690                                int endian_arch, int dims);
00691 
00708     GAIAGEO_DECLARE int
00709         gaiaEwkbGetPolygon (gaiaGeomCollPtr geom, unsigned char *blob,
00710                             int offset, int blob_size, int endian,
00711                             int endian_arch, int dims);
00712 
00731     GAIAGEO_DECLARE int
00732         gaiaEwkbGetMultiGeometry (gaiaGeomCollPtr geom, unsigned char *blob,
00733                                   int offset, int blob_size, int endian,
00734                                   int endian_arch, int dims);
00735 
00751     GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromFgf (const unsigned char *blob,
00752                                                  unsigned int size);
00753 
00769     GAIAGEO_DECLARE void gaiaToFgf (gaiaGeomCollPtr geom,
00770                                     unsigned char **result, int *size,
00771                                     int coord_dims);
00772 
00790     GAIAGEO_DECLARE gaiaGeomCollPtr gaiaParseWkt (const unsigned char
00791                                                   *in_buffer, short type);
00792 
00806     GAIAGEO_DECLARE void gaiaOutWkt (gaiaOutBufferPtr out_buf,
00807                                      gaiaGeomCollPtr geom);
00808 
00822     GAIAGEO_DECLARE void gaiaOutWktEx (gaiaOutBufferPtr out_buf,
00823                                        gaiaGeomCollPtr geom, int precision);
00824 
00838     GAIAGEO_DECLARE void gaiaOutWktStrict (gaiaOutBufferPtr out_buf,
00839                                            gaiaGeomCollPtr geom, int precision);
00840 
00855     GAIAGEO_DECLARE gaiaGeomCollPtr gaiaParseEWKT (const unsigned char
00856                                                    *in_buffer);
00857 
00868     GAIAGEO_DECLARE void gaiaToEWKT (gaiaOutBufferPtr out_buf,
00869                                      gaiaGeomCollPtr geom);
00870 
00881     GAIAGEO_DECLARE void gaiaOutPointZ (gaiaOutBufferPtr out_buf,
00882                                         gaiaPointPtr point);
00883 
00895     GAIAGEO_DECLARE void gaiaOutPointZex (gaiaOutBufferPtr out_buf,
00896                                           gaiaPointPtr point, int precision);
00897 
00908     GAIAGEO_DECLARE void gaiaOutLinestringZ (gaiaOutBufferPtr out_buf,
00909                                              gaiaLinestringPtr linestring);
00910 
00922     GAIAGEO_DECLARE void gaiaOutLinestringZex (gaiaOutBufferPtr out_buf,
00923                                                gaiaLinestringPtr linestring,
00924                                                int precision);
00925 
00936     GAIAGEO_DECLARE void gaiaOutPolygonZ (gaiaOutBufferPtr out_buf,
00937                                           gaiaPolygonPtr polygon);
00938 
00950     GAIAGEO_DECLARE void gaiaOutPolygonZex (gaiaOutBufferPtr out_buf,
00951                                             gaiaPolygonPtr polygon,
00952                                             int precision);
00953 
00968     GAIAGEO_DECLARE gaiaGeomCollPtr gaiaParseKml (const unsigned char
00969                                                   *in_buffer);
00970 
00982     GAIAGEO_DECLARE void gaiaOutBareKml (gaiaOutBufferPtr out_buf,
00983                                          gaiaGeomCollPtr geom, int precision);
00984 
00998     GAIAGEO_DECLARE void gaiaOutFullKml (gaiaOutBufferPtr out_buf,
00999                                          const char *name, const char *desc,
01000                                          gaiaGeomCollPtr geom, int precision);
01001 
01018     GAIAGEO_DECLARE gaiaGeomCollPtr gaiaParseGml (const unsigned char
01019                                                   *in_buffer,
01020                                                   sqlite3 * sqlite_handle);
01021 
01039     GAIAGEO_DECLARE gaiaGeomCollPtr gaiaParseGml_r (const void *p_cache,
01040                                                     const unsigned char
01041                                                     *in_buffer,
01042                                                     sqlite3 * sqlite_handle);
01043 
01057     GAIAGEO_DECLARE void gaiaOutGml (gaiaOutBufferPtr out_buf, int version,
01058                                      int precision, gaiaGeomCollPtr geom);
01059 
01074     GAIAGEO_DECLARE gaiaGeomCollPtr gaiaParseGeoJSON (const unsigned char
01075                                                       *in_buffer);
01076 
01095     GAIAGEO_DECLARE void gaiaOutGeoJSON (gaiaOutBufferPtr out_buf,
01096                                          gaiaGeomCollPtr geom, int precision,
01097                                          int options);
01109     GAIAGEO_DECLARE void gaiaOutSvg (gaiaOutBufferPtr out_buf,
01110                                      gaiaGeomCollPtr geom, int relative,
01111                                      int precision);
01112 
01126     GAIAGEO_DECLARE gaiaValuePtr gaiaCloneValue (gaiaValuePtr org);
01127 
01137     GAIAGEO_DECLARE void gaiaFreeValue (gaiaValuePtr p);
01138 
01162     GAIAGEO_DECLARE gaiaDbfFieldPtr gaiaAllocDbfField (char *name,
01163                                                        unsigned char type,
01164                                                        int offset,
01165                                                        unsigned char length,
01166                                                        unsigned char decimals);
01167 
01177     GAIAGEO_DECLARE void gaiaFreeDbfField (gaiaDbfFieldPtr p);
01178 
01193     GAIAGEO_DECLARE gaiaDbfFieldPtr gaiaCloneDbfField (gaiaDbfFieldPtr org);
01194 
01204     GAIAGEO_DECLARE void gaiaSetNullValue (gaiaDbfFieldPtr field);
01205 
01216     GAIAGEO_DECLARE void gaiaSetIntValue (gaiaDbfFieldPtr field,
01217                                           sqlite3_int64 value);
01218 
01228     GAIAGEO_DECLARE void gaiaSetDoubleValue (gaiaDbfFieldPtr field,
01229                                              double value);
01230 
01240     GAIAGEO_DECLARE void gaiaSetStrValue (gaiaDbfFieldPtr field, char *str);
01241 
01254     GAIAGEO_DECLARE gaiaDbfListPtr gaiaAllocDbfList (void);
01255 
01268     GAIAGEO_DECLARE void gaiaFreeDbfList (gaiaDbfListPtr list);
01269 
01280     GAIAGEO_DECLARE int gaiaIsValidDbfList (gaiaDbfListPtr list);
01281 
01302     GAIAGEO_DECLARE gaiaDbfFieldPtr gaiaAddDbfField (gaiaDbfListPtr list,
01303                                                      char *name,
01304                                                      unsigned char type,
01305                                                      int offset,
01306                                                      unsigned char length,
01307                                                      unsigned char decimals);
01308 
01319     GAIAGEO_DECLARE void gaiaResetDbfEntity (gaiaDbfListPtr list);
01320 
01333     GAIAGEO_DECLARE gaiaDbfListPtr gaiaCloneDbfEntity (gaiaDbfListPtr org);
01334 
01347     GAIAGEO_DECLARE gaiaShapefilePtr gaiaAllocShapefile (void);
01348 
01361     GAIAGEO_DECLARE void gaiaFreeShapefile (gaiaShapefilePtr shp);
01362 
01378     GAIAGEO_DECLARE void gaiaOpenShpRead (gaiaShapefilePtr shp,
01379                                           const char *path,
01380                                           const char *charFrom,
01381                                           const char *charTo);
01382 
01404     GAIAGEO_DECLARE void gaiaOpenShpWrite (gaiaShapefilePtr shp,
01405                                            const char *path, int shape,
01406                                            gaiaDbfListPtr list,
01407                                            const char *charFrom,
01408                                            const char *charTo);
01409 
01430     GAIAGEO_DECLARE int gaiaReadShpEntity (gaiaShapefilePtr shp,
01431                                            int current_row, int srid);
01432 
01454     GAIAGEO_DECLARE int gaiaReadShpEntity_ex (gaiaShapefilePtr shp,
01455                                               int current_row, int srid,
01456                                               int text_dates);
01457 
01471     GAIAGEO_DECLARE void gaiaShpAnalyze (gaiaShapefilePtr shp);
01472 
01487     GAIAGEO_DECLARE int gaiaWriteShpEntity (gaiaShapefilePtr shp,
01488                                             gaiaDbfListPtr entity);
01489 
01502     GAIAGEO_DECLARE void gaiaFlushShpHeaders (gaiaShapefilePtr shp);
01503 
01516     GAIAGEO_DECLARE gaiaDbfPtr gaiaAllocDbf (void);
01517 
01530     GAIAGEO_DECLARE void gaiaFreeDbf (gaiaDbfPtr dbf);
01531 
01546     GAIAGEO_DECLARE void gaiaOpenDbfRead (gaiaDbfPtr dbf,
01547                                           const char *path,
01548                                           const char *charFrom,
01549                                           const char *charTo);
01550 
01565     GAIAGEO_DECLARE void gaiaOpenDbfWrite (gaiaDbfPtr dbf,
01566                                            const char *path,
01567                                            const char *charFrom,
01568                                            const char *charTo);
01569 
01590     GAIAGEO_DECLARE int gaiaReadDbfEntity (gaiaDbfPtr dbf, int current_row,
01591                                            int *deleted);
01592 
01614     GAIAGEO_DECLARE int gaiaReadDbfEntity_ex (gaiaDbfPtr dbf, int current_row,
01615                                               int *deleted, int text_dates);
01616 
01631     GAIAGEO_DECLARE int gaiaWriteDbfEntity (gaiaDbfPtr dbf,
01632                                             gaiaDbfListPtr entity);
01633 
01646     GAIAGEO_DECLARE void gaiaFlushDbfHeader (gaiaDbfPtr dbf);
01647 
01648 
01649 
01650 #ifndef OMIT_ICONV              /* ICONV enabled: supporting text reader */
01651 
01673     GAIAGEO_DECLARE gaiaTextReaderPtr gaiaTextReaderAlloc (const char *path,
01674                                                            char field_separator,
01675                                                            char text_separator,
01676                                                            char
01677                                                            decimal_separator,
01678                                                            int
01679                                                            first_line_titles,
01680                                                            const char
01681                                                            *encoding);
01682 
01691     GAIAGEO_DECLARE void gaiaTextReaderDestroy (gaiaTextReaderPtr reader);
01692 
01708     GAIAGEO_DECLARE int gaiaTextReaderParse (gaiaTextReaderPtr reader);
01709 
01725     GAIAGEO_DECLARE int gaiaTextReaderGetRow (gaiaTextReaderPtr reader,
01726                                               int row_num);
01727 
01741     GAIAGEO_DECLARE int gaiaTextReaderFetchField (gaiaTextReaderPtr reader,
01742                                                   int field_num, int *type,
01743                                                   const char **value);
01744 
01745 #endif                          /* end ICONV (text reader) */
01746 
01747 #ifdef __cplusplus
01748 }
01749 #endif
01750 
01751 #endif                          /* _GG_FORMATS_H */
 All Data Structures Files Functions Variables Typedefs Defines