SpatiaLite  5.0.0
Macros | Functions
spatialite.h File Reference

Main SpatiaLite header file. More...

#include <spatialite/gaiageo.h>
Include dependency graph for spatialite.h:

Go to the source code of this file.

Macros

#define SPLITE_AXIS_1   0x51
 
#define SPLITE_AXIS_2   0x52
 
#define SPLITE_AXIS_NAME   0x3e
 
#define SPLITE_AXIS_ORIENTATION   0x3f
 

Functions

SPATIALITE_DECLARE void spatialite_initialize (void)
 Initializes the library. More...
 
SPATIALITE_DECLARE void spatialite_shutdown (void)
 Finalizes the library. More...
 
SPATIALITE_DECLARE const char * spatialite_version (void)
 Return the current library version. More...
 
SPATIALITE_DECLARE const char * spatialite_target_cpu (void)
 Return the target CPU name. More...
 
SPATIALITE_DECLARE void * spatialite_alloc_connection (void)
 Initializes the internal memory block supporting each connection. More...
 
SPATIALITE_DECLARE void spatialite_set_silent_mode (const void *ptr)
 Disables reporting GEOS/RTTOPO error and warnings on stderr. More...
 
SPATIALITE_DECLARE void spatialite_set_verbode_mode (const void *ptr)
 Enables reporting GEOS/RTTOPO error and warnings on stderr. More...
 
SPATIALITE_DECLARE void spatialite_init (int verbose)
 Initializes a SpatiaLite connection. More...
 
SPATIALITE_DECLARE void spatialite_init_ex (sqlite3 *db_handle, const void *ptr, int verbose)
 Initializes a SpatiaLite connection. More...
 
SPATIALITE_DECLARE void spatialite_init_geos (void)
 Initializes the GEOS library. More...
 
SPATIALITE_DECLARE void spatialite_cleanup (void)
 Cleanup a SpatiaLite connection. More...
 
SPATIALITE_DECLARE void spatialite_cleanup_ex (const void *ptr)
 Cleanup a SpatiaLite connection. More...
 
SPATIALITE_DECLARE void spatialite_finalize_topologies (const void *ptr)
 Partially Cleaning-up a SpatiaLite connection. More...
 
SPATIALITE_DECLARE void enable_tiny_point (const void *ptr)
 Enables the BLOB-TinyPoint encoding. More...
 
SPATIALITE_DECLARE void disable_tiny_point (const void *ptr)
 Disables the BLOB-TinyPoint encoding. More...
 
SPATIALITE_DECLARE int is_tiny_point_enabled (const void *ptr)
 Checks if the BLOB-TinyPoint encoding is enabled or not. More...
 
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. More...
 
SPATIALITE_DECLARE int dump_shapefile_ex (sqlite3 *sqlite, char *table, char *column, char *shp_path, char *charset, char *geom_type, int verbose, int *rows, int colcase_name, char *err_msg)
 Dumps a full geometry-table into an external Shapefile. More...
 
SPATIALITE_DECLARE int dump_shapefile_ex2 (sqlite3 *sqlite, void *proj_ctx, char *table, char *column, char *shp_path, char *charset, char *geom_type, int verbose, int *rows, int colcase_name, char *err_msg)
 Dumps a full geometry-table into an external Shapefile. More...
 
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. More...
 
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. More...
 
SPATIALITE_DECLARE int load_shapefile_ex2 (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 text_date, int *rows, char *err_msg)
 Loads an external Shapefile into a newly created table. More...
 
SPATIALITE_DECLARE int load_shapefile_ex3 (sqlite3 *sqlite, const char *shp_path, const char *table, const char *charset, int srid, const char *geo_column, const char *gtype, const char *pk_column, int coerce2d, int compressed, int verbose, int spatial_index, int text_date, int *rows, int colname_case, char *err_msg)
 Loads an external Shapefile into a newly created table. More...
 
SPATIALITE_DECLARE int load_zip_shapefile (sqlite3 *sqlite, const char *zip_path, const char *shp_path, const char *table, const char *charset, int srid, const char *geo_column, const char *gtype, const char *pk_column, int coerce2d, int compressed, int verbose, int spatial_index, int text_date, int *rows, int colname_case, char *err_msg)
 Loads an external Shapefile (from Zipfile) into a newly created table. More...
 
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. More...
 
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. More...
 
SPATIALITE_DECLARE int load_dbf_ex2 (sqlite3 *sqlite, char *dbf_path, char *table, char *pk_column, char *charset, int verbose, int text_date, int *rows, char *err_msg)
 Loads an external DBF file into a newly created table. More...
 
SPATIALITE_DECLARE int load_dbf_ex3 (sqlite3 *sqlite, const char *dbf_path, const char *table, const char *pk_column, const char *charset, int verbose, int text_date, int *rows, int colname_case, char *err_msg)
 Loads an external DBF file into a newly created table. More...
 
SPATIALITE_DECLARE int load_zip_dbf (sqlite3 *sqlite, const char *zip_file, const char *dbf_path, const char *table, const char *pk_column, const char *charset, int verbose, int text_date, int *rows, int colname_case, char *err_msg)
 Loads an external DBF file (from Zipfile) into a newly created table. More...
 
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. More...
 
SPATIALITE_DECLARE int dump_dbf_ex (sqlite3 *sqlite, char *table, char *dbf_path, char *charset, int *rows, char *err_msg)
 Dumps a full table into an external DBF file. More...
 
SPATIALITE_DECLARE int dump_dbf_ex2 (sqlite3 *sqlite, char *table, char *dbf_path, char *charset, int *rows, int colname_case, char *err_msg)
 Dumps a full table into an external DBF file. More...
 
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. More...
 
SPATIALITE_DECLARE double math_round (double value)
 A portable replacement for C99 round() More...
 
SPATIALITE_DECLARE sqlite3_int64 math_llabs (sqlite3_int64 value)
 A portable replacement for C99 llabs() More...
 
SPATIALITE_DECLARE int spatial_ref_sys_init (sqlite3 *sqlite, int verbose)
 Inserts the inlined EPSG dataset into the "spatial_ref_sys" table. More...
 
SPATIALITE_DECLARE int spatial_ref_sys_init2 (sqlite3 *sqlite, int mode, int verbose)
 Inserts the inlined EPSG dataset into the "spatial_ref_sys" table. More...
 
SPATIALITE_DECLARE int insert_epsg_srid (sqlite3 *sqlite, int srid)
 Inserts some inlined EPSG definition into the "spatial_ref_sys" table. More...
 
SPATIALITE_DECLARE int srid_is_geographic (sqlite3 *sqlite, int srid, int *geographic)
 checks a SRID definition from the "spatial_ref_sys" table determining if it is of the geographic type More...
 
SPATIALITE_DECLARE int srid_is_projected (sqlite3 *sqlite, int srid, int *projected)
 checks a SRID definition from the "spatial_ref_sys" table determining if it is of the projected type More...
 
SPATIALITE_DECLARE int srid_has_flipped_axes (sqlite3 *sqlite, int srid, int *flipped)
 checks a SRID definition from the "spatial_ref_sys" table determining if the axes order is X-Y or Y-X More...
 
SPATIALITE_DECLARE char * srid_get_spheroid (sqlite3 *sqlite, int srid)
 checks a SRID definition from the "spatial_ref_sys" table then returning the corresponding Spheroid name More...
 
SPATIALITE_DECLARE char * srid_get_prime_meridian (sqlite3 *sqlite, int srid)
 checks a SRID definition from the "spatial_ref_sys" table then returning the corresponding Prime Meridian name More...
 
SPATIALITE_DECLARE char * srid_get_projection (sqlite3 *sqlite, int srid)
 checks a SRID definition from the "spatial_ref_sys" table then returning the corresponding Projection name More...
 
SPATIALITE_DECLARE char * srid_get_datum (sqlite3 *sqlite, int srid)
 checks a SRID definition from the "spatial_ref_sys" table then returning the corresponding Datum name More...
 
SPATIALITE_DECLARE char * srid_get_unit (sqlite3 *sqlite, int srid)
 checks a SRID definition from the "spatial_ref_sys" table then returning the corresponding Unit name More...
 
SPATIALITE_DECLARE char * srid_get_axis (sqlite3 *sqlite, int srid, char axis, char mode)
 checks a SRID definition from the "spatial_ref_sys" table then returning an Axis definition More...
 
SPATIALITE_DECLARE int is_kml_constant (sqlite3 *sqlite, char *table, char *column)
 Checks if a column is actually defined into the given table. More...
 
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. More...
 
SPATIALITE_DECLARE int dump_kml_ex (sqlite3 *sqlite, char *table, char *geom_col, char *kml_path, char *name_col, char *desc_col, int precision, int *rows)
 Dumps a full geometry-table into an external KML file. More...
 
SPATIALITE_DECLARE void check_duplicated_rows (sqlite3 *sqlite, char *table, int *dupl_count)
 Checks for duplicated rows into the same table. More...
 
SPATIALITE_DECLARE void remove_duplicated_rows (sqlite3 *sqlite, char *table)
 Remove duplicated rows from a table. More...
 
SPATIALITE_DECLARE void remove_duplicated_rows_ex (sqlite3 *sqlite, char *table, int *removed)
 Remove duplicated rows from a table. More...
 
SPATIALITE_DECLARE void remove_duplicated_rows_ex2 (sqlite3 *sqlite, char *table, int *removed, int transaction)
 Remove duplicated rows from a table. More...
 
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. More...
 
SPATIALITE_DECLARE void elementary_geometries_ex (sqlite3 *sqlite, char *inTable, char *geometry, char *outTable, char *pKey, char *multiId, int *rows)
 Creates a derived table surely containing elementary Geometries. More...
 
SPATIALITE_DECLARE void elementary_geometries_ex2 (sqlite3 *sqlite, char *inTable, char *geometry, char *outTable, char *pKey, char *multiId, int *rows, int transaction)
 Creates a derived table surely containing elementary Geometries. More...
 
SPATIALITE_DECLARE void elementary_geometries_ex3 (sqlite3 *sqlite, char *inTable, char *geometry, char *outTable, char *pKey, char *multiId, const void *options, int *rows, int transaction)
 Creates a derived table surely containing elementary Geometries. More...
 
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 (old specification) More...
 
SPATIALITE_DECLARE int dump_geojson_ex (sqlite3 *sqlite, char *table, char *geom_col, char *outfile_path, int precision, int option, int *rows)
 Dumps a full geometry-table into an external GeoJSON file (old specification) More...
 
SPATIALITE_DECLARE int dump_geojson2 (sqlite3 *sqlite, char *table, char *geom_col, char *outfile_path, int precision, int lon_lat, int m_coords, int indented, int colname_case, int *rows, char **error_message)
 Dumps a full geometry-table into an external GeoJSON file (RFC 7946) More...
 
