Exemple #1
0
 internal DapDownload(string imagePath, Geosoft.Dap.Common.BoundingBox hBB, DAPImageStore imageStore)
     : base()
 {
     m_hBB         = hBB;
     m_oImageStore = imageStore;
     Url           = imageStore.Server.Url;
 }
Exemple #2
0
 internal DapDownload(string imagePath, Geosoft.Dap.Common.BoundingBox hBB, DAPImageStore imageStore)
     : base()
 {
     m_hBB = hBB;
     m_oImageStore = imageStore;
     Url = imageStore.Server.Url;
 }
Exemple #3
0
        /// <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);
        }
Exemple #4
0
        /// <summary>
        /// Load the default browser map for this server, from either the cache or the server
        /// </summary>
        protected void LoadBrowserMap()
        {
            string strBrowserMapFile = Path.Combine(m_strCacheDir, BROWSERMAP_FILE);

            try
            {
                if (File.Exists(strBrowserMapFile))
                {
                    m_oBrowserMap = new XmlDocument();
                    m_oBrowserMap.Load(strBrowserMapFile);
                }
                else
                {
                    Geosoft.Dap.Common.Format      oFormat      = new Geosoft.Dap.Common.Format();
                    Geosoft.Dap.Common.Resolution  oResolution  = new Geosoft.Dap.Common.Resolution();
                    Geosoft.Dap.Common.BoundingBox oBoundingBox = new Geosoft.Dap.Common.BoundingBox(m_oServerBoundingBox);

                    oFormat.Type = "image/png24";

                    oResolution.Width  = 600;
                    oResolution.Height = 600;


                    // --- Calculate the best resolution for this image, so that it is not distorted ---

                    double dWidth  = oBoundingBox.MaxX - oBoundingBox.MinX;
                    double dHeight = oBoundingBox.MaxY - oBoundingBox.MinY;

                    if (dWidth == 0 || dHeight == 0)
                    {
                        throw new Exception("Fix this");
                    }

                    double dPictureRatio = oResolution.Height / oResolution.Width;
                    double dBoxRatio     = dHeight / dWidth;

                    if (dBoxRatio > dPictureRatio)
                    {
                        // --- width is smaller than it should be ---

                        oResolution.Width = Convert.ToInt32(oResolution.Height / dBoxRatio);
                    }
                    else if (dBoxRatio < dPictureRatio)
                    {
                        // --- height is smaller than it should be ---

                        oResolution.Height = Convert.ToInt32(oResolution.Width * dBoxRatio);
                    }

                    m_oBrowserMap = m_oCommand.GetImageEx(oFormat, oBoundingBox, oResolution, true, false, new ArrayList(), null);
                    m_oBrowserMap.Save(strBrowserMapFile);
                }
            }
            catch (Exception e)
            {
                m_oBrowserMap = new XmlDocument();
                GetDapError.Instance.Write("Get Server Browser Map (" + m_strUrl + ") - " + e.Message);
            }
        }
Exemple #5
0
 internal ArcIMSImageDownload(ArcIMSImageStore oImageStore, Geosoft.Dap.Common.BoundingBox oEnvelope, int iIndexNumber, CultureInfo oInfo, double dArtificialZoom)
     : base(oImageStore.ServerUri, iIndexNumber)
 {
     m_oCultureInfo    = oInfo;
     m_oImageStore     = oImageStore;
     m_oEnvelope       = oEnvelope;
     m_dArtificialZoom = dArtificialZoom;
 }
Exemple #6
0
 /// <summary>
 /// Check to see if this is a valid bounding box
 /// </summary>
 /// <param name="dCoordinate"></param>
 /// <param name="dMin"></param>
 /// <param name="dMax"></param>
 /// <returns></returns>
 static internal bool IsValidBoundingBox(Geosoft.Dap.Common.BoundingBox oBox)
 {
     if (oBox.MinX < oBox.MaxX && oBox.MinY < oBox.MaxY)
     {
         return(true);
     }
     return(false);
 }
