LUCENE-6487: Geo3D with WGS84 patch from Karl: fix bug in GeoPoint.getLongitude with test

from https://reviews.apache.org/r/34744/diff/raw/

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene6487@1682357 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
David Wayne Smiley 2015-05-29 00:20:01 +00:00
parent 0a00734a60
commit 97a5295f07
2 changed files with 45 additions and 1 deletions

View File

@ -91,7 +91,7 @@ public class GeoPoint extends Vector {
public double getLongitude() {
if (Math.abs(x) < MINIMUM_RESOLUTION && Math.abs(y) < MINIMUM_RESOLUTION)
return 0.0;
return Math.atan2(y,z);
return Math.atan2(y,x);
}
/** Compute the linear magnitude of the point.

View File

@ -0,0 +1,44 @@
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;
/**
* Test basic GeoPoint functionality.
*/
public class GeoPointTest {
@Test
public void testConversion() {
final double pLat = 0.123;
final double pLon = -0.456;
final GeoPoint p1 = new GeoPoint(PlanetModel.SPHERE, pLat, pLon);
assertEquals(pLat, p1.getLatitude(), 1e-12);
assertEquals(pLon, p1.getLongitude(), 1e-12);
final GeoPoint p2 = new GeoPoint(PlanetModel.WGS84, pLat, pLon);
assertEquals(pLat, p2.getLatitude(), 1e-12);
assertEquals(pLon, p2.getLongitude(), 1e-12);
}
}