SPATIALITE_DECLARE int load_geojson (sqlite3 *sqlite, char *path, char *table, char *column, int spatial_index, int srid, int colname_case, int *rows, char **error_message)
 Loads an external GeoJSON file into a newly created table. More...
 
SPATIALITE_DECLARE int update_layer_statistics (sqlite3 *sqlite, const char *table, const char *column)
 Updates the LAYER_STATICS metadata table. More...
 
SPATIALITE_DECLARE int gaiaStatisticsInvalidate (sqlite3 *handle, const char *table, const char *geometry)
 Immediately and unconditionally invalidates the already existing Statistics. More...
 
SPATIALITE_DECLARE gaiaGeomCollPtr gaiaGetLayerExtent (sqlite3 *handle, const char *table, const char *geometry, int mode)
 Queries the Metadata tables returning the Layer Full Extent. More...
 
SPATIALITE_DECLARE gaiaVectorLayersListPtr gaiaGetVectorLayersList (sqlite3 *handle, const char *table, const char *geometry, int mode)
 Queries the Metadata tables supporting Vector Layers. More...
 
SPATIALITE_DECLARE int gaiaCreateMetaCatalogTables (sqlite3 *handle)
 Creates (or re-creates) the "splite_metacatalog" and "splite_metacalog_statistics" tables. More...
 
SPATIALITE_DECLARE int gaiaUpdateMetaCatalogStatistics (sqlite3 *handle, const char *table, const char *column)
 Updates the "splite_metacatalog_statistics" table. More...
 
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). More...
 
SPATIALITE_DECLARE void gaiaFreeVectorLayersList (gaiaVectorLayersListPtr ptr)
 Destroys a VectorLayersList object. More...
 
SPATIALITE_DECLARE int gaiaDropTable (sqlite3 *sqlite, const char *table)
 Drops a layer-table, removing any related dependency. More...
 
SPATIALITE_DECLARE int gaiaDropTableEx (sqlite3 *sqlite, const char *prefix, const char *table)
 Drops a layer-table, removing any related dependency. More...
 
SPATIALITE_DECLARE int gaiaDropTableEx2 (sqlite3 *sqlite, const char *prefix, const char *table, int transaction)
 Drops a layer-table, removing any related dependency. More...
 
SPATIALITE_DECLARE int gaiaDropTableEx3 (sqlite3 *sqlite, const char *prefix, const char *table, int transaction, char **error_message)
 Drops a layer-table, removing any related dependency. More...
 
SPATIALITE_DECLARE int gaiaDropTable5 (sqlite3 *sqlite, const char *prefix, const char *table, char **error_message)
 Drops a layer-table, removing any related dependency. More...
 
SPATIALITE_DECLARE int gaiaRenameTable (sqlite3 *sqlite, const char *prefix, const char *old_name, const char *new_name, char **error_message)
 Renames a Table. More...
 
SPATIALITE_DECLARE int gaiaRenameColumn (sqlite3 *sqlite, const char *prefix, const char *table, const char *old_name, const char *new_name, char **error_message)
 Renames a Table's Column. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
SPATIALITE_DECLARE int gaiaCutter (sqlite3 *db_handle, const void *cache, const char *in_db_prefix, const char *input_table, const char *input_geom, const char *blade_db_prefix, const char *blade_table, const char *blade_geom, const char *output_table, int transaction, int ram_tmp_store, char **message)
 Will precisely cut the input dataset against polygonal blade(s) and will consequently create and populate an output dataset. More...
 
SPATIALITE_DECLARE int gaia_create_routing_nodes (sqlite3 *db_handle, const void *cache, const char *prefix, const char *table, const char *geom_column, const char *from_column, const char *to_column)
 Will attempt to create the Routing Nodes columns for a spatial table. More...
 
SPATIALITE_DECLARE int gaia_create_routing (sqlite3 *db_handle, const void *cache, const char *routing_data_table, const char *virtual_routing_table, const char *input_table, const char *from_column, const char *to_column, const char *geom_column, const char *cost_column, const char *name_column, int a_star_enabled, int bidirectional, const char *oneway_from, const char *oneway_to, int overwrite)
 Will attempt to create a VirtualRouting from an input table. More...
 
SPATIALITE_DECLARE gaiaGeomCollPtr gaiaGetRTreeFullExtent (sqlite3 *db_handle, const char *db_prefix, const char *name, int srid)
 Will attempt to retrieve the Full Extent from an R*Tree (SpatiaLite) More...
 
SPATIALITE_DECLARE gaiaGeomCollPtr gaiaGetGpkgRTreeFullExtent (sqlite3 *db_handle, const char *db_prefix, const char *name, int srid)
 Will attempt to retrieve the Full Extent from an R*Tree (GeoPackage) More...
 
SPATIALITE_DECLARE const char * gaia_create_routing_get_last_error (const void *cache)
 
SPATIALITE_DECLARE int gaiaGPKG2Spatialite (sqlite3 *handle_in, const char *gpkg_in_path, sqlite3 *handle_out, const char *splite_out_path)
 
SPATIALITE_DECLARE int gaiaSpatialite2GPKG (sqlite3 *handle_in, const char *splite_in_path, sqlite3 *handle_out, const char *gpkg_out_path)
 
SPATIALITE_DECLARE const void * gaiaGetCurrentProjContext (const void *cache)
 
SPATIALITE_DECLARE int gaiaSetCurrentCachedProj (const void *cache, void *pj, const char *proj_string_1, const char *proj_string_2, void *area)
 
SPATIALITE_DECLARE void * gaiaGetCurrentCachedProj (const void *cache)
 
SPATIALITE_DECLARE int gaiaCurrentCachedProjMatches (const void *cache, const char *proj_string_1, const char *proj_string_2, void *area)
 
SPATIALITE_DECLARE char * gaiaGetDbObjectScope (sqlite3 *handle, const char *db_prefix, const char *obj_name)
 

Detailed Description

Main SpatiaLite header file.

Function Documentation

◆ check_all_geometry_columns()

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.

Parameters
sqlitehandle to current DB connection
output_dirpathname of the directory to be created for report-files
n_invalidsif this variable is not NULL on successful completion will contain the total number of invalid Geometries found
err_msgif this variable is not NULL and the return status is ZERO (failure), an appropriate error message will be returned
See also
check_all_geometry_columns_r, check_geometry_column, sanitize_geometry_column, sanitize_all_geometry_columns
Note
this function will check all Geometry Columns (vector layers) for validity; a HTML report will be produced.
an eventual error message returned via err_msg requires to be deallocated by invoking free()
not reentrant and thread unsafe.
Returns
0 on failure, any other value on success

◆ check_all_geometry_columns_r()

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.

Parameters
p_cachea memory pointer returned by spatialite_alloc_connection()
sqlitehandle to current DB connection
output_dirpathname of the directory to be created for report-files
n_invalidsif this variable is not NULL on successful completion will contain the total number of invalid Geometries found
err_msgif this variable is not NULL and the return status is ZERO (failure), an appropriate error message will be returned
See also
check_all_geometry_columns, check_geometry_column, sanitize_geometry_column, sanitize_all_geometry_columns
Note
this function will check all Geometry Columns (vector layers) for validity; a HTML report will be produced.
an eventual error message returned via err_msg requires to be deallocated by invoking free()
reentrant and thread-safe.
Returns
0 on failure, any other value on success

◆ check_duplicated_rows()

SPATIALITE_DECLARE void check_duplicated_rows ( sqlite3 *  sqlite,
char *  table,
int *  dupl_count 
)

Checks for duplicated rows into the same table.

Parameters
sqlitehandle to current DB connection
tablename of the table to be checked
dupl_counton completion will contain the number of duplicated rows found
See also
remove_duplicated_rows
Note
two (or more) rows are assumed to be duplicated if any column

value (excluding any Primary Key column) is exacly the same

◆ check_geometry_column()

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.

Parameters
sqlitehandle to current DB connection
tablename of the table
geometryname of the column to be checked
report_pathpathname of the report-file
n_rowsif this variable is not NULL on successful completion will contain the total number of rows found into the checkeck table
n_invalidsif this variable is not NULL on successful completion will contain the total number of invalid Geometries found into the checkeck table
err_msgif this variable is not NULL and the return status is ZERO (failure), an appropriate error message will be returned
See also
check_geometry_column_r, check_all_geometry_columns, sanitize_geometry_column, sanitize_all_geometry_columns
Note
this function will check a Geometry Column (layer) for validity; a HTML report will be produced.
an eventual error message returned via err_msg requires to be deallocated by invoking free()
not reentrant and thread unsafe.
Returns
0 on failure, any other value on success

◆ check_geometry_column_r()

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.

Parameters
p_cachea memory pointer returned by spatialite_alloc_connection()
sqlitehandle to current DB connection
tablename of the table
geometryname of the column to be checked
report_pathpathname of the report-file
n_rowsif this variable is not NULL on successful completion will contain the total number of rows found into the checkeck table
n_invalidsif this variable is not NULL on successful completion will contain the total number of invalid Geometries found into the checkeck table
err_msgif this variable is not NULL and the return status is ZERO (failure), an appropriate error message will be returned
See also
check_geometry_column, check_all_geometry_columns, sanitize_geometry_column, sanitize_all_geometry_columns
Note
this function will check a Geometry Column (layer) for validity; a HTML report will be produced.
an eventual error message returned via err_msg requires to be deallocated by invoking free()
reentrant and thread-safe.
Returns
0 on failure, any other value on success

◆ disable_tiny_point()

SPATIALITE_DECLARE void disable_tiny_point ( const void *  ptr)

Disables the BLOB-TinyPoint encoding.

Parameters
ptrthe same memory pointer passed to the corresponding call to spatialite_init_ex() and returned by spatialite_alloc_connection()
See also
disable_tiny_point, is_tiny_point_enabled

◆ dump_dbf()

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.

Parameters
sqlitehandle to current DB connection
tablethe name of the table to be exported
dbf_pathpathname of the DBF to be exported
charseta valid GNU ICONV charset to be used for DBF text strings
err_msgon completion will contain an error message (if any)
See also
dump_dbf_ex, dump_dbf_ex2
Returns
0 on failure, any other value on success

◆ dump_dbf_ex()

SPATIALITE_DECLARE int dump_dbf_ex ( sqlite3 *  sqlite,
char *  table,
char *  dbf_path,
char *  charset,
int *  rows,
char *  err_msg 
)

Dumps a full table into an external DBF file.

Parameters
sqlitehandle to current DB connection
tablethe name of the table to be exported
dbf_pathpathname of the DBF to be exported
charseta valid GNU ICONV charset to be used for DBF text strings
rowson completion will contain the total number of exported rows
err_msgon completion will contain an error message (if any)
See also
dump_dbf, dump_dbf_ex2
Returns
0 on failure, any other value on success

