use of org.opensearch.index.mapper.GeoShapeIndexer in project OpenSearch by opensearch-project.
the class GeoWKTShapeParserTests method testParseGeometryCollection.
@Override
public void testParseGeometryCollection() throws IOException, ParseException {
if (rarely()) {
// assert empty shape collection
GeometryCollectionBuilder builder = new GeometryCollectionBuilder();
Shape[] expected = new Shape[0];
if (randomBoolean()) {
assertEquals(shapeCollection(expected).isEmpty(), builder.buildS4J().isEmpty());
} else {
assertEquals(shapeCollection(expected).isEmpty(), builder.buildGeometry().size() == 0);
}
} else {
GeometryCollectionBuilder gcb = RandomShapeGenerator.createGeometryCollection(random());
assertExpected(gcb.buildS4J(), gcb, true);
assertExpected(new GeoShapeIndexer(true, "name").prepareForIndexing(gcb.buildGeometry()), gcb, false);
}
}
use of org.opensearch.index.mapper.GeoShapeIndexer in project OpenSearch by opensearch-project.
the class GeoJsonShapeParserTests method parse.
public Geometry parse(XContentParser parser) throws IOException, ParseException {
GeometryParser geometryParser = new GeometryParser(true, true, true);
GeoShapeIndexer indexer = new GeoShapeIndexer(true, "name");
return indexer.prepareForIndexing(geometryParser.parse(parser));
}
use of org.opensearch.index.mapper.GeoShapeIndexer in project OpenSearch by opensearch-project.
the class BaseGeoParsingTestCase method assertGeometryEquals.
protected void assertGeometryEquals(Object expected, XContentBuilder geoJson, boolean useJTS) throws IOException, ParseException {
try (XContentParser parser = createParser(geoJson)) {
parser.nextToken();
if (useJTS) {
OpenSearchGeoAssertions.assertEquals(expected, ShapeParser.parse(parser).buildS4J());
} else {
GeometryParser geometryParser = new GeometryParser(true, true, true);
org.opensearch.geometry.Geometry shape = geometryParser.parse(parser);
shape = new GeoShapeIndexer(true, "name").prepareForIndexing(shape);
OpenSearchGeoAssertions.assertEquals(expected, shape);
}
}
}
Aggregations