You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by kw...@apache.org on 2017/09/10 11:01:51 UTC
lucene-solr:branch_6x: LUCENE-7955: Adjust degenerate path logic to
not consider endpoints unless needed.
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6x d30b47c91 -> dec7f8957
LUCENE-7955: Adjust degenerate path logic to not consider endpoints unless needed.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/dec7f895
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/dec7f895
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/dec7f895
Branch: refs/heads/branch_6x
Commit: dec7f8957986523e91364e7ac5ab5af888b71799
Parents: d30b47c
Author: Karl Wright <Da...@gmail.com>
Authored: Sun Sep 10 07:00:20 2017 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Sun Sep 10 07:01:44 2017 -0400
----------------------------------------------------------------------
.../spatial3d/geom/GeoDegeneratePath.java | 21 ++++++++++----------
.../geom/SimpleGeoPolygonRelationshipsTest.java | 15 ++++++++++++++
2 files changed, 26 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/dec7f895/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegeneratePath.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegeneratePath.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegeneratePath.java
index 175ca33..eaceb26 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegeneratePath.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegeneratePath.java
@@ -259,10 +259,11 @@ class GeoDegeneratePath extends GeoBasePath {
// Well, sort of. We can detect intersections also due to overlap of segments with each other.
// But that's an edge case and we won't be optimizing for it.
//System.err.println(" Looking for intersection of plane "+plane+" with path "+this);
- for (final SegmentEndpoint pathPoint : endPoints) {
- if (pathPoint.intersects(planetModel, plane, notablePoints, bounds)) {
- return true;
- }
+
+ // Since the endpoints are included in the path segments, we only need to do this if there are
+ // no path segments
+ if (endPoints.size() == 1) {
+ return endPoints.get(0).intersects(planetModel, plane, notablePoints, bounds);
}
for (final PathSegment pathSegment : segments) {
@@ -276,10 +277,10 @@ class GeoDegeneratePath extends GeoBasePath {
@Override
public boolean intersects(GeoShape geoShape) {
- for (final SegmentEndpoint pathPoint : endPoints) {
- if (pathPoint.intersects(geoShape)) {
- return true;
- }
+ // Since the endpoints are included in the path segments, we only need to do this if there are
+ // no path segments
+ if (endPoints.size() == 1) {
+ return endPoints.get(0).intersects(geoShape);
}
for (final PathSegment pathSegment : segments) {
@@ -300,8 +301,8 @@ class GeoDegeneratePath extends GeoBasePath {
for (PathSegment pathSegment : segments) {
pathSegment.getBounds(planetModel, bounds);
}
- for (SegmentEndpoint pathPoint : endPoints) {
- pathPoint.getBounds(planetModel, bounds);
+ if (endPoints.size() == 1) {
+ endPoints.get(0).getBounds(planetModel, bounds);
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/dec7f895/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/SimpleGeoPolygonRelationshipsTest.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/SimpleGeoPolygonRelationshipsTest.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/SimpleGeoPolygonRelationshipsTest.java
index 06aa8b9..2589a19 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/SimpleGeoPolygonRelationshipsTest.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/SimpleGeoPolygonRelationshipsTest.java
@@ -736,6 +736,21 @@ public class SimpleGeoPolygonRelationshipsTest {
assertEquals(GeoArea.CONTAINS, rel);
}
+ @Test
+ public void testDegeneratePathShape(){
+ GeoPoint point1 = new GeoPoint(PlanetModel.SPHERE, 0, 0);
+ GeoPoint point2 = new GeoPoint(PlanetModel.SPHERE, 0, 1);
+ GeoPoint[] pointPath1 = new GeoPoint[] {point1, point2};
+ GeoPath path1 = GeoPathFactory.makeGeoPath(PlanetModel.SPHERE, 0, pointPath1);
+ GeoPath path2 = GeoPathFactory.makeGeoPath(PlanetModel.SPHERE, 1, pointPath1);
+ int rel = path1.getRelationship(path2);
+ //if an end point is inside the shape it will always return intersects
+ assertEquals(GeoArea.CONTAINS, rel); //should be contains?
+ rel = path2.getRelationship(path1);
+ assertEquals(GeoArea.WITHIN, rel);
+ }
+
+
private GeoPolygon buildConvexGeoPolygon(double lon1, double lat1,
double lon2, double lat2,
double lon3, double lat3,