◆ dump_dbf_ex2()

SPATIALITE_DECLARE int dump_dbf_ex2 ( sqlite3 *  sqlite,
char *  table,
char *  dbf_path,
char *  charset,
int *  rows,
int  colname_case,
char *  err_msg 
)

Dumps a full table into an external DBF file.

Parameters
sqlitehandle to current DB connection
tablethe name of the table to be exported
dbf_pathpathname of the DBF to be exported
charseta valid GNU ICONV charset to be used for DBF text strings
rowson completion will contain the total number of exported rows
colname_caseone between GAIA_DBF_COLNAME_LOWERCASE, GAIA_DBF_COLNAME_UPPERCASE or GAIA_DBF_COLNAME_CASE_IGNORE.
err_msgon completion will contain an error message (if any)
See also
dump_dbf, dump_dbf_ex
Returns
0 on failure, any other value on success

◆ dump_geojson()

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 (old specification)

Parameters
sqlitehandle to current DB connection
tablethe name of the table to be exported
geom_colthe name of the geometry column
outfile_pathpathname for the GeoJSON file to be written to
precisionnumber of decimal digits for coordinates
optionthe format to use for output
See also
dump_geojson_ex, dump_geojson2
Note
valid values for option are:
  • 0 no option
  • 1 GeoJSON MBR
  • 2 GeoJSON Short CRS (e.g EPSG:4326)
  • 3 MBR + Short CRS
  • 4 GeoJSON Long CRS (e.g urn:ogc:def:crs:EPSG::4326)
  • 5 MBR + Long CRS
Returns
0 on failure, any other value on success

◆ dump_geojson2()

SPATIALITE_DECLARE int dump_geojson2 ( sqlite3 *  sqlite,
char *  table,
char *  geom_col,
char *  outfile_path,
int  precision,
int  lon_lat,
int  m_coords,
int  indented,
int  colname_case,
int *  rows,
char **  error_message 
)

Dumps a full geometry-table into an external GeoJSON file (RFC 7946)

Parameters
sqlitehandle to current DB connection
tablethe name of the table to be exported
geom_colthe name of the geometry column
outfile_pathpathname for the GeoJSON file to be written to
precisionnumber of decimal digits for coordinates
lon_latTRUE if all coordinates are expressed as WGS84 longitudes and latitudes (as required by RFC 7946); FALSE if they are in some other (undefined) CRS
m_coordsTRUE if M-values will be exported as ordinary coordinates; FALSE for strict RFC 4796 conformance (no M-Values at all)
indentTRUE if the GeoJSON file will be properly indented for enhanced human readibility; FALSE if the GeoJSON file will be in a single monolithic line without blank spaces.
colname_caseone between GAIA_DBF_COLNAME_LOWERCASE, GAIA_DBF_COLNAME_UPPERCASE or GAIA_DBF_COLNAME_CASE_IGNORE.
rowson completion will contain the total number of exported rows
error_messagewill point to a diagnostic error message in case of failure, otherwise NULL
See also
dump_geojson, dump_geojson_ex
Returns
0 on failure, any other value on success
Note
you are expected to free before or later an eventual error message by calling sqlite3_free()

◆ dump_geojson_ex()

SPATIALITE_DECLARE int dump_geojson_ex ( sqlite3 *  sqlite,
char *  table,
char *  geom_col,
char *  outfile_path,
int  precision,
int  option,
int *  rows 
)

Dumps a full geometry-table into an external GeoJSON file (old specification)

Parameters
sqlitehandle to current DB connection
tablethe name of the table to be exported
geom_colthe name of the geometry column
outfile_pathpathname for the GeoJSON file to be written to
precisionnumber of decimal digits for coordinates
optionthe format to use for output
rowson completion will contain the total number of exported rows
See also
dump_geojson, dump_geojson2
Note
valid values for option are:
  • 0 no option
  • 1 GeoJSON MBR
  • 2 GeoJSON Short CRS (e.g EPSG:4326)
  • 3 MBR + Short CRS
  • 4 GeoJSON Long CRS (e.g urn:ogc:def:crs:EPSG::4326)
  • 5 MBR + Long CRS
Returns
0 on failure, any other value on success

◆ dump_kml()

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.

Parameters
sqlitehandle to current DB connection
tablethe name of the table to be exported
geom_colthe name of the geometry column
kml_pathpathname of the KML file to be exported
name_colcolumn to be used for KML "name" (may be null)
desc_colcolumn to be used for KML "description" (may be null)
precisionnumber of decimal digits for coordinates
See also
dump_kml_ex
Returns
0 on failure, any other value on success

◆ dump_kml_ex()

SPATIALITE_DECLARE int dump_kml_ex ( sqlite3 *  sqlite,
char *  table,
char *  geom_col,
char *  kml_path,
char *  name_col,
char *  desc_col,
int  precision,
int *  rows 
)

Dumps a full geometry-table into an external KML file.

Parameters
sqlitehandle to current DB connection
tablethe name of the table to be exported
geom_colthe name of the geometry column
kml_pathpathname of the KML file to be exported
name_colcolumn to be used for KML "name" (may be null)
desc_colcolumn to be used for KML "description" (may be null)
precisionnumber of decimal digits for coordinates
rowson completion will contain the total number of exported rows
See also
dump_kml
Returns
0 on failure, any other value on success

◆ dump_shapefile()

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.

Parameters
sqlitehandle to current DB connection
tablethe name of the table to be exported
columnthe name of the geometry column
shp_pathpathname of the Shapefile to be exported (no suffix)
charseta valid GNU ICONV charset to be used for DBF text strings
geom_type"POINT", "LINESTRING", "POLYGON", "MULTIPOINT" or NULL
verboseif TRUE a short report is shown on stderr
rowson completion will contain the total number of exported rows
err_msgon completion will contain an error message (if any)
See also
dump_shapefile_ex
Returns
0 on failure, any other value on success

◆ dump_shapefile_ex()

SPATIALITE_DECLARE int dump_shapefile_ex ( sqlite3 *  sqlite,
char *  table,
char *  column,
char *  shp_path,
char *  charset,
char *  geom_type,
int  verbose,
int *  rows,
int  colcase_name,
char *  err_msg 
)

Dumps a full geometry-table into an external Shapefile.

Parameters
sqlitehandle to current DB connection
tablethe name of the table to be exported
columnthe name of the geometry column
shp_pathpathname of the Shapefile to be exported (no suffix)
charseta valid GNU ICONV charset to be used for DBF text strings
geom_type"POINT", "LINESTRING", "POLYGON", "MULTIPOINT" or NULL
verboseif TRUE a short report is shown on stderr
rowson completion will contain the total number of exported rows
colname_caseone between GAIA_DBF_COLNAME_LOWERCASE, GAIA_DBF_COLNAME_UPPERCASE or GAIA_DBF_COLNAME_CASE_IGNORE.
err_msgon completion will contain an error message (if any)
See also
dump_shapefile
Returns
0 on failure, any other value on success

◆ dump_shapefile_ex2()

SPATIALITE_DECLARE int dump_shapefile_ex2 ( sqlite3 *  sqlite,
void *  proj_ctx,
char *  table,
char *  column,
char *  shp_path,
char *  charset,
char *  geom_type,
int  verbose,
int *  rows,
int  colcase_name,
char *  err_msg 
)

Dumps a full geometry-table into an external Shapefile.

Parameters
sqlitehandle to current DB connection
proj_ctxpointer to the current PROJ.6 context (may be NULL)
tablethe name of the table to be exported
columnthe name of the geometry column
shp_pathpathname of the Shapefile to be exported (no suffix)
charseta valid GNU ICONV charset to be used for DBF text strings
geom_type"POINT", "LINESTRING", "POLYGON", "MULTIPOINT" or NULL
verboseif TRUE a short report is shown on stderr
rowson completion will contain the total number of exported rows
colname_caseone between GAIA_DBF_COLNAME_LOWERCASE, GAIA_DBF_COLNAME_UPPERCASE or GAIA_DBF_COLNAME_CASE_IGNORE.
err_msgon completion will contain an error message (if any)
See also
dump_shapefile
Returns
0 on failure, any other value on success

◆ elementary_geometries()

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.

Parameters
sqlitehandle to current DB connection
inTablename of the input table
geometryname of the Geometry column
outTablename of the output table to be created
pKeyname of the Primary Key column in the output table
multiIdname of the column identifying origins in the output table
See also
elementary_geometries_ex
Note
if the input table contains some kind of complex Geometry (MULTIPOINT, MULTILINESTRING, MULTIPOLYGON or GEOMETRYCOLLECTION), then many rows are inserted into the output table: each single row will contain the same attributes and an elementaty Geometry. All the rows created by expanding the same input row will expose the same value in the "multiId" column.

◆ elementary_geometries_ex()

SPATIALITE_DECLARE void elementary_geometries_ex ( sqlite3 *  sqlite,
char *  inTable,
char *  geometry,
char *  outTable,
char *  pKey,
char *  multiId,
int *  rows 
)

Creates a derived table surely containing elementary Geometries.

Parameters
sqlitehandle to current DB connection
inTablename of the input table
geometryname of the Geometry column
outTablename of the output table to be created
pKeyname of the Primary Key column in the output table
multiIdname of the column identifying origins in the output table
rowson completion will contain the total number of inserted rows
See also
elementary_geometries_ex2
Note
if the input table contains some kind of complex Geometry (MULTIPOINT, MULTILINESTRING, MULTIPOLYGON or GEOMETRYCOLLECTION), then many rows are inserted into the output table: each single row will contain the same attributes and an elementaty Geometry. All the rows created by expanding the same input row will expose the same value in the "multiId" column.

◆ elementary_geometries_ex2()

SPATIALITE_DECLARE void elementary_geometries_ex2 ( sqlite3 *  sqlite,
char *  inTable,
char *  geometry,
char *  outTable,
char *  pKey,
char *  multiId,
int *  rows,
int  transaction 
)

Creates a derived table surely containing elementary Geometries.

Parameters
sqlitehandle to current DB connection
inTablename of the input table
geometryname of the Geometry column
outTablename of the output table to be created
pKeyname of the Primary Key column in the output table
multiIdname of the column identifying origins in the output table
rowson completion will contain the total number of inserted rows
transactionboolena; if set to TRUE will internally handle a SQL Transaction
See also
elementary_geometries_ex3
Note
if the input table contains some kind of complex Geometry (MULTIPOINT, MULTILINESTRING, MULTIPOLYGON or GEOMETRYCOLLECTION), then many rows are inserted into the output table: each single row will contain the same attributes and an elementaty Geometry. All the rows created by expanding the same input row will expose the same value in the "multiId" column.

