Search in sources :

Example 1 with Noder

use of com.revolsys.geometry.noding.Noder 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 2 with Noder

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

the class NodingFunctions method scaledNoding.

/**
 * Runs a ScaledNoder on input.
 * Input vertices should be rounded to precision model.
 *
 * @param geom
 * @param scaleFactor
 * @return the noded geometry
 */
public static Geometry scaledNoding(final Geometry geom, final double scaleFactor) {
    final List segs = newSegmentStrings(geom);
    final Noder noder = new ScaledNoder(new MCIndexSnapRounder(1.0), scaleFactor);
    noder.computeNodes(segs);
    final Collection nodedSegStrings = noder.getNodedSubstrings();
    return fromSegmentStrings(nodedSegStrings);
}
Also used : ScaledNoder(com.revolsys.geometry.noding.ScaledNoder) MCIndexSnapRounder(com.revolsys.geometry.noding.snapround.MCIndexSnapRounder) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) MCIndexNoder(com.revolsys.geometry.noding.MCIndexNoder) Noder(com.revolsys.geometry.noding.Noder) ScaledNoder(com.revolsys.geometry.noding.ScaledNoder)

Example 3 with Noder

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

the class GeometryNoder method node.

/**
 * Nodes the linework of a set of Geometrys using SnapRounding.
 *
 * @param geometries a Collection of Geometrys of any type
 * @return a List of LineStrings representing the noded linework of the input
 */
public List<LineString> node(final Collection<? extends Geometry> geometries) {
    // get geometry factory
    final Geometry geom0 = geometries.iterator().next();
    this.geomFact = geom0.getGeometryFactory();
    final Collection<LineString> lines = extractLines(geometries);
    final List<NodedSegmentString> segStrings = toSegmentStrings(lines);
    // Noder sr = new SimpleSnapRounder(pm);
    final Noder sr = new MCIndexSnapRounder(this.scale);
    sr.computeNodes(segStrings);
    final Collection<NodedSegmentString> nodedLines = sr.getNodedSubstrings();
    // TODO: improve this to check for full snap-rounded correctness
    if (this.isValidityChecked) {
        final NodingValidator nv = new NodingValidator(nodedLines);
        nv.checkValid();
    }
    return toLineStrings(nodedLines);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) NodedSegmentString(com.revolsys.geometry.noding.NodedSegmentString) LineString(com.revolsys.geometry.model.LineString) NodingValidator(com.revolsys.geometry.noding.NodingValidator) Noder(com.revolsys.geometry.noding.Noder)

Example 4 with Noder

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

the class Buffer method bufferFixedPrecision.

private static Geometry bufferFixedPrecision(final GeometryFactory precisionModel, final Geometry geometry, final double distance, final BufferParameters parameters) {
    final MCIndexSnapRounder rounder = new MCIndexSnapRounder(1.0);
    final double scale = precisionModel.getScaleXY();
    final Noder noder = new ScaledNoder(rounder, scale);
    return buffer(noder, precisionModel, geometry, distance, parameters);
}
Also used : ScaledNoder(com.revolsys.geometry.noding.ScaledNoder) MCIndexSnapRounder(com.revolsys.geometry.noding.snapround.MCIndexSnapRounder) MCIndexNoder(com.revolsys.geometry.noding.MCIndexNoder) Noder(com.revolsys.geometry.noding.Noder) ScaledNoder(com.revolsys.geometry.noding.ScaledNoder)

Example 5 with Noder

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

Noder (com.revolsys.geometry.noding.Noder)5 MCIndexNoder (com.revolsys.geometry.noding.MCIndexNoder)4 ScaledNoder (com.revolsys.geometry.noding.ScaledNoder)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 List (java.util.List)3 RobustLineIntersector (com.revolsys.geometry.algorithm.RobustLineIntersector)2 IntersectionAdder (com.revolsys.geometry.noding.IntersectionAdder)2 MCIndexSnapRounder (com.revolsys.geometry.noding.snapround.MCIndexSnapRounder)2 LineIntersector (com.revolsys.geometry.algorithm.LineIntersector)1 Geometry (com.revolsys.geometry.model.Geometry)1 LineString (com.revolsys.geometry.model.LineString)1 NodedSegmentString (com.revolsys.geometry.noding.NodedSegmentString)1 NodingValidator (com.revolsys.geometry.noding.NodingValidator)1