LUCENE-6487: Geo3D with WGS84: randomize GeoPointTest lat-lon round-trip

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene6487@1682359 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
David Wayne Smiley 2015-05-29 02:07:55 +00:00
parent 97a5295f07
commit e8b5e3242d
1 changed files with 6 additions and 4 deletions

View File

@ -17,19 +17,21 @@ package org.apache.lucene.spatial.spatial4j.geo3d;
* limitations under the License. * limitations under the License.
*/ */
import com.spatial4j.core.distance.DistanceUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals; import static com.carrotsearch.randomizedtesting.RandomizedTest.randomFloat;
/** /**
* Test basic GeoPoint functionality. * Test basic GeoPoint functionality.
*/ */
public class GeoPointTest { public class GeoPointTest extends LuceneTestCase {
@Test @Test
public void testConversion() { public void testConversion() {
final double pLat = 0.123; final double pLat = (randomFloat() * 180.0 - 90.0) * DistanceUtils.DEGREES_TO_RADIANS;
final double pLon = -0.456; final double pLon = (randomFloat() * 360.0 - 180.0) * DistanceUtils.DEGREES_TO_RADIANS;
final GeoPoint p1 = new GeoPoint(PlanetModel.SPHERE, pLat, pLon); final GeoPoint p1 = new GeoPoint(PlanetModel.SPHERE, pLat, pLon);
assertEquals(pLat, p1.getLatitude(), 1e-12); assertEquals(pLat, p1.getLatitude(), 1e-12);
assertEquals(pLon, p1.getLongitude(), 1e-12); assertEquals(pLon, p1.getLongitude(), 1e-12);