◆ elementary_geometries_ex3()

SPATIALITE_DECLARE void elementary_geometries_ex3 ( sqlite3 *  sqlite,
char *  inTable,
char *  geometry,
char *  outTable,
char *  pKey,
char *  multiId,
const void *  options,
int *  rows,
int  transaction 
)

Creates a derived table surely containing elementary Geometries.

Parameters
sqlitehandle to current DB connection
inTablename of the input table
geometryname of the Geometry column
outTablename of the output table to be created
pKeyname of the Primary Key column in the output table
multiIdname of the column identifying origins in the output table
optionspointer to an Options list created by gaiaAuxClonerCreate()
rowson completion will contain the total number of inserted rows
transactionboolena; if set to TRUE will internally handle a SQL Transaction
See also
elementary_geometries
Note
if the input table contains some kind of complex Geometry (MULTIPOINT, MULTILINESTRING, MULTIPOLYGON or GEOMETRYCOLLECTION), then many rows are inserted into the output table: each single row will contain the same attributes and an elementaty Geometry. All the rows created by expanding the same input row will expose the same value in the "multiId" column.

◆ enable_tiny_point()

SPATIALITE_DECLARE void enable_tiny_point ( const void *  ptr)

Enables the BLOB-TinyPoint encoding.

Parameters
ptrthe same memory pointer passed to the corresponding call to spatialite_init_ex() and returned by spatialite_alloc_connection()
See also
disable_tiny_point, is_tiny_point_enabled

◆ gaia_create_routing()

SPATIALITE_DECLARE int gaia_create_routing ( sqlite3 *  db_handle,
const void *  cache,
const char *  routing_data_table,
const char *  virtual_routing_table,
const char *  input_table,
const char *  from_column,
const char *  to_column,
const char *  geom_column,
const char *  cost_column,
const char *  name_column,
int  a_star_enabled,
int  bidirectional,
const char *  oneway_from,
const char *  oneway_to,
int  overwrite 
)

Will attempt to create a VirtualRouting from an input table.

Parameters
db_handlehandle to the current SQLite connection
cachea memory pointer returned by spatialite_alloc_connection()
routing_data_tablename of the Routing Data Table to be created.
virtual_routing_tablename of the VirtualRouting Table to be created.
input_tablename of the input table to be processed.
from_columnname of the input table column containing NodeFrom.
to_columnname of the input table column containing NodeTo.
geom_columnname of the input table column containing Linestring Geometries (could be eventually NULL).
cost_columnname of the input table column containing Cost values (could be eventually NULL).
name_columnname of the input table column containing RoadName (could be eventually NULL).
a_star_enabledif set to TRUE the Routing Data Table will support both Djiskra's Shortest Path and A* algorithms; if set to FALSE only the Djiskra's algorithm will be supported.
bidirectionalif set to TRUE all input arcs/links will be assumed to be bidirectional (from-to and to-from); if set to FALSE all input arcs/links will be assumed to be unidirectional (from-to only).
oneway_fromname of the input table column containing OneWayFrom (could be eventually NULL).
oneway_toname of the input table column containing OneWayTo (could be eventually NULL).
overwriteif set to TRUE both the Routing Data Table and the VirtualRouting Table will be dropped if already existing; if set to FALSE an already existing Routing Data Table or VirtualRouting Table will cause a fatal error.
Returns
0 on failure, any other value on success
Note
at least one between geom_column and cost_column shall not be NULL. both oneway_from and oneway_to must be NULL or must contain a valid column name; mixing a column name and a NULL will be considered a fatal error.

◆ gaia_create_routing_nodes()

SPATIALITE_DECLARE int gaia_create_routing_nodes ( sqlite3 *  db_handle,
const void *  cache,
const char *  prefix,
const char *  table,
const char *  geom_column,
const char *  from_column,
const char *  to_column 
)

Will attempt to create the Routing Nodes columns for a spatial table.

Parameters
db_handlehandle to the current SQLite connection
cachea memory pointer returned by spatialite_alloc_connection()
prefixschema prefix identifying the target DB (could be eventually NULL)
tablename of the table to be processed.
geom_columnname of the table column containing Linestring Geometries (could be eventually NULL).
from_columnname of the table column where NodeFrom values will be stored.
to_columnname of the column where ToFrom values will be stored.
Returns
0 on failure, any other value on success

◆ gaiaCreateMetaCatalogTables()

SPATIALITE_DECLARE int gaiaCreateMetaCatalogTables ( sqlite3 *  handle)

Creates (or re-creates) the "splite_metacatalog" and "splite_metacalog_statistics" tables.

Parameters
handleSQLite handle to current DB connection.
Returns
0 (FALSE) on failure, any other value (TRUE) on success
See also
gaiaUpdateMetaCatalogStatistics, gaiaUpdateMetaCatalogStatisticsFromMaster

◆ gaiaCutter()

SPATIALITE_DECLARE int gaiaCutter ( sqlite3 *  db_handle,
const void *  cache,
const char *  in_db_prefix,
const char *  input_table,
const char *  input_geom,
const char *  blade_db_prefix,
const char *  blade_table,
const char *  blade_geom,
const char *  output_table,
int  transaction,
int  ram_tmp_store,
char **  message 
)

Will precisely cut the input dataset against polygonal blade(s) and will consequently create and populate an output dataset.

Parameters
db_handlehandle to the current SQLite connection
cachea memory pointer returned by spatialite_alloc_connection()
in_db_prefixprefix of the database where the input table is expected to be found. if NULL then "MAIN" will be assumed.
input_tablename of the input table to be processed.
input_geometryname of the input table Geometry column; it could be NULL and in this case the appropriate column name will be automatically determind. anyway if the input table do contains two or more Geometries passing a NULL geometry name will raise a fatal error.
blade_db_prefixprefix of the database where the "blade" table is expected to be found. if NULL then "MAIN" will be assumed.
blade_tablename of the table expected to contain Polygons or MultiPolygon Geometries acting as blades.
blade_geometryname of the "blade" table Geometry column; it could be NULL and in this case the appropriate column name will be automatically determind. anyway if the input table do contains two or more Geometries passing a NULL geometry name will raise a fatal error.
output_tablename to assinged to the destination table intended to permanently store all results. this table must non exists.
transactionboolean; if set to TRUE will internally handle a SQL Transaction.
ram_tmp_storeboolean: if set to TRUE all TEMPORARY tables and indices will be created in RAM, otherwise in a file.
messagepointer to a string buffer; if not NULL it will point on completion an eventual error message.
Returns
0 on failure, any other value on success
Note
the message buffer if not NULL will point to a dymanic memory allocation and is expected to be released by calling sqlite3_free()

◆ gaiaDropTable()

SPATIALITE_DECLARE int gaiaDropTable ( sqlite3 *  sqlite,
const char *  table 
)

Drops a layer-table, removing any related dependency.

Parameters
sqlitehandle to current DB connection
tablename of the table to be removed
Note
this function will drop a SpatialTable, SpatialView or VirtualShape being properly registered within the Metadata tables.
an eventual Spatial Index will be dropped as well, and any row referring the selected table will be removed from the Metadata tables.
Returns
0 on failure, any other value on success
See also
gaiaDropTableEx, gaiaRenameTable, gaiaRenameColumn
Note
this one simply is a convenience method alway defaulting to gaiaDropTableEx(sqlite, "main", table);

◆ gaiaDropTable5()

SPATIALITE_DECLARE int gaiaDropTable5 ( sqlite3 *  sqlite,
const char *  prefix,
const char *  table,
char **  error_message 
)

Drops a layer-table, removing any related dependency.

Parameters
sqlitehandle to current DB connection
prefixschema prefix identifying the target DB
"main" always identifies the main DB (primary, not Attached).
tablename of the table or view to be dropped
error_messagewill point to a diagnostic error message in case of failure, otherwise NULL
Note
this function will drop a SpatialTable, SpatialView or VirtualShape being properly registered within the Metadata tables.
an eventual Spatial Index will be dropped as well, and any row referring the selected table will be removed from the Metadata tables.
an eventual diagnostic message pointed by error_message must be freed by calling sqlite3_free()
Returns
0 on failure, any other value on success
See also
gaiaDropTableEx3, gaiaRenameTable, gaiaRenameColumn

◆ gaiaDropTableEx()

SPATIALITE_DECLARE int gaiaDropTableEx ( sqlite3 *  sqlite,
const char *  prefix,
const char *  table 
)

Drops a layer-table, removing any related dependency.

Parameters
sqlitehandle to current DB connection
prefixschema prefix identifying the target DB
"main" always identifies the main DB (primary, not Attached).
tablename of the table to be removed
Note
this function will drop a SpatialTable, SpatialView or VirtualShape being properly registered within the Metadata tables.
an eventual Spatial Index will be dropped as well, and any row referring the selected table will be removed from the Metadata tables.
Returns
0 on failure, any other value on success
See also
gaiaDropTableEx2, gaiaRenameTable, gaiaRenameColumn

◆ gaiaDropTableEx2()

SPATIALITE_DECLARE int gaiaDropTableEx2 ( sqlite3 *  sqlite,
const char *  prefix,
const char *  table,
int  transaction 
)

Drops a layer-table, removing any related dependency.

Parameters
sqlitehandle to current DB connection
prefixschema prefix identifying the target DB
"main" always identifies the main DB (primary, not Attached).
tablename of the table to be removed
transactionboolena; if set to TRUE will internally handle a SQL Transaction
Note
this function will drop a SpatialTable, SpatialView or VirtualShape being properly registered within the Metadata tables.
an eventual Spatial Index will be dropped as well, and any row referring the selected table will be removed from the Metadata tables.
Returns
0 on failure, any other value on success
See also
gaiaDropTable, gaiaRenameTable, gaiaRenameColumn

◆ gaiaDropTableEx3()

SPATIALITE_DECLARE int gaiaDropTableEx3 ( sqlite3 *  sqlite,
const char *  prefix,
const char *  table,
int  transaction,
char **  error_message 
)

Drops a layer-table, removing any related dependency.

Parameters
sqlitehandle to current DB connection
prefixschema prefix identifying the target DB
"main" always identifies the main DB (primary, not Attached).
tablename of the table to be removed
transactionboolean; if set to TRUE will internally handle a SQL Transaction
error_messagewill point to a diagnostic error message in case of failure, otherwise NULL
Note
this function will drop a SpatialTable, SpatialView or VirtualShape being properly registered within the Metadata tables.
an eventual Spatial Index will be dropped as well, and any row referring the selected table will be removed from the Metadata tables.
an eventual diagnostic message pointed by error_message must be freed by calling sqlite3_free()
Returns
0 on failure, any other value on success
See also
gaiaDropTable5, gaiaRenameTable, gaiaRenameColumn
Deprecated:
use gaiaDropTable5() as a full replacement