Exemple #7
0
        /// <summary>
        /// Count the number of datasets that match this aoi
        /// </summary>
        /// <param name="hBox"></param>
        /// <returns></returns>
        internal Int32 GetDatasetCount(Geosoft.Dap.Common.BoundingBox hBox, string szKeywords)
        {
            if (!(m_blEnabled && m_blConfigured))
            {
                return(0);
            }

            m_iCount = 0;
            try
            {
                XmlDocument oDocument = m_oCommand.GetDataSetCount(String.Empty, -1, 0, 0, szKeywords, hBox, null);
                m_oCommand.Parser.DataSetCount(oDocument, out m_iCount);

                // --- check to see if we have a status node ---

                m_eStatus = ServerStatus.OnLine;

                XmlNodeList oNodeList = oDocument.SelectNodes("//" + Geosoft.Dap.Xml.Common.Constant.Tag.CONFIGURATION_TAG);
                if (oNodeList.Count > 0)
                {
                    XmlNode oNode = oNodeList[0];
                    XmlNode oAttr;

                    // --- if status attribute exists then we are in maintenance ---
                    // --- this server is currently in maintenance mode ---

                    oAttr = oNode.Attributes.GetNamedItem(Geosoft.Dap.Xml.Common.Constant.Attribute.STATUS_ATTR);
                    if (oAttr != null && oAttr.Value == "maintenance")
                    {
                        m_eStatus = ServerStatus.Maintenance;
                    }
                }
                else
                {
                }
            }
            catch (Exception e)
            {
                GetDapError.Instance.Write("Get Dataset Count (" + m_strUrl + ") - " + e.Message);
            }
            return(m_iCount);
        }
Exemple #8
0
        /// <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);
        }
Exemple #9
0
        /// <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);
        }
Exemple #10
0
        /// <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>
        internal static 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;
        }
Exemple #11
0
 public DappleSearchWebDownload(Geosoft.Dap.Common.BoundingBox oBoundingBox, String strKeywords, int iPage, long lSearchIndex)
 {
     m_oBoundingBox = oBoundingBox;
     m_strKeywords = strKeywords;
     m_iPage = iPage;
     m_lSearchIndex = lSearchIndex;
 }
Exemple #12
0
 private void precacheToolStripMenuItem_Click(object sender, EventArgs e)
 {
     SearchResult oResult = c_lbResults.SelectedItem as SearchResult;
     GED.Core.LayerInfo oInfo = new GED.Core.LayerInfo(oResult.ServerType, oResult.ServerUrl, oResult.GetAttribute("datasetname"));
     Geosoft.Dap.Common.BoundingBox oBounds = new Geosoft.Dap.Common.BoundingBox(oResult.MaxX, oResult.MaxY, oResult.MinX, oResult.MinY);
     for (int count = 0; count < 7; count++)
     {
         GED.Core.TileSet oSet = new GED.Core.TileSet(oBounds, count);
         GED.Core.DownloadSet oDownloads = new GED.Core.DownloadSet(oInfo, oSet);
         oDownloads.DownloadSync();
     }
 }
