/** * Convert to a LinearRing. * * @return LinearRing */ public LinearRing toLinearRing() { return new LinearRing(positions()); }
/** * Convert to a LinearRing. * * @return LinearRing */ public LinearRing toLinearRing() { return new LinearRing(positions()); }
/** * Create a LinearRing from the given points. * * @param points Point Iterable composed at least by 4 points, with the first and the last that are the same. * @return a LinearRing */ public static LinearRing of(Iterable<Point> points) { LinearPositions.Builder builder = LinearPositions.builder(); for(Point point : points) { builder.addSinglePosition(point.positions()); } return new LinearRing(builder.build()); }
/** * Create a LinearRing from the given points. * * @param points Point Iterable composed at least by 4 points, with the first and the last that are the same. * @return a LinearRing */ public static LinearRing of(Iterable<Point> points) { LinearPositions.Builder builder = LinearPositions.builder(); for(Point point : points) { builder.addSinglePosition(point.positions()); } return new LinearRing(builder.build()); }
private Geometry<?> buildGeometry(final Geometry.Type type, final Positions positions, final Geometry<?> geometries) { switch (type) { case GEOMETRY_COLLECTION: return geometries; case MULTI_POLYGON: return new MultiPolygon((MultiDimensionalPositions) positions); case POLYGON: return new Polygon((AreaPositions) positions); case MULTI_LINE_STRING: return new MultiLineString((AreaPositions) positions); case LINEAR_RING: case LINE_STRING: return ((LinearPositions) positions).isClosed() ? new LinearRing((LinearPositions) positions) : new LineString((LinearPositions) positions); case MULTI_POINT: if (positions instanceof SinglePosition) { return new MultiPoint(LinearPositions.builder().addSinglePosition((SinglePosition) positions).build()); } else { return new MultiPoint((LinearPositions) positions); } case POINT: return new Point(((SinglePosition) positions)); default: throw new IllegalArgumentException("Cannot build a geometry for type: " + type); } }
private Geometry<?> buildGeometry(final Geometry.Type type, final Positions positions, final Geometry<?> geometries) { switch (type) { case GEOMETRY_COLLECTION: return geometries; case MULTI_POLYGON: return new MultiPolygon((MultiDimensionalPositions) positions); case POLYGON: return new Polygon((AreaPositions) positions); case MULTI_LINE_STRING: return new MultiLineString((AreaPositions) positions); case LINEAR_RING: case LINE_STRING: return ((LinearPositions) positions).isClosed() ? new LinearRing((LinearPositions) positions) : new LineString((LinearPositions) positions); case MULTI_POINT: if (positions instanceof SinglePosition) { return new MultiPoint(LinearPositions.builder().addSinglePosition((SinglePosition) positions).build()); } else { return new MultiPoint((LinearPositions) positions); } case POINT: return new Point(((SinglePosition) positions)); default: throw new IllegalArgumentException("Cannot build a geometry for type: " + type); } }