use of org.opensearch.common.geo.XShapeCollection in project OpenSearch by opensearch-project.
the class MultiPointBuilder method buildS4J.
@Override
public XShapeCollection<Point> buildS4J() {
// Could wrap JtsGeometry but probably slower due to conversions to/from JTS in relate()
// MultiPoint geometry = FACTORY.createMultiPoint(points.toArray(new Coordinate[points.size()]));
List<Point> shapes = new ArrayList<>(coordinates.size());
for (Coordinate coord : coordinates) {
shapes.add(SPATIAL_CONTEXT.makePoint(coord.x, coord.y));
}
XShapeCollection<Point> multiPoints = new XShapeCollection<>(shapes, SPATIAL_CONTEXT);
multiPoints.setPointsOnly(true);
return multiPoints;
}
use of org.opensearch.common.geo.XShapeCollection in project OpenSearch by opensearch-project.
the class LegacyGeoShapeIndexer method indexShape.
@Override
public List<IndexableField> indexShape(ParseContext context, Shape shape) {
if (fieldType.pointsOnly()) {
// index configured for pointsOnly
if (shape instanceof XShapeCollection && XShapeCollection.class.cast(shape).pointsOnly()) {
// MULTIPOINT data: index each point separately
@SuppressWarnings("unchecked") List<Shape> shapes = ((XShapeCollection) shape).getShapes();
List<IndexableField> fields = new ArrayList<>();
for (Shape s : shapes) {
fields.addAll(Arrays.asList(fieldType.defaultPrefixTreeStrategy().createIndexableFields(s)));
}
return fields;
} else if (shape instanceof Point == false) {
throw new MapperParsingException("[{" + fieldType.name() + "}] is configured for points only but a " + ((shape instanceof JtsGeometry) ? ((JtsGeometry) shape).getGeom().getGeometryType() : shape.getClass()) + " was found");
}
}
return Arrays.asList(fieldType.defaultPrefixTreeStrategy().createIndexableFields(shape));
}
Aggregations