Search in sources :

Example 1 with GeoShapeFieldMapper

use of org.opensearch.index.mapper.GeoShapeFieldMapper in project OpenSearch by opensearch-project.

the class GeoWKTShapeParserTests method testParseMixedDimensionPolyWithHole.

public void testParseMixedDimensionPolyWithHole() throws IOException, ParseException {
    List<Coordinate> shellCoordinates = new ArrayList<>();
    shellCoordinates.add(new Coordinate(100, 0));
    shellCoordinates.add(new Coordinate(101, 0));
    shellCoordinates.add(new Coordinate(101, 1));
    shellCoordinates.add(new Coordinate(100, 1));
    shellCoordinates.add(new Coordinate(100, 0));
    // add 3d point to test ISSUE #10501
    List<Coordinate> holeCoordinates = new ArrayList<>();
    holeCoordinates.add(new Coordinate(100.2, 0.2, 15.0));
    holeCoordinates.add(new Coordinate(100.8, 0.2));
    holeCoordinates.add(new Coordinate(100.8, 0.8));
    holeCoordinates.add(new Coordinate(100.2, 0.8, 10.0));
    holeCoordinates.add(new Coordinate(100.2, 0.2));
    PolygonBuilder builder = new PolygonBuilder(new CoordinatesBuilder().coordinates(shellCoordinates));
    builder.hole(new LineStringBuilder(holeCoordinates));
    XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().value(builder.toWKT());
    XContentParser parser = createParser(xContentBuilder);
    parser.nextToken();
    Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0).put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()).build();
    Mapper.BuilderContext mockBuilderContext = new Mapper.BuilderContext(indexSettings, new ContentPath());
    final GeoShapeFieldMapper mapperBuilder = (GeoShapeFieldMapper) (new GeoShapeFieldMapper.Builder("test").ignoreZValue(false).build(mockBuilderContext));
    // test store z disabled
    OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> ShapeParser.parse(parser, mapperBuilder));
    assertThat(e, hasToString(containsString("but [ignore_z_value] parameter is [false]")));
}
Also used : MultiLineStringBuilder(org.opensearch.common.geo.builders.MultiLineStringBuilder) GeometryCollectionBuilder(org.opensearch.common.geo.builders.GeometryCollectionBuilder) MultiPointBuilder(org.opensearch.common.geo.builders.MultiPointBuilder) EnvelopeBuilder(org.opensearch.common.geo.builders.EnvelopeBuilder) MultiPolygonBuilder(org.opensearch.common.geo.builders.MultiPolygonBuilder) ShapeBuilder(org.opensearch.common.geo.builders.ShapeBuilder) PolygonBuilder(org.opensearch.common.geo.builders.PolygonBuilder) LineStringBuilder(org.opensearch.common.geo.builders.LineStringBuilder) PointBuilder(org.opensearch.common.geo.builders.PointBuilder) CoordinatesBuilder(org.opensearch.common.geo.builders.CoordinatesBuilder) XContentBuilder(org.opensearch.common.xcontent.XContentBuilder) ArrayList(java.util.ArrayList) ContentPath(org.opensearch.index.mapper.ContentPath) MultiLineStringBuilder(org.opensearch.common.geo.builders.MultiLineStringBuilder) LineStringBuilder(org.opensearch.common.geo.builders.LineStringBuilder) CoordinatesBuilder(org.opensearch.common.geo.builders.CoordinatesBuilder) GeoShapeFieldMapper(org.opensearch.index.mapper.GeoShapeFieldMapper) LegacyGeoShapeFieldMapper(org.opensearch.index.mapper.LegacyGeoShapeFieldMapper) Mapper(org.opensearch.index.mapper.Mapper) OpenSearchParseException(org.opensearch.OpenSearchParseException) Coordinate(org.locationtech.jts.geom.Coordinate) GeoShapeFieldMapper(org.opensearch.index.mapper.GeoShapeFieldMapper) LegacyGeoShapeFieldMapper(org.opensearch.index.mapper.LegacyGeoShapeFieldMapper) MultiPolygonBuilder(org.opensearch.common.geo.builders.MultiPolygonBuilder) PolygonBuilder(org.opensearch.common.geo.builders.PolygonBuilder) XContentBuilder(org.opensearch.common.xcontent.XContentBuilder) XContentParser(org.opensearch.common.xcontent.XContentParser) Settings(org.opensearch.common.settings.Settings)

Aggregations

ArrayList (java.util.ArrayList)1 Coordinate (org.locationtech.jts.geom.Coordinate)1 OpenSearchParseException (org.opensearch.OpenSearchParseException)1 CoordinatesBuilder (org.opensearch.common.geo.builders.CoordinatesBuilder)1 EnvelopeBuilder (org.opensearch.common.geo.builders.EnvelopeBuilder)1 GeometryCollectionBuilder (org.opensearch.common.geo.builders.GeometryCollectionBuilder)1 LineStringBuilder (org.opensearch.common.geo.builders.LineStringBuilder)1 MultiLineStringBuilder (org.opensearch.common.geo.builders.MultiLineStringBuilder)1 MultiPointBuilder (org.opensearch.common.geo.builders.MultiPointBuilder)1 MultiPolygonBuilder (org.opensearch.common.geo.builders.MultiPolygonBuilder)1 PointBuilder (org.opensearch.common.geo.builders.PointBuilder)1 PolygonBuilder (org.opensearch.common.geo.builders.PolygonBuilder)1 ShapeBuilder (org.opensearch.common.geo.builders.ShapeBuilder)1 Settings (org.opensearch.common.settings.Settings)1 XContentBuilder (org.opensearch.common.xcontent.XContentBuilder)1 XContentParser (org.opensearch.common.xcontent.XContentParser)1 ContentPath (org.opensearch.index.mapper.ContentPath)1 GeoShapeFieldMapper (org.opensearch.index.mapper.GeoShapeFieldMapper)1 LegacyGeoShapeFieldMapper (org.opensearch.index.mapper.LegacyGeoShapeFieldMapper)1 Mapper (org.opensearch.index.mapper.Mapper)1