Exemple #13
0
        /// <summary>
        /// Save the current contents of these controls to an xml file
        /// </summary>
        /// <param name="oDatasetElement"></param>
        /// <param name="strDestFolder"></param>
        /// <param name="bDefaultResolution"></param>
        /// <returns></returns>
        internal virtual ExtractSaveResult Save(System.Xml.XmlElement oDatasetElement, string strDestFolder, DownloadSettings.DownloadCoordinateSystem eCS)
        {
            double dMaxX, dMinX, dMaxY, dMinY;
             double dProjMinX, dProjMinY, dProjMaxX, dProjMaxY;
             string strProjCoordinateSystem;
             bool bNewMap = true;
             bool bInvalidReprojection = false;

             // --- save the dataset type ---

             System.Xml.XmlAttribute oTypeAttr = oDatasetElement.OwnerDocument.CreateAttribute("type");
             oTypeAttr.Value = m_oDAPLayer.DAPType;
             oDatasetElement.Attributes.Append(oTypeAttr);

             // --- set the server url ---

             System.Xml.XmlAttribute oAttr = oDatasetElement.OwnerDocument.CreateAttribute("title");
             oAttr.Value = m_oDAPLayer.Title;
             oDatasetElement.Attributes.Append(oAttr);

             oAttr = oDatasetElement.OwnerDocument.CreateAttribute("url");
             oAttr.Value = m_oDAPLayer.ServerURL;
             oDatasetElement.Attributes.Append(oAttr);

             oAttr = oDatasetElement.OwnerDocument.CreateAttribute("id");
             oAttr.Value = m_oDAPLayer.DatasetName;
             oDatasetElement.Attributes.Append(oAttr);

             // --- get the dataset coordinate system ---

             string strSrcCoordinateSystem = m_strLayerProjection;
             if (string.IsNullOrEmpty(strSrcCoordinateSystem))
            return ExtractSaveResult.Ignore;

             // --- get the dataset extents ---

             if (!MainForm.MontajInterface.GetExtents(m_oDAPLayer.ServerURL, m_oDAPLayer.DatasetName, out dMaxX, out dMinX, out dMaxY, out dMinY))
                return ExtractSaveResult.Ignore;

             // --- Sanity check on the data ---

             double dMapInWGS84_MinX = dMinX;
             double dMapInWGS84_MinY = dMinY;
             double dMapInWGS84_MaxX = dMaxX;
             double dMapInWGS84_MaxY = dMaxY;
             if (MainForm.MontajInterface.ProjectBoundingRectangle(strSrcCoordinateSystem, ref dMapInWGS84_MinX, ref dMapInWGS84_MinY, ref dMapInWGS84_MaxX, ref dMapInWGS84_MaxY, Resolution.WGS_84))
             {
            if (Math.Abs(m_oDAPLayer.m_hDataSet.Boundary.MinX - dMapInWGS84_MinX) > 0.01 ||
                    Math.Abs(m_oDAPLayer.m_hDataSet.Boundary.MinY - dMapInWGS84_MinY) > 0.01 ||
                    Math.Abs(m_oDAPLayer.m_hDataSet.Boundary.MaxX - dMapInWGS84_MaxX) > 0.01 ||
                    Math.Abs(m_oDAPLayer.m_hDataSet.Boundary.MaxY - dMapInWGS84_MaxY) > 0.01)
            {
                    Geosoft.Dap.Common.BoundingBox oReprojectedBox = new Geosoft.Dap.Common.BoundingBox(dMapInWGS84_MaxX, dMapInWGS84_MaxY, dMapInWGS84_MinX, dMapInWGS84_MinY);

                    Program.ShowMessageBox(
                        "A problem was encountered while preparing to download dataset " + m_oDAPLayer.Title + "\n" +
                        "The WGS 84 bounding box advertised by the server:\n" +
                        m_oDAPLayer.m_hDataSet.Boundary.ToString(2) + "\n" +
                        "does not match up with the reprojected extents of the layer's metadata:\n" +
                        oReprojectedBox.ToString(2) + "\n" +
                        "The dataset will not be downloaded.  Contact the server administrator.",
                        "Extract Datasets",
                        MessageBoxButtons.OK,
                        MessageBoxDefaultButton.Button1,
                        MessageBoxIcon.Error);
                    return ExtractSaveResult.Ignore;
            }
             }

             // End sanity check.  Insanity may resume.

             // --- calculate the extract area ---

             dProjMaxX = dMaxX;
             dProjMaxY = dMaxY;
             dProjMinX = dMinX;
             dProjMinY = dMinY;
             strProjCoordinateSystem = strSrcCoordinateSystem;

             if (MainForm.MontajInterface.ProjectBoundingRectangle(strSrcCoordinateSystem, ref dProjMinX, ref dProjMinY, ref dProjMaxX, ref dProjMaxY, Resolution.WGS_84))
             {
            dProjMaxX = Math.Min(m_oViewedAoi.East, dProjMaxX);
            dProjMinX = Math.Max(m_oViewedAoi.West, dProjMinX);
            dProjMaxY = Math.Min(m_oViewedAoi.North, dProjMaxY);
            dProjMinY = Math.Max(m_oViewedAoi.South, dProjMinY);

            if (eCS == DownloadSettings.DownloadCoordinateSystem.OriginalMap)
            {
               if (MainForm.MontajInterface.ProjectBoundingRectangle(Resolution.WGS_84, ref dProjMinX, ref dProjMinY, ref dProjMaxX, ref dProjMaxY, m_strMapProjection))
                  strProjCoordinateSystem = m_strMapProjection;
               else
                  bInvalidReprojection = true;
            }
            else
            {
               if (MainForm.MontajInterface.ProjectBoundingRectangle(Resolution.WGS_84, ref dProjMinX, ref dProjMinY, ref dProjMaxX, ref dProjMaxY, strSrcCoordinateSystem))
                  strProjCoordinateSystem = strSrcCoordinateSystem;
               else
                  bInvalidReprojection = true;
            }
             }
             else
             {
            bInvalidReprojection = true;
             }

             // --- check to see if we require a new ---

             if (!bInvalidReprojection && MainForm.MontajInterface.HostHasOpenMap())
             {
            bNewMap = !IntersectMap(ref dProjMinX, ref dProjMinY, ref dProjMaxX, ref dProjMaxY, strProjCoordinateSystem);
             }

             // --- check to see if this is a valid bounding box ---

             if (bInvalidReprojection || !(dProjMaxX > dProjMinX && dProjMaxY > dProjMinY))
             {
            // --- invalid box ---

            dProjMaxX = dMaxX;
            dProjMaxY = dMaxY;
            dProjMinX = dMinX;
            dProjMinY = dMinY;
            strProjCoordinateSystem = strSrcCoordinateSystem;
            bNewMap = true;
             }

             // --- save the extents and coordinate system ---

             oAttr = oDatasetElement.OwnerDocument.CreateAttribute("new_map");
             oAttr.Value = (bNewMap && OpenInMap).ToString();
             oDatasetElement.Attributes.Append(oAttr);

             oAttr = oDatasetElement.OwnerDocument.CreateAttribute("minx");
            oAttr.Value = dProjMinX.ToString("R", CultureInfo.InvariantCulture);
             oDatasetElement.Attributes.Append(oAttr);

             oAttr = oDatasetElement.OwnerDocument.CreateAttribute("miny");
            oAttr.Value = dProjMinY.ToString("R", CultureInfo.InvariantCulture);
             oDatasetElement.Attributes.Append(oAttr);

             oAttr = oDatasetElement.OwnerDocument.CreateAttribute("maxx");
            oAttr.Value = dProjMaxX.ToString("R", CultureInfo.InvariantCulture);
             oDatasetElement.Attributes.Append(oAttr);

             oAttr = oDatasetElement.OwnerDocument.CreateAttribute("maxy");
            oAttr.Value = dProjMaxY.ToString("R", CultureInfo.InvariantCulture);
             oDatasetElement.Attributes.Append(oAttr);

             oAttr = oDatasetElement.OwnerDocument.CreateAttribute("coordinate_system");
             oAttr.Value = strProjCoordinateSystem;
             oDatasetElement.Attributes.Append(oAttr);

            if (m_oDAPLayer != null)
            {
                oAttr = oDatasetElement.OwnerDocument.CreateAttribute("meta_stylesheet_name");
                oAttr.Value = m_oDAPLayer.StyleSheetID;
                oDatasetElement.Attributes.Append(oAttr);
            }

            #if DEBUG
             double dMapBoundMinX_WGS84 = dMinX;
             double dMapBoundMaxX_WGS84 = dMaxX;
             double dMapBoundMinY_WGS84 = dMinY;
             double dMapBoundMaxY_WGS84 = dMaxY;

             double dClipBoundMinX_WGS84 = dProjMinX;
             double dClipBoundMaxX_WGS84 = dProjMaxX;
             double dClipBoundMinY_WGS84 = dProjMinY;
             double dClipBoundMaxY_WGS84 = dProjMaxY;

             MainForm.MontajInterface.ProjectBoundingRectangle(strSrcCoordinateSystem, ref dMapBoundMinX_WGS84, ref dMapBoundMinY_WGS84, ref dMapBoundMaxX_WGS84, ref dMapBoundMaxY_WGS84, Resolution.WGS_84);
             MainForm.MontajInterface.ProjectBoundingRectangle(strProjCoordinateSystem, ref dClipBoundMinX_WGS84, ref dClipBoundMinY_WGS84, ref dClipBoundMaxX_WGS84, ref dClipBoundMaxY_WGS84, Resolution.WGS_84);

             oDatasetElement.SetAttribute("map_wgs84_west", dMapBoundMinX_WGS84.ToString("f5", CultureInfo.InvariantCulture));
            oDatasetElement.SetAttribute("map_wgs84_south", dMapBoundMinY_WGS84.ToString("f5", CultureInfo.InvariantCulture));
            oDatasetElement.SetAttribute("map_wgs84_east", dMapBoundMaxX_WGS84.ToString("f5", CultureInfo.InvariantCulture));
            oDatasetElement.SetAttribute("map_wgs84_north", dMapBoundMaxY_WGS84.ToString("f5", CultureInfo.InvariantCulture));

            oDatasetElement.SetAttribute("clip_wgs84_west", dClipBoundMinX_WGS84.ToString("f5", CultureInfo.InvariantCulture));
            oDatasetElement.SetAttribute("clip_wgs84_south", dClipBoundMinY_WGS84.ToString("f5", CultureInfo.InvariantCulture));
            oDatasetElement.SetAttribute("clip_wgs84_east", dClipBoundMaxX_WGS84.ToString("f5", CultureInfo.InvariantCulture));
            oDatasetElement.SetAttribute("clip_wgs84_north", dClipBoundMaxY_WGS84.ToString("f5", CultureInfo.InvariantCulture));
            #endif

            return ExtractSaveResult.Extract;
        }
