SpatiaLite  4.2.0
 All Data Structures Files Functions Variables Typedefs Macros Pages
spatialite.h
Go to the documentation of this file.
1 /*
2  spatialite.h -- Gaia spatial support for SQLite
3 
4  version 4.2, 2014 July 25
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 
31 Alternatively, the contents of this file may be used under the terms of
32 either the GNU General Public License Version 2 or later (the "GPL"), or
33 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
34 in which case the provisions of the GPL or the LGPL are applicable instead
35 of those above. If you wish to allow use of your version of this file only
36 under the terms of either the GPL or the LGPL, and not to allow others to
37 use your version of this file under the terms of the MPL, indicate your
38 decision by deleting the provisions above and replace them with the notice
39 and other provisions required by the GPL or the LGPL. If you do not delete
40 the provisions above, a recipient may use your version of this file under
41 the terms of any one of the MPL, the GPL or the LGPL.
42 
43 */
44 
50 #ifndef DOXYGEN_SHOULD_SKIP_THIS
51 #ifdef _WIN32
52 #ifdef DLL_EXPORT
53 #define SPATIALITE_DECLARE __declspec(dllexport)
54 #else
55 #define SPATIALITE_DECLARE extern
56 #endif
57 #else
58 #define SPATIALITE_DECLARE __attribute__ ((visibility("default")))
59 #endif
60 #endif
61 
62 #ifndef _SPATIALITE_H
63 #ifndef DOXYGEN_SHOULD_SKIP_THIS
64 #define _SPATIALITE_H
65 #endif
66 
67 
68 #ifdef __cplusplus
69 extern "C"
70 {
71 #endif
72 
73 #include <spatialite/gaiageo.h>
74 
75 #ifdef LOADABLE_EXTENSION
76  SPATIALITE_DECLARE int
77  sqlite3_spatialite_init (sqlite3 * db, char **pzErrMsg,
78  const sqlite3_api_routines * pApi);
79 #endif
80 
87  SPATIALITE_DECLARE void spatialite_initialize (void);
88 
97  SPATIALITE_DECLARE void spatialite_shutdown (void);
98 
104  SPATIALITE_DECLARE const char *spatialite_version (void);
105 
111  SPATIALITE_DECLARE const char *spatialite_target_cpu (void);
112 
119  SPATIALITE_DECLARE void *spatialite_alloc_connection (void);
120 
135  SPATIALITE_DECLARE void spatialite_init (int verbose);
136 
150  SPATIALITE_DECLARE void spatialite_init_ex (sqlite3 * db_handle,
151  const void *ptr, int verbose);
152 
159  SPATIALITE_DECLARE void spatialite_init_geos (void);
160 
171  SPATIALITE_DECLARE void spatialite_cleanup (void);
172 
184  SPATIALITE_DECLARE void spatialite_cleanup_ex (const void *ptr);
185 
201  SPATIALITE_DECLARE int dump_shapefile (sqlite3 * sqlite, char *table,
202  char *column, char *shp_path,
203  char *charset, char *geom_type,
204  int verbose, int *rows,
205  char *err_msg);
206 
230  SPATIALITE_DECLARE int load_shapefile (sqlite3 * sqlite, char *shp_path,
231  char *table, char *charset, int srid,
232  char *column, int coerce2d,
233  int compressed, int verbose,
234  int spatial_index, int *rows,
235  char *err_msg);
236 
273  SPATIALITE_DECLARE int load_shapefile_ex (sqlite3 * sqlite, char *shp_path,
274  char *table, char *charset,
275  int srid, char *geo_column,
276  char *gtype, char *pk_column,
277  int coerce2d, int compressed,
278  int verbose, int spatial_index,
279  int *rows, char *err_msg);
280 
299  SPATIALITE_DECLARE int load_dbf (sqlite3 * sqlite, char *dbf_path,
300  char *table, char *charset, int verbose,
301  int *rows, char *err_msg);
302 
320  SPATIALITE_DECLARE int load_dbf_ex (sqlite3 * sqlite, char *dbf_path,
321  char *table, char *pk_column,
322  char *charset, int verbose, int *rows,
323  char *err_msg);
324 
325 
337  SPATIALITE_DECLARE int dump_dbf (sqlite3 * sqlite, char *table,
338  char *dbf_path, char *charset,
339  char *err_msg);
340 
354  SPATIALITE_DECLARE int load_XL (sqlite3 * sqlite, const char *path,
355  const char *table,
356  unsigned int worksheetIndex,
357  int first_titles, unsigned int *rows,
358  char *err_msg);
359 
367  SPATIALITE_DECLARE double math_round (double value);
368 
376  SPATIALITE_DECLARE sqlite3_int64 math_llabs (sqlite3_int64 value);
377 
393  SPATIALITE_DECLARE int spatial_ref_sys_init (sqlite3 * sqlite, int verbose);
394 
407  SPATIALITE_DECLARE int spatial_ref_sys_init2 (sqlite3 * sqlite, int mode,
408  int verbose);
409 
418  SPATIALITE_DECLARE int insert_epsg_srid (sqlite3 * sqlite, int srid);
419 
431  SPATIALITE_DECLARE int
432  is_kml_constant (sqlite3 * sqlite, char *table, char *column);
433 
447  SPATIALITE_DECLARE int dump_kml (sqlite3 * sqlite, char *table,
448  char *geom_col, char *kml_path,
449  char *name_col, char *desc_col,
450  int precision);
451 
464  SPATIALITE_DECLARE void check_duplicated_rows (sqlite3 * sqlite,
465  char *table,
466  int *dupl_count);
467 
479  SPATIALITE_DECLARE void remove_duplicated_rows (sqlite3 * sqlite,
480  char *table);
481 
495  SPATIALITE_DECLARE void remove_duplicated_rows_ex (sqlite3 * sqlite,
496  char *table,
497  int *removed);
498 
516  SPATIALITE_DECLARE void elementary_geometries (sqlite3 * sqlite,
517  char *inTable,
518  char *geometry,
519  char *outTable, char *pKey,
520  char *multiId);
521 
542  SPATIALITE_DECLARE int dump_geojson (sqlite3 * sqlite, char *table,
543  char *geom_col, char *outfile_path,
544  int precision, int option);
545 
569  SPATIALITE_DECLARE int update_layer_statistics (sqlite3 * sqlite,
570  const char *table,
571  const char *column);
572 
588  SPATIALITE_DECLARE int gaiaStatisticsInvalidate (sqlite3 * handle,
589  const char *table,
590  const char *geometry);
591 
616  SPATIALITE_DECLARE gaiaGeomCollPtr gaiaGetLayerExtent (sqlite3 * handle,
617  const char *table,
618  const char *geometry,
619  int mode);
620 
644  SPATIALITE_DECLARE gaiaVectorLayersListPtr gaiaGetVectorLayersList (sqlite3
645  *
646  handle,
647  const
648  char
649  *table,
650  const
651  char
652  *geometry,
653  int
654  mode);
655 
666  SPATIALITE_DECLARE int gaiaCreateMetaCatalogTables (sqlite3 * handle);
667 
679  SPATIALITE_DECLARE int gaiaUpdateMetaCatalogStatistics (sqlite3 * handle,
680  const char *table,
681  const char *column);
682 
695  SPATIALITE_DECLARE int gaiaUpdateMetaCatalogStatisticsFromMaster (sqlite3 *
696  handle,
697  const char
698  *master_table,
699  const char
700  *table_name,
701  const char
702  *column_name);
703 
711  SPATIALITE_DECLARE void gaiaFreeVectorLayersList (gaiaVectorLayersListPtr
712  ptr);
713 
732  SPATIALITE_DECLARE int gaiaDropTable (sqlite3 * sqlite, const char *table);
733 
751  SPATIALITE_DECLARE int gaiaDropTableEx (sqlite3 * sqlite,
752  const char *prefix,
753  const char *table);
754 
780  SPATIALITE_DECLARE int check_geometry_column (sqlite3 * sqlite,
781  const char *table,
782  const char *geom,
783  const char *report_path,
784  int *n_rows, int *n_invalids,
785  char **err_msg);
786 
813  SPATIALITE_DECLARE int check_geometry_column_r (const void *p_cache,
814  sqlite3 * sqlite,
815  const char *table,
816  const char *geom,
817  const char *report_path,
818  int *n_rows,
819  int *n_invalids,
820  char **err_msg);
821 
843  SPATIALITE_DECLARE int check_all_geometry_columns (sqlite3 * sqlite,
844  const char *output_dir,
845  int *n_invalids,
846  char **err_msg);
847 
870  SPATIALITE_DECLARE int check_all_geometry_columns_r (const void *p_cache,
871  sqlite3 * sqlite,
872  const char *output_dir,
873  int *n_invalids,
874  char **err_msg);
875 
909  SPATIALITE_DECLARE int sanitize_geometry_column (sqlite3 * sqlite,
910  const char *table,
911  const char *geom,
912  const char *tmp_table,
913  const char *report_path,
914  int *n_invalids,
915  int *n_repaired,
916  int *n_discarded,
917  int *n_failures,
918  char **err_msg);
919 
954  SPATIALITE_DECLARE int sanitize_geometry_column_r (const void *p_cache,
955  sqlite3 * sqlite,
956  const char *table,
957  const char *geom,
958  const char *tmp_table,
959  const char *report_path,
960  int *n_invalids,
961  int *n_repaired,
962  int *n_discarded,
963  int *n_failures,
964  char **err_msg);
965 
992  SPATIALITE_DECLARE int sanitize_all_geometry_columns (sqlite3 * sqlite,
993  const char
994  *tmp_prefix,
995  const char
996  *output_dir,
997  int *not_repaired,
998  char **err_msg);
999 
1027  SPATIALITE_DECLARE int sanitize_all_geometry_columns_r (const void *p_cache,
1028  sqlite3 * sqlite,
1029  const char
1030  *tmp_prefix,
1031  const char
1032  *output_dir,
1033  int *not_repaired,
1034  char **err_msg);
1035 
1036  SPATIALITE_DECLARE int gaiaGPKG2Spatialite (sqlite3 * handle_in,
1037  const char *gpkg_in_path,
1038  sqlite3 * handle_out,
1039  const char *splite_out_path);
1040  SPATIALITE_DECLARE int gaiaSpatialite2GPKG (sqlite3 * handle_in,
1041  const char *splite_in_path,
1042  sqlite3 * handle_out,
1043  const char *gpkg_out_path);
1044 
1045 #ifdef __cplusplus
1046 }
1047 #endif
1048 
1049 #endif /* _SPATIALITE_H */
Geometry handling functions and constants.
SPATIALITE_DECLARE int insert_epsg_srid(sqlite3 *sqlite, int srid)
Inserts some inlined EPSG definition into the "spatial_ref_sys" table.
SPATIALITE_DECLARE int sanitize_geometry_column_r(const void *p_cache, sqlite3 *sqlite, const char *table, const char *geom, const char *tmp_table, const char *report_path, int *n_invalids, int *n_repaired, int *n_discarded, int *n_failures, char **err_msg)
Sanitizes a Geometry Column making all invalid geometries to be valid.
SPATIALITE_DECLARE void spatialite_cleanup_ex(const void *ptr)
Cleanup a SpatiaLite connection.
SPATIALITE_DECLARE void spatialite_init_ex(sqlite3 *db_handle, const void *ptr, int verbose)
Initializes a SpatiaLite connection.
SPATIALITE_DECLARE int sanitize_geometry_column(sqlite3 *sqlite, const char *table, const char *geom, const char *tmp_table, const char *report_path, int *n_invalids, int *n_repaired, int *n_discarded, int *n_failures, char **err_msg)
Sanitizes a Geometry Column making all invalid geometries to be valid.
SPATIALITE_DECLARE int spatial_ref_sys_init(sqlite3 *sqlite, int verbose)
Inserts the inlined EPSG dataset into the "spatial_ref_sys" table.
SPATIALITE_DECLARE void spatialite_shutdown(void)
Finalizes the library.
SPATIALITE_DECLARE void remove_duplicated_rows(sqlite3 *sqlite, char *table)
Remove duplicated rows from a table.
SPATIALITE_DECLARE void check_duplicated_rows(sqlite3 *sqlite, char *table, int *dupl_count)
Checks for duplicated rows into the same table.
SPATIALITE_DECLARE int spatial_ref_sys_init2(sqlite3 *sqlite, int mode, int verbose)
Inserts the inlined EPSG dataset into the "spatial_ref_sys" table.
SPATIALITE_DECLARE int load_shapefile(sqlite3 *sqlite, char *shp_path, char *table, char *charset, int srid, char *column, int coerce2d, int compressed, int verbose, int spatial_index, int *rows, char *err_msg)
Loads an external Shapefile into a newly created table.
SPATIALITE_DECLARE int is_kml_constant(sqlite3 *sqlite, char *table, char *column)
Checks if a column is actually defined into the given table.
SPATIALITE_DECLARE int gaiaDropTable(sqlite3 *sqlite, const char *table)
Drops a layer-table, removing any related dependency.
SPATIALITE_DECLARE int load_dbf(sqlite3 *sqlite, char *dbf_path, char *table, char *charset, int verbose, int *rows, char *err_msg)
Loads an external DBF file into a newly created table.
SPATIALITE_DECLARE int load_XL(sqlite3 *sqlite, const char *path, const char *table, unsigned int worksheetIndex, int first_titles, unsigned int *rows, char *err_msg)
Loads an external spreadsheet (.xls) file into a newly created table.
SPATIALITE_DECLARE int gaiaUpdateMetaCatalogStatisticsFromMaster(sqlite3 *handle, const char *master_table, const char *table_name, const char *column_name)
Updates the "splite_metacatalog_statistics" table (using a Master Table).
SPATIALITE_DECLARE int load_dbf_ex(sqlite3 *sqlite, char *dbf_path, char *table, char *pk_column, char *charset, int verbose, int *rows, char *err_msg)
Loads an external DBF file into a newly created table.
SPATIALITE_DECLARE void * spatialite_alloc_connection(void)
Initializes the internal memory block supporting each connection.
SPATIALITE_DECLARE void spatialite_cleanup(void)
Cleanup a SpatiaLite connection.
SPATIALITE_DECLARE int dump_shapefile(sqlite3 *sqlite, char *table, char *column, char *shp_path, char *charset, char *geom_type, int verbose, int *rows, char *err_msg)
Dumps a full geometry-table into an external Shapefile.
SPATIALITE_DECLARE int check_geometry_column(sqlite3 *sqlite, const char *table, const char *geom, const char *report_path, int *n_rows, int *n_invalids, char **err_msg)
Checks a Geometry Column for validity.
SPATIALITE_DECLARE const char * spatialite_target_cpu(void)
Return the target CPU name.
SPATIALITE_DECLARE sqlite3_int64 math_llabs(sqlite3_int64 value)
A portable replacement for C99 llabs()
SPATIALITE_DECLARE int sanitize_all_geometry_columns_r(const void *p_cache, sqlite3 *sqlite, const char *tmp_prefix, const char *output_dir, int *not_repaired, char **err_msg)
Sanitizes all Geometry Columns making all invalid geometries to be valid.
SPATIALITE_DECLARE void remove_duplicated_rows_ex(sqlite3 *sqlite, char *table, int *removed)
Remove duplicated rows from a table.
SPATIALITE_DECLARE int check_geometry_column_r(const void *p_cache, sqlite3 *sqlite, const char *table, const char *geom, const char *report_path, int *n_rows, int *n_invalids, char **err_msg)
Checks a Geometry Column for validity.
SPATIALITE_DECLARE int dump_kml(sqlite3 *sqlite, char *table, char *geom_col, char *kml_path, char *name_col, char *desc_col, int precision)
Dumps a full geometry-table into an external KML file.
SPATIALITE_DECLARE void elementary_geometries(sqlite3 *sqlite, char *inTable, char *geometry, char *outTable, char *pKey, char *multiId)
Creates a derived table surely containing elementary Geometries.
SPATIALITE_DECLARE void gaiaFreeVectorLayersList(gaiaVectorLayersListPtr ptr)
Destroys a VectorLayersList object.
SPATIALITE_DECLARE int check_all_geometry_columns(sqlite3 *sqlite, const char *output_dir, int *n_invalids, char **err_msg)
Checks all Geometry Columns for validity.
SPATIALITE_DECLARE int sanitize_all_geometry_columns(sqlite3 *sqlite, const char *tmp_prefix, const char *output_dir, int *not_repaired, char **err_msg)
Sanitizes all Geometry Columns making all invalid geometries to be valid.
SPATIALITE_DECLARE gaiaGeomCollPtr gaiaGetLayerExtent(sqlite3 *handle, const char *table, const char *geometry, int mode)
Queries the Metadata tables returning the Layer Full Extent.
SPATIALITE_DECLARE int check_all_geometry_columns_r(const void *p_cache, sqlite3 *sqlite, const char *output_dir, int *n_invalids, char **err_msg)
Checks all Geometry Columns for validity.
Container for Vector Layers List.
Definition: gg_structs.h:799
SPATIALITE_DECLARE int gaiaDropTableEx(sqlite3 *sqlite, const char *prefix, const char *table)
Drops a layer-table, removing any related dependency.
SPATIALITE_DECLARE void spatialite_init(int verbose)
Initializes a SpatiaLite connection.
SPATIALITE_DECLARE int gaiaStatisticsInvalidate(sqlite3 *handle, const char *table, const char *geometry)
Immediately and unconditionally invalidates the already existing Statistics.
SPATIALITE_DECLARE int gaiaUpdateMetaCatalogStatistics(sqlite3 *handle, const char *table, const char *column)
Updates the "splite_metacatalog_statistics" table.
SPATIALITE_DECLARE int load_shapefile_ex(sqlite3 *sqlite, char *shp_path, char *table, char *charset, int srid, char *geo_column, char *gtype, char *pk_column, int coerce2d, int compressed, int verbose, int spatial_index, int *rows, char *err_msg)
Loads an external Shapefile into a newly created table.
SPATIALITE_DECLARE const char * spatialite_version(void)
Return the current library version.
SPATIALITE_DECLARE int update_layer_statistics(sqlite3 *sqlite, const char *table, const char *column)
Updates the LAYER_STATICS metadata table.
SPATIALITE_DECLARE double math_round(double value)
A portable replacement for C99 round()
Container for OGC GEOMETRYCOLLECTION Geometry.
Definition: gg_structs.h:216
SPATIALITE_DECLARE gaiaVectorLayersListPtr gaiaGetVectorLayersList(sqlite3 *handle, const char *table, const char *geometry, int mode)
Queries the Metadata tables supporting Vector Layers.
SPATIALITE_DECLARE void spatialite_initialize(void)
Initializes the library.
SPATIALITE_DECLARE int dump_dbf(sqlite3 *sqlite, char *table, char *dbf_path, char *charset, char *err_msg)
Dumps a full table into an external DBF file.
SPATIALITE_DECLARE int gaiaCreateMetaCatalogTables(sqlite3 *handle)
Creates (or re-creates) the "splite_metacatalog" and "splite_metacalog_statistics" tables...
SPATIALITE_DECLARE int dump_geojson(sqlite3 *sqlite, char *table, char *geom_col, char *outfile_path, int precision, int option)
Dumps a full geometry-table into an external GeoJSON file.
SPATIALITE_DECLARE void spatialite_init_geos(void)
Initializes the GEOS library.