/** * Computes the set of raw offset curves for the buffer. * Each offset curve has an attached {@link Label} indicating * its left and right location. * * @return a Collection of SegmentStrings representing the raw buffer curves */ public List getCurves() { add(inputGeom); return curveList; }
private void add(Geometry g) { if (g.isEmpty()) return; if (g instanceof Polygon) addPolygon((Polygon) g); // LineString also handles LinearRings else if (g instanceof LineString) addLineString((LineString) g); else if (g instanceof Point) addPoint((Point) g); else if (g instanceof MultiPoint) addCollection((MultiPoint) g); else if (g instanceof MultiLineString) addCollection((MultiLineString) g); else if (g instanceof MultiPolygon) addCollection((MultiPolygon) g); else if (g instanceof GeometryCollection) addCollection((GeometryCollection) g); else throw new UnsupportedOperationException(g.getClass().getName()); } private void addCollection(GeometryCollection gc)
/** * Add a Point to the graph. */ private void addPoint(Point p) { // a zero or negative width buffer of a line/point is empty if (distance <= 0.0) return; Coordinate[] coord = p.getCoordinates(); Coordinate[] curve = curveBuilder.getLineCurve(coord, distance); addCurve(curve, Location.EXTERIOR, Location.INTERIOR); }
if (distance < 0.0 && isErodedCompletely(shell, distance)) return; return; addPolygonRing( shellCoord, offsetDistance, if (distance > 0.0 && isErodedCompletely(hole, -distance)) continue; addPolygonRing( holeCoord, offsetDistance,
OffsetCurveSetBuilder curveSetBuilder = new OffsetCurveSetBuilder(g, distance, curveBuilder); List bufferSegStrList = curveSetBuilder.getCurves();
/** * Compute the offset curve for a polygon, a point or a collection of geometries * @param list * @param geometry * @param offset * @param bufferParameters */ public static void geometryOffSetCurve(ArrayList<LineString> list, Geometry geometry, double offset, BufferParameters bufferParameters) { final List curves = new OffsetCurveSetBuilder(geometry, offset, new OffsetCurveBuilder(geometry.getFactory().getPrecisionModel(), bufferParameters)).getCurves(); final Iterator<SegmentString> iterator = curves.iterator(); while (iterator.hasNext()) { list.add(geometry.getFactory().createLineString(iterator.next().getCoordinates())); } }
if (distance < 0.0 && isErodedCompletely(shell, distance)) return; return; addPolygonRing( shellCoord, offsetDistance, if (distance > 0.0 && isErodedCompletely(hole, -distance)) continue; addPolygonRing( holeCoord, offsetDistance,
/** * Compute the offset curve for a polygon, a point or a collection of geometries * @param list * @param geometry * @param offset * @param bufferParameters */ public static void geometryOffSetCurve(ArrayList<LineString> list, Geometry geometry, double offset, BufferParameters bufferParameters) { final List curves = new OffsetCurveSetBuilder(geometry, offset, new OffsetCurveBuilder(geometry.getFactory().getPrecisionModel(), bufferParameters)).getCurves(); final Iterator<SegmentString> iterator = curves.iterator(); while (iterator.hasNext()) { list.add(geometry.getFactory().createLineString(iterator.next().getCoordinates())); } }
private void add(Geometry g) { if (g.isEmpty()) return; if (g instanceof Polygon) addPolygon((Polygon) g); // LineString also handles LinearRings else if (g instanceof LineString) addLineString((LineString) g); else if (g instanceof Point) addPoint((Point) g); else if (g instanceof MultiPoint) addCollection((MultiPoint) g); else if (g instanceof MultiLineString) addCollection((MultiLineString) g); else if (g instanceof MultiPolygon) addCollection((MultiPolygon) g); else if (g instanceof GeometryCollection) addCollection((GeometryCollection) g); else throw new UnsupportedOperationException(g.getClass().getName()); } private void addCollection(GeometryCollection gc)
/** * Adds an offset curve for a polygon ring. * The side and left and right topological location arguments * assume that the ring is oriented CW. * If the ring is in the opposite orientation, * the left and right locations must be interchanged and the side flipped. * * @param coord the coordinates of the ring (must not contain repeated points) * @param offsetDistance the distance at which to create the buffer * @param side the side of the ring on which to construct the buffer line * @param cwLeftLoc the location on the L side of the ring (if it is CW) * @param cwRightLoc the location on the R side of the ring (if it is CW) */ private void addPolygonRing(Coordinate[] coord, double offsetDistance, int side, int cwLeftLoc, int cwRightLoc) { // don't bother adding ring if it is "flat" and will disappear in the output if (offsetDistance == 0.0 && coord.length < LinearRing.MINIMUM_VALID_SIZE) return; int leftLoc = cwLeftLoc; int rightLoc = cwRightLoc; if (coord.length >= LinearRing.MINIMUM_VALID_SIZE && CGAlgorithms.isCCW(coord)) { leftLoc = cwRightLoc; rightLoc = cwLeftLoc; side = Position.opposite(side); } Coordinate[] curve = curveBuilder.getRingCurve(coord, side, offsetDistance); addCurve(curve, leftLoc, rightLoc); }
private void addCollection(GeometryCollection gc) { for (int i = 0; i < gc.getNumGeometries(); i++) { Geometry g = gc.getGeometryN(i); add(g); } } /**
OffsetCurveSetBuilder curveSetBuilder = new OffsetCurveSetBuilder(g, distance, curveBuilder); List bufferSegStrList = curveSetBuilder.getCurves();
private void addLineString(LineString line) { // a zero or negative width buffer of a line/point is empty if (distance <= 0.0 && ! curveBuilder.getBufferParameters().isSingleSided()) return; Coordinate[] coord = CoordinateArrays.removeRepeatedPoints(line.getCoordinates()); Coordinate[] curve = curveBuilder.getLineCurve(coord, distance); addCurve(curve, Location.EXTERIOR, Location.INTERIOR); // TESTING //Coordinate[] curveTrim = BufferCurveLoopPruner.prune(curve); //addCurve(curveTrim, Location.EXTERIOR, Location.INTERIOR); }
/** * Computes the set of raw offset curves for the buffer. * Each offset curve has an attached {@link Label} indicating * its left and right location. * * @return a Collection of SegmentStrings representing the raw buffer curves */ public List getCurves() { add(inputGeom); return curveList; }
/** * Add a Point to the graph. */ private void addPoint(Point p) { // a zero or negative width buffer of a line/point is empty if (distance <= 0.0) return; Coordinate[] coord = p.getCoordinates(); Coordinate[] curve = curveBuilder.getLineCurve(coord, distance); addCurve(curve, Location.EXTERIOR, Location.INTERIOR); }
private void addCollection(GeometryCollection gc) { for (int i = 0; i < gc.getNumGeometries(); i++) { Geometry g = gc.getGeometryN(i); add(g); } } /**
/** * Adds an offset curve for a polygon ring. * The side and left and right topological location arguments * assume that the ring is oriented CW. * If the ring is in the opposite orientation, * the left and right locations must be interchanged and the side flipped. * * @param coord the coordinates of the ring (must not contain repeated points) * @param offsetDistance the distance at which to create the buffer * @param side the side of the ring on which to construct the buffer line * @param cwLeftLoc the location on the L side of the ring (if it is CW) * @param cwRightLoc the location on the R side of the ring (if it is CW) */ private void addPolygonRing(Coordinate[] coord, double offsetDistance, int side, int cwLeftLoc, int cwRightLoc) { // don't bother adding ring if it is "flat" and will disappear in the output if (offsetDistance == 0.0 && coord.length < LinearRing.MINIMUM_VALID_SIZE) return; int leftLoc = cwLeftLoc; int rightLoc = cwRightLoc; if (coord.length >= LinearRing.MINIMUM_VALID_SIZE && CGAlgorithms.isCCW(coord)) { leftLoc = cwRightLoc; rightLoc = cwLeftLoc; side = Position.opposite(side); } Coordinate[] curve = curveBuilder.getRingCurve(coord, side, offsetDistance); addCurve(curve, leftLoc, rightLoc); }
private void addLineString(LineString line) { // a zero or negative width buffer of a line/point is empty if (distance <= 0.0 && ! curveBuilder.getBufferParameters().isSingleSided()) return; Coordinate[] coord = CoordinateArrays.removeRepeatedPoints(line.getCoordinates()); Coordinate[] curve = curveBuilder.getLineCurve(coord, distance); addCurve(curve, Location.EXTERIOR, Location.INTERIOR); // TESTING //Coordinate[] curveTrim = BufferCurveLoopPruner.prune(curve); //addCurve(curveTrim, Location.EXTERIOR, Location.INTERIOR); }