◆ gaiaFreeVectorLayersList()

SPATIALITE_DECLARE void gaiaFreeVectorLayersList ( gaiaVectorLayersListPtr  ptr)

Destroys a VectorLayersList object.

Parameters
ptrpointer to the VectorLayersList object to be destroyed
See also
gaiaGetVectorLayersList
Examples
demo5.c.

◆ gaiaGetGpkgRTreeFullExtent()

SPATIALITE_DECLARE gaiaGeomCollPtr gaiaGetGpkgRTreeFullExtent ( sqlite3 *  db_handle,
const char *  db_prefix,
const char *  name,
int  srid 
)

Will attempt to retrieve the Full Extent from an R*Tree (GeoPackage)

Parameters
db_handlehandle to the current SQLite connection
prefixschema prefix identifying the DB containing the R*Tree
"main" always identifies the main DB (primary, not Attached).
namethe name of the R*Tree table
sridthe intended SRID for the R*Tree
See also
gaiaGetRTreeFullExtent
Returns
a Rectangle Geometry corresponding to the Full Extent,
NULL on failure.

◆ gaiaGetLayerExtent()

SPATIALITE_DECLARE gaiaGeomCollPtr gaiaGetLayerExtent ( sqlite3 *  handle,
const char *  table,
const char *  geometry,
int  mode 
)

Queries the Metadata tables returning the Layer Full Extent.

Parameters
handleSQLite handle to current DB connection.
tableVectorLayer Table (or View, or VirtualShape).
geometryGeometry Column name.
modeif TRUE a PESSIMISTIC statistics update will be implied, otherwise OPTIMISTIC.
Returns
the pointer to the newly created Geometry (Envelope): NULL on failure
See also
update_layer_statistic, gaiaStatisticsInvalidate, gaiaGetVectorLayersList
Note
you are responsible to destroy (before or after) any allocated Geometry returned by gaiaGetLayerExtent().
The geometry arg is optional when the table simply has a single Geometry Column, and can be NULL in this case.
When the mode arg is set to FALSE (default) then the returned infos will be simply retrieved from the staticized statistic tables (faster, but could be inaccurate).
If the mode arg is set to TRUE a preliminary attempt to update the statistic tables will be always performed (probably slower, but surely accurate).
If the named Layer doesn't exist, or if it's completely empty (not containing any valid Geometry) NULL will be returned.

◆ gaiaGetRTreeFullExtent()

SPATIALITE_DECLARE gaiaGeomCollPtr gaiaGetRTreeFullExtent ( sqlite3 *  db_handle,
const char *  db_prefix,
const char *  name,
int  srid 
)

Will attempt to retrieve the Full Extent from an R*Tree (SpatiaLite)

Parameters
db_handlehandle to the current SQLite connection
prefixschema prefix identifying the DB containing the R*Tree
"main" always identifies the main DB (primary, not Attached).
namethe name of the R*Tree table
sridthe intended SRID for the R*Tree
See also
gaiaGetGpkgRTreeFullExtent
Returns
a Rectangle Geometry corresponding to the Full Extent,
NULL on failure.

◆ gaiaGetVectorLayersList()

SPATIALITE_DECLARE gaiaVectorLayersListPtr gaiaGetVectorLayersList ( sqlite3 *  handle,
const char *  table,
const char *  geometry,
int  mode 
)

Queries the Metadata tables supporting Vector Layers.

Parameters
handleSQLite handle to current DB connection.
tableVectorLayer Table (or View, or VirtualShape).
geometryGeometry Column name.
modeone of GAIA_VECTORS_LIST_OPTIMISTIC or GAIA_VECTORS_LIST_PESSIMISTIC.
Returns
the pointer to the newly created VectorLayersList object: NULL on failure
See also
gaiaFreeVectorLayersList, update_layer_statistics, gaiaStatisticsInvalidate, gaiaGetLayerExtent, gaiaGetVectorLayersList
Note
you are responsible to destroy (before or after) any allocated VectorLayersList returned by gaiaGetVectorLayersList().
If the table arg is NULL all VectorLayers defined within the DB will be reported (and in this case all AttributeField Infos will be always suppressed); otherwise only a single Layer will be reported (if existing).
By defining the geometry arg (not NULL) you can further restrict the returned report.
When the mode arg is set to GAIA_VECTORS_LIST_OPTIMISTIC (default) then the returned infos will be simply retrieved from the staticized statistic tables (faster, but could be inaccurate).
If the mode arg is set to GAIA_VECTORS_LIST_PESSIMISTIC a preliminary attempt to update the statistic tables will be always performed (probably slower, but surely accurate).
Examples
demo5.c.

◆ gaiaRenameColumn()

SPATIALITE_DECLARE int gaiaRenameColumn ( sqlite3 *  sqlite,
const char *  prefix,
const char *  table,
const char *  old_name,
const char *  new_name,
char **  error_message 
)

Renames a Table's Column.

Parameters
sqlitehandle to current DB connection
prefixschema prefix identifying the target DB
"main" always identifies the main DB (primary, not Attached).
tablename of the table containing the column to be renamed (always expected to be in the MAIN database).
old_namecurrent name of the column to be renamed
new_namenew column name to be set
error_messagewill point to a diagnostic error message in case of failure, otherwise NULL
Note
this function will corretly rename a Geometry Column being properly registered within the Metadata tables.
all triggers, Spatial Index and alike will be correctly recovered.
an eventual diagnostic message pointed by error_message must be freed by calling sqlite3_free()
Returns
0 on failure, any other value on success
See also
gaiaDropTable, gaiaRenameTable
Note
SQLite 3.25 (or later) is stricly required.

◆ gaiaRenameTable()

SPATIALITE_DECLARE int gaiaRenameTable ( sqlite3 *  sqlite,
const char *  prefix,
const char *  old_name,
const char *  new_name,
char **  error_message 
)

Renames a Table.

Parameters
sqlitehandle to current DB connection
prefixschema prefix identifying the target DB
"main" always identifies the main DB (primary, not Attached).
old_namecurrent name of the table to be renamed (always expected to be in the MAIN database).
new_namenew table name to be set
error_messagewill point to a diagnostic error message in case of failure, otherwise NULL
Note
this function will corretly rename a SpatialTable being properly registered within the Metadata tables.
all triggers, Spatial Index and alike will be correctly recovered.
an eventual diagnostic message pointed by error_message must be freed by calling sqlite3_free()
Returns
0 on failure, any other value on success
See also
gaiaDropTable, gaiaRenameColumn
Note
SQLite 3.25 (or later) is stricly required.

◆ gaiaStatisticsInvalidate()

SPATIALITE_DECLARE int gaiaStatisticsInvalidate ( sqlite3 *  handle,
const char *  table,
const char *  geometry 
)

Immediately and unconditionally invalidates the already existing Statistics.

Parameters
handleSQLite handle to current DB connection.
tableVectorLayer Table (or View, or VirtualShape).
geometryGeometry Column name.
Returns
0 on success, any other value on success
See also
update_layer_statistics, gaiaGetLayerExtent, gaiaGetVectorLayersList
Note
if the table arg is NULL all Statistics for any VectorLayer defined within the DB will be invalidated; otherwise only a single Layer will be affectedd (if existing).
By defining the geometry arg (not NULL) you can further restrict your selection.

◆ gaiaUpdateMetaCatalogStatistics()

SPATIALITE_DECLARE int gaiaUpdateMetaCatalogStatistics ( sqlite3 *  handle,
const char *  table,
const char *  column 
)

Updates the "splite_metacatalog_statistics" table.

Parameters
handleSQLite handle to current DB connection.
tablename of the table to be processed.
columnname of the column to be processed.
Returns
0 (FALSE) on failure, any other value (TRUE) on success
See also
gaiaCreateMetaCatalogTables, gaiaUpdateMetaCatalogStatisticsFromMaster

◆ gaiaUpdateMetaCatalogStatisticsFromMaster()

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).

Parameters
handleSQLite handle to current DB connection.
master_tablename of the master-table controlling the whole process.
table_namename of the column into the master-table containing table-names.
column_namename of the column into the master-table containing column-names.
Returns
0 (FALSE) on failure, any other value (TRUE) on success
See also
gaiaCreateMetaCatalogTables, gaiaUpdateMetaCatalogStatistics

◆ insert_epsg_srid()

SPATIALITE_DECLARE int insert_epsg_srid ( sqlite3 *  sqlite,
int  srid 
)

Inserts some inlined EPSG definition into the "spatial_ref_sys" table.

Parameters
sqlitehandle to current DB connection
sridthe SRID value uniquely identifying the required EPSG definition
Returns
0 on failure, any other value on success

◆ is_kml_constant()

SPATIALITE_DECLARE int is_kml_constant ( sqlite3 *  sqlite,
char *  table,
char *  column 
)

Checks if a column is actually defined into the given table.

Parameters
sqlitehandle to current DB connection
tablethe table to be checked
columnthe column to be checked
Returns
0 on success, any other value on success
Note
internally used to detect if some KML attribute defaults to a constant value

◆ is_tiny_point_enabled()

SPATIALITE_DECLARE int is_tiny_point_enabled ( const void *  ptr)

Checks if the BLOB-TinyPoint encoding is enabled or not.

Parameters
ptrthe same memory pointer passed to the corresponding call to spatialite_init_ex() and returned by spatialite_alloc_connection()
Returns
0 (FALSE) if not enabled, any other value (TRUE) if enabled
See also
enable_tiny_point, disable_tiny_point

◆ load_dbf()

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.

Parameters
sqlitehandle to current DB connection
dbf_pathpathname of the DBF file to be imported
tablethe name of the table to be created
charseta valid GNU ICONV charset to be used for DBF text strings
verboseif TRUE a short report is shown on stderr
rowson completion will contain the total number of actually exported rows
err_msgon completion will contain an error message (if any)
See also
load_dbf_ex, load_dbf_ex2, load_dbf_ex3
Note
this function simply calls load_dbf_ex by passing an implicit pk_column=NULL argument
Returns
0 on failure, any other value on success

◆ load_dbf_ex()

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.

Parameters
sqlitehandle to current DB connection
dbf_pathpathname of the DBF file to be imported
tablethe name of the table to be created
pk_columnname of the Primary Key column; if NULL or mismatching then "PK_UID" will be assumed by default.
charseta valid GNU ICONV charset to be used for DBF text strings
verboseif TRUE a short report is shown on stderr
rowson completion will contain the total number of actually exported rows
err_msgon completion will contain an error message (if any)
See also
load_dbf, load_dbf_ex2, load_dbf_ex3
Returns
0 on failure, any other value on success

◆ load_dbf_ex2()

