SpatiaLite  3.0.0-stable
Functions
src/headers/spatialite.h File Reference

Main SpatiaLite header file. More...

Go to the source code of this file.

Functions

SPATIALITE_DECLARE const char * spatialite_version (void)
 Return the current library version.
SPATIALITE_DECLARE void spatialite_init (int verbose)
 Initializes the library.
SPATIALITE_DECLARE void spatialite_cleanup ()
 Cleanup spatialite.
SPATIALITE_DECLARE int dump_shapefile (sqlite3 *sqlite, char *table, char *column, char *shp_path, char *charset, char *geom_type, int verbose, int *rows, char *err_msg)
 Dumps a full geometry-table into an external Shapefile.
SPATIALITE_DECLARE int load_shapefile (sqlite3 *sqlite, char *shp_path, char *table, char *charset, int srid, char *column, int coerce2d, int compressed, int verbose, int spatial_index, int *rows, char *err_msg)
 Loads an external Shapefile into a newly created table.
SPATIALITE_DECLARE int load_dbf (sqlite3 *sqlite, char *dbf_path, char *table, char *charset, int verbose, int *rows, char *err_msg)
 Loads an external DBF file into a newly created table.
SPATIALITE_DECLARE int dump_dbf (sqlite3 *sqlite, char *table, char *dbf_path, char *charset, char *err_msg)
 Dumps a full table into an external DBF file.
SPATIALITE_DECLARE int load_XL (sqlite3 *sqlite, const char *path, const char *table, unsigned int worksheetIndex, int first_titles, unsigned int *rows, char *err_msg)
 Loads an external spreadsheet (.xls) file into a newly created table.
SPATIALITE_DECLARE double math_round (double value)
 A portable replacement for C99 round()
SPATIALITE_DECLARE sqlite3_int64 math_llabs (sqlite3_int64 value)
 A portable replacement for C99 llabs()
SPATIALITE_DECLARE int spatial_ref_sys_init (sqlite3 *sqlite, int verbose)
 Inserts the inlined EPSG dataset into the "spatial_ref_sys" table.
SPATIALITE_DECLARE int is_kml_constant (sqlite3 *sqlite, char *table, char *column)
 Checks if a column is actually defined into the given table.
SPATIALITE_DECLARE int dump_kml (sqlite3 *sqlite, char *table, char *geom_col, char *kml_path, char *name_col, char *desc_col, int precision)
 Dumps a full geometry-table into an external KML file.
SPATIALITE_DECLARE void check_duplicated_rows (sqlite3 *sqlite, char *table, int *dupl_count)
 Checks for duplicated rows into the same table.
SPATIALITE_DECLARE void remove_duplicated_rows (sqlite3 *sqlite, char *table)
 Remove duplicated rows from a table.
SPATIALITE_DECLARE void elementary_geometries (sqlite3 *sqlite, char *inTable, char *geometry, char *outTable, char *pKey, char *multiId)
 Creates a derived table surely containing elementary Geometries.
SPATIALITE_DECLARE int dump_geojson (sqlite3 *sqlite, char *table, char *geom_col, char *outfile_path, int precision, int option)
 Dumps a full geometry-table into an external GeoJSON file.
SPATIALITE_DECLARE int update_layer_statistic (sqlite3 *sqlite, const char *table, const char *column)
 Updates the LAYER_STATICS metadata table.

Detailed Description

Main SpatiaLite header file.


Function Documentation

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

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)
Returns:
0 on failure, any other value on success
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.

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
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
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
Returns:
0 on failure, any other value on success
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", "MULTIPOLYGON" or NULL
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)
Returns:
0 on failure, any other value on success
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
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.
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
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)
Returns:
0 on failure, any other value on success
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 actually exported rows
err_msgon completion will contain an error message (if any)
Returns:
0 on failure, any other value on success
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
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
SPATIALITE_DECLARE double math_round ( double  value)

A portable replacement for C99 round()

Parameters:
valuea double value
Returns:
the nearest integeral value
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
Note:
when two (or more) duplicated rows exist, only the first occurence will be preserved, then deleting any further occurrence.
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
Note:
this function is internally invoked by the SQL function InitSpatialMetadata(), and is not usually intended for direct use.
SPATIALITE_DECLARE void spatialite_cleanup ( )

Cleanup spatialite.

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

See also:
spatialite_init
SPATIALITE_DECLARE void spatialite_init ( int  verbose)

Initializes the library.

Parameters:
verboseif TRUE a short start-up message is shown on stderr
Note:
You absolutely must invoke this function before attempting to perform any other SpatiaLite's call.
Examples:
demo1.c, demo2.c, demo3.c, and demo4.c.
SPATIALITE_DECLARE int update_layer_statistic ( 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.
Returns:
0 on failure, the total count of processed entries on success
 All Data Structures Files Functions Variables Typedefs Defines