Пример #1
0
        private void LoadBoundary(String FileName, bool Counties)
        {
            CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory();
            ICoordinateSystem         SourceProj  = ProjNet.Converters.WellKnownText.CoordinateSystemWktReader.Parse(File.ReadAllText(FileName.ToLower().Replace(".shp", ".prj"))) as ICoordinateSystem;
            ICoordinateSystem         DestProj    = GeographicCoordinateSystem.WGS84;
            ICoordinateTransformation XF          = ctfac.CreateFromCoordinateSystems(SourceProj, DestProj);

            using (ShapeFile sF = ShapeFile.Open(FileName))
                foreach (Shape shp in sF.GetAllShapes())
                {
                    Sim_Boundary NewBoundary = new Sim_Boundary(shp, XF, this);
                    if (Counties)
                    {
                        Boundaries.Add(NewBoundary);
                    }
                    else if (NewBoundary.Contains(Boundaries[0]))
                    {
                        NewBoundary.Name = "STATE";
                        Boundaries.Add(NewBoundary);
                    }
                }

            if (Counties)
            {
                Centroid_X /= CoordinateCount;
                Centroid_Y /= CoordinateCount;
            }
        }
Пример #2
0
 public Sim_Substation(String Name, double Longitude, double Latitude, Sim_Boundary Parent, Sim_Builder Builder)
 {
     this.Name      = Name;
     this.Longitude = Longitude;
     this.Latitude  = Latitude;
     this.Parent    = Parent;
     this.Owner     = Builder.GetOwner();
     this.ElemGuid  = Guid.NewGuid();
     this.Operator  = Builder.GetOperator();
     this.TEID      = Builder.NextTEID();
 }
Пример #3
0
        /// <summary>
        /// Initialize a new substation
        /// </summary>
        /// <param name="InLine"></param>
        /// <param name="Parents"></param>
        public Sim_Substation(String[] InLine, List <Sim_Boundary> Parents)
        {
            this.Name      = InLine[0];
            this.Longitude = ParseCoord(InLine[2]);
            this.Latitude  = ParseCoord(InLine[1]);
            foreach (Sim_Boundary ShapeToCheck in Parents)
            {
                if (ShapeToCheck.Contains(Longitude, Latitude))
                {
                    Parent = ShapeToCheck;
                    break;
                }
            }

            //If we have no parent, assign to state
            if (Parent == null)
            {
                Parent = Parents.Last();
            }
        }
Пример #4
0
 public bool Contains(Sim_Boundary OtherShape)
 {
     return(OtherShape.Centroid_X >= Min_X && OtherShape.Centroid_X <= Max_X && OtherShape.Centroid_Y >= Min_Y && OtherShape.Centroid_Y <= Max_Y);
 }