SPATIALITE_DECLARE int load_dbf_ex2 ( sqlite3 *  sqlite,
char *  dbf_path,
char *  table,
char *  pk_column,
char *  charset,
int  verbose,
int  text_date,
int *  rows,
char *  err_msg 
)

Loads an external DBF file into a newly created table.

Parameters
sqlitehandle to current DB connection
dbf_pathpathname of the DBF file to be imported
tablethe name of the table to be created
pk_columnname of the Primary Key column; if NULL or mismatching then "PK_UID" will be assumed by default.
charseta valid GNU ICONV charset to be used for DBF text strings
verboseif TRUE a short report is shown on stderr
text_datesis TRUE all DBF dates will be considered as TEXT
rowson completion will contain the total number of imported rows
err_msgon completion will contain an error message (if any)
See also
load_dbf, load_dbf_ex, load_dbf_ex3
Returns
0 on failure, any other value on success

◆ load_dbf_ex3()

SPATIALITE_DECLARE int load_dbf_ex3 ( sqlite3 *  sqlite,
const char *  dbf_path,
const char *  table,
const char *  pk_column,
const char *  charset,
int  verbose,
int  text_date,
int *  rows,
int  colname_case,
char *  err_msg 
)

Loads an external DBF file into a newly created table.

Parameters
sqlitehandle to current DB connection
dbf_pathpathname of the DBF file to be imported
tablethe name of the table to be created
pk_columnname of the Primary Key column; if NULL or mismatching then "PK_UID" will be assumed by default.
charseta valid GNU ICONV charset to be used for DBF text strings
verboseif TRUE a short report is shown on stderr
text_datesis TRUE all DBF dates will be considered as TEXT
rowson completion will contain the total number of imported rows
colname_caseone between GAIA_DBF_COLNAME_LOWERCASE, GAIA_DBF_COLNAME_UPPERCASE or GAIA_DBF_COLNAME_CASE_IGNORE.
err_msgon completion will contain an error message (if any)
See also
load_dbf, load_dbf_ex, load_dbf_ex2, load_zip_dbf
Returns
0 on failure, any other value on success

◆ load_geojson()

SPATIALITE_DECLARE int load_geojson ( sqlite3 *  sqlite,
char *  path,
char *  table,
char *  column,
int  spatial_index,
int  srid,
int  colname_case,
int *  rows,
char **  error_message 
)

Loads an external GeoJSON file into a newly created table.

Parameters
sqlitehandle to current DB connection
pathpathname of the GeoJSON file to be imported
tablethe name of the table to be created
columnthe name of the geometry column. If NULL the column will be silently named "geometry".
spatial_indexif TRUE an R*Tree Spatial Index will be created
sridwhen positive, the SRID value to be assigned to all Geometries. If 0 or negative SRID=4326 (lon-lat WGS84) will be always assumed accordingly to RFC 7946.
colname_caseone between GAIA_DBF_COLNAME_LOWERCASE, GAIA_DBF_COLNAME_UPPERCASE or GAIA_DBF_COLNAME_CASE_IGNORE.
rowson completion will contain the total number of imported rows
error_messagewill point to a diagnostic error message in case of failure, otherwise NULL
Returns
0 on failure, any other value on success
Note
you are expected to free before or later an eventual error message by calling sqlite3_free()

◆ load_shapefile()

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.

Parameters
sqlitehandle to current DB connection
shp_pathpathname of the Shapefile to be imported (no suffix)
tablethe name of the table to be created
charseta valid GNU ICONV charset to be used for DBF text strings
sridthe SRID to be set for Geometries
columnthe name of the geometry column
coerce2dif TRUE any Geometry will be casted to 2D [XY]
compressedif TRUE compressed Geometries will be created
verboseif TRUE a short report is shown on stderr
spatial_indexif TRUE an R*Tree Spatial Index will be created
rowson completion will contain the total number of imported rows
err_msgon completion will contain an error message (if any)
Returns
0 on failure, any other value on success
See also
load_shapefile_ex, load_shapefile_ex2, load_shapefile_ex3
Note
this function simply calls load_shapefile_ex by passing implicit gype="AUTO" and pk_column=NULL arguments

◆ load_shapefile_ex()

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.

Parameters
sqlitehandle to current DB connection
shp_pathpathname of the Shapefile to be imported (no suffix)
tablethe name of the table to be created
charseta valid GNU ICONV charset to be used for DBF text strings
sridthe SRID to be set for Geometries
geo_columnthe name of the geometry column
gtypeexpected to be one of: "LINESTRING", "LINESTRINGZ", "LINESTRINGM", "LINESTRINGZM", "MULTILINESTRING", "MULTILINESTRINGZ", "MULTILINESTRINGM", "MULTILINESTRINGZM", "POLYGON", "POLYGONZ", "POLYGONM", "POLYGONZM", "MULTIPOLYGON", "MULTIPOLYGONZ", "MULTIPOLYGONM", "MULTIPOLYGONZM" or "AUTO".
pk_columnname of the Primary Key column; if NULL or mismatching then "PK_UID" will be assumed by default.
coerce2dif TRUE any Geometry will be casted to 2D [XY]
compressedif TRUE compressed Geometries will be created
verboseif TRUE a short report is shown on stderr
spatial_indexif TRUE an R*Tree Spatial Index will be created
rowson completion will contain the total number of imported rows
err_msgon completion will contain an error message (if any)
Returns
0 on failure, any other value on success
See also
load_shapefile, load_shapefile_ex2, load_shapefile_ex3
Note
the Shapefile format doesn't supports any distinction between LINESTRINGs and MULTILINESTRINGs, or between POLYGONs and MULTIPOLYGONs; as does not allows to clearly distinguish if the M-measure is required.
So a first preliminary scan of the Shapefile is required in order to correctly identify the actual payload (gtype = "AUTO", default case).
By explicitly specifying some expected geometry type this first scan will be skipped at all thus introducing a noticeable performance gain.
Anyway, declaring a mismatching geometry type will surely cause a failure.

◆ load_shapefile_ex2()

SPATIALITE_DECLARE int load_shapefile_ex2 ( 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  text_date,
int *  rows,
char *  err_msg 
)

Loads an external Shapefile into a newly created table.

Parameters
sqlitehandle to current DB connection
shp_pathpathname of the Shapefile to be imported (no suffix)
tablethe name of the table to be created
charseta valid GNU ICONV charset to be used for DBF text strings
sridthe SRID to be set for Geometries
geo_columnthe name of the geometry column
gtypeexpected to be one of: "LINESTRING", "LINESTRINGZ", "LINESTRINGM", "LINESTRINGZM", "MULTILINESTRING", "MULTILINESTRINGZ", "MULTILINESTRINGM", "MULTILINESTRINGZM", "POLYGON", "POLYGONZ", "POLYGONM", "POLYGONZM", "MULTIPOLYGON", "MULTIPOLYGONZ", "MULTIPOLYGONM", "MULTIPOLYGONZM" or "AUTO".
pk_columnname of the Primary Key column; if NULL or mismatching then "PK_UID" will be assumed by default.
coerce2dif TRUE any Geometry will be casted to 2D [XY]
compressedif TRUE compressed Geometries will be created
verboseif TRUE a short report is shown on stderr
spatial_indexif TRUE an R*Tree Spatial Index will be created
text_datesis TRUE all DBF dates will be considered as TEXT
rowson completion will contain the total number of imported rows
err_msgon completion will contain an error message (if any)
Returns
0 on failure, any other value on success
See also
load_shapefile, load_shapefile_ex, load_shapefile_ex3
Note
the Shapefile format doesn't supports any distinction between LINESTRINGs and MULTILINESTRINGs, or between POLYGONs and MULTIPOLYGONs; as does not allows to clearly distinguish if the M-measure is required.
So a first preliminary scan of the Shapefile is required in order to correctly identify the actual payload (gtype = "AUTO", default case).
By explicitly specifying some expected geometry type this first scan will be skipped at all thus introducing a noticeable performance gain.
Anyway, declaring a mismatching geometry type will surely cause a failure.

◆ load_shapefile_ex3()

SPATIALITE_DECLARE int load_shapefile_ex3 ( sqlite3 *  sqlite,
const char *  shp_path,
const char *  table,
const char *  charset,
int  srid,
const char *  geo_column,
const char *  gtype,
const char *  pk_column,
int  coerce2d,
int  compressed,
int  verbose,
int  spatial_index,
int  text_date,
int *  rows,
int  colname_case,
char *  err_msg 
)

Loads an external Shapefile into a newly created table.

Parameters
sqlitehandle to current DB connection
shp_pathpathname of the Shapefile to be imported (no suffix)
tablethe name of the table to be created
charseta valid GNU ICONV charset to be used for DBF text strings
sridthe SRID to be set for Geometries
geo_columnthe name of the geometry column
gtypeexpected to be one of: "LINESTRING", "LINESTRINGZ", "LINESTRINGM", "LINESTRINGZM", "MULTILINESTRING", "MULTILINESTRINGZ", "MULTILINESTRINGM", "MULTILINESTRINGZM", "POLYGON", "POLYGONZ", "POLYGONM", "POLYGONZM", "MULTIPOLYGON", "MULTIPOLYGONZ", "MULTIPOLYGONM", "MULTIPOLYGONZM" or "AUTO".
pk_columnname of the Primary Key column; if NULL or mismatching then "PK_UID" will be assumed by default.
coerce2dif TRUE any Geometry will be casted to 2D [XY]
compressedif TRUE compressed Geometries will be created
verboseif TRUE a short report is shown on stderr
spatial_indexif TRUE an R*Tree Spatial Index will be created
text_datesis TRUE all DBF dates will be considered as TEXT
rowson completion will contain the total number of imported rows
colname_caseone between GAIA_DBF_COLNAME_LOWERCASE, GAIA_DBF_COLNAME_UPPERCASE or GAIA_DBF_COLNAME_CASE_IGNORE.
err_msgon completion will contain an error message (if any)
Returns
0 on failure, any other value on success
See also
load_shapefile, load_shapefile_ex, load_shapefile_ex2, load_zip_shapefile
Note
the Shapefile format doesn't supports any distinction between LINESTRINGs and MULTILINESTRINGs, or between POLYGONs and MULTIPOLYGONs; as does not allows to clearly distinguish if the M-measure is required.
So a first preliminary scan of the Shapefile is required in order to correctly identify the actual payload (gtype = "AUTO", default case).
By explicitly specifying some expected geometry type this first scan will be skipped at all thus introducing a noticeable performance gain.
Anyway, declaring a mismatching geometry type will surely cause a failure.

◆ load_XL()

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.

Parameters
sqlitehandle to current DB connection
pathpathname of the spreadsheet file to be imported
tablethe name of the table to be created
worksheetIndexthe index identifying the worksheet to be imported
first_titlesif TRUE the first line is assumed to contain column names
rowson completion will contain the total number of actually exported rows
err_msgon completion will contain an error message (if any)
Returns
0 on failure, any other value on success

