예제 #1
0
        // Get the bounding box of the map frame in wgs84 unprojected
        // ### Not not yet implemented, all returned values are wgs84 -> Return the values either in 'native' i.e. incoming coordinate system or convert them to wgs84
        public static Dictionary <string, string> getMapFrameWgs84BoundingBox(IMxDocument pMxDoc, string mapFrameName)
        {
            // Declare and initalise variables
            Dictionary <string, string> dict = new Dictionary <string, string>();
            IMap        pMap        = Utilities.getMapFrame(pMxDoc, mapFrameName);
            IActiveView pActiveView = pMap as IActiveView;
            IEnvelope2  pEnvelope   = pActiveView.Extent as IEnvelope2;

            // Get the spatial reference of the map frame
            // If not Geographic / WGS 84, convert it
            var spatialRefDict = getDataFrameSpatialReference(pMxDoc, mapFrameName);

            if (spatialRefDict["type"] != "Geographic" && spatialRefDict["datum"] != "WGS 1984")
            {
                //Convert active view to wgs 84
                Debug.WriteLine("Reprojecting to wgs84");
                ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironmentClass();
                ISpatialReference        wgs84;
                //GCS to project from
                IGeographicCoordinateSystem gcs = srFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);
                wgs84 = gcs;
                wgs84.SetFalseOriginAndUnits(-180, -90, 1000000);
                pEnvelope.Project(wgs84);
            }

            dict.Add("xMin", pEnvelope.XMin.ToString());
            dict.Add("yMin", pEnvelope.YMin.ToString());
            dict.Add("xMax", pEnvelope.XMax.ToString());
            dict.Add("yMax", pEnvelope.YMax.ToString());

            return(dict);
        }
예제 #2
0
파일: Utils3D.cs 프로젝트: secondii/Yutai
        public static IMultiPatch EnvelopeToBoundingBox(IEnvelope2 ienvelope2_0)
        {
            object value = Missing.Value;
            double double_;
            double double_2;
            double double_3;
            double double_4;

            ienvelope2_0.QueryCoords(out double_, out double_2, out double_3, out double_4);
            double              zMin               = ienvelope2_0.ZMin;
            double              zMax               = ienvelope2_0.ZMax;
            IMultiPatch         multiPatch         = new MultiPatch() as IMultiPatch;
            IGeometryCollection geometryCollection = multiPatch as IGeometryCollection;
            IPointCollection    pointCollection    = new TriangleStrip();

            Utils3D.MakeZMAware(pointCollection as IGeometry, true);
            pointCollection.AddPoint(Utils3D.Create3DPoint(double_, double_2, zMin), ref value, ref value);
            pointCollection.AddPoint(Utils3D.Create3DPoint(double_, double_2, zMax), ref value, ref value);
            pointCollection.AddPoint(Utils3D.Create3DPoint(double_3, double_2, zMin), ref value, ref value);
            pointCollection.AddPoint(Utils3D.Create3DPoint(double_3, double_2, zMax), ref value, ref value);
            pointCollection.AddPoint(Utils3D.Create3DPoint(double_3, double_4, zMin), ref value, ref value);
            pointCollection.AddPoint(Utils3D.Create3DPoint(double_3, double_4, zMax), ref value, ref value);
            pointCollection.AddPoint(Utils3D.Create3DPoint(double_, double_4, zMin), ref value, ref value);
            pointCollection.AddPoint(Utils3D.Create3DPoint(double_, double_4, zMax), ref value, ref value);
            pointCollection.AddPoint(Utils3D.Create3DPoint(double_, double_2, zMin), ref value, ref value);
            pointCollection.AddPoint(Utils3D.Create3DPoint(double_, double_2, zMax), ref value, ref value);
            geometryCollection.AddGeometry(pointCollection as IGeometry, ref value, ref value);
            return(multiPatch);
        }