Example #1
0
        public void AddEdgeFeature(int fcId, IFeature feature, bool oneWay, Hashtable weights, bool useWithComplexEdges)
        {
            if (feature == null)
            {
                return;
            }

            NetworkEdges edges = null;

            if (feature.Shape is IPolyline)
            {
                edges = new NetworkEdges((IPolyline)feature.Shape);
            }

            if (edges == null)
            {
                return;
            }

            foreach (NetworkEdge edge in edges)
            {
                edge.FeatureclassId      = fcId;
                edge.FeatureId           = feature.OID;
                edge.OneWay              = oneWay;
                edge.UseWithComplexEdges = useWithComplexEdges;
                edge.Weights             = weights;

                edge.FromNodeIndex = _nodes.Add(edge.FromPoint, _tolerance);
                edge.ToNodeIndex   = _nodes.Add(edge.ToPoint, _tolerance);

                _edges.Add(edge);
            }
        }
Example #2
0
        public NetworkBuilder(IEnvelope bounds, double tolerance)
        {
            if (bounds == null)
            {
                bounds = new Envelope();
            }

            _nodes     = new NetworkNodes(bounds);
            _edges     = new NetworkEdges(bounds);
            _tolerance = tolerance;
        }
Example #3
0
        public NetworkEdges Collect(IEnvelope env)
        {
            NetworkEdges edges = new NetworkEdges();

            if (_gridArray != null)
            {
                foreach (List <NetworkEdge> e in _gridArray.Collect(env))
                {
                    edges.AddRange(e);
                }
            }
            return(edges);
        }
Example #4
0
        public NetworkEdges SelectTo(int toNodeIndex)
        {
            NetworkEdges edges = new NetworkEdges();

            foreach (NetworkEdge edge in this)
            {
                if (edge.ToNodeIndex == toNodeIndex)
                {
                    edges.Add(edge);
                }
            }
            edges.Sort(new SortFromNodeIndex());
            return(edges);
        }
Example #5
0
 public EdgeCursor(NetworkEdges edges)
 {
     _edges = edges;
 }
Example #6
0
        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);
        }