Exemple #14
0
        /// <summary>
        /// Save the current contents of these controls to an xml file
        /// </summary>
        /// <param name="oDatasetElement"></param>
        /// <param name="strDestFolder"></param>
        /// <param name="bDefaultResolution"></param>
        /// <returns></returns>
        internal virtual ExtractSaveResult Save(System.Xml.XmlElement oDatasetElement, string strDestFolder, DownloadSettings.DownloadCoordinateSystem eCS)
        {
            double dMaxX, dMinX, dMaxY, dMinY;
            double dProjMinX, dProjMinY, dProjMaxX, dProjMaxY;
            string strProjCoordinateSystem;
            bool   bNewMap = true;
            bool   bInvalidReprojection = false;


            // --- save the dataset type ---

            System.Xml.XmlAttribute oTypeAttr = oDatasetElement.OwnerDocument.CreateAttribute("type");
            oTypeAttr.Value = m_oDAPLayer.DAPType;
            oDatasetElement.Attributes.Append(oTypeAttr);


            // --- set the server url ---

            System.Xml.XmlAttribute oAttr = oDatasetElement.OwnerDocument.CreateAttribute("title");
            oAttr.Value = m_oDAPLayer.Title;
            oDatasetElement.Attributes.Append(oAttr);

            oAttr       = oDatasetElement.OwnerDocument.CreateAttribute("url");
            oAttr.Value = m_oDAPLayer.ServerURL;
            oDatasetElement.Attributes.Append(oAttr);

            oAttr       = oDatasetElement.OwnerDocument.CreateAttribute("id");
            oAttr.Value = m_oDAPLayer.DatasetName;
            oDatasetElement.Attributes.Append(oAttr);


            // --- get the dataset coordinate system ---

            string strSrcCoordinateSystem = m_strLayerProjection;

            if (string.IsNullOrEmpty(strSrcCoordinateSystem))
            {
                return(ExtractSaveResult.Ignore);
            }

            // --- get the dataset extents ---

            if (!MainForm.MontajInterface.GetExtents(m_oDAPLayer.ServerURL, m_oDAPLayer.DatasetName, out dMaxX, out dMinX, out dMaxY, out dMinY))
            {
                return(ExtractSaveResult.Ignore);
            }

            // --- Sanity check on the data ---

            double dMapInWGS84_MinX = dMinX;
            double dMapInWGS84_MinY = dMinY;
            double dMapInWGS84_MaxX = dMaxX;
            double dMapInWGS84_MaxY = dMaxY;

            if (MainForm.MontajInterface.ProjectBoundingRectangle(strSrcCoordinateSystem, ref dMapInWGS84_MinX, ref dMapInWGS84_MinY, ref dMapInWGS84_MaxX, ref dMapInWGS84_MaxY, Resolution.WGS_84))
            {
                if (Math.Abs(m_oDAPLayer.m_hDataSet.Boundary.MinX - dMapInWGS84_MinX) > 0.01 ||
                    Math.Abs(m_oDAPLayer.m_hDataSet.Boundary.MinY - dMapInWGS84_MinY) > 0.01 ||
                    Math.Abs(m_oDAPLayer.m_hDataSet.Boundary.MaxX - dMapInWGS84_MaxX) > 0.01 ||
                    Math.Abs(m_oDAPLayer.m_hDataSet.Boundary.MaxY - dMapInWGS84_MaxY) > 0.01)
                {
                    Geosoft.Dap.Common.BoundingBox oReprojectedBox = new Geosoft.Dap.Common.BoundingBox(dMapInWGS84_MaxX, dMapInWGS84_MaxY, dMapInWGS84_MinX, dMapInWGS84_MinY);

                    Program.ShowMessageBox(
                        "A problem was encountered while preparing to download dataset " + m_oDAPLayer.Title + "\n" +
                        "The WGS 84 bounding box advertised by the server:\n" +
                        m_oDAPLayer.m_hDataSet.Boundary.ToString(2) + "\n" +
                        "does not match up with the reprojected extents of the layer's metadata:\n" +
                        oReprojectedBox.ToString(2) + "\n" +
                        "The dataset will not be downloaded.  Contact the server administrator.",
                        "Extract Datasets",
                        MessageBoxButtons.OK,
                        MessageBoxDefaultButton.Button1,
                        MessageBoxIcon.Error);
                    return(ExtractSaveResult.Ignore);
                }
            }

            // End sanity check.  Insanity may resume.


            // --- calculate the extract area ---

            dProjMaxX = dMaxX;
            dProjMaxY = dMaxY;
            dProjMinX = dMinX;
            dProjMinY = dMinY;
            strProjCoordinateSystem = strSrcCoordinateSystem;

            if (MainForm.MontajInterface.ProjectBoundingRectangle(strSrcCoordinateSystem, ref dProjMinX, ref dProjMinY, ref dProjMaxX, ref dProjMaxY, Resolution.WGS_84))
            {
                dProjMaxX = Math.Min(m_oViewedAoi.East, dProjMaxX);
                dProjMinX = Math.Max(m_oViewedAoi.West, dProjMinX);
                dProjMaxY = Math.Min(m_oViewedAoi.North, dProjMaxY);
                dProjMinY = Math.Max(m_oViewedAoi.South, dProjMinY);

                if (eCS == DownloadSettings.DownloadCoordinateSystem.OriginalMap)
                {
                    if (MainForm.MontajInterface.ProjectBoundingRectangle(Resolution.WGS_84, ref dProjMinX, ref dProjMinY, ref dProjMaxX, ref dProjMaxY, m_strMapProjection))
                    {
                        strProjCoordinateSystem = m_strMapProjection;
                    }
                    else
                    {
                        bInvalidReprojection = true;
                    }
                }
                else
                {
                    if (MainForm.MontajInterface.ProjectBoundingRectangle(Resolution.WGS_84, ref dProjMinX, ref dProjMinY, ref dProjMaxX, ref dProjMaxY, strSrcCoordinateSystem))
                    {
                        strProjCoordinateSystem = strSrcCoordinateSystem;
                    }
                    else
                    {
                        bInvalidReprojection = true;
                    }
                }
            }
            else
            {
                bInvalidReprojection = true;
            }

            // --- check to see if we require a new ---

            if (!bInvalidReprojection && MainForm.MontajInterface.HostHasOpenMap())
            {
                bNewMap = !IntersectMap(ref dProjMinX, ref dProjMinY, ref dProjMaxX, ref dProjMaxY, strProjCoordinateSystem);
            }


            // --- check to see if this is a valid bounding box ---

            if (bInvalidReprojection || !(dProjMaxX > dProjMinX && dProjMaxY > dProjMinY))
            {
                // --- invalid box ---

                dProjMaxX = dMaxX;
                dProjMaxY = dMaxY;
                dProjMinX = dMinX;
                dProjMinY = dMinY;
                strProjCoordinateSystem = strSrcCoordinateSystem;
                bNewMap = true;
            }

            // --- save the extents and coordinate system ---

            oAttr       = oDatasetElement.OwnerDocument.CreateAttribute("new_map");
            oAttr.Value = (bNewMap && OpenInMap).ToString();
            oDatasetElement.Attributes.Append(oAttr);

            oAttr       = oDatasetElement.OwnerDocument.CreateAttribute("minx");
            oAttr.Value = dProjMinX.ToString("R", CultureInfo.InvariantCulture);
            oDatasetElement.Attributes.Append(oAttr);

            oAttr       = oDatasetElement.OwnerDocument.CreateAttribute("miny");
            oAttr.Value = dProjMinY.ToString("R", CultureInfo.InvariantCulture);
            oDatasetElement.Attributes.Append(oAttr);

            oAttr       = oDatasetElement.OwnerDocument.CreateAttribute("maxx");
            oAttr.Value = dProjMaxX.ToString("R", CultureInfo.InvariantCulture);
            oDatasetElement.Attributes.Append(oAttr);

            oAttr       = oDatasetElement.OwnerDocument.CreateAttribute("maxy");
            oAttr.Value = dProjMaxY.ToString("R", CultureInfo.InvariantCulture);
            oDatasetElement.Attributes.Append(oAttr);

            oAttr       = oDatasetElement.OwnerDocument.CreateAttribute("coordinate_system");
            oAttr.Value = strProjCoordinateSystem;
            oDatasetElement.Attributes.Append(oAttr);

            if (m_oDAPLayer != null)
            {
                oAttr       = oDatasetElement.OwnerDocument.CreateAttribute("meta_stylesheet_name");
                oAttr.Value = m_oDAPLayer.StyleSheetID;
                oDatasetElement.Attributes.Append(oAttr);
            }

#if DEBUG
            double dMapBoundMinX_WGS84 = dMinX;
            double dMapBoundMaxX_WGS84 = dMaxX;
            double dMapBoundMinY_WGS84 = dMinY;
            double dMapBoundMaxY_WGS84 = dMaxY;

            double dClipBoundMinX_WGS84 = dProjMinX;
            double dClipBoundMaxX_WGS84 = dProjMaxX;
            double dClipBoundMinY_WGS84 = dProjMinY;
            double dClipBoundMaxY_WGS84 = dProjMaxY;

            MainForm.MontajInterface.ProjectBoundingRectangle(strSrcCoordinateSystem, ref dMapBoundMinX_WGS84, ref dMapBoundMinY_WGS84, ref dMapBoundMaxX_WGS84, ref dMapBoundMaxY_WGS84, Resolution.WGS_84);
            MainForm.MontajInterface.ProjectBoundingRectangle(strProjCoordinateSystem, ref dClipBoundMinX_WGS84, ref dClipBoundMinY_WGS84, ref dClipBoundMaxX_WGS84, ref dClipBoundMaxY_WGS84, Resolution.WGS_84);

            oDatasetElement.SetAttribute("map_wgs84_west", dMapBoundMinX_WGS84.ToString("f5", CultureInfo.InvariantCulture));
            oDatasetElement.SetAttribute("map_wgs84_south", dMapBoundMinY_WGS84.ToString("f5", CultureInfo.InvariantCulture));
            oDatasetElement.SetAttribute("map_wgs84_east", dMapBoundMaxX_WGS84.ToString("f5", CultureInfo.InvariantCulture));
            oDatasetElement.SetAttribute("map_wgs84_north", dMapBoundMaxY_WGS84.ToString("f5", CultureInfo.InvariantCulture));

            oDatasetElement.SetAttribute("clip_wgs84_west", dClipBoundMinX_WGS84.ToString("f5", CultureInfo.InvariantCulture));
            oDatasetElement.SetAttribute("clip_wgs84_south", dClipBoundMinY_WGS84.ToString("f5", CultureInfo.InvariantCulture));
            oDatasetElement.SetAttribute("clip_wgs84_east", dClipBoundMaxX_WGS84.ToString("f5", CultureInfo.InvariantCulture));
            oDatasetElement.SetAttribute("clip_wgs84_north", dClipBoundMaxY_WGS84.ToString("f5", CultureInfo.InvariantCulture));
#endif

            return(ExtractSaveResult.Extract);
        }
Exemple #15
0
        /// <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);
        }
Exemple #16
0
 internal ArcIMSImageDownload(ArcIMSImageStore oImageStore, Geosoft.Dap.Common.BoundingBox oEnvelope, int iIndexNumber, CultureInfo oInfo, double dArtificialZoom)
     : base(oImageStore.ServerUri, iIndexNumber)
 {
     m_oCultureInfo = oInfo;
     m_oImageStore = oImageStore;
      m_oEnvelope = oEnvelope;
     m_dArtificialZoom = dArtificialZoom;
 }
Exemple #17
0
        public void SetSearchParameters(String strKeyword, Geosoft.Dap.Common.BoundingBox oBoundingBox)
        {
            m_lSearchIndex++;
            m_oSearchBoundingBox = oBoundingBox;
            m_strSearchString = strKeyword;

            if (String.Empty.Equals(strKeyword) && oBoundingBox == null)
            {
                SetNoSearch();
            }
            else
            {
                DappleSearchWebDownload oDownload = new DappleSearchWebDownload(m_oSearchBoundingBox, m_strSearchString, 0, m_lSearchIndex);
                SetSearching();
                oDownload.StartDownload(new DownloadCompleteHandler(SetSearchParametersComplete));
            }
        }