Search in sources :

Example 1 with MCIndexNoder

use of com.revolsys.geometry.noding.MCIndexNoder 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 MCIndexNoder

use of com.revolsys.geometry.noding.MCIndexNoder 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 MCIndexNoder

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

the class SimpleSnapRounder method findInteriorIntersections.

/**
 * Computes all interior intersections in the collection of {@link SegmentString}s,
 * and returns their {@link Coordinates}s.
 *
 * Does NOT node the segStrings.
 *
 * @return a list of Point for the intersections
 */
private List findInteriorIntersections(final Collection segStrings, final LineIntersector li) {
    final InteriorIntersectionFinderAdder intFinderAdder = new InteriorIntersectionFinderAdder(li);
    final SinglePassNoder noder = new MCIndexNoder();
    noder.setSegmentIntersector(intFinderAdder);
    noder.computeNodes(segStrings);
    return intFinderAdder.getInteriorIntersections();
}
Also used : SinglePassNoder(com.revolsys.geometry.noding.SinglePassNoder) MCIndexNoder(com.revolsys.geometry.noding.MCIndexNoder) InteriorIntersectionFinderAdder(com.revolsys.geometry.noding.InteriorIntersectionFinderAdder)

Example 4 with MCIndexNoder

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

the class MCIndexSnapRounder method computeNodes.

@Override
public void computeNodes(final Collection<NodedSegmentString> inputSegmentStrings) {
    this.nodedSegStrings = inputSegmentStrings;
    this.noder = new MCIndexNoder();
    this.pointSnapper = new MCIndexPointSnapper(this.noder.getIndex());
    snapRound(inputSegmentStrings, this.li);
// testing purposes only - remove in final version
// checkCorrectness(inputSegmentStrings);
}
Also used : MCIndexNoder(com.revolsys.geometry.noding.MCIndexNoder)

Example 5 with MCIndexNoder

use of com.revolsys.geometry.noding.MCIndexNoder 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

MCIndexNoder (com.revolsys.geometry.noding.MCIndexNoder)5 RobustLineIntersector (com.revolsys.geometry.algorithm.RobustLineIntersector)3 IntersectionAdder (com.revolsys.geometry.noding.IntersectionAdder)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 InteriorIntersectionFinderAdder (com.revolsys.geometry.noding.InteriorIntersectionFinderAdder)1 SinglePassNoder (com.revolsys.geometry.noding.SinglePassNoder)1