Exemplo n.º 1
0
        /// <summary>
        /// Creates a new StreetSegment between two StreetConnectors.
        /// </summary>
        /// <param name="c1">The first StreetConnector</param>
        /// <param name="c2">The second StreetConnector</param>
        public StreetSegment(StreetConnector c1, StreetConnector c2)
        {
            id  = NextID;
            ep1 = new StreetEndpoint(this);
            ep2 = new StreetEndpoint(this);

            if (!ep1.Connect(c1) || !ep2.Connect(c2))
            {
                throw new StreetMapException("Could not connect this StreetSegment with all StreetConnectors");
            }

            length     = CalcLength();
            speedLimit = DEFAULT_SPEED_LIMIT;
            UpdateMinDriveTime();
            lanes = DEFAULT_LANES_COUNT;
            UpdateSpace();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Connects to the given StreetConnector.
        /// </summary>
        /// <param name="connector">The StreetConnector to connect to</param>
        /// <returns>True if a connection could be established, false otherwise</returns>
        public bool Connect(StreetConnector connector)
        {
            if (FindEndpoint(connector) != null)
            {
                return(true);
            }

            StreetEndpoint ep = new StreetEndpoint(this);

            if (!ep.Connect(connector))
            {
                throw new StreetMapException("Could not connect this StreetHub to the StreetConnector");
            }
            connections.Add(ep);
            isGreenList.Add(connector.ID, true);
            UpdateSpace();

            return(true);
        }