diff --git a/README.md b/README.md index 104803e..c2e0de9 100644 --- a/README.md +++ b/README.md @@ -422,6 +422,10 @@ Support provided for the following constraint types: ## Release History +### v0.7.2 +* bump `user_version` to reflect adopted version 1.4.0 of OGC GeoPackage +* updated r-tree triggers based on changes made in 1.4.0 + ### v0.7.1 * ensure support for Python 3.12 and update documentation / configuration diff --git a/fudgeo/__init__.py b/fudgeo/__init__.py index adee03f..239578b 100644 --- a/fudgeo/__init__.py +++ b/fudgeo/__init__.py @@ -4,7 +4,7 @@ """ -__version__ = '0.7.1' +__version__ = '0.7.2' if __name__ == '__main__': diff --git a/fudgeo/geopkg.sql b/fudgeo/geopkg.sql index c239960..87feb86 100644 --- a/fudgeo/geopkg.sql +++ b/fudgeo/geopkg.sql @@ -1,5 +1,5 @@ PRAGMA application_id=0x47504B47; -PRAGMA user_version=10301; +PRAGMA user_version=10400; -- TABLES diff --git a/fudgeo/sql.py b/fudgeo/sql.py index 8ab77c3..429da0c 100644 --- a/fudgeo/sql.py +++ b/fudgeo/sql.py @@ -303,20 +303,6 @@ ); END; - /* Conditions: Update of geometry column to non-empty geometry - No row ID change - Actions : Update record in rtree */ - CREATE TRIGGER "rtree_{0}_{1}_update1" AFTER UPDATE OF "{1}" ON "{0}" - WHEN OLD."{2}" = NEW."{2}" AND - (NEW."{1}" NOTNULL AND NOT ST_IsEmpty(NEW."{1}")) - BEGIN - INSERT OR REPLACE INTO "rtree_{0}_{1}" VALUES ( - NEW."{2}", - ST_MinX(NEW."{1}"), ST_MaxX(NEW."{1}"), - ST_MinY(NEW."{1}"), ST_MaxY(NEW."{1}") - ); - END; - /* Conditions: Update of geometry column to empty geometry No row ID change Actions : Remove record from rtree */ @@ -355,6 +341,35 @@ DELETE FROM "rtree_{0}_{1}" WHERE id IN (OLD."{2}", NEW."{2}"); END; + /* Conditions: Update a non-empty geometry with another non-empty geometry + Actions : Replace record from R-tree for identifier */ + CREATE TRIGGER "rtree_{0}_{1}_update6" AFTER UPDATE OF "{1}" ON "{0}" + WHEN OLD."{2}" = NEW."{2}" AND + (NEW."{1}" NOTNULL AND NOT ST_IsEmpty(NEW."{1}")) AND + (OLD."{1}" NOTNULL AND NOT ST_IsEmpty(OLD."{1}")) + BEGIN + UPDATE "rtree_{0}_{1}" SET + minx = ST_MinX(NEW."{1}"), + maxx = ST_MaxX(NEW."{1}"), + miny = ST_MinY(NEW."{1}"), + maxy = ST_MaxY(NEW."{1}") + WHERE id = NEW."{2}"; + END; + + /* Conditions: Update a null/empty geometry with a non-empty geometry + Actions : Insert record into R-tree for new identifier */ + CREATE TRIGGER "rtree_{0}_{1}_update7" AFTER UPDATE OF "{1}" ON "{0}" + WHEN OLD."{2}" = NEW."{2}" AND + (NEW."{1}" NOTNULL AND NOT ST_IsEmpty(NEW."{1}")) AND + (OLD."{1}" ISNULL OR ST_IsEmpty(OLD."{1}")) + BEGIN + INSERT INTO "rtree_{0}_{1}" VALUES ( + NEW."{2}", + ST_MinX(NEW."{1}"), ST_MaxX(NEW."{1}"), + ST_MinY(NEW."{1}"), ST_MaxY(NEW."{1}") + ); + END; + /* Conditions: Row deleted Actions : Remove record from rtree for old identifier */ CREATE TRIGGER "rtree_{0}_{1}_delete" AFTER DELETE ON "{0}" diff --git a/pyproject.toml b/pyproject.toml index 16bc5ac..ce421ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "fudgeo" -version = "0.7.1" +version = "0.7.2" description = """\ GeoPackage support from Python. fudgeo is a lightweight package \ for creating OGC GeoPackages, Feature Classes, and Tables. Easily \ diff --git a/tests/test_geopkg.py b/tests/test_geopkg.py index 5b42eb5..7d7252e 100644 --- a/tests/test_geopkg.py +++ b/tests/test_geopkg.py @@ -186,14 +186,14 @@ def test_create_table_drop_table(tmp_path, fields, name, ogr_contents, has_table ('SEL;ECT', False, 0, False), ('SEL ECT', True, 4, False), ('SEL ECT', False, 0, False), - ('ASDF', True, 10, True), - ('ASDF', False, 6, True), - ('SELECT', True, 10, True), - ('SELECT', False, 6, True), - ('SEL;ECT', True, 10, True), - ('SEL;ECT', False, 6, True), - ('SEL ECT', True, 10, True), - ('SEL ECT', False, 6, True), + ('ASDF', True, 11, True), + ('ASDF', False, 7, True), + ('SELECT', True, 11, True), + ('SELECT', False, 7, True), + ('SEL;ECT', True, 11, True), + ('SEL;ECT', False, 7, True), + ('SEL ECT', True, 11, True), + ('SEL ECT', False, 7, True), ]) def test_create_feature_class(tmp_path, fields, name, ogr_contents, trigger_count, add_index): """ @@ -232,14 +232,14 @@ def test_create_feature_class(tmp_path, fields, name, ogr_contents, trigger_coun ('SEL;ECT', False, False, 0, False), ('SEL ECT', True, True, 2, False), ('SEL ECT', False, False, 0, False), - ('ASDF', True, True, 8, True), - ('ASDF', False, False, 6, True), - ('SELECT', True, True, 8, True), - ('SELECT', False, False, 6, True), - ('SEL;ECT', True, True, 8, True), - ('SEL;ECT', False, False, 6, True), - ('SEL ECT', True, True, 8, True), - ('SEL ECT', False, False, 6, True), + ('ASDF', True, True, 9, True), + ('ASDF', False, False, 7, True), + ('SELECT', True, True, 9, True), + ('SELECT', False, False, 7, True), + ('SEL;ECT', True, True, 9, True), + ('SEL;ECT', False, False, 7, True), + ('SEL ECT', True, True, 9, True), + ('SEL ECT', False, False, 7, True), ]) def test_create_feature_drop_feature(tmp_path, fields, name, ogr_contents, has_table, trigger_count, add_index): """