use of org.opensearch.geometry.utils.GeometryValidator in project OpenSearch by opensearch-project.
the class CircleTests method testInitValidation.
public void testInitValidation() {
GeometryValidator validator = new GeographyValidator(true);
IllegalArgumentException ex = expectThrows(IllegalArgumentException.class, () -> validator.validate(new Circle(20, 10, -1)));
assertEquals("Circle radius [-1.0] cannot be negative", ex.getMessage());
ex = expectThrows(IllegalArgumentException.class, () -> validator.validate(new Circle(20, 100, 1)));
assertEquals("invalid latitude 100.0; must be between -90.0 and 90.0", ex.getMessage());
ex = expectThrows(IllegalArgumentException.class, () -> validator.validate(new Circle(200, 10, 1)));
assertEquals("invalid longitude 200.0; must be between -180.0 and 180.0", ex.getMessage());
ex = expectThrows(IllegalArgumentException.class, () -> new StandardValidator(false).validate(new Circle(200, 10, 1, 20)));
assertEquals("found Z value [1.0] but [ignore_z_value] parameter is [false]", ex.getMessage());
new StandardValidator(true).validate(new Circle(200, 10, 1, 20));
}
use of org.opensearch.geometry.utils.GeometryValidator in project OpenSearch by opensearch-project.
the class PointTests method testInitValidation.
public void testInitValidation() {
GeometryValidator validator = new GeographyValidator(true);
IllegalArgumentException ex = expectThrows(IllegalArgumentException.class, () -> validator.validate(new Point(10, 100)));
assertEquals("invalid latitude 100.0; must be between -90.0 and 90.0", ex.getMessage());
ex = expectThrows(IllegalArgumentException.class, () -> validator.validate(new Point(500, 10)));
assertEquals("invalid longitude 500.0; must be between -180.0 and 180.0", ex.getMessage());
ex = expectThrows(IllegalArgumentException.class, () -> new StandardValidator(false).validate(new Point(2, 1, 3)));
assertEquals("found Z value [3.0] but [ignore_z_value] parameter is [false]", ex.getMessage());
new StandardValidator(true).validate(new Point(2, 1, 3));
}
use of org.opensearch.geometry.utils.GeometryValidator in project OpenSearch by opensearch-project.
the class RectangleTests method testInitValidation.
public void testInitValidation() {
GeometryValidator validator = new GeographyValidator(true);
IllegalArgumentException ex = expectThrows(IllegalArgumentException.class, () -> validator.validate(new Rectangle(2, 3, 100, 1)));
assertEquals("invalid latitude 100.0; must be between -90.0 and 90.0", ex.getMessage());
ex = expectThrows(IllegalArgumentException.class, () -> validator.validate(new Rectangle(200, 3, 2, 1)));
assertEquals("invalid longitude 200.0; must be between -180.0 and 180.0", ex.getMessage());
ex = expectThrows(IllegalArgumentException.class, () -> validator.validate(new Rectangle(2, 3, 1, 2)));
assertEquals("max y cannot be less than min x", ex.getMessage());
ex = expectThrows(IllegalArgumentException.class, () -> validator.validate(new Rectangle(2, 3, 2, 1, 5, Double.NaN)));
assertEquals("only one z value is specified", ex.getMessage());
ex = expectThrows(IllegalArgumentException.class, () -> new StandardValidator(false).validate(new Rectangle(50, 10, 40, 30, 20, 60)));
assertEquals("found Z value [20.0] but [ignore_z_value] parameter is [false]", ex.getMessage());
new StandardValidator(true).validate(new Rectangle(50, 10, 40, 30, 20, 60));
}
use of org.opensearch.geometry.utils.GeometryValidator in project OpenSearch by opensearch-project.
the class LineTests method testInitValidation.
public void testInitValidation() {
GeometryValidator validator = new GeographyValidator(true);
IllegalArgumentException ex = expectThrows(IllegalArgumentException.class, () -> validator.validate(new Line(new double[] { 3 }, new double[] { 1 })));
assertEquals("at least two points in the line is required", ex.getMessage());
ex = expectThrows(IllegalArgumentException.class, () -> validator.validate(new Line(new double[] { 3, 4, 500, 3 }, new double[] { 1, 2, 3, 1 })));
assertEquals("invalid longitude 500.0; must be between -180.0 and 180.0", ex.getMessage());
ex = expectThrows(IllegalArgumentException.class, () -> validator.validate(new Line(new double[] { 3, 4, 5, 3 }, new double[] { 1, 100, 3, 1 })));
assertEquals("invalid latitude 100.0; must be between -90.0 and 90.0", ex.getMessage());
ex = expectThrows(IllegalArgumentException.class, () -> new StandardValidator(false).validate(new Line(new double[] { 3, 4 }, new double[] { 1, 2 }, new double[] { 6, 5 })));
assertEquals("found Z value [6.0] but [ignore_z_value] parameter is [false]", ex.getMessage());
new StandardValidator(true).validate(new Line(new double[] { 3, 4 }, new double[] { 1, 2 }, new double[] { 6, 5 }));
}
use of org.opensearch.geometry.utils.GeometryValidator in project OpenSearch by opensearch-project.
the class LinearRingTests method testInitValidation.
public void testInitValidation() {
GeometryValidator validator = new GeographyValidator(true);
IllegalArgumentException ex = expectThrows(IllegalArgumentException.class, () -> validator.validate(new LinearRing(new double[] { 3, 4, 5 }, new double[] { 1, 2, 3 })));
assertEquals("first and last points of the linear ring must be the same (it must close itself): x[0]=3.0 x[2]=5.0 y[0]=1.0 " + "y[2]=3.0", ex.getMessage());
ex = expectThrows(IllegalArgumentException.class, () -> validator.validate(new LinearRing(new double[] { 3, 4, 3 }, new double[] { 1, 2, 1 }, new double[] { 1, 2, 3 })));
assertEquals("first and last points of the linear ring must be the same (it must close itself): x[0]=3.0 x[2]=3.0 y[0]=1.0 " + "y[2]=1.0 z[0]=1.0 z[2]=3.0", ex.getMessage());
ex = expectThrows(IllegalArgumentException.class, () -> validator.validate(new LinearRing(new double[] { 3 }, new double[] { 1 })));
assertEquals("at least two points in the line is required", ex.getMessage());
ex = expectThrows(IllegalArgumentException.class, () -> validator.validate(new LinearRing(new double[] { 3, 4, 500, 3 }, new double[] { 1, 2, 3, 1 })));
assertEquals("invalid longitude 500.0; must be between -180.0 and 180.0", ex.getMessage());
ex = expectThrows(IllegalArgumentException.class, () -> validator.validate(new LinearRing(new double[] { 3, 4, 5, 3 }, new double[] { 1, 100, 3, 1 })));
assertEquals("invalid latitude 100.0; must be between -90.0 and 90.0", ex.getMessage());
ex = expectThrows(IllegalArgumentException.class, () -> new StandardValidator(false).validate(new LinearRing(new double[] { 3, 4, 5, 3 }, new double[] { 1, 2, 3, 1 }, new double[] { 1, 1, 1, 1 })));
assertEquals("found Z value [1.0] but [ignore_z_value] parameter is [false]", ex.getMessage());
new StandardValidator(true).validate(new LinearRing(new double[] { 3, 4, 5, 3 }, new double[] { 1, 2, 3, 1 }, new double[] { 1, 1, 1, 1 }));
}
Aggregations