#4269 closed task (fixed)
Spatialite write support improvements
Reported by: | Even Rouault | Owned by: | spatialite |
---|---|---|---|
Priority: | normal | Milestone: | 1.9.0 |
Component: | OGR_SF | Version: | unspecified |
Severity: | normal | Keywords: | |
Cc: | a.furieri@… |
Description
Extract from http://lists.osgeo.org/pipermail/gdal-dev/2011-September/030287.html
Hi all, just a quick social introduction: I'm the main developer and maintainer of the SpatiaLite DBMS. I'm glad to submit to your attention the attached patch-set, intended to add full and robust support for SpatiaLite [OGR/SQLite driver]. some months ago I've already contributed a patch-set for OGR effectively supporting 2.5D geometries [recent versions of SpatiaLite]: and thanks to Even Rouault's kind cooperation that patch-set was duly accepted and committed to SVN-trunk. Anyway, my previous patch-set was simply focused on "read" modes: the present patch-set is focused instead on effectively supporting "write" modes as well, thus allowing ogr2ogr to create fully valid SpatiaLite own DB-files. just a short technical reminder: supporting "read" ops doesn't strictly require OGR to be linked against libspatialite. But any attempt to perform "write" ops skipping at all the expected libspatialite support will simply create a corrupted (i.e. broken, useless) DB-file, not a genuine SpatiaLite own. ogr2ogr options: ================ the current implementation already supported several SpatiaLite specific options: -dsco SPATIALITE=YES (enabling SpatiaLite DB creation) -lco SPATIAL_INDEX=YES/NO (creating or not a Spatial Index) I left both options completely unaffected. -INIT_WITH_EPSG=YES/NO (populating or not the "spatial_ref_sys" table) I've changed the behaviour of this option: * if libspatialite 2.3.1 (or any previous) is linked to ogr2ogr, then the option behaviour is unaffected * if libspatialite 2.4.0 (or any subsequent) is linked to ogr2ogr, this option will be always ignored because any recent version automatically loads the whole EPSG dataset into "spatial_ref_sys" while creating a new DB. I've introduced a further SpatiaLite specific option: -lco FORCE_2D=YES/NO interpretations is the following one: * if libspatialite 2.3.1 is linked to ogr2ogr, then this option is completely ignored, because v.2.3.1 simply supports 2D. so, forcing any geometry to 2D is silently implied anyway. * if libspatialite 2.4.0 (or any subsequent) is linked to ogr2ogr, this option will be honoured as specified by the user. about technical implementation: =============================== ogr_sqlite.h ------------ I've introduced (several classes and methods affected) a new boolean variable: bSpatialite2D this is intended to implement the FORCE_2D option ogrsqlitetablelayer.cpp ----------------------- I've simply added support to bSpatialite2D ogrsqlitedatasource.cpp ----------------------- OGRSQLiteDataSource::CreateLayer() I've completely replaced the code implementing creation of any SpatiaLite table and geometry. Now the appropriate SpatiaLite's own SQL method AddGeometryColumn() is correctly invoked, avoiding at all any direct access to "geometry_columns". (any such attempt will easily produce an inconsistent DB) ogrsqlitedriver.cpp ------------------- OGRSQLiteDriver::CreateDataSource() I've completely changed the implementation of DB creation: now the appropriate SpatiaLite's own SQL method InitSpatialMetadata() is correctly invoked. (this too avoids generating broken and inconsistent DB-files). And I've consistently handled INIT_WITH_EPSG as explained before. ogrsqlitelayer.cpp ------------------ OGRSQLiteLayer::ComputeSpatiaLiteGeometrySize() OGRSQLiteLayer::ExportSpatiaLiteGeometryInternal() OGRSQLiteLayer::ExportSpatiaLiteGeometry() Code arranged as appropriate, so to consistently honour the FORCE_2D option accordingly to the library version linked to OGR. drv_sqlite.html --------------- updated documentation. misc ---- I've added some 'contributing' disclaimer here and there, acknowledging the financial support offered by Tuscany Region Govt. other infos ----------- the proposed patch-set doesn't impacts at all with the existing sqlite/FDO implementation. any libspatialite version (from the nowadays obsolete 2.3.1 to the latest 3.0.0) is fully supported. and finally OGR could be used to create fully valid SpatiaLite's own DB-files without any inconsistency: surely a big improvement for interoperability. ============================================
Attachments (1)
Change History (4)
by , 13 years ago
Attachment: | spatialite_patch_ticket4269.patch added |
---|
comment:1 by , 13 years ago
Milestone: | → 1.9.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
r23133 /trunk/gdal/ogr/ogrsf_frmts/sqlite/ (6 files): Spatialite write support improvements (Sandro Furieri's original patch, #4269)
r23134 /trunk/autotest/ogr/ogr_sqlite.py: Adjustments to ogr_sqlite.py due to previous commit (#4269)
r23135 /trunk/gdal/ogr/ogrsf_frmts/sqlite/ (4 files): Minor changes to r23133 : add OGRSQLiteGetSpatialiteVersionNumber() to factor code, use OGRToOGCGeomType() to convert from geometry type enum to string, prevent creation of spatialite DB when spatialite support is enabled but SPATIALITE_LOAD=NO defined (#4269)
comment:2 by , 13 years ago
comment:3 by , 13 years ago
r23158 /trunk/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitedatasource.cpp: Spatialite: CreateLayer(): don't allow creating layers in a spatialite DB without libspatialite loaded, only allow spatialite geometry format in spatialite DB (#4269)
Sandro's patch