コード例 #1
0
        /// <summary>
        /// Adds a node that is at least part of one road.
        /// </summary>
        /// <param name="nodeId"></param>
        /// <returns></returns>
        private uint?AddRoadNode(long nodeId)
        {
            uint id;

            // try and get existing node.
            if (!_idTransformations.TryGetValue(nodeId, out id))
            {
                // get coordinates.
                ICoordinate coordinates;
                if (_coordinates.TryGet(nodeId, out coordinates))
                { // the coordinate is present.
                    id = _dynamicGraph.AddVertex(
                        coordinates.Latitude, coordinates.Longitude);
                    _coordinates.Remove(nodeId); // free the memory again!

                    if (_relevantNodes.Contains(nodeId))
                    {
                        _idTransformations[nodeId] = id;
                    }

                    // trigger event.
                    if (this.VertexAdded != null)
                    {
                        this.VertexAdded(nodeId, id);
                    }

                    return(id);
                }
                return(null);
            }
            return(id);
        }
コード例 #2
0
        /// <summary>
        /// Adds a node that is at least part of one road.
        /// </summary>
        /// <param name="nodeId"></param>
        /// <returns></returns>
        private uint?AddRoadNode(long nodeId)
        {
            uint id;

            // try and get existing node.
            if (!_idTransformations.TryGetValue(nodeId, out id))
            {
                // get coordinates.
                GeoCoordinateSimple coordinates;
                if (_coordinates.TryGetValue(nodeId, out coordinates))
                { // the coordinate is present.
                    id = _dynamicGraph.AddVertex(
                        coordinates.Latitude, coordinates.Longitude);
                    _coordinates.Remove(nodeId); // free the memory again!

                    if (_usedTwiceOrMore.Contains(nodeId))
                    {
                        _idTransformations[nodeId] = id;
                    }
                    return(id);
                }
                return(null);
            }
            return(id);
        }