| Ticket Hash: | fb96512d3cb68be8d271d85255d6163629611cf1 | |||
| Title: | GetSpatialIndexExtent: missing support for GeoPackages | |||
| Status: | Fixed | Type: | Feature_Request | |
| Severity: | Minor | Priority: | Immediate | |
| Subsystem: | Resolution: | Fixed | ||
| Last Modified: | 2018-06-19 13:32:08 | |||
| Version Found In: | ||||
| User Comments: | ||||
|
mj10777 added on 2018-06-11 05:55:46:
The new 'GetSpatialIndexExtent' does not support GeoPackage, despite the fact that GeoPackage also used RTree for SpatialIndexes. When 'fnct_GetSpatialIndexExtent', the 'gpkg_layout' could be determined and passed on to get_spatial_index_extent.
if (checkSpatialMetaData_ex (sqlite,db_prefix) == 4)
{
gpkg_layout = 1;
}
get_spatial_index_extent could then build the needed
table_name primary-Key of table_name
char *idx_pkid = "pkid";
...
if (!gpkg_layout)
{
sql_statement = sqlite3_mprintf ("SELECT srid FROM \"%s\".geometry_columns "
"WHERE Upper(f_table_name) = Upper(%Q) "
"AND Upper(f_geometry_column) = Upper(%Q) AND spatial_index_enabled = 1",
xprefix, table, geom);
}
else
{
sql_statement = sqlite3_mprintf ("SELECT srs_id FROM \"%s\".gpkg_geometry_columns "
"WHERE Upper(table_name) = Upper(%Q) "
"AND Upper(column_name) = Upper(%Q)",
xprefix, table, geom);
}
...
if (!gpkg_layout)
{
idx_name = sqlite3_mprintf ("idx_%s_%s", table, geom);
}
else
{
idx_name = sqlite3_mprintf ("rtree_%s_%s", table, geom);
idx_pkid = "id";
}
which would be sent to gaiaGetRTreeFullExtent
/**
Will attempt to retrieve the Full Extent from an R*Tree
\param db_handle handle to the current SQLite connection
\param prefix schema prefix identifying the DB containing the R*Tree\n
"main" always identifies the main DB (primary, not Attached).
\param name the name of the R*Tree table [Spatialite: idx_ ; GeoPackage: rtree_ | table_name_geometry_name]
\param srid the intended SRID for the R*Tree
\param pkid the Primary-Key of the R*Tree table [Spatialite: pkid ; GeoPackage: id]
\return a Rectangle Geometry corresponding to the Full Extent,\n
NULL on failure.
*/
SPATIALITE_DECLARE gaiaGeomCollPtr gaiaGetRTreeFullExtent (sqlite3 *
db_handle,
const char
*db_prefix,
const char *name,
int srid,
const char *pkid);
In gaiaGetRTreeFullExtent only the sql needs to be changed with the given primary-key to query:
sql =
sqlite3_mprintf
("SELECT %s FROM \"%s\".\"%s\" WHERE %s MATCH rtree_bbox(1)",
pkid,xprefix, xname,pkid );
This would offer a transparent way for such queries when needed:
-- or with ST_AsBinary instead of AsEWKT
SELECT
AsEWKT(GetSpatialIndexExtent('main','middle_earth_farthings','eur_polygon')) AS extent_spatialite_view,
AsEWKT(GetSpatialIndexExtent('a','middle_earth_polygons','geom')) AS extent_geopackage;
SRID=3035;POLYGON((1891671.249999999 711161.625,6059866.5 711161.625,6059866.5 4278152.5,1891671.249999999 4278152.5,1891671.249999999 711161.625)) SRID=3035;POLYGON((1891671.249999999 711161.625,6059866.5 711161.625,6059866.5 4278152.5,1891671.249999999 4278152.5,1891671.249999999 711161.625)) sandro added on 2018-06-19 13:32:08: fixed by commit d56c06c4aa | ||||