From c2c215d3a83bda97f298f1d14c0bfd523122ca98 Mon Sep 17 00:00:00 2001 From: David Smiley Date: Fri, 29 Oct 2021 22:01:52 -0400 Subject: [PATCH] LUCENE-10201: Upgrade Spatial4j to 0.8 (#409) Upgrading Spatial4j to 0.8 improving a varitety of minor things. See release notes: https://github.com/locationtech/spatial4j/releases/tag/spatial4j-0.8 Test-only dependency on JTS is upgraded to 1.17 as well --- lucene/CHANGES.txt | 4 ++++ lucene/licenses/jts-core-1.15.0.jar.sha1 | 1 - lucene/licenses/jts-core-1.17.0.jar.sha1 | 1 + lucene/licenses/spatial4j-0.7-tests.jar.sha1 | 1 - lucene/licenses/spatial4j-0.7.jar.sha1 | 1 - lucene/licenses/spatial4j-0.8-tests.jar.sha1 | 1 + lucene/licenses/spatial4j-0.8.jar.sha1 | 1 + .../lucene/spatial/query/SpatialArgsParser.java | 17 ++++++++++------- versions.lock | 4 ++-- versions.props | 4 ++-- 10 files changed, 21 insertions(+), 14 deletions(-) delete mode 100644 lucene/licenses/jts-core-1.15.0.jar.sha1 create mode 100644 lucene/licenses/jts-core-1.17.0.jar.sha1 delete mode 100644 lucene/licenses/spatial4j-0.7-tests.jar.sha1 delete mode 100644 lucene/licenses/spatial4j-0.7.jar.sha1 create mode 100644 lucene/licenses/spatial4j-0.8-tests.jar.sha1 create mode 100644 lucene/licenses/spatial4j-0.8.jar.sha1 diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 44f0cc1b1ea..886fe28c46b 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -322,6 +322,10 @@ Improvements * LUCENE-10103: Make QueryCache respect Accountable queries. (Haoyu Zhai) +* LUCENE-10201: Spatial-Extras: Upgrading Spatial4j to 0.8 improving a varitety of minor things. + See release notes. https://github.com/locationtech/spatial4j/releases/tag/spatial4j-0.8 + (David Smiley) + Bug fixes --------------------- diff --git a/lucene/licenses/jts-core-1.15.0.jar.sha1 b/lucene/licenses/jts-core-1.15.0.jar.sha1 deleted file mode 100644 index 086ea96ad93..00000000000 --- a/lucene/licenses/jts-core-1.15.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -705981b7e25d05a76a3654e597dab6ba423eb79e diff --git a/lucene/licenses/jts-core-1.17.0.jar.sha1 b/lucene/licenses/jts-core-1.17.0.jar.sha1 new file mode 100644 index 00000000000..f1f3fbe1aca --- /dev/null +++ b/lucene/licenses/jts-core-1.17.0.jar.sha1 @@ -0,0 +1 @@ +7e1973b5babdd98734b1ab903fc1155714402eec diff --git a/lucene/licenses/spatial4j-0.7-tests.jar.sha1 b/lucene/licenses/spatial4j-0.7-tests.jar.sha1 deleted file mode 100644 index 0127b0fc67d..00000000000 --- a/lucene/licenses/spatial4j-0.7-tests.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -1cf04898a92917fd038ac5a92490a8c415f671b9 diff --git a/lucene/licenses/spatial4j-0.7.jar.sha1 b/lucene/licenses/spatial4j-0.7.jar.sha1 deleted file mode 100644 index ef240659652..00000000000 --- a/lucene/licenses/spatial4j-0.7.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -faa8ba85d503da4ab872d17ba8c00da0098ab2f2 diff --git a/lucene/licenses/spatial4j-0.8-tests.jar.sha1 b/lucene/licenses/spatial4j-0.8-tests.jar.sha1 new file mode 100644 index 00000000000..5fa337d8197 --- /dev/null +++ b/lucene/licenses/spatial4j-0.8-tests.jar.sha1 @@ -0,0 +1 @@ +134b5215f13b90e4de68e5792d507a282848ef68 diff --git a/lucene/licenses/spatial4j-0.8.jar.sha1 b/lucene/licenses/spatial4j-0.8.jar.sha1 new file mode 100644 index 00000000000..4bb173e50ab --- /dev/null +++ b/lucene/licenses/spatial4j-0.8.jar.sha1 @@ -0,0 +1 @@ +f3ff59c2c540102ae157a1786cb80e82ce9c9f19 diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/query/SpatialArgsParser.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/query/SpatialArgsParser.java index 8c49d6a1841..3d284cbafae 100644 --- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/query/SpatialArgsParser.java +++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/query/SpatialArgsParser.java @@ -16,6 +16,7 @@ */ package org.apache.lucene.spatial.query; +import java.io.IOException; import java.text.ParseException; import java.util.HashMap; import java.util.Locale; @@ -28,10 +29,10 @@ import org.locationtech.spatial4j.shape.Shape; /** * Parses a string that usually looks like "OPERATION(SHAPE)" into a {@link SpatialArgs} object. The * set of operations supported are defined in {@link SpatialOperation}, such as "Intersects" being a - * common one. The shape portion is defined by WKT {@link - * org.locationtech.spatial4j.io.WktShapeParser}, but it can be overridden/customized via {@link - * #parseShape(String, org.locationtech.spatial4j.context.SpatialContext)}. There are some optional - * name-value pair parameters that follow the closing parenthesis. Example: + * common one. The shape portion is defined by WKT {@link org.locationtech.spatial4j.io.WKTReader}, + * but it can be overridden/customized via {@link #parseShape(String, + * org.locationtech.spatial4j.context.SpatialContext)}. There are some optional name-value pair + * parameters that follow the closing parenthesis. Example: * *
  *   Intersects(ENVELOPE(-10,-8,22,20)) distErrPct=0.025
@@ -116,10 +117,12 @@ public class SpatialArgsParser {
     args.setDistErr(readDouble(nameValPairs.remove(DIST_ERR)));
   }
 
-  @SuppressWarnings("deprecation")
   protected Shape parseShape(String str, SpatialContext ctx) throws ParseException {
-    // return ctx.readShape(str);//still in Spatial4j 0.4 but will be deleted
-    return ctx.readShapeFromWkt(str);
+    try {
+      return ctx.getFormats().getWktReader().read(str);
+    } catch (IOException e) {
+      throw new ParseException(e.toString(), 0); // impossible but whatever;
+    }
   }
 
   protected static Double readDouble(String v) {
diff --git a/versions.lock b/versions.lock
index 930f68c2724..17093f9ff89 100644
--- a/versions.lock
+++ b/versions.lock
@@ -19,7 +19,7 @@ org.carrot2:morfologik-fsa:2.1.5 (1 constraints: d70d9836)
 org.carrot2:morfologik-polish:2.1.5 (1 constraints: 0a05fd35)
 org.carrot2:morfologik-stemming:2.1.5 (2 constraints: 0b12640c)
 org.hamcrest:hamcrest:2.2 (1 constraints: a8041f2c)
-org.locationtech.spatial4j:spatial4j:0.7 (1 constraints: ab041e2c)
+org.locationtech.spatial4j:spatial4j:0.8 (1 constraints: ac041f2c)
 org.ow2.asm:asm:7.2 (2 constraints: 900e3e5e)
 org.ow2.asm:asm-commons:7.2 (1 constraints: ad042e2c)
 ua.net.nlp:morfologik-ukrainian-search:4.9.1 (1 constraints: 10051b36)
@@ -33,4 +33,4 @@ org.eclipse.jetty:jetty-server:9.4.41.v20210516 (1 constraints: 7907fe7c)
 org.eclipse.jetty:jetty-servlet:9.4.41.v20210516 (1 constraints: 7907fe7c)
 org.eclipse.jetty:jetty-util:9.4.41.v20210516 (3 constraints: 422efaf1)
 org.eclipse.jetty:jetty-util-ajax:9.4.41.v20210516 (1 constraints: 64101be2)
-org.locationtech.jts:jts-core:1.15.0 (1 constraints: 3905383b)
+org.locationtech.jts:jts-core:1.17.0 (1 constraints: 3b053e3b)
diff --git a/versions.props b/versions.props
index f5010d321bf..001497b8494 100644
--- a/versions.props
+++ b/versions.props
@@ -23,8 +23,8 @@ org.apache.opennlp:opennlp-tools=1.9.1
 org.carrot2:morfologik-*=2.1.5
 org.eclipse.jetty:*=9.4.41.v20210516
 org.hamcrest:*=2.2
-org.locationtech.jts:jts-core=1.15.0
-org.locationtech.spatial4j:*=0.7
+org.locationtech.jts:jts-core=1.17.0
+org.locationtech.spatial4j:*=0.8
 org.ow2.asm:*=7.2
 ua.net.nlp:morfologik-ukrainian-search=4.9.1
 xerces:xercesImpl=2.12.0