SpatiaLite  4.0.0
 All Data Structures Files Functions Variables Typedefs Macros Pages
gg_formats.h
Go to the documentation of this file.
1 /*
2  gg_formats.h -- Gaia common support for geometries: formats
3 
4  version 4.0, 2012 August 6
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-2012
27 the Initial Developer. All Rights Reserved.
28 
29 Contributor(s):
30 Klaus Foerster klaus.foerster@svg.cc
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_FORMATS_H
54 #ifndef DOXYGEN_SHOULD_SKIP_THIS
55 #define _GG_FORMATS_H
56 #endif
57 
58 #ifdef __cplusplus
59 extern "C"
60 {
61 #endif
62 
63 /* function prototypes */
64 
70  GAIAGEO_DECLARE int gaiaEndianArch (void);
71 
87  GAIAGEO_DECLARE short gaiaImport16 (const unsigned char *p,
88  int little_endian,
89  int little_endian_arch);
90 
106  GAIAGEO_DECLARE int gaiaImport32 (const unsigned char *p, int little_endian,
107  int little_endian_arch);
108 
124  GAIAGEO_DECLARE float gaiaImportF32 (const unsigned char *p,
125  int little_endian,
126  int little_endian_arch);
127 
143  GAIAGEO_DECLARE double gaiaImport64 (const unsigned char *p,
144  int little_endian,
145  int little_endian_arch);
146 
162  GAIAGEO_DECLARE sqlite3_int64 gaiaImportI64 (const unsigned char *p,
163  int little_endian,
164  int little_endian_arch);
165 
180  GAIAGEO_DECLARE void gaiaExport16 (unsigned char *p, short value,
181  int little_endian,
182  int little_endian_arch);
183 
198  GAIAGEO_DECLARE void gaiaExport32 (unsigned char *p, int value,
199  int little_endian,
200  int little_endian_arch);
201 
216  GAIAGEO_DECLARE void gaiaExportF32 (unsigned char *p, float value,
217  int little_endian,
218  int little_endian_arch);
219 
234  GAIAGEO_DECLARE void gaiaExport64 (unsigned char *p, double value,
235  int little_endian,
236  int little_endian_arch);
237 
252  GAIAGEO_DECLARE void gaiaExportI64 (unsigned char *p, sqlite3_int64 value,
253  int little_endian,
254  int little_endian_arch);
255 
271  GAIAGEO_DECLARE void gaiaOutBufferInitialize (gaiaOutBufferPtr buf);
272 
284  GAIAGEO_DECLARE void gaiaOutBufferReset (gaiaOutBufferPtr buf);
285 
299  GAIAGEO_DECLARE void gaiaAppendToOutBuffer (gaiaOutBufferPtr buf,
300  const char *text);
301 
318  GAIAGEO_DECLARE void gaiaMakePoint (double x, double y, int srid,
319  unsigned char **result, int *size);
320 
338  GAIAGEO_DECLARE void gaiaMakePointZ (double x, double y, double z, int srid,
339  unsigned char **result, int *size);
340 
358  GAIAGEO_DECLARE void gaiaMakePointM (double x, double y, double m, int srid,
359  unsigned char **result, int *size);
360 
379  GAIAGEO_DECLARE void gaiaMakePointZM (double x, double y, double z,
380  double m, int srid,
381  unsigned char **result, int *size);
382 
398  GAIAGEO_DECLARE void gaiaMakeLine (gaiaGeomCollPtr geom1,
399  gaiaGeomCollPtr geom2,
400  unsigned char **result, int *size);
401 
417  GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromSpatiaLiteBlobWkb (const unsigned
418  char *blob,
419  unsigned int
420  size);
421 
436  GAIAGEO_DECLARE void gaiaToSpatiaLiteBlobWkb (gaiaGeomCollPtr geom,
437  unsigned char **result,
438  int *size);
439 
456  GAIAGEO_DECLARE void gaiaToCompressedBlobWkb (gaiaGeomCollPtr geom,
457  unsigned char **result,
458  int *size);
459 
475  GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromWkb (const unsigned char *blob,
476  unsigned int size);
477 
495  GAIAGEO_DECLARE void gaiaToWkb (gaiaGeomCollPtr geom,
496  unsigned char **result, int *size);
497 
512  GAIAGEO_DECLARE char *gaiaToHexWkb (gaiaGeomCollPtr geom);
513 
525  GAIAGEO_DECLARE void gaiaToEWKB (gaiaOutBufferPtr out_buf,
526  gaiaGeomCollPtr geom);
527 
543  GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromEWKB (const unsigned char
544  *in_buffer);
545 
560  GAIAGEO_DECLARE unsigned char *gaiaParseHexEWKB (const unsigned char
561  *blob_hex, int *blob_size);
562 
581  GAIAGEO_DECLARE int
582  gaiaEwkbGetPoint (gaiaGeomCollPtr geom, unsigned char *blob,
583  int offset, int blob_size, int endian,
584  int endian_arch, int dims);
585 
604  GAIAGEO_DECLARE int
605  gaiaEwkbGetLinestring (gaiaGeomCollPtr geom, unsigned char *blob,
606  int offset, int blob_size, int endian,
607  int endian_arch, int dims);
608 
625  GAIAGEO_DECLARE int
626  gaiaEwkbGetPolygon (gaiaGeomCollPtr geom, unsigned char *blob,
627  int offset, int blob_size, int endian,
628  int endian_arch, int dims);
629 
648  GAIAGEO_DECLARE int
649  gaiaEwkbGetMultiGeometry (gaiaGeomCollPtr geom, unsigned char *blob,
650  int offset, int blob_size, int endian,
651  int endian_arch, int dims);
652 
668  GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromFgf (const unsigned char *blob,
669  unsigned int size);
670 
686  GAIAGEO_DECLARE void gaiaToFgf (gaiaGeomCollPtr geom,
687  unsigned char **result, int *size,
688  int coord_dims);
689 
707  GAIAGEO_DECLARE gaiaGeomCollPtr gaiaParseWkt (const unsigned char
708  *in_buffer, short type);
709 
722  GAIAGEO_DECLARE void gaiaOutWkt (gaiaOutBufferPtr out_buf,
723  gaiaGeomCollPtr geom);
724 
738  GAIAGEO_DECLARE void gaiaOutWktStrict (gaiaOutBufferPtr out_buf,
739  gaiaGeomCollPtr geom, int precision);
740 
755  GAIAGEO_DECLARE gaiaGeomCollPtr gaiaParseEWKT (const unsigned char
756  *in_buffer);
757 
768  GAIAGEO_DECLARE void gaiaToEWKT (gaiaOutBufferPtr out_buf,
769  gaiaGeomCollPtr geom);
770 
781  GAIAGEO_DECLARE void gaiaOutPointZ (gaiaOutBufferPtr out_buf,
782  gaiaPointPtr point);
783 
794  GAIAGEO_DECLARE void gaiaOutLinestringZ (gaiaOutBufferPtr out_buf,
795  gaiaLinestringPtr linestring);
796 
807  GAIAGEO_DECLARE void gaiaOutPolygonZ (gaiaOutBufferPtr out_buf,
808  gaiaPolygonPtr polygon);
823  GAIAGEO_DECLARE gaiaGeomCollPtr gaiaParseKml (const unsigned char
824  *in_buffer);
825 
837  GAIAGEO_DECLARE void gaiaOutBareKml (gaiaOutBufferPtr out_buf,
838  gaiaGeomCollPtr geom, int precision);
839 
853  GAIAGEO_DECLARE void gaiaOutFullKml (gaiaOutBufferPtr out_buf,
854  const char *name, const char *desc,
855  gaiaGeomCollPtr geom, int precision);
856 
872  GAIAGEO_DECLARE gaiaGeomCollPtr gaiaParseGml (const unsigned char
873  *in_buffer,
874  sqlite3 * sqlite_handle);
875 
889  GAIAGEO_DECLARE void gaiaOutGml (gaiaOutBufferPtr out_buf, int version,
890  int precision, gaiaGeomCollPtr geom);
891 
906  GAIAGEO_DECLARE gaiaGeomCollPtr gaiaParseGeoJSON (const unsigned char
907  *in_buffer);
908 
927  GAIAGEO_DECLARE void gaiaOutGeoJSON (gaiaOutBufferPtr out_buf,
928  gaiaGeomCollPtr geom, int precision,
929  int options);
941  GAIAGEO_DECLARE void gaiaOutSvg (gaiaOutBufferPtr out_buf,
942  gaiaGeomCollPtr geom, int relative,
943  int precision);
944 
958  GAIAGEO_DECLARE gaiaValuePtr gaiaCloneValue (gaiaValuePtr org);
959 
969  GAIAGEO_DECLARE void gaiaFreeValue (gaiaValuePtr p);
970 
994  GAIAGEO_DECLARE gaiaDbfFieldPtr gaiaAllocDbfField (char *name,
995  unsigned char type,
996  int offset,
997  unsigned char length,
998  unsigned char decimals);
999 
1009  GAIAGEO_DECLARE void gaiaFreeDbfField (gaiaDbfFieldPtr p);
1010 
1025  GAIAGEO_DECLARE gaiaDbfFieldPtr gaiaCloneDbfField (gaiaDbfFieldPtr org);
1026 
1036  GAIAGEO_DECLARE void gaiaSetNullValue (gaiaDbfFieldPtr field);
1037 
1048  GAIAGEO_DECLARE void gaiaSetIntValue (gaiaDbfFieldPtr field,
1049  sqlite3_int64 value);
1050 
1060  GAIAGEO_DECLARE void gaiaSetDoubleValue (gaiaDbfFieldPtr field,
1061  double value);
1062 
1072  GAIAGEO_DECLARE void gaiaSetStrValue (gaiaDbfFieldPtr field, char *str);
1073 
1086  GAIAGEO_DECLARE gaiaDbfListPtr gaiaAllocDbfList (void);
1087 
1100  GAIAGEO_DECLARE void gaiaFreeDbfList (gaiaDbfListPtr list);
1101 
1112  GAIAGEO_DECLARE int gaiaIsValidDbfList (gaiaDbfListPtr list);
1113 
1134  GAIAGEO_DECLARE gaiaDbfFieldPtr gaiaAddDbfField (gaiaDbfListPtr list,
1135  char *name,
1136  unsigned char type,
1137  int offset,
1138  unsigned char length,
1139  unsigned char decimals);
1140 
1151  GAIAGEO_DECLARE void gaiaResetDbfEntity (gaiaDbfListPtr list);
1152 
1165  GAIAGEO_DECLARE gaiaDbfListPtr gaiaCloneDbfEntity (gaiaDbfListPtr org);
1166 
1179  GAIAGEO_DECLARE gaiaShapefilePtr gaiaAllocShapefile (void);
1180 
1193  GAIAGEO_DECLARE void gaiaFreeShapefile (gaiaShapefilePtr shp);
1194 
1210  GAIAGEO_DECLARE void gaiaOpenShpRead (gaiaShapefilePtr shp,
1211  const char *path,
1212  const char *charFrom,
1213  const char *charTo);
1214 
1236  GAIAGEO_DECLARE void gaiaOpenShpWrite (gaiaShapefilePtr shp,
1237  const char *path, int shape,
1238  gaiaDbfListPtr list,
1239  const char *charFrom,
1240  const char *charTo);
1241 
1262  GAIAGEO_DECLARE int gaiaReadShpEntity (gaiaShapefilePtr shp,
1263  int current_row, int srid);
1264 
1278  GAIAGEO_DECLARE void gaiaShpAnalyze (gaiaShapefilePtr shp);
1279 
1294  GAIAGEO_DECLARE int gaiaWriteShpEntity (gaiaShapefilePtr shp,
1295  gaiaDbfListPtr entity);
1296 
1309  GAIAGEO_DECLARE void gaiaFlushShpHeaders (gaiaShapefilePtr shp);
1310 
1323  GAIAGEO_DECLARE gaiaDbfPtr gaiaAllocDbf (void);
1324 
1337  GAIAGEO_DECLARE void gaiaFreeDbf (gaiaDbfPtr dbf);
1338 
1353  GAIAGEO_DECLARE void gaiaOpenDbfRead (gaiaDbfPtr dbf,
1354  const char *path,
1355  const char *charFrom,
1356  const char *charTo);
1357 
1372  GAIAGEO_DECLARE void gaiaOpenDbfWrite (gaiaDbfPtr dbf,
1373  const char *path,
1374  const char *charFrom,
1375  const char *charTo);
1376 
1397  GAIAGEO_DECLARE int gaiaReadDbfEntity (gaiaDbfPtr dbf, int current_row,
1398  int *deleted);
1399 
1414  GAIAGEO_DECLARE int gaiaWriteDbfEntity (gaiaDbfPtr dbf,
1415  gaiaDbfListPtr entity);
1416 
1429  GAIAGEO_DECLARE void gaiaFlushDbfHeader (gaiaDbfPtr dbf);
1430 
1431 
1432 
1433 #ifndef OMIT_ICONV /* ICONV enabled: supporting text reader */
1434 
1456  GAIAGEO_DECLARE gaiaTextReaderPtr gaiaTextReaderAlloc (const char *path,
1457  char field_separator,
1458  char text_separator,
1459  char
1460  decimal_separator,
1461  int
1462  first_line_titles,
1463  const char
1464  *encoding);
1465 
1474  GAIAGEO_DECLARE void gaiaTextReaderDestroy (gaiaTextReaderPtr reader);
1475 
1491  GAIAGEO_DECLARE int gaiaTextReaderParse (gaiaTextReaderPtr reader);
1492 
1508  GAIAGEO_DECLARE int gaiaTextReaderGetRow (gaiaTextReaderPtr reader,
1509  int row_num);
1510 
1524  GAIAGEO_DECLARE int gaiaTextReaderFetchField (gaiaTextReaderPtr reader,
1525  int field_num, int *type,
1526  const char **value);
1527 
1528 #endif /* end ICONV (text reader) */
1529 
1530 #ifdef __cplusplus
1531 }
1532 #endif
1533 
1534 #endif /* _GG_FORMATS_H */