new SQL functions introduced since version 4.3.0
TOC - Table Of Contents
- Inherited from the aborted 4.2.1 Release Candidate
- Persistent Connection Modifiers
- Trigonometry
- Pathname manipulation
- URL manipulation
- Affine Transformations support
- Ground Control Points support
- SE Styling helpers
- Extended SRID Inspection
1 - Inherited from the aborted 4.2.1 Release Candidate
During November 2014 an earlier 4.2.1-RC was released, but no 4.2.1-STABLE will be never released simply because 4.2.1 progressively continued to evolve step by step until it finally become 4.3.0.So all new SQL functions introduced by 4.2.1-RC have not to be considered as integral part of 4.3.0; anyway for the sake of clarity you can check the corresponding documentation from this separate Wiki page
2 - Persistent Connection Modifiers
Starting since version 4.3.0 libspatialite has the capability to support few modifiers affecting the behavior of several SQL functions.Such modifiers are connection-persistent, i.e. they'll be active during all the life-cycle of the current connection (unless explicitly reset); anyway they'll never propagate outside the specific context of the current connection, and when the connection will be closed they'll completely disappear leaving absolutely no persistent trace.
Modifier | Intended Target | Effect | Notes |
---|---|---|---|
GPKG mode |
| When GPKG mode is actively enabled the following changes will happen:
| GPKG mode can be effectively enabled only when the current connection target is a fully qualified GeoPackage database. If the current database target is not a GeoPackage any attempt to activate the GPKG mode will be always forbidden. |
GPKG amphibious mode |
| When GPKG amphibious mode is actively enabled the following changes will happen:
| Simply intended to be an universally compatible mode for unsophisticated readers. GPKG mode and GPKG amphibious mode are mutually exclusive options. |
Decimal Precision |
| Explicitly selects the preferred number of decimal digits to be represented when printing floating point values (coordinates) in their textual representation. The implicit default setting is using 6 decimal digits. | spatialite_gui will honor this setting for all floating point values shown on the screen and coming from some SQL resultset. |
SQL examples
SELECT EnableGpkgMode(); SELECT DisableGpkgMode(); SELECT GetGpkgMode(); <-- will return 1 or 0 accordingly to the current setting SELECT EnableAmphibiousGpkgMode(); SELECT DisableAmphibiousGpkgMode(); SELECT GetAmphibiousGpkgMode(); <-- will return 1 or 0 accordingly to the current setting SELECT SetDecimalPrecision(8); SELECT SetDecimalPrecision(.1); <-- any negative value will reset to the default initial setting SELECT GetDecimalPrecision(); <-- will return the current setting
3 - Trigonometry
SELECT atan2 ( y double, x double );The two args variant of arc tangent is now supported.
Returns the principal value of the arc tangent of y/x in radians, using the signs of the two arguments to determine the quadrant of the result. The return value is in the range (-pi, pi).
For more detail please check man atan2
4 - Pathname manipulation
MS-DOS / Windows paths:SELECT DirNameFromPath( 'C:\users\sandro\my_data\arezzo\strade.shp' ); ------ C:\users\sandro\my_data\arezzo\ SELECT FullFileNameFromPath( 'C:\users\sandro\my_data\arezzo\strade.shp' ); ------ strade.shp SELECT FileNameFromPath( 'C:\users\sandro\my_data\arezzo\strade.shp' ); ------ strade SELECT FileExtFromPath( 'C:\users\sandro\my_data\arezzo\strade.shp' ); ------ shpUnix / Linux paths:
SELECT DirNameFromPath( '/home/sandro/my_data/arezzo/strade.shp' ); ------ /home/sandro/my_data/arezzo/ SELECT FullFileNameFromPath( '/home/sandro/my_data/arezzo/strade.shp' ); ------ strade.shp SELECT FileNameFromPath( '/home/sandro/my_data/arezzo/strade.shp' ); ------ strade SELECT FileExtFromPath( '/home/sandro/my_data/arezzo/strade.shp' ); ------ shpThese functions are mainly intended to facilitate the task of writing complex SQL scripts performing massive import / export operations.
The following could be a rather realistic example:
-- creating a table intended to store many digital pictures CREATE TABLE my_pics ( id INTEGER PRIMARY KEY, photo BLOB, input_path TEXT NOT NULL); -- populating the list of all pictures to be loaded into the table BEGIN; INSERT INTO my_pics VALUES (NULL, NULL, '../my_pics/nikon/pic0001.JPG'); ... INSERT INTO my_pics VALUES (NULL, NULL, '../my_pics/canon/IMG000001.jpeg'); ... INSERT INTO my_pics VALUES (NULL, NULL, '../my_pics/misc/florence.jpg'); INSERT INTO my_pics VALUES (NULL, NULL, '../my_pics/misc/Rome.jpeg'); INSERT INTO my_pics VALUES (NULL, NULL, '../my_pics/misc/VENICE.JPG'); COMMIT; -- loading all pictures into the DB UPDATE my_pics SET photo = BlobFromFILE(input_path); -- exporting all pictures into the same dir with normalized names SELECT BlobToFile(photo, './output_dir/' || Lower(FileNameFromPath(input_path)) || '.jpg');
5 - URL manipulation
Two new SQL functions are now available supporting URL percent encoding:- EncodeURL ( text ) : text
- DecodeURL ( text ) : text
The following could be a rather realistic example:
CREATE TABLE cgi_requests ( id INTEGER PRIMARY KEY, arg1 TEXT NOT NULL, arg2 TEXT NOT NULL, request_url TEXT); INSERT INTO cgi_requests VALUES (NULL, 'Den Haag', 'fist class', NULL); INSERT INTO cgi_requests VALUES (NULL, 'Antwerpen', '***any***', NULL); INSERT INTO cgi_requests VALUES (NULL, '''s-Hertogenbosch', 'second class', NULL); UPDATE cgi_requests SET request_url = 'http://www.someserver.org/cgi-bin/someservice?arg1=' || EncodeURL(arg1) || '&arg2=' || EncodeURL(arg2); SELECT request_url FROM cgi_requests; ------ http://www.someserver.org/cgi-bin/someservice?arg1=Den+Haag&arg2=fist+class http://www.someserver.org/cgi-bin/someservice?arg1=Antwerpen&arg2=%2a%2a%2aany%2a%2a%2a http://www.someserver.org/cgi-bin/someservice?arg1=%27s-Hertogenbosch&arg2=second+class SELECT DecodeURL(request_url) FROM cgi_requests; ------ http://www.someserver.org/cgi-bin/someservice?arg1=Den Haag&arg2=fist class http://www.someserver.org/cgi-bin/someservice?arg1=Antwerpen&arg2=***any*** http://www.someserver.org/cgi-bin/someservice?arg1='s-Hertogenbosch&arg2=second class
6 - Affine Transformations support
The new ATM (Affine Tranformation Matrix) module is fully documented in this separate Wiki page7 - Ground Control Points support
The new GCP (Ground Control Points) module is fully documented in this separate Wiki page8 - SE Styling helpers
The following SQL functions are intended to fully support SE Styling.Note: any direct interaction with SE Styling meta-tables should be always considered a risky and dangerous operation, and should be always carefully avoided.
This is because the meta-tables physical layout could easily change in future versions; anyway the supporting SQL functions can be safely assumed to be stable during the time and will adapt to any future change in the most appropriate way.
The following list enumerates all SE Styling related SQL function by homogeneous groups:
- Raster Coverages (auxiliaries; complementing the main SQL functions implemented in RasterLite2)
SE_RegisterRasterCoverageSrid ( coverage_name String , srid Integer ) : Integer SE_UnregisterRasterCoverageSrid ( coverage_name String , srid Integer ) : Integer SE_RegisterRasterCoverageKeyword ( coverage_name String , keyword String ) : Integer SE_UnregisterRasterCoverageKeyword ( coverage_name String , keyword String ) : Integer SE_UpdateRasterCoverageExtent () : Integer> SE_UpdateRasterCoverageExtent ( transaction Integer ) : Integer SE_UpdateRasterCoverageExtent ( coverage_name String ) : Integer SE_UpdateRasterCoverageExtent ( coverage_name String , transaction Integer ) : Integer
- Vector Coverages
SE_RegisterVectorCoverage ( coverage_name String , f_table_name String , f_geometry_column Sting ) : Integer SE_RegisterVectorCoverage ( coverage_name String , f_table_name String , f_geometry_column Sting , title String , abstract String ) : Integer SE_UnregisterVectorCoverage( coverage_name String ) : Integer SE_SetVectorCoverageInfos ( coverage_name String , title String , abstract String ) : Integer SE_RegisterVectorCoverageSrid ( coverage_name String , srid Integer ) : Integer SE_UnregisterVectorCoverageSrid ( coverage_name String , srid Integer ) : Integer SE_RegisterVectorCoverageeKeyword ( coverage_name String , keyword String ) : Integer SE_UnregisterVectorCoverageKeyword ( coverage_name String , keyword String ) : Integer SE_UpdateVectorCoverageExtent () : Integer SE_UpdateVectorCoverageExtent ( transaction Integer ) : Integer SE_UpdateVectorCoverageExtent ( coverage_name String ) : Integer SE_UpdateVectorCoverageExtent ( coverage_name String , transaction Integer ) : Integer
- Complex Layers (Groups aggregating many elementary Layers)
SE_SetStyledGroupInfosx ( group_name String , title String , abstract String ) : Integer SE_UnregisterStyledGroup ( group_name String ) : Integer SE_RegisterStyledGroupRaster ( group_name String , coverage_name String ) : Integer SE_RegisterStyledGroupVector ( group_name String , coverage_name String ) : Integer SE_SetStyledGroupLayerPaintOrder ( item_id Integer , paint_order Integer ) : Integer SE_SetStyledGroupRasterPaintOrder ( group_name Text , coverage_name String , paint_order Integer ) : Integer SE_SetStyledGroupVectorPaintOrder ( group_name Text , coverage_name String , paint_order Integer ) : Integer SE_UnregisterStyledGroupLayer ( item_id Integer ) : Integer SE_UnregisterStyledGroupRaster ( group_name Text , coverage_name String ) : Integer SE_UnregisterStyledGroupVector ( group_name Text , coverage_name String ) : Integer
- External Graphic Resources
SE_RegisterExternalGraphic ( xlink_href String , resource BLOB ) : Integer SE_RegisterExternalGraphic ( xlink_href String , resource BLOB , title String , abstract String , file_name String ) : Integer SE_UnregisterExternalGraphic ( xlink_href String ) : Integer
- Raster SE Styles
SE_RegisterRasterStyle ( style BLOB ) : Integer SE_UnregisterRasterStyle ( style_id Integer [ , remove_all Integer ] ) : Integer SE_UnregisterRasterStyle ( style_name Text [ , remove_all Integer ] ) : Integer SE_ReloadRasterStyle ( style_id Integer , style BLOB ) : Integer SE_ReloadRasterStyle ( style_name Text , style BLOB ) : Integer
- Vector SE Styles
SE_RegisterVectorStyle ( style BLOB ) : Integer SE_UnregisterVectorStyle ( style_id Integer [ , remove_all Integer ] ) : Integer SE_UnregisterVectorStyle ( style_name Text [ , remove_all Integer ] ) : Integer SE_ReloadVectorStyle ( style_id Integer , style BLOB ) : Integer SE_ReloadVectorStyle ( style_name Text , style BLOB ) : Integer
- SLD Styles for Complex Layers
SE_RegisterGroupStyle ( style BLOB ) : Integer SE_UnregisterGroupStyle ( style_id Integer [ , remove_all Integer ] ) : Integer SE_UnregisterGroupStyle ( style_name Text [ , remove_all Integer ] ) : Integer SE_ReloadGroupStyle ( style_id Integer , style BLOB ) : Integer SE_ReloadGroupStyle ( style_name Text , style BLOB ) : Integer
- Raster Styled Layers
SE_RegisterRasterStyledLayer ( coverage_name String , style_id Integer ) : Integer SE_RegisterRasterStyledLayer ( coverage_name String , style_name Text ) : Integer SE_UnregisterRasterStyledLayer ( coverage_name String , style_id Integer ) : Integer SE_UnregisterRasterStyledLayer ( coverage_name String , style_name Text ) : Integer
- Vector Styled Layers
SE_RegisterVectorStyledLayer ( coverage_name String , style_id Integer ) : Integer SE_RegisterVectorStyledLayer ( coverage_name String , style_name Text ) : Integer SE_UnregisterVectorStyledLayer ( coverage_name String , style_id Integer ) : Integer SE_UnregisterVectorStyledLayer ( coverage_name String , style_name Text ) : Integer
- Styled Complex Layers
SE_RegisterStyledGroupStyle ( group_name String , style_id Integer ) : Integer SE_RegisterStyledGroupStyle ( group_name String , style_name Text ) : Integer SE_UnregisterStyledGroupStyle ( group_name String , style_id Integer ) : Integer SE_UnregisterStyledGroupStyle ( group_name String , style_name Text ) : Integer
8 - Extended SRID Inspection
This new module is fully documented in this separate Wiki pageback