/// <summary> /// Converts a Label to a Line label (that is, one with no side Locations). /// </summary> /// <param name="label">Label to convert.</param> /// <returns>Label as Line label.</returns> public static Label ToLineLabel(Label label) { Label lineLabel = new Label(Locations.Null); for (int i = 0; i < 2; i++) lineLabel.SetLocation(i, label.GetLocation(i)); return lineLabel; }
/// <summary> /// Converts a Label to a Line label (that is, one with no side Locations). /// </summary> /// <param name="label">Label to convert.</param> /// <returns>Label as Line label.</returns> public static Label ToLineLabel(Label label) { Label lineLabel = new Label(Locations.Null); for (int i = 0; i < 2; i++) { lineLabel.SetLocation(i, label.GetLocation(i)); } return(lineLabel); }
/// <summary> /// /// </summary> /// <param name="argIndex"></param> /// <param name="coord"></param> /// <param name="onLocation"></param> private void InsertPoint(int argIndex, ICoordinate coord, Locations onLocation) { Node n = nodes.AddNode(coord); Label lbl = n.Label; if (lbl == null) { n.Label = new Label(argIndex, onLocation); } else { lbl.SetLocation(argIndex, onLocation); } }
/// <summary> /// Merge the RHS label from a DirectedEdge into the label for this EdgeRing. /// The DirectedEdge label may be null. This is acceptable - it results /// from a node which is NOT an intersection node between the Geometries /// (e.g. the end node of a LinearRing). In this case the DirectedEdge label /// does not contribute any information to the overall labelling, and is simply skipped. /// </summary> /// <param name="deLabel"></param> /// <param name="geomIndex"></param> protected void MergeLabel(Label deLabel, int geomIndex) { Locations loc = deLabel.GetLocation(geomIndex, Positions.Right); // no information to be had from this label if (loc == Locations.Null) { return; } // if there is no current RHS value, set it if (label.GetLocation(geomIndex) == Locations.Null) { label.SetLocation(geomIndex, loc); return; } }
/// <summary> /// Adds points using the mod-2 rule of SFS. This is used to add the boundary /// points of dim-1 geometries (Curves/MultiCurves). According to the SFS, /// an endpoint of a Curve is on the boundary /// if it is in the boundaries of an odd number of Geometries. /// </summary> /// <param name="argIndex"></param> /// <param name="coord"></param> private void InsertBoundaryPoint(int argIndex, ICoordinate coord) { Node n = nodes.AddNode(coord); Label lbl = n.Label; // the new point to insert is on a boundary int boundaryCount = 1; // determine the current location for the point (if any) Locations loc = Locations.Null; if (lbl != null) { loc = lbl.GetLocation(argIndex, Positions.On); } if (loc == Locations.Boundary) { boundaryCount++; } // determine the boundary status of the point according to the Boundary Determination Rule Locations newLoc = DetermineBoundary(boundaryCount); lbl.SetLocation(argIndex, newLoc); }
/// <summary> /// Compute the labelling for all dirEdges in this star, as well /// as the overall labelling. /// </summary> /// <param name="geom"></param> public override void ComputeLabelling(GeometryGraph[] geom) { base.ComputeLabelling(geom); // determine the overall labelling for this DirectedEdgeStar // (i.e. for the node it is based at) label = new Label(Locations.Null); IEnumerator it = GetEnumerator(); while (it.MoveNext()) { EdgeEnd ee = (EdgeEnd)it.Current; Edge e = ee.Edge; Label eLabel = e.Label; for (int i = 0; i < 2; i++) { Locations eLoc = eLabel.GetLocation(i); if (eLoc == Locations.Interior || eLoc == Locations.Boundary) { label.SetLocation(i, Locations.Interior); } } } }
/// <summary> /// Compute the labelling for all dirEdges in this star, as well /// as the overall labelling. /// </summary> /// <param name="geom"></param> public override void ComputeLabelling(GeometryGraph[] geom) { base.ComputeLabelling(geom); // determine the overall labelling for this DirectedEdgeStar // (i.e. for the node it is based at) label = new Label(Locations.Null); IEnumerator it = GetEnumerator(); while(it.MoveNext()) { EdgeEnd ee = (EdgeEnd)it.Current; Edge e = ee.Edge; Label eLabel = e.Label; for (int i = 0; i < 2; i++) { Locations eLoc = eLabel.GetLocation(i); if (eLoc == Locations.Interior || eLoc == Locations.Boundary) label.SetLocation(i, Locations.Interior); } } }
/// <summary> /// /// </summary> /// <param name="geomIndex"></param> public void PropagateSideLabels(int geomIndex) { // Since edges are stored in CCW order around the node, // As we move around the ring we move from the right to the left side of the edge Locations startLoc = Locations.Null; // initialize loc to location of last Curve side (if any) for (IEnumerator it = GetEnumerator(); it.MoveNext();) { EdgeEnd e = (EdgeEnd)it.Current; Label label = e.Label; if (label.IsArea(geomIndex) && label.GetLocation(geomIndex, Positions.Left) != Locations.Null) { startLoc = label.GetLocation(geomIndex, Positions.Left); } } // no labelled sides found, so no labels to propagate if (startLoc == Locations.Null) { return; } Locations currLoc = startLoc; for (IEnumerator it = GetEnumerator(); it.MoveNext();) { EdgeEnd e = (EdgeEnd)it.Current; Label label = e.Label; // set null On values to be in current location if (label.GetLocation(geomIndex, Positions.On) == Locations.Null) { label.SetLocation(geomIndex, Positions.On, currLoc); } // set side labels (if any) if (label.IsArea(geomIndex)) { Locations leftLoc = label.GetLocation(geomIndex, Positions.Left); Locations rightLoc = label.GetLocation(geomIndex, Positions.Right); // if there is a right location, that is the next location to propagate if (rightLoc != Locations.Null) { if (rightLoc != currLoc) { throw new TopologyException("side location conflict", e.Coordinate); } if (leftLoc == Locations.Null) { Assert.ShouldNeverReachHere("found single null side (at " + e.Coordinate + ")"); } currLoc = leftLoc; } else { /* RHS is null - LHS must be null too. * This must be an edge from the other point, which has no location * labelling for this point. This edge must lie wholly inside or outside * the other point (which is determined by the current location). * Assign both sides to be the current location. */ Assert.IsTrue(label.GetLocation(geomIndex, Positions.Left) == Locations.Null, "found single null side"); label.SetLocation(geomIndex, Positions.Right, currLoc); label.SetLocation(geomIndex, Positions.Left, currLoc); } } } }