コード例 #1
0
ファイル: Constant.cs プロジェクト: paladin74/Dapple
        /// <summary>
        /// Reproject the src bounding box into the destination coordinate system
        /// </summary>
        /// <param name="hSrcBB"></param>
        /// <param name="hDestCS"></param>
        /// <returns></returns>
        static internal bool Reproject(Geosoft.Dap.Common.BoundingBox hSrcBB, Geosoft.Dap.Common.CoordinateSystem hDestCS)
        {
#if !DAPPLE
            Geosoft.GXNet.CIPJ hSrcIPJ  = null;
            Geosoft.GXNet.CIPJ hDestIPJ = null;

            try
            {
                hSrcIPJ  = Geosoft.GXNet.CIPJ.Create();
                hDestIPJ = Geosoft.GXNet.CIPJ.Create();

                hSrcIPJ.SetGXF("", hSrcBB.CoordinateSystem.Datum, hSrcBB.CoordinateSystem.Method, hSrcBB.CoordinateSystem.Units, hSrcBB.CoordinateSystem.LocalDatum);
                hDestIPJ.SetGXF("", hDestCS.Datum, hDestCS.Method, hDestCS.Units, hDestCS.LocalDatum);

                return(Reproject(hSrcBB, hSrcIPJ, hDestIPJ));
            }
            catch (Exception e)
            {
                GetDapError.Instance.Write("Reproject - " + e.Message);
            }
            finally
            {
                if (hSrcIPJ != null)
                {
                    hSrcIPJ.Dispose();
                }
                if (hDestIPJ != null)
                {
                    hDestIPJ.Dispose();
                }
            }
#endif
            return(false);
        }
コード例 #2
0
ファイル: Constant.cs プロジェクト: paladin74/Dapple
        /// <summary>
        /// Reproject the src bounding box into the destination coordinate system
        /// </summary>
        /// <param name="hSrcBB"></param>
        /// <param name="hDestCS"></param>
        /// <returns></returns>
        static internal bool Reproject(Geosoft.Dap.Common.BoundingBox hSrcBB, Geosoft.GXNet.CIPJ ipDestIPJ)
        {
            Geosoft.GXNet.CIPJ ipSrcIPJ = null;

            try {
                ipSrcIPJ = Geosoft.GXNet.CIPJ.Create();

                ipSrcIPJ.SetGXF("", hSrcBB.CoordinateSystem.Datum, hSrcBB.CoordinateSystem.Method, hSrcBB.CoordinateSystem.Units, hSrcBB.CoordinateSystem.LocalDatum);

                return(Reproject(hSrcBB, ipSrcIPJ, ipDestIPJ));
            } catch (Exception e) {
                GetDapError.Instance.Write("Reproject - " + e.Message);
            } finally {
                if (ipSrcIPJ != null)
                {
                    ipSrcIPJ.Dispose();
                }
            }
            return(false);
        }
コード例 #3
0
ファイル: Constant.cs プロジェクト: paladin74/Dapple
        /// <summary>
        /// Create a coordinate system from an ipj and a bounding box
        /// </summary>
        /// <param name="dMinX"></param>
        /// <param name="dMinY"></param>
        /// <param name="dMinZ"></param>
        /// <param name="dMaxX"></param>
        /// <param name="dMaxY"></param>
        /// <param name="dMaxZ"></param>
        /// <param name="hIPJ"></param>
        /// <returns></returns>
        static internal Geosoft.Dap.Common.BoundingBox SetCoordinateSystem(double dMinX, double dMinY, double dMinZ, double dMaxX, double dMaxY, double dMaxZ, Geosoft.GXNet.CIPJ hIPJ)
        {
            Geosoft.Dap.Common.BoundingBox hBoundingBox = null;
            string strProjectionName = string.Empty;
            string strDatum          = string.Empty;
            string strProjection     = string.Empty;
            string strUnits          = string.Empty;
            string strLocalDatum     = string.Empty;

            hIPJ.IGetGXF(ref strProjectionName, ref strDatum, ref strProjection, ref strUnits, ref strLocalDatum);

            hBoundingBox = new Geosoft.Dap.Common.BoundingBox(dMaxX, dMaxY, dMaxZ, dMinX, dMinY, dMinZ);
            hBoundingBox.CoordinateSystem            = new Geosoft.Dap.Common.CoordinateSystem();
            hBoundingBox.CoordinateSystem.Projection = strProjectionName;
            hBoundingBox.CoordinateSystem.Datum      = strDatum;
            hBoundingBox.CoordinateSystem.Method     = strProjection;
            hBoundingBox.CoordinateSystem.Units      = strUnits;
            hBoundingBox.CoordinateSystem.LocalDatum = strLocalDatum;
            return(hBoundingBox);
        }
