diff --git a/CHANGELOG.md b/CHANGELOG.md index fdaf769ba..a1a8be26b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ Adheres to [Semantic Versioning](http://semver.org/). ## 6.6.7 (TBD) +* GeoPackage user version 1.4.0 +* R-tree update trigger modifications * DAO column range support (including geometry envelopes & bounding boxes) to build where clauses & args for queries * oapi-features-json version 2.3.3 diff --git a/src/main/java/mil/nga/geopackage/GeoPackageConstants.java b/src/main/java/mil/nga/geopackage/GeoPackageConstants.java index 9c1adde54..9c7cf8b85 100644 --- a/src/main/java/mil/nga/geopackage/GeoPackageConstants.java +++ b/src/main/java/mil/nga/geopackage/GeoPackageConstants.java @@ -36,7 +36,7 @@ public class GeoPackageConstants { * * @since 1.2.1 */ - public static final int USER_VERSION = 10301; + public static final int USER_VERSION = 10400; /** * Expected magic number diff --git a/src/main/java/mil/nga/geopackage/extension/rtree/RTreeIndexCoreExtension.java b/src/main/java/mil/nga/geopackage/extension/rtree/RTreeIndexCoreExtension.java index a66b37abf..fe03a3af7 100644 --- a/src/main/java/mil/nga/geopackage/extension/rtree/RTreeIndexCoreExtension.java +++ b/src/main/java/mil/nga/geopackage/extension/rtree/RTreeIndexCoreExtension.java @@ -105,6 +105,8 @@ public abstract class RTreeIndexCoreExtension extends BaseExtension { /** * Trigger update 1 name + * + * @deprecated replaced by update6 and update7 */ public static final String TRIGGER_UPDATE1_NAME = "update1"; @@ -115,6 +117,8 @@ public abstract class RTreeIndexCoreExtension extends BaseExtension { /** * Trigger update 3 name + * + * @deprecated replaced by update5 */ public static final String TRIGGER_UPDATE3_NAME = "update3"; @@ -123,6 +127,21 @@ public abstract class RTreeIndexCoreExtension extends BaseExtension { */ public static final String TRIGGER_UPDATE4_NAME = "update4"; + /** + * Trigger update 5 name + */ + public static final String TRIGGER_UPDATE5_NAME = "update5"; + + /** + * Trigger update 6 name + */ + public static final String TRIGGER_UPDATE6_NAME = "update6"; + + /** + * Trigger update 7 name + */ + public static final String TRIGGER_UPDATE7_NAME = "update7"; + /** * Trigger delete name */ @@ -524,10 +543,13 @@ public void createAllTriggers(String tableName, String geometryColumnName, String idColumnName) { createInsertTrigger(tableName, geometryColumnName, idColumnName); - createUpdate1Trigger(tableName, geometryColumnName, idColumnName); + // createUpdate1Trigger(tableName, geometryColumnName, idColumnName); createUpdate2Trigger(tableName, geometryColumnName, idColumnName); - createUpdate3Trigger(tableName, geometryColumnName, idColumnName); + // createUpdate3Trigger(tableName, geometryColumnName, idColumnName); createUpdate4Trigger(tableName, geometryColumnName, idColumnName); + createUpdate5Trigger(tableName, geometryColumnName, idColumnName); + createUpdate6Trigger(tableName, geometryColumnName, idColumnName); + createUpdate7Trigger(tableName, geometryColumnName, idColumnName); createDeleteTrigger(tableName, geometryColumnName, idColumnName); } @@ -537,7 +559,7 @@ public void createAllTriggers(String tableName, String geometryColumnName, * *
* Conditions: Insertion of non-empty geometry - * Actions : Insert record into rtree + * Actions : Insert record into R-tree ** * @param tableName @@ -561,7 +583,7 @@ public void createInsertTrigger(String tableName, String geometryColumnName, *
* Conditions: Update of geometry column to non-empty geometry * No row ID change - * Actions : Update record in rtree + * Actions : Update record in R-tree ** * @param tableName @@ -570,6 +592,7 @@ public void createInsertTrigger(String tableName, String geometryColumnName, * geometry column name * @param idColumnName * id column name + * @deprecated replaced by update6 and update7 */ public void createUpdate1Trigger(String tableName, String geometryColumnName, String idColumnName) { @@ -585,7 +608,7 @@ public void createUpdate1Trigger(String tableName, *
* Conditions: Update of geometry column to empty geometry * No row ID change - * Actions : Remove record from rtree + * Actions : Remove record from R-tree ** * @param tableName @@ -610,8 +633,8 @@ public void createUpdate2Trigger(String tableName, * Conditions: Update of any column * Row ID change * Non-empty geometry - * Actions : Remove record from rtree for old {@literal } - * Insert record into rtree for new {@literal } + * Actions : Remove record from R-tree for old {@literal } + * Insert record into R-tree for new {@literal } * * * @param tableName @@ -620,6 +643,7 @@ public void createUpdate2Trigger(String tableName, * geometry column name * @param idColumnName * id column name + * @deprecated replaced by update5 */ public void createUpdate3Trigger(String tableName, String geometryColumnName, String idColumnName) { @@ -636,7 +660,7 @@ public void createUpdate3Trigger(String tableName, * Conditions: Update of any column * Row ID change * Empty geometry - * Actions : Remove record from rtree for old and new {@literal } + * Actions : Remove record from R-tree for old and new {@literal } * * * @param tableName @@ -654,12 +678,84 @@ public void createUpdate4Trigger(String tableName, executeSQL(sqlName, tableName, geometryColumnName, idColumnName); } + /** + * Create update 5 trigger + * + *
+ * Conditions: Update of any column + * Row ID change + * Non-empty geometry + * Actions : Remove record from R-tree for old {@literal } + * Insert record into R-tree for new {@literal } + *+ * + * @param tableName + * table name + * @param geometryColumnName + * geometry column name + * @param idColumnName + * id column name + */ + public void createUpdate5Trigger(String tableName, + String geometryColumnName, String idColumnName) { + + String sqlName = GeoPackageProperties.getProperty(TRIGGER_PROPERTY, + TRIGGER_UPDATE5_NAME); + executeSQL(sqlName, tableName, geometryColumnName, idColumnName); + } + + /** + * Create update 6 trigger + * + *
+ * Conditions: Update a non-empty geometry with another non-empty geometry + * Actions : Replace record from R-tree for {@literal } + *+ * + * @param tableName + * table name + * @param geometryColumnName + * geometry column name + * @param idColumnName + * id column name + */ + public void createUpdate6Trigger(String tableName, + String geometryColumnName, String idColumnName) { + + String sqlName = GeoPackageProperties.getProperty(TRIGGER_PROPERTY, + TRIGGER_UPDATE6_NAME); + executeSQL(sqlName, tableName, geometryColumnName, idColumnName); + } + + /** + * Create update 7 trigger + * + *
+ * Conditions: Update a null/empty geometry with a non-empty geometry + * Actions : Insert record into R-tree for new {@literal } + *+ * + * @param tableName + * table name + * @param geometryColumnName + * geometry column name + * @param idColumnName + * id column name + */ + public void createUpdate7Trigger(String tableName, + String geometryColumnName, String idColumnName) { + + String sqlName = GeoPackageProperties.getProperty(TRIGGER_PROPERTY, + TRIGGER_UPDATE7_NAME); + executeSQL(sqlName, tableName, geometryColumnName, idColumnName); + } + /** * Create delete trigger * *
* Conditions: Row deleted - * Actions : Remove record from rtree for old {@literal } + * Actions : Remove record from R-tree for old {@literal } ** * @param tableName @@ -887,6 +983,9 @@ public void dropAllTriggers(String tableName, String geometryColumnName) { dropUpdate2Trigger(tableName, geometryColumnName); dropUpdate3Trigger(tableName, geometryColumnName); dropUpdate4Trigger(tableName, geometryColumnName); + dropUpdate5Trigger(tableName, geometryColumnName); + dropUpdate6Trigger(tableName, geometryColumnName); + dropUpdate7Trigger(tableName, geometryColumnName); dropDeleteTrigger(tableName, geometryColumnName); } @@ -955,6 +1054,45 @@ public void dropUpdate4Trigger(String tableName, dropTrigger(tableName, geometryColumnName, TRIGGER_UPDATE4_NAME); } + /** + * Drop update 5 trigger + * + * @param tableName + * table name + * @param geometryColumnName + * geometry column name + */ + public void dropUpdate5Trigger(String tableName, + String geometryColumnName) { + dropTrigger(tableName, geometryColumnName, TRIGGER_UPDATE5_NAME); + } + + /** + * Drop update 6 trigger + * + * @param tableName + * table name + * @param geometryColumnName + * geometry column name + */ + public void dropUpdate6Trigger(String tableName, + String geometryColumnName) { + dropTrigger(tableName, geometryColumnName, TRIGGER_UPDATE6_NAME); + } + + /** + * Drop update 7 trigger + * + * @param tableName + * table name + * @param geometryColumnName + * geometry column name + */ + public void dropUpdate7Trigger(String tableName, + String geometryColumnName) { + dropTrigger(tableName, geometryColumnName, TRIGGER_UPDATE7_NAME); + } + /** * Drop delete trigger * diff --git a/src/main/resources/geopackage.properties b/src/main/resources/geopackage.properties index 955d84d41..8da323104 100644 --- a/src/main/resources/geopackage.properties +++ b/src/main/resources/geopackage.properties @@ -76,6 +76,9 @@ geopackage.extensions.rtree_index.sql.trigger.update1=rtree_trigger_update1 geopackage.extensions.rtree_index.sql.trigger.update2=rtree_trigger_update2 geopackage.extensions.rtree_index.sql.trigger.update3=rtree_trigger_update3 geopackage.extensions.rtree_index.sql.trigger.update4=rtree_trigger_update4 +geopackage.extensions.rtree_index.sql.trigger.update5=rtree_trigger_update5 +geopackage.extensions.rtree_index.sql.trigger.update6=rtree_trigger_update6 +geopackage.extensions.rtree_index.sql.trigger.update7=rtree_trigger_update7 geopackage.extensions.rtree_index.sql.trigger.delete=rtree_trigger_delete geopackage.extensions.rtree_index.sql.trigger.drop=rtree_trigger_drop geopackage.extensions.2d_gridded_coverage=http://docs.opengeospatial.org/is/17-066r1/17-066r1.html diff --git a/src/main/resources/sql/extension/rtree/rtree_trigger_update5 b/src/main/resources/sql/extension/rtree/rtree_trigger_update5 new file mode 100644 index 000000000..ec853d788 --- /dev/null +++ b/src/main/resources/sql/extension/rtree/rtree_trigger_update5 @@ -0,0 +1,11 @@ +CREATE TRIGGER "rtree_