protected KdNodeVisitor(Coordinate p0, Coordinate p1, NodedSegmentString ss, int segIndex) { P0 = p0; P1 = p1; SS = ss; SegIndex = segIndex; }
public static ICollection <ISegmentString> GetNodedSubstrings(NodedSegmentString nss) { var resultEdgelist = new List <ISegmentString>(); nss.NodeList.AddSplitEdges(resultEdgelist); return(resultEdgelist); }
/// <summary> /// Add nodes for any vertices in hot pixels that were /// added as nodes during segment noding. /// </summary> /// <param name="ss">A noded segment string</param> private void AddVertexNodeSnaps(NodedSegmentString ss) { var pts = ss.Coordinates; for (int i = 1; i < pts.Length - 1; i++) { var p0 = pts[i]; SnapVertexNode(p0, ss, i); } }
/// <summary> /// This is where all the work of snapping to hot pixels gets done /// (in a very inefficient brute-force way). /// </summary> private void SnapSegment(Coordinate p0, Coordinate p1, NodedSegmentString ss, int segIndex) { foreach (var hp in _hotPixels) { if (hp.Intersects(p0, p1)) { ss.AddIntersection(hp.Coordinate, segIndex); } } }
public static IList <ISegmentString> ToSegmentStrings(IEnumerable <Geometry> lines) { var nssList = new List <ISegmentString>(); foreach (LineString line in lines) { var nss = new NodedSegmentString(line.Coordinates, line); nssList.Add(nss); } return(nssList); }
/// <summary> /// Creates a {SegmentString} for a coordinate list which is a raw offset curve, /// and adds it to the list of buffer curves. /// The SegmentString is tagged with a Label giving the topology of the curve. /// The curve may be oriented in either direction. /// If the curve is oriented CW, the locations will be: /// Left: Location.Exterior. /// Right: Location.Interior. /// </summary> private void AddCurve(Coordinate[] coord, Location leftLoc, Location rightLoc) { // don't add null or trivial curves! if (coord == null || coord.Length < 2) { return; } // add the edge for a coordinate list which is a raw offset curve var e = new NodedSegmentString(coord, new Label(0, Location.Boundary, leftLoc, rightLoc)); _curveList.Add(e); }
/// <summary> /// /// </summary> /// <param name="ss"></param> private NodedSegmentString ComputeSnaps(NodedSegmentString ss) { //Coordinate[] pts = ss.getCoordinates(); /* * Get edge coordinates, including added intersection nodes. * The coordinates are now rounded to the grid, * in preparation for snapping to the Hot Pixels */ var pts = ss.NodedCoordinates; var ptsRound = Round(pts); // if complete collapse this edge can be eliminated if (ptsRound.Length <= 1) { return(null); } // Create new nodedSS to allow adding any hot pixel nodes var snapSS = new NodedSegmentString(ptsRound, ss.Context); int snapSSindex = 0; for (int i = 0; i < pts.Length - 1; i++) { var currSnap = snapSS.GetCoordinate(snapSSindex); /* * If the segment has collapsed completely, skip it */ var p1 = pts[i + 1]; var p1Round = Round(p1); if (p1Round.Equals2D(currSnap)) { continue; } var p0 = pts[i]; /* * Add any Hot Pixel intersections with *original* segment to rounded segment. * (It is important to check original segment because rounding can * move it enough to intersect other hot pixels not intersecting original segment) */ SnapSegment(p0, p1, snapSS, snapSSindex); snapSSindex++; } return(snapSS); }
private void CheckNodedStrings(string wkt, PrecisionModel pm) { var g = rdr.Read(wkt); var strings = new List <ISegmentString>(); strings.Add(new NodedSegmentString(g.Coordinates, null)); new SnapRoundingNoder(pm).ComputeNodes(strings); var noded = NodedSegmentString.GetNodedSubstrings(strings); foreach (var s in noded) { Assert.That(s.Count, Is.GreaterThanOrEqualTo(2), "Found a 1-point segmentstring"); Assert.That(IsCollapsed(s), Is.False, "Found a collapsed edge"); } }
public static NodedSegmentString CreateNSS(params double[] ords) { if (ords.Length % 2 != 0) { throw new ArgumentException("Must provide pairs of ordinates"); } var pts = new Coordinate[ords.Length / 2]; for (int i = 0; i <= ords.Length; i += 2) { var p = new Coordinate(ords[i], ords[i + 1]); pts[i / 2] = p; } var nss = new NodedSegmentString(pts, null); return(nss); }
private void CheckNoding(string wktLine, string wktNodes, int[] segmentIndex, string wktExpected) { var line = Read(wktLine); var pts = Read(wktNodes); var nss = new NodedSegmentString(line.Coordinates, null); var node = pts.Coordinates; for (int i = 0; i < node.Length; i++) { nss.AddIntersection(node[i], segmentIndex[i]); } var nodedSS = NodingTestUtility.GetNodedSubstrings(nss); var result = NodingTestUtility.ToLines(nodedSS, line.Factory); //System.out.println(result); var expected = Read(wktExpected); CheckEqual(expected, result); }
/// <summary> /// Returns a <see cref="IList"/> of fully noded <see cref="ISegmentString"/>s. /// The <see cref="ISegmentString"/>s have the same context as their parent. /// </summary> /// <returns>A Collection of NodedSegmentStrings representing the substrings</returns> public IList <ISegmentString> GetNodedSubstrings() { return(NodedSegmentString.GetNodedSubstrings(_nodedSegStrings)); }
public SnapVertexVisitor(Coordinate p0, NodedSegmentString ss, int segIndex) : base(p0, null, ss, segIndex) { }
private void SnapVertexNode(Coordinate p0, NodedSegmentString ss, int segIndex) { _pixelIndex.Query(p0, p0, new SnapVertexVisitor(p0, ss, segIndex)); }
public SnapSegmentVisitor(Coordinate p0, Coordinate p1, NodedSegmentString ss, int segIndex) : base(p0, p1, ss, segIndex) { }
/// <summary> /// Snaps a segment in a segmentString to HotPixels that it intersects. /// </summary> /// <param name="p0">The segment start coordinate</param> /// <param name="p1">The segment end coordinate</param> /// <param name="ss">The segment string to add intersections to</param> /// <param name="segIndex">The index of the segment/</param> private void SnapSegment(Coordinate p0, Coordinate p1, NodedSegmentString ss, int segIndex) { _pixelIndex.Query(p0, p1, visitor: new SnapSegmentVisitor(p0, p1, ss, segIndex)); }
/// <summary> /// Returns a <see cref="IList"/> of fully noded <see cref="ISegmentString"/>s. /// The <see cref="ISegmentString"/>s have the same context as their parent. /// </summary> /// <returns>A Collection of NodedSegmentStrings representing the substrings</returns> public IList <ISegmentString> GetNodedSubstrings() { return(NodedSegmentString.GetNodedSubstrings(_snappedResult)); }
public LineTopology(ICoordinate[] pts, IGeometryFactory geomFact) { _segStr = new NodedSegmentString(pts, this); _geomFact = geomFact; }
private static void PerformTest(ICoordinateSequence sequence) { if (sequence == null) throw new ArgumentNullException("sequence"); Coordinate[] coordinates = sequence.ToCoordinateArray(); NodedSegmentString segmentString = new NodedSegmentString(coordinates, null); Stopwatch watch = new Stopwatch(); NodingValidator validator = new NodingValidator(new[] { segmentString }); validator.CheckValid(); watch.Start(); validator.CheckValid(); watch.Stop(); Console.WriteLine("NodingValidator.CheckValid => ElapsedMilliseconds: {0}", watch.ElapsedMilliseconds); BasicSegmentString segmentStringBasic = new BasicSegmentString(coordinates, null); FastNodingValidator fastValidator = new FastNodingValidator(new[] { segmentStringBasic }); watch.Reset(); watch.Start(); fastValidator.CheckValid(); watch.Stop(); Console.WriteLine("FastNodingValidator.CheckValid => ElapsedMilliseconds: {0}", watch.ElapsedMilliseconds); }