コード例 #1
0
ファイル: MgrsBoundingBox.cs プロジェクト: TNOCS/csTouch
        public MgrsBoundingBox(System.Windows.Point[] pPoints)
        {
            var result = new WGS84LatLongPoint[4];
            bool init = false;
            foreach (var pnt in pPoints)
            {
                if (!init)
                {
                    init = true;
                    result[0] = WGS84LatLongPoint.Create(pnt.Y, pnt.X);
                    result[1] = WGS84LatLongPoint.Create(pnt.Y, pnt.X); ;
                    result[2] = WGS84LatLongPoint.Create(pnt.Y, pnt.X); ;
                    result[3] = WGS84LatLongPoint.Create(pnt.Y, pnt.X); ;
                }
                else
                {
                    result[0].Longitude = Math.Min(result[0].Longitude, pnt.X);
                    result[0].Latitude = Math.Max(result[0].Latitude, pnt.Y);

                    result[1].Longitude = Math.Max(result[1].Longitude, pnt.X);
                    result[1].Latitude = Math.Max(result[1].Latitude, pnt.Y);

                    result[2].Longitude = Math.Max(result[2].Longitude, pnt.X);
                    result[2].Latitude = Math.Min(result[2].Latitude, pnt.Y);

                    result[3].Longitude = Math.Min(result[3].Longitude, pnt.X);
                    result[3].Latitude = Math.Min(result[3].Latitude, pnt.Y);
                }
            }
            UpperLeft = WGS84LatLongPoint.Create(result[0].Latitude, result[0].Longitude);
            UpperRight = WGS84LatLongPoint.Create(result[1].Latitude, result[1].Longitude);
            LowerRight = WGS84LatLongPoint.Create(result[2].Latitude, result[2].Longitude);
            LowerLeft = WGS84LatLongPoint.Create(result[3].Latitude, result[3].Longitude);
        }
コード例 #2
0
        public static GeographicBoundingBox Create(WGS84LatLongPoint pUpperLeft, WGS84LatLongPoint pLowerRight)
        {
            // switch east and west, because the bounding box is positioned around the 180 degree meridian
            return new GeographicBoundingBox()
            {
                NorthBoundLatitude = Math.Max(pUpperLeft.Latitude, pLowerRight.Latitude),
                WestBoundLongitude = Math.Min(pUpperLeft.Longitude, pLowerRight.Longitude),
                SouthBoundLatitude = Math.Min(pUpperLeft.Latitude, pLowerRight.Latitude),
                EastBoundLongitude = Math.Max(pUpperLeft.Longitude, pLowerRight.Longitude)
            };

        }