SpatiaLite  4.1.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.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 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 unsigned int gaiaImportU32 (const unsigned char *p,
125  int little_endian,
126  int little_endian_arch);
127 
143  GAIAGEO_DECLARE float gaiaImportF32 (const unsigned char *p,
144  int little_endian,
145  int little_endian_arch);
146 
162  GAIAGEO_DECLARE double gaiaImport64 (const unsigned char *p,
163  int little_endian,
164  int little_endian_arch);
165 
181  GAIAGEO_DECLARE sqlite3_int64 gaiaImportI64 (const unsigned char *p,
182  int little_endian,
183  int little_endian_arch);
184 
199  GAIAGEO_DECLARE void gaiaExport16 (unsigned char *p, short value,
200  int little_endian,
201  int little_endian_arch);
202 
217  GAIAGEO_DECLARE void gaiaExport32 (unsigned char *p, int value,
218  int little_endian,
219  int little_endian_arch);
220 
235  GAIAGEO_DECLARE void gaiaExportU32 (unsigned char *p, unsigned int value,
236  int little_endian,
237  int little_endian_arch);
238 
253  GAIAGEO_DECLARE void gaiaExportF32 (unsigned char *p, float value,
254  int little_endian,
255  int little_endian_arch);
256 
271  GAIAGEO_DECLARE void gaiaExport64 (unsigned char *p, double value,
272  int little_endian,
273  int little_endian_arch);
274 
289  GAIAGEO_DECLARE void gaiaExportI64 (unsigned char *p, sqlite3_int64 value,
290  int little_endian,
291  int little_endian_arch);
292 
308  GAIAGEO_DECLARE void gaiaOutBufferInitialize (gaiaOutBufferPtr buf);
309 
321  GAIAGEO_DECLARE void gaiaOutBufferReset (gaiaOutBufferPtr buf);
322 
336  GAIAGEO_DECLARE void gaiaAppendToOutBuffer (gaiaOutBufferPtr buf,
337  const char *text);
338 
355  GAIAGEO_DECLARE void gaiaMakePoint (double x, double y, int srid,
356  unsigned char **result, int *size);
357 
375  GAIAGEO_DECLARE void gaiaMakePointZ (double x, double y, double z, int srid,
376  unsigned char **result, int *size);
377 
395  GAIAGEO_DECLARE void gaiaMakePointM (double x, double y, double m, int srid,
396  unsigned char **result, int *size);
397 
416  GAIAGEO_DECLARE void gaiaMakePointZM (double x, double y, double z,
417  double m, int srid,
418  unsigned char **result, int *size);
419 
435  GAIAGEO_DECLARE void gaiaMakeLine (gaiaGeomCollPtr geom1,
436  gaiaGeomCollPtr geom2,
437  unsigned char **result, int *size);
438 
454  GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromSpatiaLiteBlobWkb (const unsigned
455  char *blob,
456  unsigned int
457  size);
458 
473  GAIAGEO_DECLARE void gaiaToSpatiaLiteBlobWkb (gaiaGeomCollPtr geom,
474  unsigned char **result,
475  int *size);
476 
493  GAIAGEO_DECLARE void gaiaToCompressedBlobWkb (gaiaGeomCollPtr geom,
494  unsigned char **result,
495  int *size);
496 
512  GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromWkb (const unsigned char *blob,
513  unsigned int size);
514 
532  GAIAGEO_DECLARE void gaiaToWkb (gaiaGeomCollPtr geom,
533  unsigned char **result, int *size);
534 
549  GAIAGEO_DECLARE char *gaiaToHexWkb (gaiaGeomCollPtr geom);
550 
562  GAIAGEO_DECLARE void gaiaToEWKB (gaiaOutBufferPtr out_buf,
563  gaiaGeomCollPtr geom);
564 
580  GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromEWKB (const unsigned char
581  *in_buffer);
582 
597  GAIAGEO_DECLARE unsigned char *gaiaParseHexEWKB (const unsigned char
598  *blob_hex, int *blob_size);
599 
618  GAIAGEO_DECLARE int
619  gaiaEwkbGetPoint (gaiaGeomCollPtr geom, unsigned char *blob,
620  int offset, int blob_size, int endian,
621  int endian_arch, int dims);
622 
641  GAIAGEO_DECLARE int
642  gaiaEwkbGetLinestring (gaiaGeomCollPtr geom, unsigned char *blob,
643  int offset, int blob_size, int endian,
644  int endian_arch, int dims);
645 
662  GAIAGEO_DECLARE int
663  gaiaEwkbGetPolygon (gaiaGeomCollPtr geom, unsigned char *blob,
664  int offset, int blob_size, int endian,
665  int endian_arch, int dims);
666 
685  GAIAGEO_DECLARE int
686  gaiaEwkbGetMultiGeometry (gaiaGeomCollPtr geom, unsigned char *blob,
687  int offset, int blob_size, int endian,
688  int endian_arch, int dims);
689 
705  GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromFgf (const unsigned char *blob,
706  unsigned int size);
707 
723  GAIAGEO_DECLARE void gaiaToFgf (gaiaGeomCollPtr geom,
724  unsigned char **result, int *size,
725  int coord_dims);
726 
744  GAIAGEO_DECLARE gaiaGeomCollPtr gaiaParseWkt (const unsigned char
745  *in_buffer, short type);
746 
759  GAIAGEO_DECLARE void gaiaOutWkt (gaiaOutBufferPtr out_buf,
760  gaiaGeomCollPtr geom);
761 
775  GAIAGEO_DECLARE void gaiaOutWktStrict (gaiaOutBufferPtr out_buf,
776  gaiaGeomCollPtr geom, int precision);
777 
792  GAIAGEO_DECLARE gaiaGeomCollPtr gaiaParseEWKT (const unsigned char
793  *in_buffer);
794 
805  GAIAGEO_DECLARE void gaiaToEWKT (gaiaOutBufferPtr out_buf,
806  gaiaGeomCollPtr geom);
807 
818  GAIAGEO_DECLARE void gaiaOutPointZ (gaiaOutBufferPtr out_buf,
819  gaiaPointPtr point);
820 
831  GAIAGEO_DECLARE void gaiaOutLinestringZ (gaiaOutBufferPtr out_buf,
832  gaiaLinestringPtr linestring);
833 
844  GAIAGEO_DECLARE void gaiaOutPolygonZ (gaiaOutBufferPtr out_buf,
845  gaiaPolygonPtr polygon);
860  GAIAGEO_DECLARE gaiaGeomCollPtr gaiaParseKml (const unsigned char
861  *in_buffer);
862 
874  GAIAGEO_DECLARE void gaiaOutBareKml (gaiaOutBufferPtr out_buf,
875  gaiaGeomCollPtr geom, int precision);
876 
890  GAIAGEO_DECLARE void gaiaOutFullKml (gaiaOutBufferPtr out_buf,
891  const char *name, const char *desc,
892  gaiaGeomCollPtr geom, int precision);
893 
909  GAIAGEO_DECLARE gaiaGeomCollPtr gaiaParseGml (const unsigned char
910  *in_buffer,
911  sqlite3 * sqlite_handle);
912 
926  GAIAGEO_DECLARE void gaiaOutGml (gaiaOutBufferPtr out_buf, int version,
927  int precision, gaiaGeomCollPtr geom);
928 
943  GAIAGEO_DECLARE gaiaGeomCollPtr gaiaParseGeoJSON (const unsigned char
944  *in_buffer);
945 
964  GAIAGEO_DECLARE void gaiaOutGeoJSON (gaiaOutBufferPtr out_buf,
965  gaiaGeomCollPtr geom, int precision,
966  int options);
978  GAIAGEO_DECLARE void gaiaOutSvg (gaiaOutBufferPtr out_buf,
979  gaiaGeomCollPtr geom, int relative,
980  int precision);
981 
995  GAIAGEO_DECLARE gaiaValuePtr gaiaCloneValue (gaiaValuePtr org);
996 
1006  GAIAGEO_DECLARE void gaiaFreeValue (gaiaValuePtr p);
1007 
1031  GAIAGEO_DECLARE gaiaDbfFieldPtr gaiaAllocDbfField (char *name,
1032  unsigned char type,
1033  int offset,
1034  unsigned char length,
1035  unsigned char decimals);
1036 
1046  GAIAGEO_DECLARE void gaiaFreeDbfField (gaiaDbfFieldPtr p);
1047 
1062  GAIAGEO_DECLARE gaiaDbfFieldPtr gaiaCloneDbfField (gaiaDbfFieldPtr org);
1063 
1073  GAIAGEO_DECLARE void gaiaSetNullValue (gaiaDbfFieldPtr field);
1074 
1085  GAIAGEO_DECLARE void gaiaSetIntValue (gaiaDbfFieldPtr field,
1086  sqlite3_int64 value);
1087 
1097  GAIAGEO_DECLARE void gaiaSetDoubleValue (gaiaDbfFieldPtr field,
1098  double value);
1099 
1109  GAIAGEO_DECLARE void gaiaSetStrValue (gaiaDbfFieldPtr field, char *str);
1110 
1123  GAIAGEO_DECLARE gaiaDbfListPtr gaiaAllocDbfList (void);
1124 
1137  GAIAGEO_DECLARE void gaiaFreeDbfList (gaiaDbfListPtr list);
1138 
1149  GAIAGEO_DECLARE int gaiaIsValidDbfList (gaiaDbfListPtr list);
1150 
1171  GAIAGEO_DECLARE gaiaDbfFieldPtr gaiaAddDbfField (gaiaDbfListPtr list,
1172  char *name,
1173  unsigned char type,
1174  int offset,
1175  unsigned char length,
1176  unsigned char decimals);
1177 
1188  GAIAGEO_DECLARE void gaiaResetDbfEntity (gaiaDbfListPtr list);
1189 
1202  GAIAGEO_DECLARE gaiaDbfListPtr gaiaCloneDbfEntity (gaiaDbfListPtr org);
1203 
1216  GAIAGEO_DECLARE gaiaShapefilePtr gaiaAllocShapefile (void);
1217 
1230  GAIAGEO_DECLARE void gaiaFreeShapefile (gaiaShapefilePtr shp);
1231 
1247  GAIAGEO_DECLARE void gaiaOpenShpRead (gaiaShapefilePtr shp,
1248  const char *path,
1249  const char *charFrom,
1250  const char *charTo);
1251 
1273  GAIAGEO_DECLARE void gaiaOpenShpWrite (gaiaShapefilePtr shp,
1274  const char *path, int shape,
1275  gaiaDbfListPtr list,
1276  const char *charFrom,
1277  const char *charTo);
1278 
1299  GAIAGEO_DECLARE int gaiaReadShpEntity (gaiaShapefilePtr shp,
1300  int current_row, int srid);
1301 
1315  GAIAGEO_DECLARE void gaiaShpAnalyze (gaiaShapefilePtr shp);
1316 
1331  GAIAGEO_DECLARE int gaiaWriteShpEntity (gaiaShapefilePtr shp,
1332  gaiaDbfListPtr entity);
1333 
1346  GAIAGEO_DECLARE void gaiaFlushShpHeaders (gaiaShapefilePtr shp);
1347 
1360  GAIAGEO_DECLARE gaiaDbfPtr gaiaAllocDbf (void);
1361 
1374  GAIAGEO_DECLARE void gaiaFreeDbf (gaiaDbfPtr dbf);
1375 
1390  GAIAGEO_DECLARE void gaiaOpenDbfRead (gaiaDbfPtr dbf,
1391  const char *path,
1392  const char *charFrom,
1393  const char *charTo);
1394 
1409  GAIAGEO_DECLARE void gaiaOpenDbfWrite (gaiaDbfPtr dbf,
1410  const char *path,
1411  const char *charFrom,
1412  const char *charTo);
1413 
1434  GAIAGEO_DECLARE int gaiaReadDbfEntity (gaiaDbfPtr dbf, int current_row,
1435  int *deleted);
1436 
1451  GAIAGEO_DECLARE int gaiaWriteDbfEntity (gaiaDbfPtr dbf,
1452  gaiaDbfListPtr entity);
1453 
1466  GAIAGEO_DECLARE void gaiaFlushDbfHeader (gaiaDbfPtr dbf);
1467 
1468 
1469 
1470 #ifndef OMIT_ICONV /* ICONV enabled: supporting text reader */
1471 
1493  GAIAGEO_DECLARE gaiaTextReaderPtr gaiaTextReaderAlloc (const char *path,
1494  char field_separator,
1495  char text_separator,
1496  char
1497  decimal_separator,
1498  int
1499  first_line_titles,
1500  const char
1501  *encoding);
1502 
1511  GAIAGEO_DECLARE void gaiaTextReaderDestroy (gaiaTextReaderPtr reader);
1512 
1528  GAIAGEO_DECLARE int gaiaTextReaderParse (gaiaTextReaderPtr reader);
1529 
1545  GAIAGEO_DECLARE int gaiaTextReaderGetRow (gaiaTextReaderPtr reader,
1546  int row_num);
1547 
1561  GAIAGEO_DECLARE int gaiaTextReaderFetchField (gaiaTextReaderPtr reader,
1562  int field_num, int *type,
1563  const char **value);
1564 
1565 #endif /* end ICONV (text reader) */
1566 
1567 #ifdef __cplusplus
1568 }
1569 #endif
1570 
1571 #endif /* _GG_FORMATS_H */