/** * Read from a stream. */ public GeometryCollectionBuilder(StreamInput in) throws IOException { int shapes = in.readVInt(); for (int i = 0; i < shapes; i++) { shape(in.readNamedWriteable(ShapeBuilder.class)); } }
private static GeometryCollectionBuilder parseGeometryCollection(StreamTokenizer stream, final boolean ignoreZValue, final boolean coerce) throws IOException, ElasticsearchParseException { if (nextEmptyOrOpen(stream).equals(EMPTY)) { return null; } GeometryCollectionBuilder builder = new GeometryCollectionBuilder().shape( parseGeometry(stream, GeoShapeType.GEOMETRYCOLLECTION, ignoreZValue, coerce)); while (nextCloserOrComma(stream).equals(COMMA)) { builder.shape(parseGeometry(stream, null, ignoreZValue, coerce)); } return builder; }
/** * Parse the geometries array of a GeometryCollection * * @param parser Parser that will be read from * @return Geometry[] geometries of the GeometryCollection * @throws IOException Thrown if an error occurs while reading from the XContentParser */ static GeometryCollectionBuilder parseGeometries(XContentParser parser, BaseGeoShapeFieldMapper mapper) throws IOException { if (parser.currentToken() != XContentParser.Token.START_ARRAY) { throw new ElasticsearchParseException("geometries must be an array of geojson objects"); } XContentParser.Token token = parser.nextToken(); GeometryCollectionBuilder geometryCollection = new GeometryCollectionBuilder(); while (token != XContentParser.Token.END_ARRAY) { ShapeBuilder shapeBuilder = ShapeParser.parse(parser); geometryCollection.shape(shapeBuilder); token = parser.nextToken(); } return geometryCollection; } }
private static GeometryCollectionBuilder parseGeometryCollection(StreamTokenizer stream, final boolean ignoreZValue) throws IOException, ElasticsearchParseException { if (nextEmptyOrOpen(stream).equals(EMPTY)) { return null; } GeometryCollectionBuilder builder = new GeometryCollectionBuilder().shape( parseGeometry(stream, GeoShapeType.GEOMETRYCOLLECTION, ignoreZValue)); while (nextCloserOrComma(stream).equals(COMMA)) { builder.shape(parseGeometry(stream, null, ignoreZValue)); } return builder; }
/** * Read from a stream. */ public GeometryCollectionBuilder(StreamInput in) throws IOException { int shapes = in.readVInt(); for (int i = 0; i < shapes; i++) { shape(in.readNamedWriteable(ShapeBuilder.class)); } }
/** * Read from a stream. */ public GeometryCollectionBuilder(StreamInput in) throws IOException { int shapes = in.readVInt(); for (int i = 0; i < shapes; i++) { shape(in.readNamedWriteable(ShapeBuilder.class)); } }
private static GeometryCollectionBuilder parseGeometryCollection(StreamTokenizer stream, final boolean ignoreZValue) throws IOException, ElasticsearchParseException { if (nextEmptyOrOpen(stream).equals(EMPTY)) { return null; } GeometryCollectionBuilder builder = new GeometryCollectionBuilder().shape( parseGeometry(stream, GeoShapeType.GEOMETRYCOLLECTION, ignoreZValue)); while (nextCloserOrComma(stream).equals(COMMA)) { builder.shape(parseGeometry(stream, null, ignoreZValue)); } return builder; }
/** * Read from a stream. */ public GeometryCollectionBuilder(StreamInput in) throws IOException { int shapes = in.readVInt(); for (int i = 0; i < shapes; i++) { shape(in.readNamedWriteable(ShapeBuilder.class)); } }
private GeometryCollectionBuilder getGeometryCollectionBuilder(GeoCollection geoCollection) { GeometryCollectionBuilder shapeBuilder = ShapeBuilders.newGeometryCollection(); geoCollection.getGeoShapes().forEach(shape -> shapeBuilder.shape(getShapeBuilder(shape))); return shapeBuilder; }
private GeometryCollectionBuilder getGeometryCollectionBuilder(GeoCollection geoCollection) { GeometryCollectionBuilder shapeBuilder = ShapeBuilders.newGeometryCollection(); geoCollection.getGeoShapes().forEach(shape -> shapeBuilder.shape(getShapeBuilder(shape))); return shapeBuilder; }
/** * Parse the geometries array of a GeometryCollection * * @param parser Parser that will be read from * @return Geometry[] geometries of the GeometryCollection * @throws IOException Thrown if an error occurs while reading from the XContentParser */ static GeometryCollectionBuilder parseGeometries(XContentParser parser, GeoShapeFieldMapper mapper) throws IOException { if (parser.currentToken() != XContentParser.Token.START_ARRAY) { throw new ElasticsearchParseException("geometries must be an array of geojson objects"); } XContentParser.Token token = parser.nextToken(); GeometryCollectionBuilder geometryCollection = new GeometryCollectionBuilder(); while (token != XContentParser.Token.END_ARRAY) { ShapeBuilder shapeBuilder = ShapeParser.parse(parser); geometryCollection.shape(shapeBuilder); token = parser.nextToken(); } return geometryCollection; } }
/** * Parse the geometries array of a GeometryCollection * * @param parser Parser that will be read from * @return Geometry[] geometries of the GeometryCollection * @throws IOException Thrown if an error occurs while reading from the XContentParser */ static GeometryCollectionBuilder parseGeometries(XContentParser parser, GeoShapeFieldMapper mapper) throws IOException { if (parser.currentToken() != XContentParser.Token.START_ARRAY) { throw new ElasticsearchParseException("geometries must be an array of geojson objects"); } XContentParser.Token token = parser.nextToken(); GeometryCollectionBuilder geometryCollection = new GeometryCollectionBuilder(); while (token != XContentParser.Token.END_ARRAY) { ShapeBuilder shapeBuilder = ShapeParser.parse(parser); geometryCollection.shape(shapeBuilder); token = parser.nextToken(); } return geometryCollection; } }
/** * Parse the geometries array of a GeometryCollection * * @param parser Parser that will be read from * @return Geometry[] geometries of the GeometryCollection * @throws IOException Thrown if an error occurs while reading from the XContentParser */ protected static GeometryCollectionBuilder parseGeometries(XContentParser parser, GeoShapeFieldMapper mapper) throws IOException { if (parser.currentToken() != XContentParser.Token.START_ARRAY) { throw new ElasticsearchParseException("geometries must be an array of geojson objects"); } XContentParser.Token token = parser.nextToken(); GeometryCollectionBuilder geometryCollection = ShapeBuilders.newGeometryCollection(); while (token != XContentParser.Token.END_ARRAY) { ShapeBuilder shapeBuilder = GeoShapeType.parse(parser); geometryCollection.shape(shapeBuilder); token = parser.nextToken(); } return geometryCollection; } }
/** * Parse the geometries array of a GeometryCollection * * @param parser Parser that will be read from * @return Geometry[] geometries of the GeometryCollection * @throws IOException Thrown if an error occurs while reading from the XContentParser */ protected static GeometryCollectionBuilder parseGeometries(XContentParser parser, GeoShapeFieldMapper mapper) throws IOException { if (parser.currentToken() != XContentParser.Token.START_ARRAY) { throw new ElasticsearchParseException("geometries must be an array of geojson objects"); } XContentParser.Token token = parser.nextToken(); GeometryCollectionBuilder geometryCollection = newGeometryCollection( (mapper == null) ? Orientation.RIGHT : mapper .fieldType().orientation()); while (token != XContentParser.Token.END_ARRAY) { ShapeBuilder shapeBuilder = GeoShapeType.parse(parser); geometryCollection.shape(shapeBuilder); token = parser.nextToken(); } return geometryCollection; } }