Blame SOURCES/0003-Remove-dep-on-missing-google-geometry-library.patch

345190
From 9101a214c2b38c1a7bb154c3b48f4a1b3ce63ea4 Mon Sep 17 00:00:00 2001
345190
From: Mat Booth <mat.booth@redhat.com>
345190
Date: Thu, 14 Feb 2019 18:25:01 +0000
345190
Subject: [PATCH 3/3] Remove dep on missing google geometry library
345190
345190
---
345190
 lucene/CHANGES.txt                            |   5 -
345190
 .../s2-geometry-library-java-1.0.0.jar.sha1   |   1 -
345190
 .../s2-geometry-library-java-LICENSE-ASL.txt  | 202 ------------
345190
 .../s2-geometry-library-java-NOTICE.txt       |   0
345190
 lucene/spatial-extras/ivy.xml                 |   2 -
345190
 .../spatial/prefix/tree/S2PrefixTree.java     | 157 ---------
345190
 .../spatial/prefix/tree/S2PrefixTreeCell.java | 297 ------------------
345190
 .../spatial/prefix/tree/S2ShapeFactory.java   |  40 ---
345190
 .../prefix/tree/SpatialPrefixTreeFactory.java |   2 -
345190
 .../spatial/spatial4j/Geo3dShapeFactory.java  |  24 +-
345190
 .../spatial/prefix/tree/S2PrefixTreeTest.java | 113 -------
345190
 .../spatial/spatial4j/Geo3dRptTest.java       |  23 +-
345190
 .../lucene/spatial3d/geom/GeoS2Shape.java     | 202 ------------
345190
 .../spatial3d/geom/GeoS2ShapeFactory.java     |  50 ---
345190
 .../spatial3d/geom/StandardObjects.java       |   1 -
345190
 15 files changed, 7 insertions(+), 1112 deletions(-)
345190
 delete mode 100644 lucene/licenses/s2-geometry-library-java-1.0.0.jar.sha1
345190
 delete mode 100644 lucene/licenses/s2-geometry-library-java-LICENSE-ASL.txt
345190
 delete mode 100644 lucene/licenses/s2-geometry-library-java-NOTICE.txt
345190
 delete mode 100644 lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/S2PrefixTree.java
345190
 delete mode 100644 lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/S2PrefixTreeCell.java
345190
 delete mode 100644 lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/S2ShapeFactory.java
345190
 delete mode 100644 lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/tree/S2PrefixTreeTest.java
345190
 delete mode 100644 lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoS2Shape.java
345190
 delete mode 100644 lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoS2ShapeFactory.java
345190
345190
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
345190
index 67aba94..eeee301 100644
345190
--- a/lucene/CHANGES.txt
345190
+++ b/lucene/CHANGES.txt
345190
@@ -690,11 +690,6 @@ New Features
345190
   (Lance Norskog, Grant Ingersoll, Joern Kottmann, Em, Kai Gülzau,
345190
   Rene Nederhand, Robert Muir, Steven Bower, Steve Rowe)
345190
 
345190
-* LUCENE-8126: Add new spatial prefix tree (SPT) based on google S2 geometry.
345190
-  It can only be used currently with Geo3D spatial context and it provides
345190
-  improvements on indexing time for non-points shapes and on query performance.
345190
-  (Ignacio Vera, David Smiley).
345190
-
345190
 Improvements
345190
 
345190
 * LUCENE-8081: Allow IndexWriter to opt out of flushing on indexing threads
345190
diff --git a/lucene/licenses/s2-geometry-library-java-1.0.0.jar.sha1 b/lucene/licenses/s2-geometry-library-java-1.0.0.jar.sha1
345190
deleted file mode 100644
345190
index ef4e3ee..0000000
345190
--- a/lucene/licenses/s2-geometry-library-java-1.0.0.jar.sha1
345190
+++ /dev/null
345190
@@ -1 +0,0 @@
345190
-f95b25589b40b5b0965deb592445073ff3efa299
345190
diff --git a/lucene/licenses/s2-geometry-library-java-LICENSE-ASL.txt b/lucene/licenses/s2-geometry-library-java-LICENSE-ASL.txt
345190
deleted file mode 100644
345190
index 03c7bfc..0000000
345190
--- a/lucene/licenses/s2-geometry-library-java-LICENSE-ASL.txt
345190
+++ /dev/null
345190
@@ -1,202 +0,0 @@
345190
-
345190
-                                 Apache License
345190
-                           Version 2.0, January 2004
345190
-                        http://www.apache.org/licenses/
345190
-
345190
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
345190
-
345190
-   1. Definitions.
345190
-
345190
-      "License" shall mean the terms and conditions for use, reproduction,
345190
-      and distribution as defined by Sections 1 through 9 of this document.
345190
-
345190
-      "Licensor" shall mean the copyright owner or entity authorized by
345190
-      the copyright owner that is granting the License.
345190
-
345190
-      "Legal Entity" shall mean the union of the acting entity and all
345190
-      other entities that control, are controlled by, or are under common
345190
-      control with that entity. For the purposes of this definition,
345190
-      "control" means (i) the power, direct or indirect, to cause the
345190
-      direction or management of such entity, whether by contract or
345190
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
345190
-      outstanding shares, or (iii) beneficial ownership of such entity.
345190
-
345190
-      "You" (or "Your") shall mean an individual or Legal Entity
345190
-      exercising permissions granted by this License.
345190
-
345190
-      "Source" form shall mean the preferred form for making modifications,
345190
-      including but not limited to software source code, documentation
345190
-      source, and configuration files.
345190
-
345190
-      "Object" form shall mean any form resulting from mechanical
345190
-      transformation or translation of a Source form, including but
345190
-      not limited to compiled object code, generated documentation,
345190
-      and conversions to other media types.
345190
-
345190
-      "Work" shall mean the work of authorship, whether in Source or
345190
-      Object form, made available under the License, as indicated by a
345190
-      copyright notice that is included in or attached to the work
345190
-      (an example is provided in the Appendix below).
345190
-
345190
-      "Derivative Works" shall mean any work, whether in Source or Object
345190
-      form, that is based on (or derived from) the Work and for which the
345190
-      editorial revisions, annotations, elaborations, or other modifications
345190
-      represent, as a whole, an original work of authorship. For the purposes
345190
-      of this License, Derivative Works shall not include works that remain
345190
-      separable from, or merely link (or bind by name) to the interfaces of,
345190
-      the Work and Derivative Works thereof.
345190
-
345190
-      "Contribution" shall mean any work of authorship, including
345190
-      the original version of the Work and any modifications or additions
345190
-      to that Work or Derivative Works thereof, that is intentionally
345190
-      submitted to Licensor for inclusion in the Work by the copyright owner
345190
-      or by an individual or Legal Entity authorized to submit on behalf of
345190
-      the copyright owner. For the purposes of this definition, "submitted"
345190
-      means any form of electronic, verbal, or written communication sent
345190
-      to the Licensor or its representatives, including but not limited to
345190
-      communication on electronic mailing lists, source code control systems,
345190
-      and issue tracking systems that are managed by, or on behalf of, the
345190
-      Licensor for the purpose of discussing and improving the Work, but
345190
-      excluding communication that is conspicuously marked or otherwise
345190
-      designated in writing by the copyright owner as "Not a Contribution."
345190
-
345190
-      "Contributor" shall mean Licensor and any individual or Legal Entity
345190
-      on behalf of whom a Contribution has been received by Licensor and
345190
-      subsequently incorporated within the Work.
345190
-
345190
-   2. Grant of Copyright License. Subject to the terms and conditions of
345190
-      this License, each Contributor hereby grants to You a perpetual,
345190
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
345190
-      copyright license to reproduce, prepare Derivative Works of,
345190
-      publicly display, publicly perform, sublicense, and distribute the
345190
-      Work and such Derivative Works in Source or Object form.
345190
-
345190
-   3. Grant of Patent License. Subject to the terms and conditions of
345190
-      this License, each Contributor hereby grants to You a perpetual,
345190
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
345190
-      (except as stated in this section) patent license to make, have made,
345190
-      use, offer to sell, sell, import, and otherwise transfer the Work,
345190
-      where such license applies only to those patent claims licensable
345190
-      by such Contributor that are necessarily infringed by their
345190
-      Contribution(s) alone or by combination of their Contribution(s)
345190
-      with the Work to which such Contribution(s) was submitted. If You
345190
-      institute patent litigation against any entity (including a
345190
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
345190
-      or a Contribution incorporated within the Work constitutes direct
345190
-      or contributory patent infringement, then any patent licenses
345190
-      granted to You under this License for that Work shall terminate
345190
-      as of the date such litigation is filed.
345190
-
345190
-   4. Redistribution. You may reproduce and distribute copies of the
345190
-      Work or Derivative Works thereof in any medium, with or without
345190
-      modifications, and in Source or Object form, provided that You
345190
-      meet the following conditions:
345190
-
345190
-      (a) You must give any other recipients of the Work or
345190
-          Derivative Works a copy of this License; and
345190
-
345190
-      (b) You must cause any modified files to carry prominent notices
345190
-          stating that You changed the files; and
345190
-
345190
-      (c) You must retain, in the Source form of any Derivative Works
345190
-          that You distribute, all copyright, patent, trademark, and
345190
-          attribution notices from the Source form of the Work,
345190
-          excluding those notices that do not pertain to any part of
345190
-          the Derivative Works; and
345190
-
345190
-      (d) If the Work includes a "NOTICE" text file as part of its
345190
-          distribution, then any Derivative Works that You distribute must
345190
-          include a readable copy of the attribution notices contained
345190
-          within such NOTICE file, excluding those notices that do not
345190
-          pertain to any part of the Derivative Works, in at least one
345190
-          of the following places: within a NOTICE text file distributed
345190
-          as part of the Derivative Works; within the Source form or
345190
-          documentation, if provided along with the Derivative Works; or,
345190
-          within a display generated by the Derivative Works, if and
345190
-          wherever such third-party notices normally appear. The contents
345190
-          of the NOTICE file are for informational purposes only and
345190
-          do not modify the License. You may add Your own attribution
345190
-          notices within Derivative Works that You distribute, alongside
345190
-          or as an addendum to the NOTICE text from the Work, provided
345190
-          that such additional attribution notices cannot be construed
345190
-          as modifying the License.
345190
-
345190
-      You may add Your own copyright statement to Your modifications and
345190
-      may provide additional or different license terms and conditions
345190
-      for use, reproduction, or distribution of Your modifications, or
345190
-      for any such Derivative Works as a whole, provided Your use,
345190
-      reproduction, and distribution of the Work otherwise complies with
345190
-      the conditions stated in this License.
345190
-
345190
-   5. Submission of Contributions. Unless You explicitly state otherwise,
345190
-      any Contribution intentionally submitted for inclusion in the Work
345190
-      by You to the Licensor shall be under the terms and conditions of
345190
-      this License, without any additional terms or conditions.
345190
-      Notwithstanding the above, nothing herein shall supersede or modify
345190
-      the terms of any separate license agreement you may have executed
345190
-      with Licensor regarding such Contributions.
345190
-
345190
-   6. Trademarks. This License does not grant permission to use the trade
345190
-      names, trademarks, service marks, or product names of the Licensor,
345190
-      except as required for reasonable and customary use in describing the
345190
-      origin of the Work and reproducing the content of the NOTICE file.
345190
-
345190
-   7. Disclaimer of Warranty. Unless required by applicable law or
345190
-      agreed to in writing, Licensor provides the Work (and each
345190
-      Contributor provides its Contributions) on an "AS IS" BASIS,
345190
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
345190
-      implied, including, without limitation, any warranties or conditions
345190
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
345190
-      PARTICULAR PURPOSE. You are solely responsible for determining the
345190
-      appropriateness of using or redistributing the Work and assume any
345190
-      risks associated with Your exercise of permissions under this License.
345190
-
345190
-   8. Limitation of Liability. In no event and under no legal theory,
345190
-      whether in tort (including negligence), contract, or otherwise,
345190
-      unless required by applicable law (such as deliberate and grossly
345190
-      negligent acts) or agreed to in writing, shall any Contributor be
345190
-      liable to You for damages, including any direct, indirect, special,
345190
-      incidental, or consequential damages of any character arising as a
345190
-      result of this License or out of the use or inability to use the
345190
-      Work (including but not limited to damages for loss of goodwill,
345190
-      work stoppage, computer failure or malfunction, or any and all
345190
-      other commercial damages or losses), even if such Contributor
345190
-      has been advised of the possibility of such damages.
345190
-
345190
-   9. Accepting Warranty or Additional Liability. While redistributing
345190
-      the Work or Derivative Works thereof, You may choose to offer,
345190
-      and charge a fee for, acceptance of support, warranty, indemnity,
345190
-      or other liability obligations and/or rights consistent with this
345190
-      License. However, in accepting such obligations, You may act only
345190
-      on Your own behalf and on Your sole responsibility, not on behalf
345190
-      of any other Contributor, and only if You agree to indemnify,
345190
-      defend, and hold each Contributor harmless for any liability
345190
-      incurred by, or claims asserted against, such Contributor by reason
345190
-      of your accepting any such warranty or additional liability.
345190
-
345190
-   END OF TERMS AND CONDITIONS
345190
-
345190
-   APPENDIX: How to apply the Apache License to your work.
345190
-
345190
-      To apply the Apache License to your work, attach the following
345190
-      boilerplate notice, with the fields enclosed by brackets "[]"
345190
-      replaced with your own identifying information. (Don't include
345190
-      the brackets!)  The text should be enclosed in the appropriate
345190
-      comment syntax for the file format. We also recommend that a
345190
-      file or class name and description of purpose be included on the
345190
-      same "printed page" as the copyright notice for easier
345190
-      identification within third-party archives.
345190
-
345190
-   Copyright [yyyy] [name of copyright owner]
345190
-
345190
-   Licensed under the Apache License, Version 2.0 (the "License");
345190
-   you may not use this file except in compliance with the License.
345190
-   You may obtain a copy of the License at
345190
-
345190
-       http://www.apache.org/licenses/LICENSE-2.0
345190
-
345190
-   Unless required by applicable law or agreed to in writing, software
345190
-   distributed under the License is distributed on an "AS IS" BASIS,
345190
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
345190
-   See the License for the specific language governing permissions and
345190
-limitations under the License.
345190
\ No newline at end of file
345190
diff --git a/lucene/licenses/s2-geometry-library-java-NOTICE.txt b/lucene/licenses/s2-geometry-library-java-NOTICE.txt
345190
deleted file mode 100644
345190
index e69de29..0000000
345190
diff --git a/lucene/spatial-extras/ivy.xml b/lucene/spatial-extras/ivy.xml
345190
index c3d982f..df67503 100644
345190
--- a/lucene/spatial-extras/ivy.xml
345190
+++ b/lucene/spatial-extras/ivy.xml
345190
@@ -25,8 +25,6 @@
345190
   <dependencies>
345190
     <dependency org="org.locationtech.spatial4j" name="spatial4j" rev="${/org.locationtech.spatial4j/spatial4j}" conf="compile"/>
345190
 
345190
-    <dependency org="io.sgr" name="s2-geometry-library-java" rev="${/io.sgr/s2-geometry-library-java}" conf="compile"/>
345190
-
345190
     <dependency org="org.locationtech.spatial4j" name="spatial4j" rev="${/org.locationtech.spatial4j/spatial4j}" conf="test">
345190
       <artifact name="spatial4j" type="test" ext="jar" maven:classifier="tests" />
345190
     </dependency>
345190
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/S2PrefixTree.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/S2PrefixTree.java
345190
deleted file mode 100644
345190
index f77c578..0000000
345190
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/S2PrefixTree.java
345190
+++ /dev/null
345190
@@ -1,157 +0,0 @@
345190
-/*
345190
- * Licensed to the Apache Software Foundation (ASF) under one or more
345190
- * contributor license agreements.  See the NOTICE file distributed with
345190
- * this work for additional information regarding copyright ownership.
345190
- * The ASF licenses this file to You under the Apache License, Version 2.0
345190
- * (the "License"); you may not use this file except in compliance with
345190
- * the License.  You may obtain a copy of the License at
345190
- *
345190
- *     http://www.apache.org/licenses/LICENSE-2.0
345190
- *
345190
- * Unless required by applicable law or agreed to in writing, software
345190
- * distributed under the License is distributed on an "AS IS" BASIS,
345190
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
345190
- * See the License for the specific language governing permissions and
345190
- * limitations under the License.
345190
- */
345190
-
345190
-package org.apache.lucene.spatial.prefix.tree;
345190
-
345190
-import java.util.ArrayList;
345190
-import java.util.List;
345190
-
345190
-import com.google.common.geometry.S2CellId;
345190
-import com.google.common.geometry.S2LatLng;
345190
-import com.google.common.geometry.S2Projections;
345190
-import org.apache.lucene.util.BytesRef;
345190
-import org.locationtech.spatial4j.context.SpatialContext;
345190
-import org.locationtech.spatial4j.distance.DistanceUtils;
345190
-import org.locationtech.spatial4j.shape.Point;
345190
-import org.locationtech.spatial4j.shape.Shape;
345190
-
345190
-/**
345190
- * Spatial prefix tree for S2 Geometry. Shape factories
345190
- * for the given {@link SpatialContext} must implement the interface {@link S2ShapeFactory}.
345190
- *
345190
- * The tree can be configured on how it divided itself by providing an arity. The default arity is 1
345190
- * which divided every sub-cell in 4 (except the first level that is always divided by 6) . Arity 2
345190
- * divides sub-cells in 16 and arity 3 in 64 sub-cells.
345190
- *
345190
- * @lucene.experimental
345190
- */
345190
-public class S2PrefixTree extends SpatialPrefixTree {
345190
-
345190
-
345190
-    /**
345190
-     * Factory for creating {@link S2PrefixTree} instances with useful defaults
345190
-     */
345190
-    protected static class Factory extends SpatialPrefixTreeFactory {
345190
-
345190
-        @Override
345190
-        protected int getLevelForDistance(double degrees) {
345190
-            S2PrefixTree grid = new S2PrefixTree(ctx, S2PrefixTree.getMaxLevels(1));
345190
-            return grid.getLevelForDistance(degrees);
345190
-        }
345190
-
345190
-        @Override
345190
-        protected SpatialPrefixTree newSPT() {
345190
-            return new S2PrefixTree(ctx,
345190
-                maxLevels != null ? maxLevels : S2PrefixTree.getMaxLevels(1));
345190
-        }
345190
-
345190
-    }
345190
-
345190
-    //factory to generate S2 cell shapes
345190
-    protected final S2ShapeFactory s2ShapeFactory;
345190
-    protected final int arity;
345190
-
345190
-    /**
345190
-     * Creates a S2 spatial tree with arity 1.
345190
-     *
345190
-     * @param ctx The provided spatial context. The shape factor of the spatial context
345190
-     *           must implement {@link S2ShapeFactory}
345190
-     * @param maxLevels The provided maximum level for this tree.
345190
-     */
345190
-    public S2PrefixTree(SpatialContext ctx, int maxLevels) {
345190
-        this(ctx, maxLevels, 1);
345190
-    }
345190
-
345190
-    /**
345190
-     * Creates a S2 spatial tree with provided arity.
345190
-     *
345190
-     * @param ctx The provided spatial context. The shape factor of the spatial context
345190
-     *           must implement {@link S2ShapeFactory}
345190
-     * @param maxLevels The provided maximum level for this tree.
345190
-     * @param arity The arity of the tree.
345190
-     */
345190
-    public S2PrefixTree(SpatialContext ctx, int maxLevels, int arity) {
345190
-        super(ctx, maxLevels);
345190
-        if (!(ctx.getShapeFactory() instanceof S2ShapeFactory)) {
345190
-            throw new IllegalArgumentException("Spatial context does not support S2 spatial index.");
345190
-        }
345190
-        this.s2ShapeFactory = (S2ShapeFactory) ctx.getShapeFactory();
345190
-        if (arity <1 || arity > 3) {
345190
-            throw new IllegalArgumentException("Invalid value for S2 tree arity. Possible values are 1, 2 or 3. Provided value is " + arity  + ".");
345190
-        }
345190
-        this.arity = arity;
345190
-    }
345190
-
345190
-    /**
345190
-     * Get max levels for this spatial tree.
345190
-     *
345190
-     * @param arity The arity of the tree.
345190
-     * @return The maximum number of levels by the provided arity.
345190
-     */
345190
-    public static int getMaxLevels(int arity) {
345190
-        return  S2CellId.MAX_LEVEL/arity + 1;
345190
-    }
345190
-
345190
-    @Override
345190
-    public int getLevelForDistance(double dist) {
345190
-        if (dist == 0){
345190
-            return maxLevels;
345190
-        }
345190
-        int level =  S2Projections.MAX_WIDTH.getMinLevel(dist * DistanceUtils.DEGREES_TO_RADIANS);
345190
-        int roundLevel = level % arity != 0 ? 1 : 0;
345190
-        level = level/arity + roundLevel;
345190
-        return Math.min(maxLevels, level + 1);
345190
-    }
345190
-
345190
-    @Override
345190
-    public double getDistanceForLevel(int level) {
345190
-        if (level == 0) {
345190
-            return 180;
345190
-        }
345190
-        return S2Projections.MAX_WIDTH.getValue(arity * (level - 1)) * DistanceUtils.RADIANS_TO_DEGREES;
345190
-    }
345190
-
345190
-    @Override
345190
-    public Cell getWorldCell() {
345190
-        return  new S2PrefixTreeCell(this, null);
345190
-    }
345190
-
345190
-    @Override
345190
-    public Cell readCell(BytesRef term, Cell scratch) {
345190
-        S2PrefixTreeCell cell = (S2PrefixTreeCell) scratch;
345190
-        if (cell == null) {
345190
-            cell = (S2PrefixTreeCell) getWorldCell();
345190
-        }
345190
-        cell.readCell(this, term);
345190
-        return cell;
345190
-    }
345190
-
345190
-    @Override
345190
-    public CellIterator getTreeCellIterator(Shape shape, int detailLevel) {
345190
-        if (!(shape instanceof Point)) {
345190
-            return  super.getTreeCellIterator(shape, detailLevel);
345190
-        }
345190
-        Point p = (Point) shape;
345190
-        S2CellId id = S2CellId.fromLatLng(S2LatLng.fromDegrees(p.getY(), p.getX())).parent(arity * (detailLevel - 1));
345190
-        List<Cell> cells = new ArrayList<>(detailLevel);
345190
-        for (int i=0; i < detailLevel - 1; i++) {
345190
-            cells.add(new S2PrefixTreeCell(this, id.parent(i * arity)));
345190
-        }
345190
-        cells.add(new S2PrefixTreeCell(this, id));
345190
-        return new FilterCellIterator(cells.iterator(), null);
345190
-    }
345190
-}
345190
\ No newline at end of file
345190
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/S2PrefixTreeCell.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/S2PrefixTreeCell.java
345190
deleted file mode 100644
345190
index e9b5818..0000000
345190
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/S2PrefixTreeCell.java
345190
+++ /dev/null
345190
@@ -1,297 +0,0 @@
345190
-/*
345190
- * Licensed to the Apache Software Foundation (ASF) under one or more
345190
- * contributor license agreements.  See the NOTICE file distributed with
345190
- * this work for additional information regarding copyright ownership.
345190
- * The ASF licenses this file to You under the Apache License, Version 2.0
345190
- * (the "License"); you may not use this file except in compliance with
345190
- * the License.  You may obtain a copy of the License at
345190
- *
345190
- *     http://www.apache.org/licenses/LICENSE-2.0
345190
- *
345190
- * Unless required by applicable law or agreed to in writing, software
345190
- * distributed under the License is distributed on an "AS IS" BASIS,
345190
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
345190
- * See the License for the specific language governing permissions and
345190
- * limitations under the License.
345190
- */
345190
-
345190
-package org.apache.lucene.spatial.prefix.tree;
345190
-
345190
-import java.util.ArrayList;
345190
-import java.util.HashMap;
345190
-import java.util.List;
345190
-import java.util.Map;
345190
-import java.util.Objects;
345190
-
345190
-import com.google.common.geometry.S2CellId;
345190
-import org.apache.lucene.util.BytesRef;
345190
-import org.locationtech.spatial4j.shape.Shape;
345190
-import org.locationtech.spatial4j.shape.SpatialRelation;
345190
-
345190
-/**
345190
- * This class represents a S2 pixel in the RPT.
345190
- *
345190
- * @lucene.internal
345190
- */
345190
-class S2PrefixTreeCell implements CellCanPrune {
345190
-
345190
-    //Faces of S2 Geometry
345190
-    private static S2CellId[] FACES = new S2CellId[6];
345190
-
345190
-    static {
345190
-        FACES[0] = S2CellId.fromFacePosLevel(0, 0, 0);
345190
-        FACES[1] = S2CellId.fromFacePosLevel(1, 0, 0);
345190
-        FACES[2] = S2CellId.fromFacePosLevel(2, 0, 0);
345190
-        FACES[3] = S2CellId.fromFacePosLevel(3, 0, 0);
345190
-        FACES[4] = S2CellId.fromFacePosLevel(4, 0, 0);
345190
-        FACES[5] = S2CellId.fromFacePosLevel(5, 0, 0);
345190
-    }
345190
-
345190
-    /*Special character to define a cell leaf*/
345190
-    private static final byte LEAF = '+';
345190
-    /*Tokens are used to serialize cells*/
345190
-    private static final byte[] TOKENS = {'.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
345190
-        'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
345190
-        'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
345190
-    /*Map containing mapping between tokens and integer values*/
345190
-    private static final Map<Byte, Integer> PIXELS;
345190
-
345190
-    static {
345190
-        PIXELS = new HashMap<>(TOKENS.length);
345190
-        for (int i = 0; i < TOKENS.length; i++) {
345190
-            PIXELS.put(TOKENS[i], i);
345190
-        }
345190
-    }
345190
-
345190
-    S2CellId cellId;
345190
-    int level; //cache level
345190
-    S2PrefixTree tree;
345190
-
345190
-    SpatialRelation shapeRel = null;
345190
-    boolean isLeaf;
345190
-    Shape shape = null;
345190
-
345190
-    S2PrefixTreeCell(S2PrefixTree tree, S2CellId cellId) {
345190
-        this.cellId = cellId;
345190
-        this.tree = tree;
345190
-        setLevel();
345190
-        if (getLevel() == tree.getMaxLevels()) {
345190
-            setLeaf();
345190
-        }
345190
-    }
345190
-
345190
-    void readCell(S2PrefixTree tree, BytesRef ref) {
345190
-        isLeaf = false;
345190
-        shape = null;
345190
-        shapeRel = null;
345190
-        this.tree = tree;
345190
-        cellId = getS2CellIdFromBytesRef(ref);
345190
-        setLevel();
345190
-        if (isLeaf(ref) || getLevel() == tree.getMaxLevels()) {
345190
-            setLeaf();
345190
-        }
345190
-    }
345190
-
345190
-    @Override
345190
-    public SpatialRelation getShapeRel() {
345190
-        return shapeRel;
345190
-    }
345190
-
345190
-    @Override
345190
-    public void setShapeRel(SpatialRelation rel) {
345190
-        shapeRel = rel;
345190
-    }
345190
-
345190
-    @Override
345190
-    public boolean isLeaf() {
345190
-        return isLeaf;
345190
-    }
345190
-
345190
-    @Override
345190
-    public void setLeaf() {
345190
-        isLeaf = true;
345190
-    }
345190
-
345190
-    @Override
345190
-    public BytesRef getTokenBytesWithLeaf(BytesRef result) {
345190
-        result = getTokenBytesNoLeaf(result);
345190
-        //max levels do not have leaf
345190
-        if (isLeaf() && !(getLevel() == tree.getMaxLevels())) {
345190
-            //Add leaf byte
345190
-            result.bytes[result.offset + result.length] = LEAF;
345190
-            result.length++;
345190
-        }
345190
-        return result;
345190
-    }
345190
-
345190
-    @Override
345190
-    public BytesRef getTokenBytesNoLeaf(BytesRef result) {
345190
-        if (result == null) {
345190
-            result = new BytesRef();
345190
-        }
345190
-        getBytesRefFromS2CellId(cellId, result);
345190
-        return result;
345190
-    }
345190
-
345190
-    @Override
345190
-    public int getLevel() {
345190
-        return this.level;
345190
-    }
345190
-
345190
-    /**
345190
-     * Cache level of cell.
345190
-     */
345190
-    private void setLevel() {
345190
-        if (this.cellId == null) {
345190
-            this.level = 0;
345190
-        } else {
345190
-            assert cellId.level() % tree.arity == 0;
345190
-            this.level = (this.cellId.level() / tree.arity) + 1;
345190
-        }
345190
-    }
345190
-
345190
-    @Override
345190
-    public CellIterator getNextLevelCells(Shape shapeFilter) {
345190
-        S2CellId[] children;
345190
-        if (cellId == null) { // this is the world cell
345190
-            children = FACES;
345190
-        } else {
345190
-            int nChildren = (int) Math.pow(4, tree.arity);
345190
-            children = new S2CellId[nChildren];
345190
-            children[0] = cellId.childBegin(cellId.level() + tree.arity);
345190
-            for (int i = 1; i < nChildren; i++) {
345190
-                children[i] = children[i - 1].next();
345190
-            }
345190
-        }
345190
-        List<Cell> cells = new ArrayList<>(children.length);
345190
-        for (S2CellId pixel : children) {
345190
-            cells.add(new S2PrefixTreeCell(tree, pixel));
345190
-        }
345190
-        return new FilterCellIterator(cells.iterator(), shapeFilter);
345190
-    }
345190
-
345190
-    @Override
345190
-    public Shape getShape() {
345190
-        if (shape == null) {
345190
-            if (cellId == null) { //World cell
345190
-                shape = tree.getSpatialContext().getWorldBounds();
345190
-            } else {
345190
-                shape = tree.s2ShapeFactory.getS2CellShape(cellId);
345190
-            }
345190
-        }
345190
-        return shape;
345190
-    }
345190
-
345190
-    @Override
345190
-    public boolean isPrefixOf(Cell c) {
345190
-        if (cellId == null) {
345190
-            return true;
345190
-        }
345190
-        S2PrefixTreeCell cell = (S2PrefixTreeCell) c;
345190
-        return cellId.contains(cell.cellId);
345190
-    }
345190
-
345190
-    @Override
345190
-    public int compareToNoLeaf(Cell fromCell) {
345190
-        if (cellId == null) {
345190
-            return 1;
345190
-        }
345190
-        S2PrefixTreeCell cell = (S2PrefixTreeCell) fromCell;
345190
-        return cellId.compareTo(cell.cellId);
345190
-    }
345190
-
345190
-    /**
345190
-     * Check if a cell is a leaf.
345190
-     *
345190
-     * @param ref The Byteref of the leaf
345190
-     * @return true if it is a leaf, e.g last byte is the special Character.
345190
-     */
345190
-    private boolean isLeaf(BytesRef ref) {
345190
-        return (ref.bytes[ref.offset + ref.length - 1] == LEAF);
345190
-    }
345190
-
345190
-    /**
345190
-     * Get the {@link S2CellId} from the {@link BytesRef} representation.
345190
-     *
345190
-     * @param ref The bytes.
345190
-     * @return the corresponding S2 cell.
345190
-     */
345190
-    private S2CellId getS2CellIdFromBytesRef(BytesRef ref) {
345190
-        int length = ref.length;
345190
-        if (isLeaf(ref)) {
345190
-            length--;
345190
-        }
345190
-        if (length == 0) {
345190
-            return null; //world cell
345190
-        }
345190
-        int face = PIXELS.get(ref.bytes[ref.offset]);
345190
-        S2CellId cellId = FACES[face];
345190
-        long id = cellId.id();
345190
-        for (int i = ref.offset + 1; i < ref.offset + length; i++) {
345190
-            int thisLevel = i - ref.offset;
345190
-            int pos = PIXELS.get(ref.bytes[i]);
345190
-            // first child at level
345190
-            id  = id - (id & -id) + (1L << (2 * (S2CellId.MAX_LEVEL -  thisLevel * tree.arity)));
345190
-            // next until pos
345190
-            id  = id + pos * ((id & -id) << 1);
345190
-        }
345190
-        return new S2CellId(id);
345190
-    }
345190
-
345190
-    /**
345190
-     * Codify a {@link S2CellId} into its {@link BytesRef} representation.
345190
-     *
345190
-     * @param cellId The S2 Cell id to codify.
345190
-     * @param bref   The byteref representation.
345190
-     */
345190
-    private void getBytesRefFromS2CellId(S2CellId cellId, BytesRef bref) {
345190
-        if (cellId == null) {//world cell
345190
-            bref.length = 0;
345190
-            return;
345190
-        }
345190
-        int length = getLevel() + 1;
345190
-        byte[] b = bref.bytes.length >= length ? bref.bytes : new byte[length];
345190
-        b[0] = TOKENS[cellId.face()];
345190
-        for (int i = 1; i < getLevel(); i++) {
345190
-            int offset = 0;
345190
-            int level = tree.arity * i;
345190
-            for (int j = 1; j < tree.arity; j++) {
345190
-                offset = 4 * offset + cellId.childPosition(level - tree.arity + j);
345190
-            }
345190
-            b[i] = TOKENS[4 * offset + cellId.childPosition(level)];
345190
-        }
345190
-        bref.bytes = b;
345190
-        bref.length = getLevel();
345190
-        bref.offset = 0;
345190
-    }
345190
-
345190
-    @Override
345190
-    public int getSubCellsSize() {
345190
-        if (cellId == null) { //root node
345190
-            return 6;
345190
-        }
345190
-        return  (int) Math.pow(4, tree.arity);
345190
-    }
345190
-
345190
-    @Override
345190
-    public int hashCode() {
345190
-        if (cellId == null) {
345190
-            return super.hashCode();
345190
-        }
345190
-        return this.cellId.hashCode();
345190
-    }
345190
-
345190
-    @Override
345190
-    public boolean equals(Object o) {
345190
-        S2PrefixTreeCell cell = (S2PrefixTreeCell) o;
345190
-        return Objects.equals(cellId, cell.cellId);
345190
-    }
345190
-
345190
-    @Override
345190
-    public String toString() {
345190
-        if (cellId == null) {
345190
-            return "0";
345190
-        }
345190
-        return cellId.toString();
345190
-    }
345190
-}
345190
\ No newline at end of file
345190
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/S2ShapeFactory.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/S2ShapeFactory.java
345190
deleted file mode 100644
345190
index 1306f60..0000000
345190
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/S2ShapeFactory.java
345190
+++ /dev/null
345190
@@ -1,40 +0,0 @@
345190
-/*
345190
- * Licensed to the Apache Software Foundation (ASF) under one or more
345190
- * contributor license agreements.  See the NOTICE file distributed with
345190
- * this work for additional information regarding copyright ownership.
345190
- * The ASF licenses this file to You under the Apache License, Version 2.0
345190
- * (the "License"); you may not use this file except in compliance with
345190
- * the License.  You may obtain a copy of the License at
345190
- *
345190
- *     http://www.apache.org/licenses/LICENSE-2.0
345190
- *
345190
- * Unless required by applicable law or agreed to in writing, software
345190
- * distributed under the License is distributed on an "AS IS" BASIS,
345190
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
345190
- * See the License for the specific language governing permissions and
345190
- * limitations under the License.
345190
- */
345190
-
345190
-package org.apache.lucene.spatial.prefix.tree;
345190
-
345190
-
345190
-import com.google.common.geometry.S2CellId;
345190
-import org.locationtech.spatial4j.shape.Shape;
345190
-import org.locationtech.spatial4j.shape.ShapeFactory;
345190
-
345190
-/**
345190
- * Shape factory for Spatial contexts that support S2 geometry. It is an extension of
345190
- * Spatial4j {@link ShapeFactory}.
345190
- *
345190
- * @lucene.experimental
345190
- */
345190
-public interface S2ShapeFactory extends ShapeFactory{
345190
-
345190
-  /**
345190
-   * Factory method for S2 cell shapes.
345190
-   *
345190
-   * @param cellId The S2 cell id
345190
-   * @return the shape representing the cell.
345190
-   */
345190
-  Shape getS2CellShape(S2CellId cellId);
345190
-}
345190
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/SpatialPrefixTreeFactory.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/SpatialPrefixTreeFactory.java
345190
index d88e41a..6e537dd 100644
345190
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/SpatialPrefixTreeFactory.java
345190
+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/SpatialPrefixTreeFactory.java
345190
@@ -54,8 +54,6 @@ public abstract class SpatialPrefixTreeFactory {
345190
       instance = new QuadPrefixTree.Factory();
345190
     else if ("packedQuad".equalsIgnoreCase(cname))
345190
       instance = new PackedQuadPrefixTree.Factory();
345190
-    else if ("s2".equalsIgnoreCase(cname))
345190
-      instance = new S2PrefixTree.Factory();
345190
     else {
345190
       try {
345190
         Class c = classLoader.loadClass(cname);
345190
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShapeFactory.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShapeFactory.java
345190
index 071c775..5c03f20 100644
345190
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShapeFactory.java
345190
+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShapeFactory.java
345190
@@ -20,10 +20,6 @@ package org.apache.lucene.spatial.spatial4j;
345190
 import java.util.ArrayList;
345190
 import java.util.List;
345190
 
345190
-import com.google.common.geometry.S2Cell;
345190
-import com.google.common.geometry.S2CellId;
345190
-import com.google.common.geometry.S2Point;
345190
-import org.apache.lucene.spatial.prefix.tree.S2ShapeFactory;
345190
 import org.apache.lucene.spatial3d.geom.GeoBBox;
345190
 import org.apache.lucene.spatial3d.geom.GeoBBoxFactory;
345190
 import org.apache.lucene.spatial3d.geom.GeoCircle;
345190
@@ -36,7 +32,6 @@ import org.apache.lucene.spatial3d.geom.GeoPointShape;
345190
 import org.apache.lucene.spatial3d.geom.GeoPointShapeFactory;
345190
 import org.apache.lucene.spatial3d.geom.GeoPolygon;
345190
 import org.apache.lucene.spatial3d.geom.GeoPolygonFactory;
345190
-import org.apache.lucene.spatial3d.geom.GeoS2ShapeFactory;
345190
 import org.apache.lucene.spatial3d.geom.PlanetModel;
345190
 import org.locationtech.spatial4j.context.SpatialContext;
345190
 import org.locationtech.spatial4j.context.SpatialContextFactory;
345190
@@ -47,13 +42,14 @@ import org.locationtech.spatial4j.shape.Point;
345190
 import org.locationtech.spatial4j.shape.Rectangle;
345190
 import org.locationtech.spatial4j.shape.Shape;
345190
 import org.locationtech.spatial4j.shape.ShapeCollection;
345190
+import org.locationtech.spatial4j.shape.ShapeFactory;
345190
 
345190
 /**
345190
- * Geo3d implementation of {@link S2ShapeFactory}
345190
+ * Geo3d implementation of {@link ShapeFactory}
345190
  *
345190
  * @lucene.experimental
345190
  */
345190
-public class Geo3dShapeFactory implements S2ShapeFactory {
345190
+public class Geo3dShapeFactory implements ShapeFactory {
345190
 
345190
   private final boolean normWrapLongitude;
345190
   private SpatialContext context;
345190
@@ -241,20 +237,6 @@ public class Geo3dShapeFactory implements S2ShapeFactory {
345190
     return new Geo3dMultiPolygonBuilder();
345190
   }
345190
 
345190
-  @Override
345190
-  public Shape getS2CellShape(S2CellId cellId) {
345190
-    S2Cell cell = new S2Cell(cellId);
345190
-    GeoPoint point1 = getGeoPoint(cell.getVertexRaw(0));
345190
-    GeoPoint point2 = getGeoPoint(cell.getVertexRaw(1));
345190
-    GeoPoint point3 = getGeoPoint(cell.getVertexRaw(2));
345190
-    GeoPoint point4 = getGeoPoint(cell.getVertexRaw(3));
345190
-    return new Geo3dShape<>(GeoS2ShapeFactory.makeGeoS2Shape(planetModel, point1, point2, point3, point4), context);
345190
-  }
345190
-
345190
-  private GeoPoint getGeoPoint(S2Point point) {
345190
-    return planetModel.createSurfacePoint(point.get(0), point.get(1), point.get(2));
345190
-  }
345190
-
345190
   /**
345190
    * Geo3d implementation of {@link org.locationtech.spatial4j.shape.ShapeFactory.PointsBuilder} interface to
345190
    * generate {@link GeoPoint}.
345190
diff --git a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/tree/S2PrefixTreeTest.java b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/tree/S2PrefixTreeTest.java
345190
deleted file mode 100644
345190
index f3bfe3e..0000000
345190
--- a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/tree/S2PrefixTreeTest.java
345190
+++ /dev/null
345190
@@ -1,113 +0,0 @@
345190
-/*
345190
- * Licensed to the Apache Software Foundation (ASF) under one or more
345190
- * contributor license agreements.  See the NOTICE file distributed with
345190
- * this work for additional information regarding copyright ownership.
345190
- * The ASF licenses this file to You under the Apache License, Version 2.0
345190
- * (the "License"); you may not use this file except in compliance with
345190
- * the License.  You may obtain a copy of the License at
345190
- *
345190
- *     http://www.apache.org/licenses/LICENSE-2.0
345190
- *
345190
- * Unless required by applicable law or agreed to in writing, software
345190
- * distributed under the License is distributed on an "AS IS" BASIS,
345190
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
345190
- * See the License for the specific language governing permissions and
345190
- * limitations under the License.
345190
- */
345190
-
345190
-package org.apache.lucene.spatial.prefix.tree;
345190
-
345190
-import com.carrotsearch.randomizedtesting.annotations.Repeat;
345190
-import com.google.common.geometry.S2CellId;
345190
-import com.google.common.geometry.S2Projections;
345190
-import org.apache.lucene.spatial.spatial4j.Geo3dSpatialContextFactory;
345190
-import org.apache.lucene.util.BytesRef;
345190
-import org.apache.lucene.util.LuceneTestCase;
345190
-import org.junit.Test;
345190
-import org.locationtech.spatial4j.context.SpatialContext;
345190
-import org.locationtech.spatial4j.shape.Point;
345190
-
345190
-/**
345190
- * Test for S2 Spatial prefix tree.
345190
- */
345190
-public class S2PrefixTreeTest extends LuceneTestCase{
345190
-
345190
-  @Test
345190
-  @Repeat(iterations = 10)
345190
-  public void testCells() {
345190
-    int face = random().nextInt(6);
345190
-    S2CellId id = S2CellId.fromFacePosLevel(face, 0, 0);
345190
-    int arity = random().nextInt(3) + 1;
345190
-    int level = random().nextInt(S2PrefixTree.getMaxLevels(arity));
345190
-    level = level * arity;
345190
-    for (int i = 0; i < level; i++) {
345190
-      int pos = random().nextInt(4);
345190
-      id = id.childBegin();
345190
-      if (pos == 0) continue;
345190
-      id = id.next();
345190
-      if (pos == 1) continue;
345190
-      id = id.next();
345190
-      if (pos == 2) continue;
345190
-      id = id.next();
345190
-    }
345190
-    S2PrefixTree tree = new S2PrefixTree(new Geo3dSpatialContextFactory().newSpatialContext(), S2PrefixTree.getMaxLevels(arity), arity);
345190
-    S2PrefixTreeCell cell = new S2PrefixTreeCell(tree, id);
345190
-    BytesRef ref = cell.getTokenBytesWithLeaf(null);
345190
-    if (random().nextBoolean()) {
345190
-      int newOffset = random().nextInt(10) + 1;
345190
-      byte[] newBytes = new byte[ref.bytes.length +  newOffset];
345190
-      for (int i = 0; i < ref.bytes.length; i++) {
345190
-        newBytes[i + newOffset] = ref.bytes[i];
345190
-      }
345190
-      ref.bytes = newBytes;
345190
-      ref.offset = ref.offset + newOffset;
345190
-    }
345190
-    S2PrefixTreeCell cell2 = new S2PrefixTreeCell(tree, null);
345190
-    cell2.readCell(tree, ref);
345190
-    assertEquals(cell, cell2);
345190
-  }
345190
-
345190
-  @Test
345190
-  @Repeat(iterations = 10)
345190
-  public void testDistanceAndLevels() {
345190
-    S2PrefixTree tree = new S2PrefixTree(new Geo3dSpatialContextFactory().newSpatialContext(), S2PrefixTree.getMaxLevels(1), 1);
345190
-
345190
-    double randomDist = random().nextDouble() * 5;
345190
-    int levelDistance = tree.getLevelForDistance(randomDist);
345190
-    double distanceLevel = tree.getDistanceForLevel(levelDistance);
345190
-    assertTrue(randomDist > distanceLevel);
345190
-
345190
-
345190
-    tree = new S2PrefixTree(new Geo3dSpatialContextFactory().newSpatialContext(), S2PrefixTree.getMaxLevels(2), 2);
345190
-
345190
-    levelDistance = tree.getLevelForDistance(randomDist);
345190
-    distanceLevel = tree.getDistanceForLevel(levelDistance);
345190
-    assertTrue(randomDist > distanceLevel);
345190
-
345190
-    tree = new S2PrefixTree(new Geo3dSpatialContextFactory().newSpatialContext(), S2PrefixTree.getMaxLevels(3), 3);
345190
-
345190
-    levelDistance = tree.getLevelForDistance(randomDist);
345190
-    distanceLevel = tree.getDistanceForLevel(levelDistance);
345190
-    assertTrue(randomDist > distanceLevel);
345190
-
345190
-  }
345190
-
345190
-  @Test
345190
-  @Repeat(iterations = 10)
345190
-  public void testPrecision() {
345190
-    int arity = random().nextInt(3) +1;
345190
-    SpatialContext context = new Geo3dSpatialContextFactory().newSpatialContext();
345190
-    S2PrefixTree tree = new S2PrefixTree(context, S2PrefixTree.getMaxLevels(arity), arity);
345190
-    double precision = random().nextDouble();
345190
-    int level = tree.getLevelForDistance(precision);
345190
-    Point point = context.getShapeFactory().pointXY(0, 0);
345190
-    CellIterator iterator = tree.getTreeCellIterator(point, level);
345190
-    S2PrefixTreeCell cell = null;
345190
-    while (iterator.hasNext()) {
345190
-      cell = (S2PrefixTreeCell)iterator.next();
345190
-    }
345190
-    assertTrue(cell.getLevel() == level);
345190
-    double precisionCell = S2Projections.MAX_WIDTH.getValue(cell.cellId.level());
345190
-    assertTrue(precision > precisionCell);
345190
-  }
345190
-}
345190
\ No newline at end of file
345190
diff --git a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/spatial4j/Geo3dRptTest.java b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/spatial4j/Geo3dRptTest.java
345190
index 327b65c..cc4cd31 100644
345190
--- a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/spatial4j/Geo3dRptTest.java
345190
+++ b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/spatial4j/Geo3dRptTest.java
345190
@@ -27,8 +27,6 @@ import org.apache.lucene.spatial.composite.CompositeSpatialStrategy;
345190
 import org.apache.lucene.spatial.prefix.RandomSpatialOpStrategyTestCase;
345190
 import org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy;
345190
 import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree;
345190
-import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;
345190
-import org.apache.lucene.spatial.prefix.tree.S2PrefixTree;
345190
 import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
345190
 import org.apache.lucene.spatial.query.SpatialOperation;
345190
 import org.apache.lucene.spatial.serialized.SerializedDVStrategy;
345190
@@ -36,7 +34,6 @@ import org.apache.lucene.spatial3d.geom.GeoAreaShape;
345190
 import org.apache.lucene.spatial3d.geom.GeoPath;
345190
 import org.apache.lucene.spatial3d.geom.GeoPathFactory;
345190
 import org.apache.lucene.spatial3d.geom.GeoPoint;
345190
-import org.apache.lucene.spatial3d.geom.GeoPointShape;
345190
 import org.apache.lucene.spatial3d.geom.GeoPolygonFactory;
345190
 import org.apache.lucene.spatial3d.geom.PlanetModel;
345190
 import org.apache.lucene.spatial3d.geom.RandomGeo3dShapeGenerator;
345190
@@ -53,18 +50,9 @@ public class Geo3dRptTest extends RandomSpatialOpStrategyTestCase {
345190
   private SpatialPrefixTree grid;
345190
   private RecursivePrefixTreeStrategy rptStrategy;
345190
 
345190
-  private void setupGrid() {
345190
-    int type = random().nextInt(4);
345190
-    if (type == 0) {
345190
-      this.grid = new GeohashPrefixTree(ctx, 2);
345190
-    } else if (type == 1) {
345190
-      this.grid = new QuadPrefixTree(ctx, 5);
345190
-    } else {
345190
-      int arity = random().nextInt(3) + 1;
345190
-      this.grid = new S2PrefixTree(ctx, 5 - arity, arity);
345190
-    }
345190
+  private void setupGeohashGrid() {
345190
+    this.grid = new GeohashPrefixTree(ctx, 2);//A fairly shallow grid
345190
     this.rptStrategy = newRPT();
345190
-    this.rptStrategy.setPruneLeafyBranches(random().nextBoolean());
345190
   }
345190
 
345190
   protected RecursivePrefixTreeStrategy newRPT() {
345190
@@ -81,7 +69,7 @@ public class Geo3dRptTest extends RandomSpatialOpStrategyTestCase {
345190
     factory.planetModel = planetModel;
345190
     ctx = factory.newSpatialContext();
345190
 
345190
-    setupGrid();
345190
+    setupGeohashGrid();
345190
 
345190
     SerializedDVStrategy serializedDVStrategy = new SerializedDVStrategy(ctx, getClass().getSimpleName() + "_sdv");
345190
     this.strategy = new CompositeSpatialStrategy("composite_" + getClass().getSimpleName(),
345190
@@ -123,7 +111,7 @@ public class Geo3dRptTest extends RandomSpatialOpStrategyTestCase {
345190
   }
345190
 
345190
   @Test
345190
-  @Repeat(iterations = 30)
345190
+  @Repeat(iterations = 10)
345190
   public void testOperations() throws IOException {
345190
     setupStrategy();
345190
 
345190
@@ -134,9 +122,6 @@ public class Geo3dRptTest extends RandomSpatialOpStrategyTestCase {
345190
   protected Shape randomIndexedShape() {
345190
     int type = shapeGenerator.randomShapeType();
345190
     GeoAreaShape areaShape = shapeGenerator.randomGeoAreaShape(type, planetModel);
345190
-    if (areaShape instanceof GeoPointShape) {
345190
-      return new Geo3dPointShape((GeoPointShape) areaShape, ctx);
345190
-    }
345190
     return new Geo3dShape<>(areaShape, ctx);
345190
   }
345190
 
345190
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoS2Shape.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoS2Shape.java
345190
deleted file mode 100644
345190
index b4c5d06..0000000
345190
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoS2Shape.java
345190
+++ /dev/null
345190
@@ -1,202 +0,0 @@
345190
-/*
345190
- * Licensed to the Apache Software Foundation (ASF) under one or more
345190
- * contributor license agreements.  See the NOTICE file distributed with
345190
- * this work for additional information regarding copyright ownership.
345190
- * The ASF licenses this file to You under the Apache License, Version 2.0
345190
- * (the "License"); you may not use this file except in compliance with
345190
- * the License.  You may obtain a copy of the License at
345190
- *
345190
- *     http://www.apache.org/licenses/LICENSE-2.0
345190
- *
345190
- * Unless required by applicable law or agreed to in writing, software
345190
- * distributed under the License is distributed on an "AS IS" BASIS,
345190
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
345190
- * See the License for the specific language governing permissions and
345190
- * limitations under the License.
345190
- */
345190
-
345190
-package org.apache.lucene.spatial3d.geom;
345190
-
345190
-import java.io.IOException;
345190
-import java.io.InputStream;
345190
-import java.io.OutputStream;
345190
-
345190
-/**
345190
- * Fast implementation of a polygon representing S2 geometry cell. There are no checks validating that
345190
- * points are convex therefore users must be provide four points in CCW or the logic will fail.
345190
- *
345190
- * @lucene.internal
345190
- */
345190
-class GeoS2Shape extends GeoBasePolygon {
345190
-
345190
-    /** The first point */
345190
-    protected final GeoPoint point1;
345190
-    /** The second point */
345190
-    protected final GeoPoint point2;
345190
-    /** The third point */
345190
-    protected final GeoPoint point3;
345190
-    /** The fourth point */
345190
-    protected final GeoPoint point4;
345190
-
345190
-    /** The first plane */
345190
-    protected final SidedPlane plane1;
345190
-    /** The second plane */
345190
-    protected final SidedPlane plane2;
345190
-    /** The third plane */
345190
-    protected final SidedPlane plane3;
345190
-    /** The fourth plane */
345190
-    protected final SidedPlane plane4;
345190
-
345190
-    /** Notable points for the first plane */
345190
-    protected final GeoPoint[] plane1Points;
345190
-    /** Notable points for second plane */
345190
-    protected final GeoPoint[] plane2Points;
345190
-    /** Notable points for third plane */
345190
-    protected final GeoPoint[] plane3Points;
345190
-    /** Notable points for fourth plane */
345190
-    protected final GeoPoint[] plane4Points;
345190
-
345190
-    /** Edge point for this S2 cell */
345190
-    protected final GeoPoint[] edgePoints;
345190
-
345190
-    /**
345190
-     * It builds from 4 points given in CCW. It must be convex or logic will fail.
345190
-     *
345190
-     *@param planetModel is the planet model.
345190
-     *@param point1  the first point.
345190
-     *@param point2  the second point.
345190
-     *@param point3  the third point.
345190
-     *@param point4  the four point.
345190
-     */
345190
-    public GeoS2Shape(final PlanetModel planetModel, GeoPoint point1, GeoPoint point2, GeoPoint point3, GeoPoint point4) {
345190
-        super(planetModel);
345190
-        this.point1 = point1;
345190
-        this.point2 = point2;
345190
-        this.point3 = point3;
345190
-        this.point4 = point4;
345190
-
345190
-        // Now build the four planes
345190
-        this.plane1 = new SidedPlane(point4, point1, point2);
345190
-        this.plane2 = new SidedPlane(point1, point2, point3);
345190
-        this.plane3 = new SidedPlane(point2, point3, point4);
345190
-        this.plane4 = new SidedPlane(point3, point4, point1);
345190
-
345190
-        //collect the notable points for the planes
345190
-        this.plane1Points = new GeoPoint[]{point1, point2};
345190
-        this.plane2Points = new GeoPoint[]{point2, point3};
345190
-        this.plane3Points = new GeoPoint[]{point3, point4};
345190
-        this.plane4Points = new GeoPoint[]{point4, point1};
345190
-
345190
-        this.edgePoints = new GeoPoint[]{point1};
345190
-    }
345190
-
345190
-    /**
345190
-     * Constructor for deserialization.
345190
-     * @param planetModel is the planet model.
345190
-     * @param inputStream is the input stream.
345190
-     */
345190
-    public GeoS2Shape(final PlanetModel planetModel, final InputStream inputStream) throws IOException {
345190
-        this(planetModel,
345190
-                (GeoPoint) SerializableObject.readObject(inputStream),
345190
-                (GeoPoint) SerializableObject.readObject(inputStream),
345190
-                (GeoPoint) SerializableObject.readObject(inputStream),
345190
-                (GeoPoint) SerializableObject.readObject(inputStream));
345190
-    }
345190
-
345190
-    @Override
345190
-    public void write(final OutputStream outputStream) throws IOException {
345190
-        SerializableObject.writeObject(outputStream, point1);
345190
-        SerializableObject.writeObject(outputStream, point2);
345190
-        SerializableObject.writeObject(outputStream, point3);
345190
-        SerializableObject.writeObject(outputStream, point4);
345190
-    }
345190
-
345190
-
345190
-    @Override
345190
-    public boolean isWithin(final double x, final double y, final double z) {
345190
-        return plane1.isWithin(x, y, z) &&
345190
-               plane2.isWithin(x, y, z) &&
345190
-               plane3.isWithin(x, y, z) &&
345190
-               plane4.isWithin(x, y, z);
345190
-    }
345190
-
345190
-
345190
-    @Override
345190
-    public GeoPoint[] getEdgePoints() {
345190
-        return edgePoints;
345190
-    }
345190
-
345190
-    @Override
345190
-    public boolean intersects(final Plane p, final GeoPoint[] notablePoints, final Membership... bounds) {
345190
-        return p.intersects(planetModel, plane1, notablePoints, plane1Points, bounds, plane2, plane4) ||
345190
-               p.intersects(planetModel, plane2, notablePoints, plane2Points, bounds, plane3, plane1) ||
345190
-               p.intersects(planetModel, plane3, notablePoints, plane3Points, bounds, plane4, plane2) ||
345190
-               p.intersects(planetModel, plane4, notablePoints, plane4Points, bounds, plane1, plane3);
345190
-    }
345190
-
345190
-    @Override
345190
-    public boolean intersects(GeoShape geoShape) {
345190
-        return geoShape.intersects(plane1, plane1Points, plane2, plane4) ||
345190
-               geoShape.intersects(plane2, plane2Points, plane3, plane1) ||
345190
-               geoShape.intersects(plane3, plane3Points, plane4, plane2) ||
345190
-               geoShape.intersects(plane4, plane4Points, plane1, plane3);
345190
-    }
345190
-
345190
-    @Override
345190
-    public void getBounds(Bounds bounds) {
345190
-        super.getBounds(bounds);
345190
-        bounds.addPlane(planetModel, plane1, plane2, plane4)
345190
-              .addPlane(planetModel, plane2, plane3, plane1)
345190
-              .addPlane(planetModel, plane3, plane4, plane2)
345190
-              .addPlane(planetModel, plane4, plane1, plane3)
345190
-              .addPoint(point1).addPoint(point2).addPoint(point3).addPoint(point4);
345190
-    }
345190
-
345190
-    @Override
345190
-    public double outsideDistance(DistanceStyle distanceStyle, double x, double y, double z) {
345190
-        final double planeDistance1 = distanceStyle.computeDistance(planetModel, plane1, x,y,z, plane2, plane4);
345190
-        final double planeDistance2 = distanceStyle.computeDistance(planetModel, plane2, x,y,z, plane3, plane1);
345190
-        final double planeDistance3 = distanceStyle.computeDistance(planetModel, plane3, x,y,z, plane4, plane2);
345190
-        final double planeDistance4 = distanceStyle.computeDistance(planetModel, plane4, x,y,z, plane1, plane3);
345190
-
345190
-        final double pointDistance1 = distanceStyle.computeDistance(point1, x,y,z);
345190
-        final double pointDistance2 = distanceStyle.computeDistance(point2, x,y,z);
345190
-        final double pointDistance3 = distanceStyle.computeDistance(point3, x,y,z);
345190
-        final double pointDistance4 = distanceStyle.computeDistance(point4, x,y,z);
345190
-
345190
-        return Math.min(
345190
-                Math.min(
345190
-                        Math.min(planeDistance1, planeDistance2),
345190
-                        Math.min(planeDistance3, planeDistance4)),
345190
-                Math.min(
345190
-                        Math.min(pointDistance1, pointDistance2),
345190
-                        Math.min(pointDistance3, pointDistance4)));
345190
-    }
345190
-
345190
-    @Override
345190
-    public boolean equals(Object o) {
345190
-        if (!(o instanceof GeoS2Shape))
345190
-            return false;
345190
-        GeoS2Shape other = (GeoS2Shape) o;
345190
-        return super.equals(other) && other.point1.equals(point1)
345190
-                && other.point2.equals(point2) && other.point3.equals(point3)
345190
-                && other.point4.equals(point4);
345190
-    }
345190
-
345190
-    @Override
345190
-    public int hashCode() {
345190
-        int result = super.hashCode();
345190
-        result = 31 * result  + point1.hashCode();
345190
-        result = 31 * result  + point2.hashCode();
345190
-        result = 31 * result  + point3.hashCode();
345190
-        result = 31 * result  + point4.hashCode();
345190
-        return result;
345190
-    }
345190
-
345190
-    @Override
345190
-    public String toString() {
345190
-        return "GeoS2Shape: {planetmodel="+planetModel+", point1=" + point1 +", point2=" + point2 +", point3=" + point3 +", point4=" + point4+ "}";
345190
-    }
345190
-
345190
-}
345190
-
345190
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoS2ShapeFactory.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoS2ShapeFactory.java
345190
deleted file mode 100644
345190
index 848b2e6..0000000
345190
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoS2ShapeFactory.java
345190
+++ /dev/null
345190
@@ -1,50 +0,0 @@
345190
-/*
345190
- * Licensed to the Apache Software Foundation (ASF) under one or more
345190
- * contributor license agreements.  See the NOTICE file distributed with
345190
- * this work for additional information regarding copyright ownership.
345190
- * The ASF licenses this file to You under the Apache License, Version 2.0
345190
- * (the "License"); you may not use this file except in compliance with
345190
- * the License.  You may obtain a copy of the License at
345190
- *
345190
- *     http://www.apache.org/licenses/LICENSE-2.0
345190
- *
345190
- * Unless required by applicable law or agreed to in writing, software
345190
- * distributed under the License is distributed on an "AS IS" BASIS,
345190
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
345190
- * See the License for the specific language governing permissions and
345190
- * limitations under the License.
345190
- */
345190
-
345190
-package org.apache.lucene.spatial3d.geom;
345190
-
345190
-/**
345190
- * Class which constructs a GeoPolygon representing S2 google pixel.
345190
- *
345190
- * @lucene.experimental
345190
- */
345190
-public class GeoS2ShapeFactory {
345190
-
345190
-  private GeoS2ShapeFactory() {
345190
-  }
345190
-
345190
-  /**
345190
-   * Creates a convex polygon with 4 planes by providing 4 points in CCW.
345190
-   * This is a very fast shape and there are no checks that the points currently define
345190
-   * a convex shape.
345190
-   *
345190
-   * @param planetModel The planet model
345190
-   * @param point1 the first point.
345190
-   * @param point2 the second point.
345190
-   * @param point3 the third point.
345190
-   * @param point4 the four point.
345190
-   * @return the generated shape.
345190
-   */
345190
-  public static GeoPolygon makeGeoS2Shape(final PlanetModel planetModel,
345190
-                                          final GeoPoint point1,
345190
-                                          final GeoPoint point2,
345190
-                                          final GeoPoint point3,
345190
-                                          final GeoPoint point4) {
345190
-    return new GeoS2Shape(planetModel, point1, point2, point3, point4);
345190
-  }
345190
-}
345190
-
345190
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/StandardObjects.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/StandardObjects.java
345190
index 4e0acae..bcebf43 100644
345190
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/StandardObjects.java
345190
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/StandardObjects.java
345190
@@ -75,7 +75,6 @@ class StandardObjects {
345190
    classRegsitry.put(PlanetModel.class, 35);
345190
    classRegsitry.put(GeoDegeneratePath.class, 36);
345190
    classRegsitry.put(GeoExactCircle.class, 37);
345190
-   classRegsitry.put(GeoS2Shape.class, 38);
345190
 
345190
    for (Class clazz : classRegsitry.keySet()){
345190
      codeRegsitry.put(classRegsitry.get(clazz), clazz);
345190
-- 
345190
2.20.1
345190