use of org.apache.lucene.spatial3d.geom.GeoPoint in project lucene-solr by apache.
the class TestGeo3DPoint method convertToPoints.
protected static List<GeoPoint> convertToPoints(final PlanetModel pm, final GeoPoint pole, final double[] angles, final double[] arcDistances) {
// To do the point rotations, we need the sine and cosine of the pole latitude and longitude. Get it here for performance.
final double sinLatitude = Math.sin(pole.getLatitude());
final double cosLatitude = Math.cos(pole.getLatitude());
final double sinLongitude = Math.sin(pole.getLongitude());
final double cosLongitude = Math.cos(pole.getLongitude());
final List<GeoPoint> rval = new ArrayList<>();
for (int i = 0; i < angles.length; i++) {
rval.add(createPoint(pm, angles[i], arcDistances[i], sinLatitude, cosLatitude, sinLongitude, cosLongitude));
}
return rval;
}
use of org.apache.lucene.spatial3d.geom.GeoPoint in project lucene-solr by apache.
the class TestGeo3DPoint method testEncodeDecodeCeil.
public void testEncodeDecodeCeil() throws Exception {
// just for testing quantization error
final double ENCODING_TOLERANCE = Geo3DUtil.DECODE;
int iters = atLeast(10000);
for (int iter = 0; iter < iters; iter++) {
GeoPoint point = new GeoPoint(PlanetModel.WGS84, toRadians(GeoTestUtil.nextLatitude()), toRadians(GeoTestUtil.nextLongitude()));
double xEnc = Geo3DUtil.decodeValue(Geo3DUtil.encodeValue(point.x));
assertEquals("x=" + point.x + " xEnc=" + xEnc + " diff=" + (point.x - xEnc), point.x, xEnc, ENCODING_TOLERANCE);
double yEnc = Geo3DUtil.decodeValue(Geo3DUtil.encodeValue(point.y));
assertEquals("y=" + point.y + " yEnc=" + yEnc + " diff=" + (point.y - yEnc), point.y, yEnc, ENCODING_TOLERANCE);
double zEnc = Geo3DUtil.decodeValue(Geo3DUtil.encodeValue(point.z));
assertEquals("z=" + point.z + " zEnc=" + zEnc + " diff=" + (point.z - zEnc), point.z, zEnc, ENCODING_TOLERANCE);
}
// check edge/interesting cases explicitly
double planetMax = PlanetModel.WGS84.getMaximumMagnitude();
for (double value : new double[] { 0.0, -planetMax, planetMax }) {
assertEquals(value, Geo3DUtil.decodeValue(Geo3DUtil.encodeValue(value)), ENCODING_TOLERANCE);
}
}
use of org.apache.lucene.spatial3d.geom.GeoPoint in project lucene-solr by apache.
the class Geo3dRptTest method testFailureLucene6535.
@Test
public void testFailureLucene6535() throws IOException {
setupStrategy();
final List<GeoPoint> points = new ArrayList<>();
points.add(new GeoPoint(PlanetModel.SPHERE, 18 * DEGREES_TO_RADIANS, -27 * DEGREES_TO_RADIANS));
points.add(new GeoPoint(PlanetModel.SPHERE, -57 * DEGREES_TO_RADIANS, 146 * DEGREES_TO_RADIANS));
points.add(new GeoPoint(PlanetModel.SPHERE, 14 * DEGREES_TO_RADIANS, -180 * DEGREES_TO_RADIANS));
points.add(new GeoPoint(PlanetModel.SPHERE, -15 * DEGREES_TO_RADIANS, 153 * DEGREES_TO_RADIANS));
final GeoPoint[] pathPoints = new GeoPoint[] { new GeoPoint(PlanetModel.SPHERE, 55.0 * DEGREES_TO_RADIANS, -26.0 * DEGREES_TO_RADIANS), new GeoPoint(PlanetModel.SPHERE, -90.0 * DEGREES_TO_RADIANS, 0.0), new GeoPoint(PlanetModel.SPHERE, 54.0 * DEGREES_TO_RADIANS, 165.0 * DEGREES_TO_RADIANS), new GeoPoint(PlanetModel.SPHERE, -90.0 * DEGREES_TO_RADIANS, 0.0) };
final GeoShape path = GeoPathFactory.makeGeoPath(PlanetModel.SPHERE, 29 * DEGREES_TO_RADIANS, pathPoints);
final Shape shape = new Geo3dShape(path, ctx);
final Rectangle rect = ctx.makeRectangle(131, 143, 39, 54);
testOperation(rect, SpatialOperation.Intersects, shape, true);
}
use of org.apache.lucene.spatial3d.geom.GeoPoint in project lucene-solr by apache.
the class TestGeo3DPoint method testEncodeDecodeRoundsDown.
/** make sure values always go down: this is important for edge case consistency */
public void testEncodeDecodeRoundsDown() throws Exception {
int iters = atLeast(1000);
for (int iter = 0; iter < iters; iter++) {
final double latBase = GeoTestUtil.nextLatitude();
final double lonBase = GeoTestUtil.nextLongitude();
// test above the value
double lat = latBase;
double lon = lonBase;
for (int i = 0; i < 1000; i++) {
lat = Math.min(90, Math.nextUp(lat));
lon = Math.min(180, Math.nextUp(lon));
GeoPoint point = new GeoPoint(PlanetModel.WGS84, toRadians(lat), toRadians(lon));
GeoPoint pointEnc = new GeoPoint(Geo3DUtil.decodeValueFloor(Geo3DUtil.encodeValue(point.x)), Geo3DUtil.decodeValueFloor(Geo3DUtil.encodeValue(point.y)), Geo3DUtil.decodeValueFloor(Geo3DUtil.encodeValue(point.z)));
assertTrue(pointEnc.x <= point.x);
assertTrue(pointEnc.y <= point.y);
assertTrue(pointEnc.z <= point.z);
}
// test below the value
lat = latBase;
lon = lonBase;
for (int i = 0; i < 1000; i++) {
lat = Math.max(-90, Math.nextDown(lat));
lon = Math.max(-180, Math.nextDown(lon));
GeoPoint point = new GeoPoint(PlanetModel.WGS84, toRadians(lat), toRadians(lon));
GeoPoint pointEnc = new GeoPoint(Geo3DUtil.decodeValueFloor(Geo3DUtil.encodeValue(point.x)), Geo3DUtil.decodeValueFloor(Geo3DUtil.encodeValue(point.y)), Geo3DUtil.decodeValueFloor(Geo3DUtil.encodeValue(point.z)));
assertTrue(pointEnc.x <= point.x);
assertTrue(pointEnc.y <= point.y);
assertTrue(pointEnc.z <= point.z);
}
}
}
Aggregations