Skip to content

Commit

Permalink
rtree geodesic index support
Browse files Browse the repository at this point in the history
  • Loading branch information
bosborn committed Mar 19, 2024
1 parent 1e777ba commit 60f1ccb
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/main/java/mil/nga/geopackage/io/SQLExec.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ public class SQLExec {
*/
public static final String ARGUMENT_BOUNDS_MANUAL = "m";

/**
* R-tree geodesic argument
*/
public static final String ARGUMENT_RTREE_GEODESIC = "g";

/**
* R-tree drop argument
*/
Expand Down Expand Up @@ -1256,9 +1261,13 @@ private static void printHelp(GeoPackage database) {
System.out.println("\t" + COMMAND_EXTENSIONS
+ " [name] - List GeoPackage extensions (all or LIKE table name)");
System.out.println("\t" + COMMAND_RTREE + " [" + ARGUMENT_PREFIX
+ ARGUMENT_RTREE_GEODESIC + "|" + ARGUMENT_PREFIX
+ ARGUMENT_RTREE_DROP + "] <name>");
System.out.println(
"\t - Create, recreate, or drop a feature table R-tree");
System.out
.println("\t " + ARGUMENT_RTREE_GEODESIC
+ " - index using geodesic bounds");
System.out.println("\t " + ARGUMENT_RTREE_DROP
+ " - drop the R-tree if it exists");
System.out.println(
Expand Down Expand Up @@ -2455,6 +2464,7 @@ private static void rtree(GeoPackage database, StringBuilder sqlBuilder,
boolean valid = true;
String tableName = null;
boolean drop = false;
boolean geodesic = false;

for (int i = 0; valid && i < parts.length; i++) {

Expand All @@ -2466,6 +2476,10 @@ private static void rtree(GeoPackage database, StringBuilder sqlBuilder,

switch (argument) {

case ARGUMENT_RTREE_GEODESIC:
geodesic = true;
break;

case ARGUMENT_RTREE_DROP:
drop = true;
break;
Expand Down Expand Up @@ -2495,8 +2509,14 @@ private static void rtree(GeoPackage database, StringBuilder sqlBuilder,
}
}

if (geodesic && drop) {
valid = false;
System.out.println("Error: Unsupported combination of arguments");
}

if (valid) {
RTreeIndexExtension extension = new RTreeIndexExtension(database);
RTreeIndexExtension extension = new RTreeIndexExtension(database,
geodesic);
RTreeIndexTableDao dao = extension.getTableDao(tableName);
boolean exists = dao.has();
System.out.println();
Expand All @@ -2508,7 +2528,8 @@ private static void rtree(GeoPackage database, StringBuilder sqlBuilder,
if (!drop) {
dao.create();
System.out.println(
"R-tree created for table '" + tableName + "'");
"R-tree created" + (geodesic ? " (geodesic)" : "")
+ " for table '" + tableName + "'");
} else if (!exists) {
System.out.println("No R-tree exists to drop for table '"
+ tableName + "'");
Expand Down

0 comments on commit 60f1ccb

Please sign in to comment.