◆ load_zip_dbf()

SPATIALITE_DECLARE int load_zip_dbf ( sqlite3 *  sqlite,
const char *  zip_file,
const char *  dbf_path,
const char *  table,
const char *  pk_column,
const char *  charset,
int  verbose,
int  text_date,
int *  rows,
int  colname_case,
char *  err_msg 
)

Loads an external DBF file (from Zipfile) into a newly created table.

Parameters
sqlitehandle to current DB connection
zip_pathpathname of the Zipfile
shp_pathpseudo-pathname of the Shapefile to be imported (no suffix)
sqlitehandle to current DB connection
zip_pathpathname of the Zipfile
filenamepseudo-pathnameof the DBF file to be imported (including the '.dbf' suffix)
tablethe name of the table to be created
pk_columnname of the Primary Key column; if NULL or mismatching then "PK_UID" will be assumed by default.
charseta valid GNU ICONV charset to be used for DBF text strings
verboseif TRUE a short report is shown on stderr
text_datesis TRUE all DBF dates will be considered as TEXT
rowson completion will contain the total number of imported rows
colname_caseone between GAIA_DBF_COLNAME_LOWERCASE, GAIA_DBF_COLNAME_UPPERCASE or GAIA_DBF_COLNAME_CASE_IGNORE.
err_msgon completion will contain an error message (if any)
See also
load_dbf_ex3
Returns
0 on failure, any other value on success

◆ load_zip_shapefile()

SPATIALITE_DECLARE int load_zip_shapefile ( sqlite3 *  sqlite,
const char *  zip_path,
const char *  shp_path,
const char *  table,
const char *  charset,
int  srid,
const char *  geo_column,
const char *  gtype,
const char *  pk_column,
int  coerce2d,
int  compressed,
int  verbose,
int  spatial_index,
int  text_date,
int *  rows,
int  colname_case,
char *  err_msg 
)

Loads an external Shapefile (from Zipfile) into a newly created table.

Parameters
sqlitehandle to current DB connection
zip_pathpathname of the Zipfile
shp_pathpseudo-pathname of the Shapefile to be imported (no suffix)
tablethe name of the table to be created
charseta valid GNU ICONV charset to be used for DBF text strings
sridthe SRID to be set for Geometries
geo_columnthe name of the geometry column
gtypeexpected to be one of: "LINESTRING", "LINESTRINGZ", "LINESTRINGM", "LINESTRINGZM", "MULTILINESTRING", "MULTILINESTRINGZ", "MULTILINESTRINGM", "MULTILINESTRINGZM", "POLYGON", "POLYGONZ", "POLYGONM", "POLYGONZM", "MULTIPOLYGON", "MULTIPOLYGONZ", "MULTIPOLYGONM", "MULTIPOLYGONZM" or "AUTO".
pk_columnname of the Primary Key column; if NULL or mismatching then "PK_UID" will be assumed by default.
coerce2dif TRUE any Geometry will be casted to 2D [XY]
compressedif TRUE compressed Geometries will be created
verboseif TRUE a short report is shown on stderr
spatial_indexif TRUE an R*Tree Spatial Index will be created
text_datesis TRUE all DBF dates will be considered as TEXT
rowson completion will contain the total number of imported rows
colname_caseone between GAIA_DBF_COLNAME_LOWERCASE, GAIA_DBF_COLNAME_UPPERCASE or GAIA_DBF_COLNAME_CASE_IGNORE.
err_msgon completion will contain an error message (if any)
Returns
0 on failure, any other value on success
See also
load_shapefile_ex3
Note
the Shapefile format doesn't supports any distinction between LINESTRINGs and MULTILINESTRINGs, or between POLYGONs and MULTIPOLYGONs; as does not allows to clearly distinguish if the M-measure is required.
So a first preliminary scan of the Shapefile is required in order to correctly identify the actual payload (gtype = "AUTO", default case).
By explicitly specifying some expected geometry type this first scan will be skipped at all thus introducing a noticeable performance gain.
Anyway, declaring a mismatching geometry type will surely cause a failure.

◆ math_llabs()

SPATIALITE_DECLARE sqlite3_int64 math_llabs ( sqlite3_int64  value)

A portable replacement for C99 llabs()

Parameters
valuea 64 bit integer value
Returns
the corresponding absolute value

◆ math_round()

SPATIALITE_DECLARE double math_round ( double  value)

A portable replacement for C99 round()

Parameters
valuea double value
Returns
the nearest integeral value

◆ remove_duplicated_rows()

SPATIALITE_DECLARE void remove_duplicated_rows ( sqlite3 *  sqlite,
char *  table 
)

Remove duplicated rows from a table.

Parameters
sqlitehandle to current DB connection
tablename of the table to be cleaned
See also
check_duplicated_rows, remove_duplicated_rows_ex
Note
when two (or more) duplicated rows exist, only the first occurrence will be preserved, then deleting any further occurrence.

◆ remove_duplicated_rows_ex()

SPATIALITE_DECLARE void remove_duplicated_rows_ex ( sqlite3 *  sqlite,
char *  table,
int *  removed 
)

Remove duplicated rows from a table.

Parameters
sqlitehandle to current DB connection
tablename of the table to be cleaned
removedon successful completion will contain the total count of removed duplicate rows
See also
check_duplicated_rows, remove_duplicated_rows_ex2
Note
when two (or more) duplicated rows exist, only the first occurrence will be preserved, then deleting any further occurrence.

◆ remove_duplicated_rows_ex2()

SPATIALITE_DECLARE void remove_duplicated_rows_ex2 ( sqlite3 *  sqlite,
char *  table,
int *  removed,
int  transaction 
)

Remove duplicated rows from a table.

Parameters
sqlitehandle to current DB connection
tablename of the table to be cleaned
removedon successful completion will contain the total count of removed duplicate rows
transactionboolena; if set to TRUE will internally handle a SQL Transaction
See also
check_duplicated_rows, remove_duplicated_rows
Note
when two (or more) duplicated rows exist, only the first occurrence will be preserved, then deleting any further occurrence.

◆ sanitize_all_geometry_columns()

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.

Parameters
sqlitehandle to current DB connection
tmp_prefixname-prefix for temporary tables
output_dirpathname of the directory to be created for report-files
not_repairedif this variable is not NULL on successful completion will contain the total count of repair failures (i.e. Geometries beyond possible repair)
err_msgif this variable is not NULL and the return status is ZERO (failure), an appropriate error message will be returned
See also
sanitize_all_geometry_columns_r, check_geometry_column, check_all_geometry_columns, sanitize_geometry_column
Note
this function will attempt to make valid all invalid geometries found within all Geometry Columns (vector layers); a temporary table is required so to support each input table.
if the process has full success the temprary table will be deleted; otherwise it will be preserved for further inspection. a HTML report will be produced as well.
an eventual error message returned via err_msg requires to be deallocated by invoking free()
not reentrant and thread unsafe.
Returns
0 on failure, any other value on success

◆ sanitize_all_geometry_columns_r()

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.

Parameters
p_cachea memory pointer returned by spatialite_alloc_connection()
sqlitehandle to current DB connection
tmp_prefixname-prefix for temporary tables
output_dirpathname of the directory to be created for report-files
not_repairedif this variable is not NULL on successful completion will contain the total count of repair failures (i.e. Geometries beyond possible repair)
err_msgif this variable is not NULL and the return status is ZERO (failure), an appropriate error message will be returned
See also
sanitize_all_geometry_columns, check_geometry_column, check_all_geometry_columns, sanitize_geometry_column
Note
this function will attempt to make valid all invalid geometries found within all Geometry Columns (vector layers); a temporary table is required so to support each input table.
if the process has full success the temprary table will be deleted; otherwise it will be preserved for further inspection. a HTML report will be produced as well.
an eventual error message returned via err_msg requires to be deallocated by invoking free()
reentrant and thread-safe.
Returns
0 on failure, any other value on success

◆ sanitize_geometry_column()

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.

Parameters
sqlitehandle to current DB connection
tablename of the table
geometryname of the column to be checked
tmp_tablename of the temporary table
report_pathpathname of the report-file
n_invalidsif this variable is not NULL on successful completion will contain the total number of invalid Geometries found into the sanitize table
n_repairedif this variable is not NULL on successful completion will contain the total number of repaired Geometries
n_discardedif this variable is not NULL on successful completion will contain the total number of repaired Geometries (by discarding fragments)
n_failuresif this variable is not NULL on successful completion will contain the total number of repair failures (i.e. Geometries beyond possible repair)
err_msgif this variable is not NULL and the return status is ZERO (failure), an appropriate error message will be returned
See also
sanitize_geometry_column_r, check_geometry_column, check_all_geometry_columns, sanitize_all_geometry_columns
Note
this function will attempt to make valid all invalid geometries found within a Geometry Column (layer); a temporary table is required.
if the process has full success the temprary table will be deleted; otherwise it will be preserved for further inspection. a HTML report will be produced as well.
an eventual error message returned via err_msg requires to be deallocated by invoking free()
not reentrant and thread unsafe.
Returns
0 on failure, any other value on success

◆ sanitize_geometry_column_r()

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.

Parameters
p_cachea memory pointer returned by spatialite_alloc_connection()
sqlitehandle to current DB connection
tablename of the table
geometryname of the column to be checked
tmp_tablename of the temporary table
report_pathpathname of the report-file
n_invalidsif this variable is not NULL on successful completion will contain the total number of invalid Geometries found into the sanitize table
n_repairedif this variable is not NULL on successful completion will contain the total number of repaired Geometries
n_discardedif this variable is not NULL on successful completion will contain the total number of repaired Geometries (by discarding fragments)
n_failuresif this variable is not NULL on successful completion will contain the total number of repair failures (i.e. Geometries beyond possible repair)
err_msgif this variable is not NULL and the return status is ZERO (failure), an appropriate error message will be returned
See also
sanitize_geometry_column, check_geometry_column, check_all_geometry_columns, sanitize_all_geometry_columns
Note
this function will attempt to make valid all invalid geometries found within a Geometry Column (layer); a temporary table is required.
if the process has full success the temprary table will be deleted; otherwise it will be preserved for further inspection. a HTML report will be produced as well.
an eventual error message returned via err_msg requires to be deallocated by invoking free()
reentrant and thread-safe.
Returns
0 on failure, any other value on success

◆ spatial_ref_sys_init()

SPATIALITE_DECLARE int spatial_ref_sys_init ( sqlite3 *  sqlite,
int  verbose 
)

Inserts the inlined EPSG dataset into the "spatial_ref_sys" table.

Parameters
sqlitehandle to current DB connection
verboseif TRUE a short report is shown on stderr
Returns
0 on failure, any other value on success
See also
spatial_ref_sys_init2
Note
this function is internally invoked by the SQL function InitSpatialMetadata(), and is not usually intended for direct use. This functions is now deprecated, and will simply call spatial_ref_sys_init2(sqlite, GAIA_EPSG_ANY, verbose).

◆ spatial_ref_sys_init2()

SPATIALITE_DECLARE int spatial_ref_sys_init2 ( sqlite3 *  sqlite,
int  mode,
int  verbose 
)

Inserts the inlined EPSG dataset into the "spatial_ref_sys" table.

Parameters
sqlitehandle to current DB connection
modecan be one of GAIA_EPSG_ANY, GAIA_EPSG_NONE or GAIA_EPSG_WGS84_ONLY
verboseif TRUE a short report is shown on stderr
Returns
0 on failure, any other value on success
Note
this function is internally invoked by the SQL function InitSpatialMetadata(), and is not usually intended for direct use.

◆ spatialite_alloc_connection()

SPATIALITE_DECLARE void* spatialite_alloc_connection ( void  )

Initializes the internal memory block supporting each connection.

See also
spatialite_init_ex, spatialite_cleanup_ex
Examples
demo1.c, demo2.c, demo3.c, demo4.c, and demo5.c.

◆ spatialite_cleanup()

SPATIALITE_DECLARE void spatialite_cleanup ( void  )

Cleanup a SpatiaLite connection.

This function is now DEPRECATED; use spatialite_cleanup_ex() for all new development.

This function performs general cleanup, essentially undoing the effect of spatialite_init().

See also
spatialite_init

◆ spatialite_cleanup_ex()

SPATIALITE_DECLARE void spatialite_cleanup_ex ( const void *  ptr)

Cleanup a SpatiaLite connection.

This function performs general cleanup, essentially undoing the effect of spatialite_init_ex().

Parameters
ptrthe same memory pointer passed to the corresponding call to spatialite_init_ex() and returned by spatialite_alloc_connection()
See also
spatialite_init_ex, spatialite_alloc_connection
Examples
demo1.c, demo2.c, demo3.c, demo4.c, and demo5.c.

◆ spatialite_finalize_topologies()

SPATIALITE_DECLARE void spatialite_finalize_topologies ( const void *  ptr)

Partially Cleaning-up a SpatiaLite connection.

This function will destroy all TopoGeo and TopoNet objects from within a local cache.

Parameters
ptrthe same memory pointer passed to the corresponding call to spatialite_init_ex() and returned by spatialite_alloc_connection()
See also
spatialite_init_ex, spatialite_alloc_connection

◆ spatialite_init()

SPATIALITE_DECLARE void spatialite_init ( int  verbose)

Initializes a SpatiaLite connection.

This function is now DEPRECATED because is not reentrant (not thread safe); use spatialite_init_ex() for all new development.

Parameters
verboseif TRUE a short start-up message is shown on stderr
See also
spatialite_cleanup, spatialite_init_ex
Note
You absolutely must invoke this function before attempting to perform any other SpatiaLite's call.

◆ spatialite_init_ex()

SPATIALITE_DECLARE void spatialite_init_ex ( sqlite3 *  db_handle,
const void *  ptr,
int  verbose 
)

Initializes a SpatiaLite connection.

Parameters
db_handlehandle to the current SQLite connection
ptra memory pointer returned by spatialite_alloc_connection()
verboseif TRUE a short start-up message is shown on stderr
See also
spatialite_alloc_connection, spatialite_cleanup_ex, spatialite_init
Note
You absolutely must invoke this function before attempting to perform any other SpatiaLite's call.
Examples
demo1.c, demo2.c, demo3.c, demo4.c, and demo5.c.

◆ spatialite_init_geos()

SPATIALITE_DECLARE void spatialite_init_geos ( void  )

Initializes the GEOS library.

Note
You are never supposed to invoke this function (internally handled).

◆ spatialite_initialize()

SPATIALITE_DECLARE void spatialite_initialize ( void  )

Initializes the library.

Note
you are always expected to explicitly call this function before attempting to call any SpatiaLite own function.

◆ spatialite_set_silent_mode()

SPATIALITE_DECLARE void spatialite_set_silent_mode ( const void *  ptr)

Disables reporting GEOS/RTTOPO error and warnings on stderr.

Parameters
ptra memory pointer returned by spatialite_alloc_connection()
See also
spatialite_init_ex, spatialite_cleanup_ex, spatialite_set_verbose_mode

◆ spatialite_set_verbode_mode()

SPATIALITE_DECLARE void spatialite_set_verbode_mode ( const void *  ptr)

Enables reporting GEOS/RTTOPO error and warnings on stderr.

Parameters
ptra memory pointer returned by spatialite_alloc_connection()
See also
spatialite_init_ex, spatialite_cleanup_ex, spatialite_set_silent_mode

◆ spatialite_shutdown()

SPATIALITE_DECLARE void spatialite_shutdown ( void  )

Finalizes the library.

Note
you are always expected to explicitly call this function immediately before exiting the main application.
This function will free any memory allocation and will release any system resource internally used by the library.
Examples
demo1.c, demo2.c, demo3.c, demo4.c, and demo5.c.

◆ spatialite_target_cpu()

SPATIALITE_DECLARE const char* spatialite_target_cpu ( void  )

Return the target CPU name.

Returns
the target CPU string.

◆ spatialite_version()

SPATIALITE_DECLARE const char* spatialite_version ( void  )

Return the current library version.

Returns
the version string.
Examples
demo1.c, demo3.c, demo4.c, and demo5.c.

◆ srid_get_axis()

SPATIALITE_DECLARE char* srid_get_axis ( sqlite3 *  sqlite,
int  srid,
char  axis,
char  mode 
)

checks a SRID definition from the "spatial_ref_sys" table then returning an Axis definition

Parameters
sqlitehandle to current DB connection
sridthe SRID value uniquely identifying the required EPSG definition
axisshould be one of SPLITE_AXIS_1 or SPLITE_AXIS_2
modeshould be one of SPLITE_AXIS_NAME or SPLITE_AXIS_ORIENTATION
Returns
the reqested name on succes, NULL on failure
Note
you are responsible for freeing the returned name.

◆ srid_get_datum()

SPATIALITE_DECLARE char* srid_get_datum ( sqlite3 *  sqlite,
int  srid 
)

checks a SRID definition from the "spatial_ref_sys" table then returning the corresponding Datum name

Parameters
sqlitehandle to current DB connection
sridthe SRID value uniquely identifying the required EPSG definition
Returns
the Datum name on succes, NULL on failure
Note
you are responsible for freeing the returned name.

◆ srid_get_prime_meridian()

SPATIALITE_DECLARE char* srid_get_prime_meridian ( sqlite3 *  sqlite,
int  srid 
)

checks a SRID definition from the "spatial_ref_sys" table then returning the corresponding Prime Meridian name

Parameters
sqlitehandle to current DB connection
sridthe SRID value uniquely identifying the required EPSG definition
Returns
the Prime Meridian name on succes, NULL on failure
Note
you are responsible for freeing the returned name.

◆ srid_get_projection()

SPATIALITE_DECLARE char* srid_get_projection ( sqlite3 *  sqlite,
int  srid 
)

checks a SRID definition from the "spatial_ref_sys" table then returning the corresponding Projection name

Parameters
sqlitehandle to current DB connection
sridthe SRID value uniquely identifying the required EPSG definition
Returns
the Projection name on succes, NULL on failure
Note
you are responsible for freeing the returned name.

◆ srid_get_spheroid()

SPATIALITE_DECLARE char* srid_get_spheroid ( sqlite3 *  sqlite,
int  srid 
)

checks a SRID definition from the "spatial_ref_sys" table then returning the corresponding Spheroid name

Parameters
sqlitehandle to current DB connection
sridthe SRID value uniquely identifying the required EPSG definition
Returns
the Spheroid name on succes, NULL on failure
Note
you are responsible for freeing the returned name.

◆ srid_get_unit()

SPATIALITE_DECLARE char* srid_get_unit ( sqlite3 *  sqlite,
int  srid 
)

checks a SRID definition from the "spatial_ref_sys" table then returning the corresponding Unit name

Parameters
sqlitehandle to current DB connection
sridthe SRID value uniquely identifying the required EPSG definition
Returns
the Unit name on succes, NULL on failure
Note
you are responsible for freeing the returned name.

◆ srid_has_flipped_axes()

SPATIALITE_DECLARE int srid_has_flipped_axes ( sqlite3 *  sqlite,
int  srid,
int *  flipped 
)

checks a SRID definition from the "spatial_ref_sys" table determining if the axes order is X-Y or Y-X

Parameters
sqlitehandle to current DB connection
sridthe SRID value uniquely identifying the required EPSG definition
flippedon successful completion will contain 0 (FALSE) if axes order is X-Y, any other value (TRUE) if axes order is Y-X.
Returns
0 on failure, any other value on success

◆ srid_is_geographic()

SPATIALITE_DECLARE int srid_is_geographic ( sqlite3 *  sqlite,
int  srid,
int *  geographic 
)

checks a SRID definition from the "spatial_ref_sys" table determining if it is of the geographic type

Parameters
sqlitehandle to current DB connection
sridthe SRID value uniquely identifying the required EPSG definition
geographicon successful completion will contain TRUE or FALSE
Returns
0 on failure, any other value on success

◆ srid_is_projected()

SPATIALITE_DECLARE int srid_is_projected ( sqlite3 *  sqlite,
int  srid,
int *  projected 
)

checks a SRID definition from the "spatial_ref_sys" table determining if it is of the projected type

Parameters
sqlitehandle to current DB connection
sridthe SRID value uniquely identifying the required EPSG definition
projectedon successful completion will contain TRUE or FALSE
Returns
0 on failure, any other value on success

◆ update_layer_statistics()

SPATIALITE_DECLARE int update_layer_statistics ( sqlite3 *  sqlite,
const char *  table,
const char *  column 
)

Updates the LAYER_STATICS metadata table.

Parameters
sqlitehandle to current DB connection
tablename of the table to be processed
columnname of the geometry to be processed
Note
this function will explore the given table/geometry determining the number of rows and the full layer extent; a corresponding table/geometry entry is expected to be already declared in the GEOMETRY_COLUMNS table. These informations will be permanently stored into the LAYER_STATISTICS table; if such table does not yet exists will be implicitly created.
  • if table is NULL, any entry found within GEOMETRY_COLUMNS will be processed.
  • if table is not NULL and column is NULL, any geometry belonging to the given table will be processed.
  • if both table and column are not NULL, then only the given entry will be processed.
See also
gaiaStatisticsInvalidate, gaiaGetLayerExtent, gaiaGetVectorLayersList
Returns
0 on failure, the total count of processed entries on success