/** * Add a new hole to the polygon * @param hole linear ring defining the hole * @return this */ public PolygonBuilder hole(LineStringBuilder hole) { return this.hole(hole, false); }
/** * Add a shallow copy of the polygon to the multipolygon. This will apply the orientation of the * {@link MultiPolygonBuilder} to the polygon if polygon has different orientation. */ public MultiPolygonBuilder polygon(PolygonBuilder polygon) { PolygonBuilder pb = new PolygonBuilder(new CoordinatesBuilder().coordinates(polygon.shell().coordinates(false)), this.orientation); for (LineStringBuilder hole : polygon.holes()) { pb.hole(hole); } this.polygons.add(pb); return this; }
@Override public ShapeBuilder getBuilder(CoordinateNode coordinates, DistanceUnit.Distance radius, Orientation orientation, boolean coerce) { validate(coordinates, coerce); // build shell LineStringBuilder shell = LineStringBuilder.class.cast(LINESTRING.getBuilder(coordinates.children.get(0), radius, orientation, coerce)); // build polygon with shell and holes PolygonBuilder polygon = new PolygonBuilder(shell, orientation); for (int i = 1; i < coordinates.children.size(); ++i) { CoordinateNode child = coordinates.children.get(i); LineStringBuilder hole = LineStringBuilder.class.cast(LINESTRING.getBuilder(child, radius, orientation, coerce)); polygon.hole(hole); } return polygon; }
/** * Add a shallow copy of the polygon to the multipolygon. This will apply the orientation of the * {@link MultiPolygonBuilder} to the polygon if polygon has different orientation. */ public MultiPolygonBuilder polygon(PolygonBuilder polygon) { PolygonBuilder pb = new PolygonBuilder(new CoordinatesBuilder().coordinates(polygon.shell().coordinates(false)), this.orientation); for (LineStringBuilder hole : polygon.holes()) { pb.hole(hole); } this.polygons.add(pb); return this; }
private static PolygonBuilder parsePolygon(StreamTokenizer stream, final boolean ignoreZValue, final boolean coerce) throws IOException, ElasticsearchParseException { if (nextEmptyOrOpen(stream).equals(EMPTY)) { return null; } PolygonBuilder builder = new PolygonBuilder(parseLinearRing(stream, ignoreZValue, coerce), BaseGeoShapeFieldMapper.Defaults.ORIENTATION.value()); while (nextCloserOrComma(stream).equals(COMMA)) { builder.hole(parseLinearRing(stream, ignoreZValue, coerce)); } return builder; }
/** * Add a shallow copy of the polygon to the multipolygon. This will apply the orientation of the * {@link MultiPolygonBuilder} to the polygon if polygon has different orientation. */ public MultiPolygonBuilder polygon(PolygonBuilder polygon) { PolygonBuilder pb = new PolygonBuilder(new CoordinatesBuilder().coordinates(polygon.shell().coordinates(false)), this.orientation); for (LineStringBuilder hole : polygon.holes()) { pb.hole(hole); } this.polygons.add(pb); return this; }
/** * Read from a stream. */ public PolygonBuilder(StreamInput in) throws IOException { shell = new LineStringBuilder(in); orientation = Orientation.readFrom(in); int holes = in.readVInt(); for (int i = 0; i < holes; i++) { hole(new LineStringBuilder(in)); } }
/** * Add a shallow copy of the polygon to the multipolygon. This will apply the orientation of the * {@link MultiPolygonBuilder} to the polygon if polygon has different orientation. */ public MultiPolygonBuilder polygon(PolygonBuilder polygon) { PolygonBuilder pb = new PolygonBuilder(new CoordinatesBuilder().coordinates(polygon.shell().coordinates(false)), this.orientation); for (LineStringBuilder hole : polygon.holes()) { pb.hole(hole); } this.polygons.add(pb); return this; }
/** * Add a new hole to the polygon * @param hole linear ring defining the hole * @return this */ public PolygonBuilder hole(LineStringBuilder hole) { return this.hole(hole, false); }
/** * Add a new hole to the polygon * @param hole linear ring defining the hole * @return this */ public PolygonBuilder hole(LineStringBuilder hole) { return this.hole(hole, false); }
/** * Add a new hole to the polygon * @param hole linear ring defining the hole * @return this */ public PolygonBuilder hole(LineStringBuilder hole) { return this.hole(hole, false); }
protected static PolygonBuilder parsePolygon(CoordinateNode coordinates, final Orientation orientation, final boolean coerce) { if (coordinates.children == null || coordinates.children.isEmpty()) { throw new ElasticsearchParseException("invalid LinearRing provided for type polygon. Linear ring must be an array of coordinates"); } LineStringBuilder shell = parseLinearRing(coordinates.children.get(0), coerce); PolygonBuilder polygon = new PolygonBuilder(shell.points, orientation); for (int i = 1; i < coordinates.children.size(); i++) { polygon.hole(parseLinearRing(coordinates.children.get(i), coerce)); } return polygon; }
protected static PolygonBuilder parsePolygon(CoordinateNode coordinates, final Orientation orientation, final boolean coerce) { if (coordinates.children == null || coordinates.children.isEmpty()) { throw new ElasticsearchParseException( "invalid LinearRing provided for type polygon. Linear ring must be an array of coordinates"); } LineStringBuilder shell = parseLinearRing(coordinates.children.get(0), coerce); PolygonBuilder polygon = new PolygonBuilder(shell, orientation); for (int i = 1; i < coordinates.children.size(); i++) { polygon.hole(parseLinearRing(coordinates.children.get(i), coerce)); } return polygon; }
private PolygonBuilder getPolygonBuilder(GeoPolygon geoPolygon) { List<Coordinate> shell = geoPolygon.getOuterBoundary().stream() .map(geoPoint -> new Coordinate(geoPoint.getLongitude(), geoPoint.getLatitude())) .collect(Collectors.toList()); PolygonBuilder polygonBuilder = ShapeBuilders.newPolygon(shell); geoPolygon.getHoles().forEach(hole -> { List<Coordinate> coordinates = hole.stream() .map(geoPoint -> new Coordinate(geoPoint.getLongitude(), geoPoint.getLatitude())) .collect(Collectors.toList()); polygonBuilder.hole(ShapeBuilders.newLineString(coordinates)); }); return polygonBuilder; }
private PolygonBuilder getPolygonBuilder(GeoPolygon geoPolygon) { List<Coordinate> shell = geoPolygon.getOuterBoundary().stream() .map(geoPoint -> new Coordinate(geoPoint.getLongitude(), geoPoint.getLatitude())) .collect(Collectors.toList()); PolygonBuilder polygonBuilder = ShapeBuilders.newPolygon(shell); geoPolygon.getHoles().forEach(hole -> { List<Coordinate> coordinates = hole.stream() .map(geoPoint -> new Coordinate(geoPoint.getLongitude(), geoPoint.getLatitude())) .collect(Collectors.toList()); polygonBuilder.hole(ShapeBuilders.newLineString(coordinates)); }); return polygonBuilder; }
private static PolygonBuilder parsePolygon(StreamTokenizer stream, final boolean ignoreZValue) throws IOException, ElasticsearchParseException { if (nextEmptyOrOpen(stream).equals(EMPTY)) { return null; } PolygonBuilder builder = new PolygonBuilder(parseLine(stream, ignoreZValue), ShapeBuilder.Orientation.RIGHT); while (nextCloserOrComma(stream).equals(COMMA)) { builder.hole(parseLine(stream, ignoreZValue)); } return builder; }
private static PolygonBuilder parsePolygon(StreamTokenizer stream, final boolean ignoreZValue) throws IOException, ElasticsearchParseException { if (nextEmptyOrOpen(stream).equals(EMPTY)) { return null; } PolygonBuilder builder = new PolygonBuilder(parseLine(stream, ignoreZValue), ShapeBuilder.Orientation.RIGHT); while (nextCloserOrComma(stream).equals(COMMA)) { builder.hole(parseLine(stream, ignoreZValue)); } return builder; }
/** * Read from a stream. */ public PolygonBuilder(StreamInput in) throws IOException { shell = new LineStringBuilder(in); orientation = Orientation.readFrom(in); int holes = in.readVInt(); for (int i = 0; i < holes; i++) { hole(new LineStringBuilder(in)); } }
/** * Read from a stream. */ public PolygonBuilder(StreamInput in) throws IOException { shell = new LineStringBuilder(in); orientation = Orientation.readFrom(in); int holes = in.readVInt(); for (int i = 0; i < holes; i++) { hole(new LineStringBuilder(in)); } }
/** * Read from a stream. */ public PolygonBuilder(StreamInput in) throws IOException { shell = new LineStringBuilder(in); orientation = Orientation.readFrom(in); int holes = in.readVInt(); for (int i = 0; i < holes; i++) { hole(new LineStringBuilder(in)); } }