コード例 #4
0
ファイル: Constant.cs プロジェクト: paladin74/Dapple
        /// <summary>
        /// Reproject the src bounding box into the destination coordinate system
        /// </summary>
        /// <param name="hSrcBB"></param>
        /// <param name="hDestCS"></param>
        /// <returns></returns>
        static internal bool Reproject(Geosoft.Dap.Common.BoundingBox hSrcBB, Geosoft.GXNet.CIPJ ipSrcIPJ, Geosoft.GXNet.CIPJ ipDestIPJ)
        {
            Geosoft.GXNet.CPJ hPJ = null;

            double dMinX;
            double dMinY;
            double dMaxX;
            double dMaxY;

            String strProjectionName = String.Empty;
            String strDatum          = String.Empty;
            String strProjection     = String.Empty;
            String strUnits          = String.Empty;
            String strLocalDatum     = String.Empty;

            // --- All dummies therefore will be dummies in new coordinate sytem as well ---

            if (hSrcBB.MinX == Geosoft.GXNet.Constant.rDUMMY ||
                hSrcBB.MinY == Geosoft.GXNet.Constant.rDUMMY ||
                hSrcBB.MaxX == Geosoft.GXNet.Constant.rDUMMY ||
                hSrcBB.MaxY == Geosoft.GXNet.Constant.rDUMMY)
            {
                return(true);
            }


            try
            {
                // --- check to see if this is a valid coordinate system for the given coordinates ---

                hPJ   = Geosoft.GXNet.CPJ.CreateIPJ(ipSrcIPJ, ipDestIPJ);
                dMinX = hSrcBB.MinX;
                dMinY = hSrcBB.MinY;
                dMaxX = hSrcBB.MaxX;
                dMaxY = hSrcBB.MaxY;

                hPJ.ProjectBoundingRectangle(ref dMinX, ref dMinY, ref dMaxX, ref dMaxY);

                if (dMinX == Geosoft.GXNet.Constant.rDUMMY ||
                    dMinY == Geosoft.GXNet.Constant.rDUMMY ||
                    dMaxX == Geosoft.GXNet.Constant.rDUMMY ||
                    dMaxY == Geosoft.GXNet.Constant.rDUMMY)
                {
                    return(false); // --- unable to convert to the desired coordinate system ---
                }


                // --- copy new projection into src bounding box ---

                ipDestIPJ.IGetName(Geosoft.GXNet.Constant.IPJ_NAME_PCS, ref strProjectionName);
                ipDestIPJ.IGetName(Geosoft.GXNet.Constant.IPJ_NAME_DATUM, ref strDatum);
                ipDestIPJ.IGetName(Geosoft.GXNet.Constant.IPJ_NAME_PROJECTION, ref strProjection);
                ipDestIPJ.IGetName(Geosoft.GXNet.Constant.IPJ_NAME_LDATUM, ref strLocalDatum);
                ipDestIPJ.IGetName(Geosoft.GXNet.Constant.IPJ_NAME_UNIT_ABBR, ref strUnits);

                hSrcBB.CoordinateSystem.Projection = strProjectionName;
                hSrcBB.CoordinateSystem.Datum      = strDatum;
                hSrcBB.CoordinateSystem.Method     = strProjection;
                hSrcBB.CoordinateSystem.Units      = strUnits;
                hSrcBB.CoordinateSystem.LocalDatum = strLocalDatum;
                hSrcBB.MinX = dMinX;
                hSrcBB.MinY = dMinY;
                hSrcBB.MaxX = dMaxX;
                hSrcBB.MaxY = dMaxY;

                return(true);
            }
            catch (Exception e)
            {
                GetDapError.Instance.Write("Reproject - " + e.Message);
            }
            finally
            {
                if (hPJ != null)
                {
                    hPJ.Dispose();
                }
            }
            return(false);
        }