public Task <IFeature> NextFeature() { if (_edges == null || _pos >= _edges.Count) { return(Task.FromResult <IFeature>(null)); } NetworkEdge edge = _edges[_pos++]; Feature feature = new Feature(); feature.Shape = new Polyline(); ((Polyline)feature.Shape).AddPath(edge.Path); feature.Fields.Add(new FieldValue("EID", edge.Id)); feature.Fields.Add(new FieldValue("N1", edge.FromNodeIndex)); feature.Fields.Add(new FieldValue("N2", edge.ToNodeIndex)); //feature.Fields.Add(new FieldValue("Length", edge.Length)); //feature.Fields.Add(new FieldValue("GeoLength", edge.GeoLength)); feature.Fields.Add(new FieldValue("FCID", edge.FeatureclassId)); feature.Fields.Add(new FieldValue("OID", edge.FeatureId)); feature.Fields.Add(new FieldValue("ISCOMPLEX", edge.IsComplex)); return(Task.FromResult <IFeature>(feature)); }
public bool SplitToComplexEdges(NetworkNode node) { if (node == null || node.Point == null) { return(false); } Envelope env = new Envelope(node.Point.X - _tolerance, node.Point.Y - _tolerance, node.Point.X + _tolerance, node.Point.Y + _tolerance); NetworkEdges edges = _edges.Collect(env); foreach (NetworkEdge edge in edges) { if (edge.FromNodeIndex == node.Id || edge.ToNodeIndex == node.Id) { continue; } double dist, stat; IPoint snapped = SpatialAlgorithms.Algorithm.Point2PathDistance(edge.Path, node.Point, out dist, out stat); if (snapped != null) { if (dist <= _tolerance) { Polyline pLine = new Polyline(edge.Path); Polyline p1 = SpatialAlgorithms.Algorithm.PolylineSplit(pLine, 0, stat); Polyline p2 = SpatialAlgorithms.Algorithm.PolylineSplit(pLine, stat, double.MaxValue); if (p1.PathCount != 1 || p2.PathCount != 1) { continue; } // Edge bekommt neue Geometrie edge.Path = p1[0]; edge.Length = edge.GeoLength = p1[0].Length; // Edge bekommt neuen Zielknoten int toNodeIndex = edge.ToNodeIndex; edge.ToNodeIndex = node.Id; NetworkEdge edge2 = new NetworkEdge(); edge2.Path = p2[0]; edge2.Length = edge2.GeoLength = p2[0].Length; edge2.FeatureclassId = edge.FeatureclassId; edge2.FeatureId = edge.FeatureId; edge2.OneWay = edge.OneWay; edge2.Weights = edge.Weights; edge.UseWithComplexEdges = edge2.UseWithComplexEdges = true; // edge.Bounds neu berechnen edge.IsComplex = edge2.IsComplex = true; // Edge2 NodeIds setzen edge2.FromNodeIndex = node.Id; edge2.ToNodeIndex = toNodeIndex; _edges.Add(edge2); } } } return(false); }