Revision: 6237
http://sourceforge.net/p/jump-pilot/code/6237
Author: elnico
Date: 2020-02-12 14:16:26 +0000 (Wed, 12 Feb 2020)
Log Message:
-----------
fix bug in Spatialite datasources management, where spatial index query was not
built even if a spatial index was defined on the geometric column.
Also removed debug comments preventing spatialite to be detected
Modified Paths:
--------------
core/trunk/ChangeLog
core/trunk/src/com/vividsolutions/jump/datastore/GeometryColumn.java
core/trunk/src/com/vividsolutions/jump/datastore/spatialdatabases/SpatialDatabasesDSMetadata.java
core/trunk/src/com/vividsolutions/jump/datastore/spatialite/SpatialiteDSMetadata.java
core/trunk/src/com/vividsolutions/jump/datastore/spatialite/SpatialiteSQLBuilder.java
Modified: core/trunk/ChangeLog
===================================================================
--- core/trunk/ChangeLog 2020-02-11 10:23:54 UTC (rev 6236)
+++ core/trunk/ChangeLog 2020-02-12 14:16:26 UTC (rev 6237)
@@ -5,6 +5,10 @@
* Changes.txt updated until here **********************************************
+2020-02-12 Nicolas Ribot
+ * fix bug in Spatialite datasources management, where spatial index query
was not built
+ even if a spatial index was defined on the geometric column
+
2020-01-26 mmichaud <[email protected]>
* FR#265 : add a plugin to make line from ordered points
* fix bug in MakeValidOp
Modified: core/trunk/src/com/vividsolutions/jump/datastore/GeometryColumn.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/datastore/GeometryColumn.java
2020-02-11 10:23:54 UTC (rev 6236)
+++ core/trunk/src/com/vividsolutions/jump/datastore/GeometryColumn.java
2020-02-12 14:16:26 UTC (rev 6237)
@@ -8,7 +8,7 @@
private String name;
private int srid = 0;
private String type = "Geometry";
- private boolean indexed = false;
+ private Boolean indexed = null;
private int coordDimension = 2;
public GeometryColumn(String name) {
@@ -90,11 +90,11 @@
", srid=" + srid + ")";
}
- public boolean isIndexed() {
+ public Boolean isIndexed() {
return indexed;
}
- public void setIndexed(boolean indexed) {
+ public void setIndexed(Boolean indexed) {
this.indexed = indexed;
}
}
Modified:
core/trunk/src/com/vividsolutions/jump/datastore/spatialdatabases/SpatialDatabasesDSMetadata.java
===================================================================
---
core/trunk/src/com/vividsolutions/jump/datastore/spatialdatabases/SpatialDatabasesDSMetadata.java
2020-02-11 10:23:54 UTC (rev 6236)
+++
core/trunk/src/com/vividsolutions/jump/datastore/spatialdatabases/SpatialDatabasesDSMetadata.java
2020-02-12 14:16:26 UTC (rev 6237)
@@ -279,7 +279,9 @@
if (! datasetNames.contains(table)) {
datasetNames.add(table);
}
- // datastoreLayers
+ // datastoreLayers:
+ // 2020-02-12: caution here; geometryColumn is built without
index info
+ // this info is retrieved as necessary by specialized classes
GeometryColumn geo = new GeometryColumn(
resultSet.getString(3),
resultSet.getInt(4),
Modified:
core/trunk/src/com/vividsolutions/jump/datastore/spatialite/SpatialiteDSMetadata.java
===================================================================
---
core/trunk/src/com/vividsolutions/jump/datastore/spatialite/SpatialiteDSMetadata.java
2020-02-11 10:23:54 UTC (rev 6236)
+++
core/trunk/src/com/vividsolutions/jump/datastore/spatialite/SpatialiteDSMetadata.java
2020-02-12 14:16:26 UTC (rev 6237)
@@ -189,6 +189,7 @@
* Overriden to deal with indexed geo columns, as queries to get features
are different
* if spatial index is detected on the column.
* Buids a GeometryColumn object with 5 params ctor.
+ * TODO: no more used now all layers info are retrieved at once ? refactor
* @param sql
* @param datasetName
* @return
@@ -290,17 +291,17 @@
// tries to load spatialite, assuming it is available on the system's path
Statement stmt = null;
try {
-// stmt = conn.getJdbcConnection().createStatement();
-// stmt.executeUpdate("SELECT load_extension('mod_spatialite')");
-// // ex is thrown if extension cannot be loaded
-// this.spatialiteLoaded = true;
-// ResultSet rs = stmt.executeQuery("select spatialite_version()");
-// rs.next();
-// this.setSpatialiteVersion(rs.getString(1));
-//
-// JUMPWorkbench.getInstance().getFrame().log(
-// "SpatialDatabasesPlugin: Spatialite extension loaded for this
connexion, version: "
-// + this.getSpatialiteVersion(), this.getClass());
+ stmt = conn.getJdbcConnection().createStatement();
+ stmt.executeUpdate("SELECT load_extension('mod_spatialite')");
+ // ex is thrown if extension cannot be loaded
+ this.spatialiteLoaded = true;
+ ResultSet rs = stmt.executeQuery("select spatialite_version()");
+ rs.next();
+ this.setSpatialiteVersion(rs.getString(1));
+
+ JUMPWorkbench.getInstance().getFrame().log(
+ "SpatialDatabasesPlugin: Spatialite extension loaded for this
connexion, version: "
+ + this.getSpatialiteVersion(), this.getClass());
} catch (Exception e) {
JUMPWorkbench.getInstance().getFrame().log(
"SpatialDatabasesPlugin: CANNOT load Spatialite Extention
(mod_spatialite), reason:"
@@ -446,7 +447,8 @@
}
public boolean isSpatialiteLoaded() {
- return spatialiteLoaded;
+ // TODO: clean up type detection: geopackage vs spatialite
+ return spatialiteLoaded || this.geometryColumnsLayout ==
GeometryColumnsLayout.OGC_GEOPACKAGE_LAYOUT;
}
public String getSpatialiteVersion() {
@@ -471,7 +473,7 @@
* @param datasetName the name of the dataset this column belongs to
* @param gc the geometry column to set
*/
- private void setIndexInfo(String datasetName, final GeometryColumn gc) {
+ protected void setIndexInfo(String datasetName, final GeometryColumn gc) {
String q = String.format(Locale.US, spatialIndexQuery, datasetName,
gc.getName());
try {
JDBCUtil.execute(
@@ -521,3 +523,4 @@
}
}
+
Modified:
core/trunk/src/com/vividsolutions/jump/datastore/spatialite/SpatialiteSQLBuilder.java
===================================================================
---
core/trunk/src/com/vividsolutions/jump/datastore/spatialite/SpatialiteSQLBuilder.java
2020-02-11 10:23:54 UTC (rev 6236)
+++
core/trunk/src/com/vividsolutions/jump/datastore/spatialite/SpatialiteSQLBuilder.java
2020-02-12 14:16:26 UTC (rev 6237)
@@ -154,6 +154,10 @@
SpatialiteDSMetadata dsm = (SpatialiteDSMetadata) getDbMetadata();
// test if geometry column is indexed, if so, builds special query
according to type:
GeometryColumn gc = dsm.getGeometryColumn(query.getDatasetName(),
query.getGeometryAttributeName());
+ // 2020-02-12: if info is not set, retrieve column index status here
+ if (gc.isIndexed() == null) {
+ dsm.setIndexInfo(datasetName, gc);
+ }
if (gc.isIndexed()) {
if (dsm.getGeometryColumnsLayout() ==
GeometryColumnsLayout.OGC_GEOPACKAGE_LAYOUT) {
String idxName = SQLUtil.quote(String.format("rtree_%s_%s",
@@ -174,4 +178,6 @@
return ret;
}
+
+
}
_______________________________________________
Jump-pilot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel