This commit is contained in:
parent
04a531dcfa
commit
14ab35e323
|
@ -251,14 +251,16 @@ public class CentroidCalculatorTests extends ESTestCase {
|
|||
assertThat(calculator.getDimensionalShapeType(), equalTo(LINE));
|
||||
}
|
||||
|
||||
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/58245")
|
||||
public void testPolygonAsPoint() {
|
||||
Point point = GeometryTestUtils.randomPoint(false);
|
||||
Polygon polygon = new Polygon(new LinearRing(new double[] { point.getX(), point.getX(), point.getX(), point.getX() },
|
||||
new double[] { point.getY(), point.getY(), point.getY(), point.getY() }));
|
||||
CentroidCalculator calculator = new CentroidCalculator(polygon);
|
||||
assertThat(calculator.getX(), equalTo(GeoUtils.normalizeLon(point.getX())));
|
||||
assertThat(calculator.getY(), equalTo(GeoUtils.normalizeLat(point.getY())));
|
||||
double normLon = GeoUtils.normalizeLon(point.getX());
|
||||
double normLat = GeoUtils.normalizeLat(point.getY());
|
||||
// make calculation to account for floating-point arithmetic
|
||||
assertThat(calculator.getX(), equalTo((3 * normLon) / 3));
|
||||
assertThat(calculator.getY(), equalTo((3 * normLat) / 3));
|
||||
assertThat(calculator.sumWeight(), equalTo(3.0));
|
||||
assertThat(calculator.getDimensionalShapeType(), equalTo(POINT));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue