use of org.opensearch.geometry.Point in project OpenSearch by opensearch-project.
the class GeometryIndexerTests method testPoint.
public void testPoint() {
Point point = new Point(2, 1);
Geometry indexed = point;
assertEquals(indexed, indexer.prepareForIndexing(point));
point = new Point(2, 1, 3);
assertEquals(indexed, indexer.prepareForIndexing(point));
point = new Point(362, 1);
assertEquals(indexed, indexer.prepareForIndexing(point));
point = new Point(-178, 179);
assertEquals(indexed, indexer.prepareForIndexing(point));
point = new Point(180, 180);
assertEquals(new Point(0, 0), indexer.prepareForIndexing(point));
point = new Point(-180, -180);
assertEquals(new Point(0, 0), indexer.prepareForIndexing(point));
}
use of org.opensearch.geometry.Point in project OpenSearch by opensearch-project.
the class GeoJsonParserTests method testParseGeometryCollection.
@Override
public void testParseGeometryCollection() throws IOException {
XContentBuilder geometryCollectionGeoJson = XContentFactory.jsonBuilder().startObject().field("type", "GeometryCollection").startArray("geometries").startObject().field("type", "LineString").startArray("coordinates").startArray().value(100.0).value(0.0).endArray().startArray().value(101.0).value(1.0).endArray().endArray().endObject().startObject().field("type", "Point").startArray("coordinates").value(102.0).value(2.0).endArray().endObject().startObject().field("type", "Polygon").startArray("coordinates").startArray().startArray().value(-177.0).value(10.0).endArray().startArray().value(176.0).value(15.0).endArray().startArray().value(172.0).value(0.0).endArray().startArray().value(176.0).value(-15.0).endArray().startArray().value(-177.0).value(-10.0).endArray().startArray().value(-177.0).value(10.0).endArray().endArray().endArray().endObject().endArray().endObject();
GeometryCollection<Geometry> geometryExpected = new GeometryCollection<>(Arrays.asList(new Line(new double[] { 100d, 101d }, new double[] { 0d, 1d }), new Point(102d, 2d), new Polygon(new LinearRing(new double[] { -177, 176, 172, 176, -177, -177 }, new double[] { 10, 15, 0, -15, -10, 10 }))));
assertGeometryEquals(geometryExpected, geometryCollectionGeoJson);
}
use of org.opensearch.geometry.Point in project OpenSearch by opensearch-project.
the class GeoJsonParserTests method testParseMultiPoint.
@Override
public void testParseMultiPoint() throws IOException {
XContentBuilder multiPointGeoJson = XContentFactory.jsonBuilder().startObject().field("type", "MultiPoint").startArray("coordinates").startArray().value(100.0).value(0.0).endArray().startArray().value(101.0).value(1.0).endArray().endArray().endObject();
assertGeometryEquals(new MultiPoint(Arrays.asList(new Point(100, 0), new Point(101, 1))), multiPointGeoJson);
}
use of org.opensearch.geometry.Point in project OpenSearch by opensearch-project.
the class GeoPointShapeQueryTests method testQueryPoint.
public void testQueryPoint() throws Exception {
XContentBuilder xcb = createDefaultMapping();
client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get();
ensureGreen();
PointBuilder pb = new PointBuilder().coordinate(-35, -25);
Point point = pb.buildGeometry();
try {
client().prepareSearch("test").setQuery(QueryBuilders.geoShapeQuery(defaultGeoFieldName, point)).get();
} catch (Exception e) {
assertThat(e.getCause().getMessage(), containsString("does not support " + GeoShapeType.POINT + " queries"));
}
}
use of org.opensearch.geometry.Point in project OpenSearch by opensearch-project.
the class GeometryTestUtils method randomMultiPoint.
public static MultiPoint randomMultiPoint(boolean hasAlt) {
int size = OpenSearchTestCase.randomIntBetween(3, 10);
List<Point> points = new ArrayList<>();
for (int i = 0; i < size; i++) {
points.add(randomPoint(hasAlt));
}
return new MultiPoint(points);
}
Aggregations