You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2015/05/27 06:54:51 UTC
svn commit: r1681907 [4/4] - in
/lucene/dev/branches/lucene6487/lucene/spatial/src:
java/org/apache/lucene/spatial/spatial4j/
java/org/apache/lucene/spatial/spatial4j/geo3d/
test/org/apache/lucene/spatial/spatial4j/
test/org/apache/lucene/spatial/spati...
Modified: lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoCircleTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoCircleTest.java?rev=1681907&r1=1681906&r2=1681907&view=diff
==============================================================================
--- lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoCircleTest.java (original)
+++ lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoCircleTest.java Wed May 27 04:54:50 2015
@@ -30,16 +30,16 @@ public class GeoCircleTest {
public void testCircleDistance() {
GeoCircle c;
GeoPoint gp;
- c = new GeoCircle(0.0, -0.5, 0.1);
- gp = new GeoPoint(0.0, 0.0);
+ c = new GeoCircle(PlanetModel.SPHERE, 0.0, -0.5, 0.1);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, 0.0);
assertEquals(Double.MAX_VALUE, c.computeArcDistance(gp), 0.0);
assertEquals(Double.MAX_VALUE, c.computeLinearDistance(gp), 0.0);
assertEquals(Double.MAX_VALUE, c.computeNormalDistance(gp), 0.0);
- gp = new GeoPoint(0.0, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.5);
assertEquals(0.0, c.computeArcDistance(gp), 0.000001);
assertEquals(0.0, c.computeLinearDistance(gp), 0.000001);
assertEquals(0.0, c.computeNormalDistance(gp), 0.000001);
- gp = new GeoPoint(0.05, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.05, -0.5);
assertEquals(0.05, c.computeArcDistance(gp), 0.000001);
assertEquals(0.049995, c.computeLinearDistance(gp), 0.000001);
assertEquals(0.049979, c.computeNormalDistance(gp), 0.000001);
@@ -49,18 +49,18 @@ public class GeoCircleTest {
public void testCirclePointWithin() {
GeoCircle c;
GeoPoint gp;
- c = new GeoCircle(0.0, -0.5, 0.1);
- gp = new GeoPoint(0.0, 0.0);
+ c = new GeoCircle(PlanetModel.SPHERE, 0.0, -0.5, 0.1);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, 0.0);
assertFalse(c.isWithin(gp));
- gp = new GeoPoint(0.0, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.5);
assertTrue(c.isWithin(gp));
- gp = new GeoPoint(0.0, -0.55);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.55);
assertTrue(c.isWithin(gp));
- gp = new GeoPoint(0.0, -0.45);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.45);
assertTrue(c.isWithin(gp));
- gp = new GeoPoint(Math.PI * 0.5, 0.0);
+ gp = new GeoPoint(PlanetModel.SPHERE, Math.PI * 0.5, 0.0);
assertFalse(c.isWithin(gp));
- gp = new GeoPoint(0.0, Math.PI);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, Math.PI);
assertFalse(c.isWithin(gp));
}
@@ -71,7 +71,7 @@ public class GeoCircleTest {
// Vertical circle cases
- c = new GeoCircle(0.0, -0.5, 0.1);
+ c = new GeoCircle(PlanetModel.SPHERE, 0.0, -0.5, 0.1);
b = c.getBounds(null);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
@@ -80,7 +80,7 @@ public class GeoCircleTest {
assertEquals(-0.4, b.getRightLongitude(), 0.000001);
assertEquals(-0.1, b.getMinLatitude(), 0.000001);
assertEquals(0.1, b.getMaxLatitude(), 0.000001);
- c = new GeoCircle(0.0, 0.5, 0.1);
+ c = new GeoCircle(PlanetModel.SPHERE, 0.0, 0.5, 0.1);
b = c.getBounds(null);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
@@ -89,7 +89,7 @@ public class GeoCircleTest {
assertEquals(0.6, b.getRightLongitude(), 0.000001);
assertEquals(-0.1, b.getMinLatitude(), 0.000001);
assertEquals(0.1, b.getMaxLatitude(), 0.000001);
- c = new GeoCircle(0.0, 0.0, 0.1);
+ c = new GeoCircle(PlanetModel.SPHERE, 0.0, 0.0, 0.1);
b = c.getBounds(null);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
@@ -98,7 +98,7 @@ public class GeoCircleTest {
assertEquals(0.1, b.getRightLongitude(), 0.000001);
assertEquals(-0.1, b.getMinLatitude(), 0.000001);
assertEquals(0.1, b.getMaxLatitude(), 0.000001);
- c = new GeoCircle(0.0, Math.PI, 0.1);
+ c = new GeoCircle(PlanetModel.SPHERE, 0.0, Math.PI, 0.1);
b = c.getBounds(null);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
@@ -108,13 +108,13 @@ public class GeoCircleTest {
assertEquals(-0.1, b.getMinLatitude(), 0.000001);
assertEquals(0.1, b.getMaxLatitude(), 0.000001);
// Horizontal circle cases
- c = new GeoCircle(Math.PI * 0.5, 0.0, 0.1);
+ c = new GeoCircle(PlanetModel.SPHERE, Math.PI * 0.5, 0.0, 0.1);
b = c.getBounds(null);
assertTrue(b.checkNoLongitudeBound());
assertTrue(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
assertEquals(Math.PI * 0.5 - 0.1, b.getMinLatitude(), 0.000001);
- c = new GeoCircle(-Math.PI * 0.5, 0.0, 0.1);
+ c = new GeoCircle(PlanetModel.SPHERE, -Math.PI * 0.5, 0.0, 0.1);
b = c.getBounds(null);
assertTrue(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
@@ -122,7 +122,7 @@ public class GeoCircleTest {
assertEquals(-Math.PI * 0.5 + 0.1, b.getMaxLatitude(), 0.000001);
// Now do a somewhat tilted plane, facing different directions.
- c = new GeoCircle(0.01, 0.0, 0.1);
+ c = new GeoCircle(PlanetModel.SPHERE, 0.01, 0.0, 0.1);
b = c.getBounds(null);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
@@ -132,7 +132,7 @@ public class GeoCircleTest {
assertEquals(-0.1, b.getLeftLongitude(), 0.00001);
assertEquals(0.1, b.getRightLongitude(), 0.00001);
- c = new GeoCircle(0.01, Math.PI, 0.1);
+ c = new GeoCircle(PlanetModel.SPHERE, 0.01, Math.PI, 0.1);
b = c.getBounds(null);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
@@ -142,7 +142,7 @@ public class GeoCircleTest {
assertEquals(Math.PI - 0.1, b.getLeftLongitude(), 0.00001);
assertEquals(-Math.PI + 0.1, b.getRightLongitude(), 0.00001);
- c = new GeoCircle(0.01, Math.PI * 0.5, 0.1);
+ c = new GeoCircle(PlanetModel.SPHERE, 0.01, Math.PI * 0.5, 0.1);
b = c.getBounds(null);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
@@ -152,7 +152,7 @@ public class GeoCircleTest {
assertEquals(Math.PI * 0.5 - 0.1, b.getLeftLongitude(), 0.00001);
assertEquals(Math.PI * 0.5 + 0.1, b.getRightLongitude(), 0.00001);
- c = new GeoCircle(0.01, -Math.PI * 0.5, 0.1);
+ c = new GeoCircle(PlanetModel.SPHERE, 0.01, -Math.PI * 0.5, 0.1);
b = c.getBounds(null);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
@@ -163,7 +163,7 @@ public class GeoCircleTest {
assertEquals(-Math.PI * 0.5 + 0.1, b.getRightLongitude(), 0.00001);
// Slightly tilted, PI/4 direction.
- c = new GeoCircle(0.01, Math.PI * 0.25, 0.1);
+ c = new GeoCircle(PlanetModel.SPHERE, 0.01, Math.PI * 0.25, 0.1);
b = c.getBounds(null);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
@@ -173,7 +173,7 @@ public class GeoCircleTest {
assertEquals(Math.PI * 0.25 - 0.1, b.getLeftLongitude(), 0.00001);
assertEquals(Math.PI * 0.25 + 0.1, b.getRightLongitude(), 0.00001);
- c = new GeoCircle(0.01, -Math.PI * 0.25, 0.1);
+ c = new GeoCircle(PlanetModel.SPHERE, 0.01, -Math.PI * 0.25, 0.1);
b = c.getBounds(null);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
@@ -183,7 +183,7 @@ public class GeoCircleTest {
assertEquals(-Math.PI * 0.25 - 0.1, b.getLeftLongitude(), 0.00001);
assertEquals(-Math.PI * 0.25 + 0.1, b.getRightLongitude(), 0.00001);
- c = new GeoCircle(-0.01, Math.PI * 0.25, 0.1);
+ c = new GeoCircle(PlanetModel.SPHERE, -0.01, Math.PI * 0.25, 0.1);
b = c.getBounds(null);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
@@ -193,7 +193,7 @@ public class GeoCircleTest {
assertEquals(Math.PI * 0.25 - 0.1, b.getLeftLongitude(), 0.00001);
assertEquals(Math.PI * 0.25 + 0.1, b.getRightLongitude(), 0.00001);
- c = new GeoCircle(-0.01, -Math.PI * 0.25, 0.1);
+ c = new GeoCircle(PlanetModel.SPHERE, -0.01, -Math.PI * 0.25, 0.1);
b = c.getBounds(null);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
@@ -204,7 +204,7 @@ public class GeoCircleTest {
assertEquals(-Math.PI * 0.25 + 0.1, b.getRightLongitude(), 0.00001);
// Now do a somewhat tilted plane.
- c = new GeoCircle(0.01, -0.5, 0.1);
+ c = new GeoCircle(PlanetModel.SPHERE, 0.01, -0.5, 0.1);
b = c.getBounds(null);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
Modified: lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoConvexPolygonTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoConvexPolygonTest.java?rev=1681907&r1=1681906&r2=1681907&view=diff
==============================================================================
--- lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoConvexPolygonTest.java (original)
+++ lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoConvexPolygonTest.java Wed May 27 04:54:50 2015
@@ -30,37 +30,37 @@ public class GeoConvexPolygonTest {
public void testPolygonPointWithin() {
GeoConvexPolygon c;
GeoPoint gp;
- c = new GeoConvexPolygon(-0.1, -0.5);
+ c = new GeoConvexPolygon(PlanetModel.SPHERE, -0.1, -0.5);
c.addPoint(0.0, -0.6, false);
c.addPoint(0.1, -0.5, false);
c.addPoint(0.0, -0.4, false);
c.donePoints(false);
// Sample some points within
- gp = new GeoPoint(0.0, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.5);
assertTrue(c.isWithin(gp));
- gp = new GeoPoint(0.0, -0.55);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.55);
assertTrue(c.isWithin(gp));
- gp = new GeoPoint(0.0, -0.45);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.45);
assertTrue(c.isWithin(gp));
- gp = new GeoPoint(-0.05, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, -0.05, -0.5);
assertTrue(c.isWithin(gp));
- gp = new GeoPoint(0.05, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.05, -0.5);
assertTrue(c.isWithin(gp));
// Sample some nearby points outside
- gp = new GeoPoint(0.0, -0.65);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.65);
assertFalse(c.isWithin(gp));
- gp = new GeoPoint(0.0, -0.35);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.35);
assertFalse(c.isWithin(gp));
- gp = new GeoPoint(-0.15, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, -0.15, -0.5);
assertFalse(c.isWithin(gp));
- gp = new GeoPoint(0.15, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.15, -0.5);
assertFalse(c.isWithin(gp));
// Random points outside
- gp = new GeoPoint(0.0, 0.0);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, 0.0);
assertFalse(c.isWithin(gp));
- gp = new GeoPoint(Math.PI * 0.5, 0.0);
+ gp = new GeoPoint(PlanetModel.SPHERE, Math.PI * 0.5, 0.0);
assertFalse(c.isWithin(gp));
- gp = new GeoPoint(0.0, Math.PI);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, Math.PI);
assertFalse(c.isWithin(gp));
}
@@ -69,7 +69,7 @@ public class GeoConvexPolygonTest {
GeoConvexPolygon c;
Bounds b;
- c = new GeoConvexPolygon(-0.1, -0.5);
+ c = new GeoConvexPolygon(PlanetModel.SPHERE, -0.1, -0.5);
c.addPoint(0.0, -0.6, false);
c.addPoint(0.1, -0.5, false);
c.addPoint(0.0, -0.4, false);
Added: lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoModelTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoModelTest.java?rev=1681907&view=auto
==============================================================================
--- lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoModelTest.java (added)
+++ lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoModelTest.java Wed May 27 04:54:50 2015
@@ -0,0 +1,106 @@
+package org.apache.lucene.spatial.spatial4j.geo3d;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test basic plane functionality.
+ */
+public class GeoModelTest {
+
+ protected final static PlanetModel scaledModel = new PlanetModel(1.2,1.5);
+
+ @Test
+ public void testBasicCircle() {
+ // The point of this test is just to make sure nothing blows up doing normal things with a quite non-spherical model
+ // Make sure that the north pole is in the circle, and south pole isn't
+ final GeoPoint northPole = new GeoPoint(scaledModel, Math.PI * 0.5, 0.0);
+ final GeoPoint southPole = new GeoPoint(scaledModel, -Math.PI * 0.5, 0.0);
+ final GeoPoint point1 = new GeoPoint(scaledModel, Math.PI * 0.25, 0.0);
+ final GeoPoint point2 = new GeoPoint(scaledModel, Math.PI * 0.125, 0.0);
+
+ GeoCircle circle = new GeoCircle(scaledModel, Math.PI * 0.5, 0.0, 0.01);
+ assertTrue(circle.isWithin(northPole));
+ assertFalse(circle.isWithin(southPole));
+ assertFalse(circle.isWithin(point1));
+ Bounds bounds = circle.getBounds(null);
+ assertTrue(bounds.checkNoLongitudeBound());
+ assertTrue(bounds.checkNoTopLatitudeBound());
+ assertFalse(bounds.checkNoBottomLatitudeBound());
+ assertEquals(Math.PI * 0.5 - 0.01, bounds.getMinLatitude(), 0.01);
+
+ circle = new GeoCircle(scaledModel, Math.PI * 0.25, 0.0, 0.01);
+ assertTrue(circle.isWithin(point1));
+ assertFalse(circle.isWithin(northPole));
+ assertFalse(circle.isWithin(southPole));
+ bounds = circle.getBounds(null);
+ assertFalse(bounds.checkNoTopLatitudeBound());
+ assertFalse(bounds.checkNoLongitudeBound());
+ assertFalse(bounds.checkNoBottomLatitudeBound());
+ assertEquals(1.20, bounds.getMaxLatitude(), 0.01);
+ assertEquals(Math.PI * 0.25 - 0.01, bounds.getMinLatitude(), 0.01);
+ assertEquals(-0.36, bounds.getLeftLongitude(), 0.01);
+ assertEquals(0.36, bounds.getRightLongitude(), 0.01);
+
+ circle = new GeoCircle(scaledModel, Math.PI * 0.125, 0.0, 0.01);
+ assertTrue(circle.isWithin(point2));
+ assertFalse(circle.isWithin(northPole));
+ assertFalse(circle.isWithin(southPole));
+ bounds = circle.getBounds(null);
+ assertFalse(bounds.checkNoLongitudeBound());
+ assertFalse(bounds.checkNoTopLatitudeBound());
+ assertFalse(bounds.checkNoBottomLatitudeBound());
+ // Asymmetric, as expected
+ assertEquals(Math.PI * 0.125 - 0.01, bounds.getMinLatitude(), 0.01);
+ assertEquals(0.74, bounds.getMaxLatitude(), 0.01);
+ assertEquals(-0.18, bounds.getLeftLongitude(), 0.01);
+ assertEquals(0.18, bounds.getRightLongitude(), 0.01);
+
+ }
+
+ @Test
+ public void testBasicRectangle() {
+ final GeoBBox bbox = GeoBBoxFactory.makeGeoBBox(scaledModel, 1.0, 0.0, 0.0, 1.0);
+ final GeoPoint insidePoint = new GeoPoint(scaledModel, 0.5, 0.5);
+ assertTrue(bbox.isWithin(insidePoint));
+ final GeoPoint topOutsidePoint = new GeoPoint(scaledModel, 1.01, 0.5);
+ assertFalse(bbox.isWithin(topOutsidePoint));
+ final GeoPoint bottomOutsidePoint = new GeoPoint(scaledModel, -0.01, 0.5);
+ assertFalse(bbox.isWithin(bottomOutsidePoint));
+ final GeoPoint leftOutsidePoint = new GeoPoint(scaledModel, 0.5, -0.01);
+ assertFalse(bbox.isWithin(leftOutsidePoint));
+ final GeoPoint rightOutsidePoint = new GeoPoint(scaledModel, 0.5, 1.01);
+ assertFalse(bbox.isWithin(rightOutsidePoint));
+ final Bounds bounds = bbox.getBounds(null);
+ assertFalse(bounds.checkNoLongitudeBound());
+ assertFalse(bounds.checkNoTopLatitudeBound());
+ assertFalse(bounds.checkNoBottomLatitudeBound());
+ assertEquals(1.0, bounds.getMaxLatitude(), 0.00001);
+ assertEquals(0.0, bounds.getMinLatitude(), 0.00001);
+ assertEquals(1.0, bounds.getRightLongitude(), 0.00001);
+ assertEquals(0.0, bounds.getLeftLongitude(), 0.00001);
+ }
+
+}
+
+
Modified: lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoPathTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoPathTest.java?rev=1681907&r1=1681906&r2=1681907&view=diff
==============================================================================
--- lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoPathTest.java (original)
+++ lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoPathTest.java Wed May 27 04:54:50 2015
@@ -30,47 +30,47 @@ public class GeoPathTest {
// Start with a really simple case
GeoPath p;
GeoPoint gp;
- p = new GeoPath(0.1);
+ p = new GeoPath(PlanetModel.SPHERE, 0.1);
p.addPoint(0.0, 0.0);
p.addPoint(0.0, 0.1);
p.addPoint(0.0, 0.2);
p.done();
- gp = new GeoPoint(Math.PI * 0.5, 0.15);
+ gp = new GeoPoint(PlanetModel.SPHERE, Math.PI * 0.5, 0.15);
assertEquals(Double.MAX_VALUE, p.computeArcDistance(gp), 0.0);
- gp = new GeoPoint(0.05, 0.15);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.05, 0.15);
assertEquals(0.15 + 0.05, p.computeArcDistance(gp), 0.000001);
- gp = new GeoPoint(0.0, 0.12);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, 0.12);
assertEquals(0.12 + 0.0, p.computeArcDistance(gp), 0.000001);
- gp = new GeoPoint(-0.15, 0.05);
+ gp = new GeoPoint(PlanetModel.SPHERE, -0.15, 0.05);
assertEquals(Double.MAX_VALUE, p.computeArcDistance(gp), 0.000001);
- gp = new GeoPoint(0.0, 0.25);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, 0.25);
assertEquals(0.20 + 0.05, p.computeArcDistance(gp), 0.000001);
- gp = new GeoPoint(0.0, -0.05);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.05);
assertEquals(0.0 + 0.05, p.computeArcDistance(gp), 0.000001);
// Compute path distances now
- p = new GeoPath(0.1);
+ p = new GeoPath(PlanetModel.SPHERE, 0.1);
p.addPoint(0.0, 0.0);
p.addPoint(0.0, 0.1);
p.addPoint(0.0, 0.2);
p.done();
- gp = new GeoPoint(0.05, 0.15);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.05, 0.15);
assertEquals(0.15 + 0.05, p.computeArcDistance(gp), 0.000001);
- gp = new GeoPoint(0.0, 0.12);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, 0.12);
assertEquals(0.12, p.computeArcDistance(gp), 0.000001);
// Now try a vertical path, and make sure distances are as expected
- p = new GeoPath(0.1);
+ p = new GeoPath(PlanetModel.SPHERE, 0.1);
p.addPoint(-Math.PI * 0.25, -0.5);
p.addPoint(Math.PI * 0.25, -0.5);
p.done();
- gp = new GeoPoint(0.0, 0.0);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, 0.0);
assertEquals(Double.MAX_VALUE, p.computeArcDistance(gp), 0.0);
- gp = new GeoPoint(-0.1, -1.0);
+ gp = new GeoPoint(PlanetModel.SPHERE, -0.1, -1.0);
assertEquals(Double.MAX_VALUE, p.computeArcDistance(gp), 0.0);
- gp = new GeoPoint(Math.PI * 0.25 + 0.05, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, Math.PI * 0.25 + 0.05, -0.5);
assertEquals(Math.PI * 0.5 + 0.05, p.computeArcDistance(gp), 0.000001);
- gp = new GeoPoint(-Math.PI * 0.25 - 0.05, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, -Math.PI * 0.25 - 0.05, -0.5);
assertEquals(0.0 + 0.05, p.computeArcDistance(gp), 0.000001);
}
@@ -79,47 +79,48 @@ public class GeoPathTest {
// Tests whether we can properly detect whether a point is within a path or not
GeoPath p;
GeoPoint gp;
- p = new GeoPath(0.1);
+ p = new GeoPath(PlanetModel.SPHERE, 0.1);
// Build a diagonal path crossing the equator
p.addPoint(-0.2, -0.2);
p.addPoint(0.2, 0.2);
p.done();
// Test points on the path
- gp = new GeoPoint(-0.2, -0.2);
+ gp = new GeoPoint(PlanetModel.SPHERE, -0.2, -0.2);
assertTrue(p.isWithin(gp));
- gp = new GeoPoint(0.0, 0.0);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, 0.0);
assertTrue(p.isWithin(gp));
- gp = new GeoPoint(0.1, 0.1);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.1, 0.1);
assertTrue(p.isWithin(gp));
// Test points off the path
- gp = new GeoPoint(-0.2, 0.2);
+ gp = new GeoPoint(PlanetModel.SPHERE, -0.2, 0.2);
assertFalse(p.isWithin(gp));
- gp = new GeoPoint(-Math.PI * 0.5, 0.0);
+ gp = new GeoPoint(PlanetModel.SPHERE, -Math.PI * 0.5, 0.0);
assertFalse(p.isWithin(gp));
- gp = new GeoPoint(0.2, -0.2);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.2, -0.2);
assertFalse(p.isWithin(gp));
- gp = new GeoPoint(0.0, Math.PI);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, Math.PI);
assertFalse(p.isWithin(gp));
// Repeat the test, but across the terminator
- p = new GeoPath(0.1);
+ p = new GeoPath(PlanetModel.SPHERE, 0.1);
// Build a diagonal path crossing the equator
p.addPoint(-0.2, Math.PI - 0.2);
p.addPoint(0.2, -Math.PI + 0.2);
+ p.done();
// Test points on the path
- gp = new GeoPoint(-0.2, Math.PI - 0.2);
+ gp = new GeoPoint(PlanetModel.SPHERE, -0.2, Math.PI - 0.2);
assertTrue(p.isWithin(gp));
- gp = new GeoPoint(0.0, Math.PI);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, Math.PI);
assertTrue(p.isWithin(gp));
- gp = new GeoPoint(0.1, -Math.PI + 0.1);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.1, -Math.PI + 0.1);
assertTrue(p.isWithin(gp));
// Test points off the path
- gp = new GeoPoint(-0.2, -Math.PI + 0.2);
+ gp = new GeoPoint(PlanetModel.SPHERE, -0.2, -Math.PI + 0.2);
assertFalse(p.isWithin(gp));
- gp = new GeoPoint(-Math.PI * 0.5, 0.0);
+ gp = new GeoPoint(PlanetModel.SPHERE, -Math.PI * 0.5, 0.0);
assertFalse(p.isWithin(gp));
- gp = new GeoPoint(0.2, Math.PI - 0.2);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.2, Math.PI - 0.2);
assertFalse(p.isWithin(gp));
- gp = new GeoPoint(0.0, 0.0);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, 0.0);
assertFalse(p.isWithin(gp));
}
@@ -131,31 +132,31 @@ public class GeoPathTest {
// Start by testing the basic kinds of relationship, increasing in order of difficulty.
- p = new GeoPath(0.1);
+ p = new GeoPath(PlanetModel.SPHERE, 0.1);
p.addPoint(-0.3, -0.3);
p.addPoint(0.3, 0.3);
p.done();
// Easiest: The path is wholly contains the georect
- rect = new GeoRectangle(0.05, -0.05, -0.05, 0.05);
+ rect = new GeoRectangle(PlanetModel.SPHERE, 0.05, -0.05, -0.05, 0.05);
assertEquals(GeoArea.CONTAINS, rect.getRelationship(p));
// Next easiest: Some endpoints of the rectangle are inside, and some are outside.
- rect = new GeoRectangle(0.05, -0.05, -0.05, 0.5);
+ rect = new GeoRectangle(PlanetModel.SPHERE, 0.05, -0.05, -0.05, 0.5);
assertEquals(GeoArea.OVERLAPS, rect.getRelationship(p));
// Now, all points are outside, but the figures intersect
- rect = new GeoRectangle(0.05, -0.05, -0.5, 0.5);
+ rect = new GeoRectangle(PlanetModel.SPHERE, 0.05, -0.05, -0.5, 0.5);
assertEquals(GeoArea.OVERLAPS, rect.getRelationship(p));
// Finally, all points are outside, and the figures *do not* intersect
- rect = new GeoRectangle(0.5, -0.5, -0.5, 0.5);
+ rect = new GeoRectangle(PlanetModel.SPHERE, 0.5, -0.5, -0.5, 0.5);
assertEquals(GeoArea.WITHIN, rect.getRelationship(p));
// Check that segment edge overlap detection works
- rect = new GeoRectangle(0.1, 0.0, -0.1, 0.0);
+ rect = new GeoRectangle(PlanetModel.SPHERE, 0.1, 0.0, -0.1, 0.0);
assertEquals(GeoArea.OVERLAPS, rect.getRelationship(p));
- rect = new GeoRectangle(0.2, 0.1, -0.2, -0.1);
+ rect = new GeoRectangle(PlanetModel.SPHERE, 0.2, 0.1, -0.2, -0.1);
assertEquals(GeoArea.DISJOINT, rect.getRelationship(p));
// Check if overlap at endpoints behaves as expected next
- rect = new GeoRectangle(0.5, -0.5, -0.5, -0.35);
+ rect = new GeoRectangle(PlanetModel.SPHERE, 0.5, -0.5, -0.5, -0.35);
assertEquals(GeoArea.OVERLAPS, rect.getRelationship(p));
- rect = new GeoRectangle(0.5, -0.5, -0.5, -0.45);
+ rect = new GeoRectangle(PlanetModel.SPHERE, 0.5, -0.5, -0.5, -0.45);
assertEquals(GeoArea.DISJOINT, rect.getRelationship(p));
}
@@ -165,7 +166,7 @@ public class GeoPathTest {
GeoPath c;
Bounds b;
- c = new GeoPath(0.1);
+ c = new GeoPath(PlanetModel.SPHERE, 0.1);
c.addPoint(-0.3, -0.3);
c.addPoint(0.3, 0.3);
c.done();
Modified: lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoPolygonTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoPolygonTest.java?rev=1681907&r1=1681906&r2=1681907&view=diff
==============================================================================
--- lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoPolygonTest.java (original)
+++ lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoPolygonTest.java Wed May 27 04:54:50 2015
@@ -36,49 +36,49 @@ public class GeoPolygonTest {
List<GeoPoint> points;
points = new ArrayList<GeoPoint>();
- points.add(new GeoPoint(-0.1, -0.5));
- points.add(new GeoPoint(0.0, -0.6));
- points.add(new GeoPoint(0.1, -0.5));
- points.add(new GeoPoint(0.0, -0.4));
+ points.add(new GeoPoint(PlanetModel.SPHERE, -0.1, -0.5));
+ points.add(new GeoPoint(PlanetModel.SPHERE, 0.0, -0.6));
+ points.add(new GeoPoint(PlanetModel.SPHERE, 0.1, -0.5));
+ points.add(new GeoPoint(PlanetModel.SPHERE, 0.0, -0.4));
- c = GeoPolygonFactory.makeGeoPolygon(points, 0);
+ c = GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points, 0);
// Sample some points within
- gp = new GeoPoint(0.0, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.5);
assertTrue(c.isWithin(gp));
- gp = new GeoPoint(0.0, -0.55);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.55);
assertTrue(c.isWithin(gp));
- gp = new GeoPoint(0.0, -0.45);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.45);
assertTrue(c.isWithin(gp));
- gp = new GeoPoint(-0.05, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, -0.05, -0.5);
assertTrue(c.isWithin(gp));
- gp = new GeoPoint(0.05, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.05, -0.5);
assertTrue(c.isWithin(gp));
// Sample some nearby points outside
- gp = new GeoPoint(0.0, -0.65);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.65);
assertFalse(c.isWithin(gp));
- gp = new GeoPoint(0.0, -0.35);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.35);
assertFalse(c.isWithin(gp));
- gp = new GeoPoint(-0.15, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, -0.15, -0.5);
assertFalse(c.isWithin(gp));
- gp = new GeoPoint(0.15, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.15, -0.5);
assertFalse(c.isWithin(gp));
// Random points outside
- gp = new GeoPoint(0.0, 0.0);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, 0.0);
assertFalse(c.isWithin(gp));
- gp = new GeoPoint(Math.PI * 0.5, 0.0);
+ gp = new GeoPoint(PlanetModel.SPHERE, Math.PI * 0.5, 0.0);
assertFalse(c.isWithin(gp));
- gp = new GeoPoint(0.0, Math.PI);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, Math.PI);
assertFalse(c.isWithin(gp));
points = new ArrayList<GeoPoint>();
- points.add(new GeoPoint(-0.1, -0.5));
- points.add(new GeoPoint(-0.01, -0.6));
- points.add(new GeoPoint(-0.1, -0.7));
- points.add(new GeoPoint(0.0, -0.8));
- points.add(new GeoPoint(0.1, -0.7));
- points.add(new GeoPoint(0.01, -0.6));
- points.add(new GeoPoint(0.1, -0.5));
- points.add(new GeoPoint(0.0, -0.4));
+ points.add(new GeoPoint(PlanetModel.SPHERE, -0.1, -0.5));
+ points.add(new GeoPoint(PlanetModel.SPHERE, -0.01, -0.6));
+ points.add(new GeoPoint(PlanetModel.SPHERE, -0.1, -0.7));
+ points.add(new GeoPoint(PlanetModel.SPHERE, 0.0, -0.8));
+ points.add(new GeoPoint(PlanetModel.SPHERE, 0.1, -0.7));
+ points.add(new GeoPoint(PlanetModel.SPHERE, 0.01, -0.6));
+ points.add(new GeoPoint(PlanetModel.SPHERE, 0.1, -0.5));
+ points.add(new GeoPoint(PlanetModel.SPHERE, 0.0, -0.4));
/*
System.out.println("Points: ");
@@ -87,33 +87,33 @@ public class GeoPolygonTest {
}
*/
- c = GeoPolygonFactory.makeGeoPolygon(points, 0);
+ c = GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points, 0);
// Sample some points within
- gp = new GeoPoint(0.0, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.5);
assertTrue(c.isWithin(gp));
- gp = new GeoPoint(0.0, -0.55);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.55);
assertTrue(c.isWithin(gp));
- gp = new GeoPoint(0.0, -0.45);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.45);
assertTrue(c.isWithin(gp));
- gp = new GeoPoint(-0.05, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, -0.05, -0.5);
assertTrue(c.isWithin(gp));
- gp = new GeoPoint(0.05, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.05, -0.5);
assertTrue(c.isWithin(gp));
- gp = new GeoPoint(0.0, -0.7);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.7);
assertTrue(c.isWithin(gp));
// Sample some nearby points outside
- gp = new GeoPoint(0.0, -0.35);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, -0.35);
assertFalse(c.isWithin(gp));
- gp = new GeoPoint(-0.15, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, -0.15, -0.5);
assertFalse(c.isWithin(gp));
- gp = new GeoPoint(0.15, -0.5);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.15, -0.5);
assertFalse(c.isWithin(gp));
// Random points outside
- gp = new GeoPoint(0.0, 0.0);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, 0.0);
assertFalse(c.isWithin(gp));
- gp = new GeoPoint(Math.PI * 0.5, 0.0);
+ gp = new GeoPoint(PlanetModel.SPHERE, Math.PI * 0.5, 0.0);
assertFalse(c.isWithin(gp));
- gp = new GeoPoint(0.0, Math.PI);
+ gp = new GeoPoint(PlanetModel.SPHERE, 0.0, Math.PI);
assertFalse(c.isWithin(gp));
}
@@ -125,12 +125,12 @@ public class GeoPolygonTest {
List<GeoPoint> points;
points = new ArrayList<GeoPoint>();
- points.add(new GeoPoint(-0.1, -0.5));
- points.add(new GeoPoint(0.0, -0.6));
- points.add(new GeoPoint(0.1, -0.5));
- points.add(new GeoPoint(0.0, -0.4));
+ points.add(new GeoPoint(PlanetModel.SPHERE, -0.1, -0.5));
+ points.add(new GeoPoint(PlanetModel.SPHERE, 0.0, -0.6));
+ points.add(new GeoPoint(PlanetModel.SPHERE, 0.1, -0.5));
+ points.add(new GeoPoint(PlanetModel.SPHERE, 0.0, -0.4));
- c = GeoPolygonFactory.makeGeoPolygon(points, 0);
+ c = GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points, 0);
b = c.getBounds(null);
assertFalse(b.checkNoLongitudeBound());
Modified: lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/PlaneTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/PlaneTest.java?rev=1681907&r1=1681906&r2=1681907&view=diff
==============================================================================
--- lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/PlaneTest.java (original)
+++ lucene/dev/branches/lucene6487/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/PlaneTest.java Wed May 27 04:54:50 2015
@@ -30,7 +30,7 @@ public class PlaneTest {
@Test
public void testIdenticalPlanes() {
- final GeoPoint p = new GeoPoint(0.123, -0.456);
+ final GeoPoint p = new GeoPoint(PlanetModel.SPHERE, 0.123, -0.456);
final Plane plane1 = new Plane(p, 0.0);
final Plane plane2 = new Plane(p, 0.0);
assertTrue(plane1.isNumericallyIdentical(plane2));