Search in sources :

Example 1 with IntersectionAdder

use of com.revolsys.geometry.noding.IntersectionAdder in project com.revolsys.open by revolsys.

the class Buffer method buffer.

/**
 * Comutes the buffer for a geometry for a given buffer distance
 * and accuracy of approximation.
 *
 * @param g the geometry to buffer
 * @param distance the buffer distance
 * @param parameters the buffer parameters to use
 * @return the buffer of the input geometry
 */
@SuppressWarnings("unchecked")
public static <G extends Geometry> G buffer(final Geometry geometry, final double distance, final BufferParameters parameters) {
    final GeometryFactory geometryFactory = geometry.getGeometryFactory();
    try {
        final MCIndexNoder noder = new MCIndexNoder();
        final LineIntersector li = new RobustLineIntersector(geometryFactory.getScaleXY());
        noder.setSegmentIntersector(new IntersectionAdder(li));
        return (G) buffer(noder, geometryFactory, geometry, distance, parameters);
    } catch (final RuntimeException e) {
        if (geometryFactory.isFloating()) {
            return (G) bufferReducedPrecision(geometry, distance, parameters);
        } else {
            return (G) bufferFixedPrecision(geometryFactory, geometry, distance, parameters);
        }
    }
}
Also used : LineIntersector(com.revolsys.geometry.algorithm.LineIntersector) RobustLineIntersector(com.revolsys.geometry.algorithm.RobustLineIntersector) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) MCIndexNoder(com.revolsys.geometry.noding.MCIndexNoder) RobustLineIntersector(com.revolsys.geometry.algorithm.RobustLineIntersector) IntersectionAdder(com.revolsys.geometry.noding.IntersectionAdder)

Example 2 with IntersectionAdder

use of com.revolsys.geometry.noding.IntersectionAdder in project com.revolsys.open by revolsys.

the class NodingFunctions method MCIndexNoding.

public static Geometry MCIndexNoding(final Geometry geom) {
    final List segs = newNodedSegmentStrings(geom);
    final Noder noder = new MCIndexNoder(new IntersectionAdder(new RobustLineIntersector()));
    noder.computeNodes(segs);
    final Collection nodedSegStrings = noder.getNodedSubstrings();
    return fromSegmentStrings(nodedSegStrings);
}
Also used : MCIndexNoder(com.revolsys.geometry.noding.MCIndexNoder) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) RobustLineIntersector(com.revolsys.geometry.algorithm.RobustLineIntersector) IntersectionAdder(com.revolsys.geometry.noding.IntersectionAdder) MCIndexNoder(com.revolsys.geometry.noding.MCIndexNoder) Noder(com.revolsys.geometry.noding.Noder) ScaledNoder(com.revolsys.geometry.noding.ScaledNoder)

Example 3 with IntersectionAdder

use of com.revolsys.geometry.noding.IntersectionAdder in project com.revolsys.open by revolsys.

the class NodingFunctions method MCIndexNodingWithPrecision.

public static Geometry MCIndexNodingWithPrecision(final Geometry geom, final double scaleFactor) {
    final List segs = newNodedSegmentStrings(geom);
    final LineIntersector li = new RobustLineIntersector(scaleFactor);
    final Noder noder = new MCIndexNoder(new IntersectionAdder(li));
    noder.computeNodes(segs);
    final Collection nodedSegStrings = noder.getNodedSubstrings();
    return fromSegmentStrings(nodedSegStrings);
}
Also used : LineIntersector(com.revolsys.geometry.algorithm.LineIntersector) RobustLineIntersector(com.revolsys.geometry.algorithm.RobustLineIntersector) MCIndexNoder(com.revolsys.geometry.noding.MCIndexNoder) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) RobustLineIntersector(com.revolsys.geometry.algorithm.RobustLineIntersector) IntersectionAdder(com.revolsys.geometry.noding.IntersectionAdder) MCIndexNoder(com.revolsys.geometry.noding.MCIndexNoder) Noder(com.revolsys.geometry.noding.Noder) ScaledNoder(com.revolsys.geometry.noding.ScaledNoder)

Aggregations

RobustLineIntersector (com.revolsys.geometry.algorithm.RobustLineIntersector)3 IntersectionAdder (com.revolsys.geometry.noding.IntersectionAdder)3 MCIndexNoder (com.revolsys.geometry.noding.MCIndexNoder)3 LineIntersector (com.revolsys.geometry.algorithm.LineIntersector)2 Noder (com.revolsys.geometry.noding.Noder)2 ScaledNoder (com.revolsys.geometry.noding.ScaledNoder)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 List (java.util.List)2 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1