private static int createEdges(int component, Orientation orientation, LineStringBuilder shell, LineStringBuilder hole, Edge[] edges, int offset, final AtomicBoolean translated) { // inner rings (holes) have an opposite direction than the outer rings // XOR will invert the orientation for outer ring cases (Truth Table:, T/T = F, T/F = T, F/T = T, F/F = F) boolean direction = (component == 0 ^ orientation == Orientation.RIGHT); // set the points array accordingly (shell or hole) Coordinate[] points = (hole != null) ? hole.coordinates(false) : shell.coordinates(false); ring(component, direction, orientation == Orientation.LEFT, points, 0, edges, offset, points.length-1, translated); return points.length-1; }
public PolygonBuilder(LineStringBuilder lineString, Orientation orientation, boolean coerce) { this.orientation = orientation; if (coerce) { lineString.close(); } validateLinearRing(lineString); this.shell = lineString; }
/** * Create a new PolygonBuilder * @return a new {@link PolygonBuilder} */ public static PolygonBuilder newPolygon(List<Coordinate> shell) { return new PolygonBuilder(new CoordinatesBuilder().coordinates(shell)); }
/** * 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) { return new CircleBuilder().center(coordinates.coordinate).radius(radius); }
/** * 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 MultiPolygonBuilder(StreamInput in) throws IOException { orientation = Orientation.readFrom(in); int holes = in.readVInt(); for (int i = 0; i < holes; i++) { polygon(new PolygonBuilder(in)); } }
/** * Set the radius of the circle * @param radius radius of the circle (see {@link org.elasticsearch.common.unit.DistanceUnit.Distance}) * @return this */ public CircleBuilder radius(Distance radius) { return radius(radius.value, radius.unit); }
public Geometry buildS4JGeometry(GeometryFactory factory, boolean fixDateline) { if(fixDateline) { Coordinate[][][] polygons = coordinates(); return polygons.length == 1 ? polygonS4J(factory, polygons[0]) : multipolygonS4J(factory, polygons); } else { return toPolygonS4J(factory); } }
/** * 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); }
/** * Create a new lineString * @return a new {@link LineStringBuilder} */ public static LineStringBuilder newLineString(List<Coordinate> list) { return new LineStringBuilder(list); }
/** * Create a new PolygonBuilder * @return a new {@link PolygonBuilder} */ public static PolygonBuilder newPolygon(CoordinatesBuilder shell) { return new PolygonBuilder(shell); }
/** * Create a new Collection of polygons * @return a new {@link MultiPolygonBuilder} */ public static MultiPolygonBuilder newMultiPolygon(ShapeBuilder.Orientation orientation) { return new MultiPolygonBuilder(orientation); }
protected Edge(Coordinate coordinate, Edge next, Coordinate intersection) { this.coordinate = coordinate; // use setter to catch duplicate point cases this.setNext(next); this.intersect = intersection; if (next != null) { this.component = next.component; } }
/** * create a new Circle * * @return a new {@link CircleBuilder} */ public static CircleBuilder newCircleBuilder() { return new CircleBuilder(); }
/** * Create a new GeometryCollection * @return a new {@link GeometryCollectionBuilder} */ public static GeometryCollectionBuilder newGeometryCollection() { return new GeometryCollectionBuilder(); }
/** * Close the shell of the polygon */ public PolygonBuilder close() { shell.close(); return this; }
/** * Read from a stream. */ public EnvelopeBuilder(StreamInput in) throws IOException { topLeft = readFromStream(in); bottomRight = readFromStream(in); }
@Override public void writeTo(StreamOutput out) throws IOException { writeCoordinateTo(topLeft, out); writeCoordinateTo(bottomRight, out); }
/** * Create a new lineString * @return a new {@link LineStringBuilder} */ public static LineStringBuilder newLineString(CoordinatesBuilder coordinates) { return new LineStringBuilder(coordinates); }