SpatiaLite 4.3.0a

src/headers/spatialite.h

Go to the documentation of this file.
00001 /* 
00002  spatialite.h -- Gaia spatial support for SQLite 
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 
00031 Alternatively, the contents of this file may be used under the terms of
00032 either the GNU General Public License Version 2 or later (the "GPL"), or
00033 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00034 in which case the provisions of the GPL or the LGPL are applicable instead
00035 of those above. If you wish to allow use of your version of this file only
00036 under the terms of either the GPL or the LGPL, and not to allow others to
00037 use your version of this file under the terms of the MPL, indicate your
00038 decision by deleting the provisions above and replace them with the notice
00039 and other provisions required by the GPL or the LGPL. If you do not delete
00040 the provisions above, a recipient may use your version of this file under
00041 the terms of any one of the MPL, the GPL or the LGPL.
00042  
00043 */
00044 
00050 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00051 #ifdef _WIN32
00052 #ifdef DLL_EXPORT
00053 #define SPATIALITE_DECLARE __declspec(dllexport)
00054 #else
00055 #define SPATIALITE_DECLARE extern
00056 #endif
00057 #else
00058 #define SPATIALITE_DECLARE __attribute__ ((visibility("default")))
00059 #endif
00060 #endif
00061 
00062 #ifndef _SPATIALITE_H
00063 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00064 #define _SPATIALITE_H
00065 #endif
00066 
00067 #define SPLITE_AXIS_1           0x51
00068 #define SPLITE_AXIS_2           0x52
00069 #define SPLITE_AXIS_NAME        0x3e
00070 #define SPLITE_AXIS_ORIENTATION 0x3f
00071 
00072 #ifdef __cplusplus
00073 extern "C"
00074 {
00075 #endif
00076 
00077 #include <spatialite/gaiageo.h>
00078 
00079 #ifdef LOADABLE_EXTENSION
00080     SPATIALITE_DECLARE int
00081         sqlite3_spatialite_init (sqlite3 * db, char **pzErrMsg,
00082                                  const sqlite3_api_routines * pApi);
00083 #endif
00084 
00091     SPATIALITE_DECLARE void spatialite_initialize (void);
00092 
00101     SPATIALITE_DECLARE void spatialite_shutdown (void);
00102 
00108     SPATIALITE_DECLARE const char *spatialite_version (void);
00109 
00115     SPATIALITE_DECLARE const char *spatialite_target_cpu (void);
00116 
00123     SPATIALITE_DECLARE void *spatialite_alloc_connection (void);
00124 
00139     SPATIALITE_DECLARE void spatialite_init (int verbose);
00140 
00154     SPATIALITE_DECLARE void spatialite_init_ex (sqlite3 * db_handle,
00155                                                 const void *ptr, int verbose);
00156 
00163     SPATIALITE_DECLARE void spatialite_init_geos (void);
00164 
00175     SPATIALITE_DECLARE void spatialite_cleanup (void);
00176 
00188     SPATIALITE_DECLARE void spatialite_cleanup_ex (const void *ptr);
00189 
00205     SPATIALITE_DECLARE int dump_shapefile (sqlite3 * sqlite, char *table,
00206                                            char *column, char *shp_path,
00207                                            char *charset, char *geom_type,
00208                                            int verbose, int *rows,
00209                                            char *err_msg);
00210 
00234     SPATIALITE_DECLARE int load_shapefile (sqlite3 * sqlite, char *shp_path,
00235                                            char *table, char *charset, int srid,
00236                                            char *column, int coerce2d,
00237                                            int compressed, int verbose,
00238                                            int spatial_index, int *rows,
00239                                            char *err_msg);
00240 
00277     SPATIALITE_DECLARE int load_shapefile_ex (sqlite3 * sqlite, char *shp_path,
00278                                               char *table, char *charset,
00279                                               int srid, char *geo_column,
00280                                               char *gtype, char *pk_column,
00281                                               int coerce2d, int compressed,
00282                                               int verbose, int spatial_index,
00283                                               int *rows, char *err_msg);
00284 
00322     SPATIALITE_DECLARE int load_shapefile_ex2 (sqlite3 * sqlite, char *shp_path,
00323                                                char *table, char *charset,
00324                                                int srid, char *geo_column,
00325                                                char *gtype, char *pk_column,
00326                                                int coerce2d, int compressed,
00327                                                int verbose, int spatial_index,
00328                                                int text_date, int *rows,
00329                                                char *err_msg);
00330 
00349     SPATIALITE_DECLARE int load_dbf (sqlite3 * sqlite, char *dbf_path,
00350                                      char *table, char *charset, int verbose,
00351                                      int *rows, char *err_msg);
00352 
00370     SPATIALITE_DECLARE int load_dbf_ex (sqlite3 * sqlite, char *dbf_path,
00371                                         char *table, char *pk_column,
00372                                         char *charset, int verbose, int *rows,
00373                                         char *err_msg);
00374 
00393     SPATIALITE_DECLARE int load_dbf_ex2 (sqlite3 * sqlite, char *dbf_path,
00394                                          char *table, char *pk_column,
00395                                          char *charset, int verbose,
00396                                          int text_date, int *rows,
00397                                          char *err_msg);
00398 
00412     SPATIALITE_DECLARE int dump_dbf (sqlite3 * sqlite, char *table,
00413                                      char *dbf_path, char *charset,
00414                                      char *err_msg);
00415 
00430     SPATIALITE_DECLARE int dump_dbf_ex (sqlite3 * sqlite, char *table,
00431                                         char *dbf_path, char *charset,
00432                                         int *rows, char *err_msg);
00433 
00447     SPATIALITE_DECLARE int load_XL (sqlite3 * sqlite, const char *path,
00448                                     const char *table,
00449                                     unsigned int worksheetIndex,
00450                                     int first_titles, unsigned int *rows,
00451                                     char *err_msg);
00452 
00460     SPATIALITE_DECLARE double math_round (double value);
00461 
00469     SPATIALITE_DECLARE sqlite3_int64 math_llabs (sqlite3_int64 value);
00470 
00486     SPATIALITE_DECLARE int spatial_ref_sys_init (sqlite3 * sqlite, int verbose);
00487 
00500     SPATIALITE_DECLARE int spatial_ref_sys_init2 (sqlite3 * sqlite, int mode,
00501                                                   int verbose);
00502 
00511     SPATIALITE_DECLARE int insert_epsg_srid (sqlite3 * sqlite, int srid);
00512 
00523     SPATIALITE_DECLARE int srid_is_geographic (sqlite3 * sqlite, int srid,
00524                                                int *geographic);
00525 
00536     SPATIALITE_DECLARE int srid_is_projected (sqlite3 * sqlite, int srid,
00537                                               int *projected);
00538 
00550     SPATIALITE_DECLARE int srid_has_flipped_axes (sqlite3 * sqlite, int srid,
00551                                                   int *flipped);
00552 
00564     SPATIALITE_DECLARE char *srid_get_spheroid (sqlite3 * sqlite, int srid);
00565 
00577     SPATIALITE_DECLARE char *srid_get_prime_meridian (sqlite3 * sqlite,
00578                                                       int srid);
00579 
00591     SPATIALITE_DECLARE char *srid_get_projection (sqlite3 * sqlite, int srid);
00592 
00604     SPATIALITE_DECLARE char *srid_get_datum (sqlite3 * sqlite, int srid);
00605 
00617     SPATIALITE_DECLARE char *srid_get_unit (sqlite3 * sqlite, int srid);
00618 
00632     SPATIALITE_DECLARE char *srid_get_axis (sqlite3 * sqlite, int srid,
00633                                             char axis, char mode);
00634 
00646     SPATIALITE_DECLARE int
00647         is_kml_constant (sqlite3 * sqlite, char *table, char *column);
00648 
00664     SPATIALITE_DECLARE int dump_kml (sqlite3 * sqlite, char *table,
00665                                      char *geom_col, char *kml_path,
00666                                      char *name_col, char *desc_col,
00667                                      int precision);
00668 
00685     SPATIALITE_DECLARE int dump_kml_ex (sqlite3 * sqlite, char *table,
00686                                         char *geom_col, char *kml_path,
00687                                         char *name_col, char *desc_col,
00688                                         int precision, int *rows);
00689 
00702     SPATIALITE_DECLARE void check_duplicated_rows (sqlite3 * sqlite,
00703                                                    char *table,
00704                                                    int *dupl_count);
00705 
00717     SPATIALITE_DECLARE void remove_duplicated_rows (sqlite3 * sqlite,
00718                                                     char *table);
00719 
00733     SPATIALITE_DECLARE void remove_duplicated_rows_ex (sqlite3 * sqlite,
00734                                                        char *table,
00735                                                        int *removed);
00736 
00752     SPATIALITE_DECLARE void remove_duplicated_rows_ex2 (sqlite3 * sqlite,
00753                                                         char *table,
00754                                                         int *removed,
00755                                                         int transaction);
00756 
00776     SPATIALITE_DECLARE void elementary_geometries (sqlite3 * sqlite,
00777                                                    char *inTable,
00778                                                    char *geometry,
00779                                                    char *outTable, char *pKey,
00780                                                    char *multiId);
00781 
00802     SPATIALITE_DECLARE void elementary_geometries_ex (sqlite3 * sqlite,
00803                                                       char *inTable,
00804                                                       char *geometry,
00805                                                       char *outTable,
00806                                                       char *pKey, char *multiId,
00807                                                       int *rows);
00808 
00831     SPATIALITE_DECLARE void elementary_geometries_ex2 (sqlite3 * sqlite,
00832                                                        char *inTable,
00833                                                        char *geometry,
00834                                                        char *outTable,
00835                                                        char *pKey,
00836                                                        char *multiId, int *rows,
00837                                                        int transaction);
00838 
00861     SPATIALITE_DECLARE int dump_geojson (sqlite3 * sqlite, char *table,
00862                                          char *geom_col, char *outfile_path,
00863                                          int precision, int option);
00864 
00888     SPATIALITE_DECLARE int dump_geojson_ex (sqlite3 * sqlite, char *table,
00889                                             char *geom_col, char *outfile_path,
00890                                             int precision, int option,
00891                                             int *rows);
00892 
00916     SPATIALITE_DECLARE int update_layer_statistics (sqlite3 * sqlite,
00917                                                     const char *table,
00918                                                     const char *column);
00919 
00935     SPATIALITE_DECLARE int gaiaStatisticsInvalidate (sqlite3 * handle,
00936                                                      const char *table,
00937                                                      const char *geometry);
00938 
00963     SPATIALITE_DECLARE gaiaGeomCollPtr gaiaGetLayerExtent (sqlite3 * handle,
00964                                                            const char *table,
00965                                                            const char *geometry,
00966                                                            int mode);
00967 
00991     SPATIALITE_DECLARE gaiaVectorLayersListPtr gaiaGetVectorLayersList (sqlite3
00992                                                                         *
00993                                                                         handle,
00994                                                                         const
00995                                                                         char
00996                                                                         *table,
00997                                                                         const
00998                                                                         char
00999                                                                         *geometry,
01000                                                                         int
01001                                                                         mode);
01002 
01013     SPATIALITE_DECLARE int gaiaCreateMetaCatalogTables (sqlite3 * handle);
01014 
01026     SPATIALITE_DECLARE int gaiaUpdateMetaCatalogStatistics (sqlite3 * handle,
01027                                                             const char *table,
01028                                                             const char *column);
01029 
01042     SPATIALITE_DECLARE int gaiaUpdateMetaCatalogStatisticsFromMaster (sqlite3 *
01043                                                                       handle,
01044                                                                       const char
01045                                                                       *master_table,
01046                                                                       const char
01047                                                                       *table_name,
01048                                                                       const char
01049                                                                       *column_name);
01050 
01058     SPATIALITE_DECLARE void gaiaFreeVectorLayersList (gaiaVectorLayersListPtr
01059                                                       ptr);
01060 
01079     SPATIALITE_DECLARE int gaiaDropTable (sqlite3 * sqlite, const char *table);
01080 
01098     SPATIALITE_DECLARE int gaiaDropTableEx (sqlite3 * sqlite,
01099                                             const char *prefix,
01100                                             const char *table);
01101 
01121     SPATIALITE_DECLARE int gaiaDropTableEx2 (sqlite3 * sqlite,
01122                                              const char *prefix,
01123                                              const char *table,
01124                                              int transaction);
01125 
01151     SPATIALITE_DECLARE int check_geometry_column (sqlite3 * sqlite,
01152                                                   const char *table,
01153                                                   const char *geom,
01154                                                   const char *report_path,
01155                                                   int *n_rows, int *n_invalids,
01156                                                   char **err_msg);
01157 
01184     SPATIALITE_DECLARE int check_geometry_column_r (const void *p_cache,
01185                                                     sqlite3 * sqlite,
01186                                                     const char *table,
01187                                                     const char *geom,
01188                                                     const char *report_path,
01189                                                     int *n_rows,
01190                                                     int *n_invalids,
01191                                                     char **err_msg);
01192 
01214     SPATIALITE_DECLARE int check_all_geometry_columns (sqlite3 * sqlite,
01215                                                        const char *output_dir,
01216                                                        int *n_invalids,
01217                                                        char **err_msg);
01218 
01241     SPATIALITE_DECLARE int check_all_geometry_columns_r (const void *p_cache,
01242                                                          sqlite3 * sqlite,
01243                                                          const char *output_dir,
01244                                                          int *n_invalids,
01245                                                          char **err_msg);
01246 
01280     SPATIALITE_DECLARE int sanitize_geometry_column (sqlite3 * sqlite,
01281                                                      const char *table,
01282                                                      const char *geom,
01283                                                      const char *tmp_table,
01284                                                      const char *report_path,
01285                                                      int *n_invalids,
01286                                                      int *n_repaired,
01287                                                      int *n_discarded,
01288                                                      int *n_failures,
01289                                                      char **err_msg);
01290 
01325     SPATIALITE_DECLARE int sanitize_geometry_column_r (const void *p_cache,
01326                                                        sqlite3 * sqlite,
01327                                                        const char *table,
01328                                                        const char *geom,
01329                                                        const char *tmp_table,
01330                                                        const char *report_path,
01331                                                        int *n_invalids,
01332                                                        int *n_repaired,
01333                                                        int *n_discarded,
01334                                                        int *n_failures,
01335                                                        char **err_msg);
01336 
01363     SPATIALITE_DECLARE int sanitize_all_geometry_columns (sqlite3 * sqlite,
01364                                                           const char
01365                                                           *tmp_prefix,
01366                                                           const char
01367                                                           *output_dir,
01368                                                           int *not_repaired,
01369                                                           char **err_msg);
01370 
01398     SPATIALITE_DECLARE int sanitize_all_geometry_columns_r (const void *p_cache,
01399                                                             sqlite3 * sqlite,
01400                                                             const char
01401                                                             *tmp_prefix,
01402                                                             const char
01403                                                             *output_dir,
01404                                                             int *not_repaired,
01405                                                             char **err_msg);
01406 
01407     SPATIALITE_DECLARE int gaiaGPKG2Spatialite (sqlite3 * handle_in,
01408                                                 const char *gpkg_in_path,
01409                                                 sqlite3 * handle_out,
01410                                                 const char *splite_out_path);
01411     SPATIALITE_DECLARE int gaiaSpatialite2GPKG (sqlite3 * handle_in,
01412                                                 const char *splite_in_path,
01413                                                 sqlite3 * handle_out,
01414                                                 const char *gpkg_out_path);
01415 
01416 #ifdef __cplusplus
01417 }
01418 #endif
01419 
01420 #endif                          /* _SPATIALITE_H */
 All Data Structures Files Functions Variables Typedefs Defines