Esempio n. 1
0
        private List <LinearFacility> GenerateLinearRoads(DataSet linearNetworkDefinition)
        {
            List <LinearFacility> linearRoads     = new List <LinearFacility>();
            LinearFacility        currentFacility = null;

            foreach (DataRow linearRow in linearNetworkDefinition.Tables[0].Rows)
            {
                if (currentFacility != null)
                {
                    if (linearRow["ROUTES"].ToString() != currentFacility.Name)
                    {
                        linearRoads.Add(currentFacility);
                        currentFacility = new LinearFacility(linearRow["ROUTES"].ToString());
                    }
                    currentFacility.Directions.Add(new Direction(linearRow["DIRECTION"].ToString(), double.Parse(linearRow["BEGIN_STATION"].ToString()), double.Parse(linearRow["END_STATION"].ToString())));
                }
                else
                {
                    currentFacility = new LinearFacility(linearRow["ROUTES"].ToString());
                    currentFacility.Directions.Add(new Direction(linearRow["DIRECTION"].ToString(), double.Parse(linearRow["BEGIN_STATION"].ToString()), double.Parse(linearRow["END_STATION"].ToString())));
                }
            }
            if (currentFacility != null)
            {
                linearRoads.Add(currentFacility);
            }

            return(linearRoads);
        }
Esempio n. 2
0
        /// <summary>
        /// Checks to see whether or not a given segment exists in the NETWORK_DEFINITION table.
        /// </summary>
        /// <param name="segToValidate">network definition information to check against the NETWORK_DEFINITION table.</param>
        private void ValidateLinear(Segment segToValidate)
        {
            LinearFacility networkFacility = linearRoads.Find(delegate(LinearFacility f){ return(f.Name == segToValidate.Facility); });

            if (networkFacility != null)
            {
                Direction networkDirection = networkFacility.Directions.Find(delegate(Direction d) { return(segToValidate.Direction == d.Name && segToValidate.BMP >= d.BMP && segToValidate.BMP <= d.EMP && segToValidate.EMP >= d.BMP && segToValidate.EMP <= d.EMP); });
                if (networkDirection == null)
                {
                    segToValidate.AddError(segToValidate.Facility + " [" + segToValidate.Direction + "] (" + segToValidate.BMP + "-" + segToValidate.EMP + ") does not exist in the network defintion.");
                    segToValidate.Exclude = true;
                }
            }
            else
            {
                segToValidate.AddError(segToValidate.Facility + " [" + segToValidate.Direction + "] (" + segToValidate.BMP + "-" + segToValidate.EMP + ") does not exist in the network defintion.");
                segToValidate.Exclude = true;
            }
        }