Search in sources :

Example 1 with GeoShapeIndexer

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);
    }
}
Also used : GeometryCollectionBuilder(org.opensearch.common.geo.builders.GeometryCollectionBuilder) Shape(org.locationtech.spatial4j.shape.Shape) GeoShapeIndexer(org.opensearch.index.mapper.GeoShapeIndexer)

Example 2 with GeoShapeIndexer

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));
}
Also used : GeoShapeIndexer(org.opensearch.index.mapper.GeoShapeIndexer)

Example 3 with GeoShapeIndexer

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);
        }
    }
}
Also used : GeoShapeIndexer(org.opensearch.index.mapper.GeoShapeIndexer) XContentParser(org.opensearch.common.xcontent.XContentParser)

Aggregations

GeoShapeIndexer (org.opensearch.index.mapper.GeoShapeIndexer)3 Shape (org.locationtech.spatial4j.shape.Shape)1 GeometryCollectionBuilder (org.opensearch.common.geo.builders.GeometryCollectionBuilder)1 XContentParser (org.opensearch.common.xcontent.XContentParser)1