Пример #1
0
 internal double ResolutionValueSpecific(DownloadSettings.DownloadCoordinateSystem eCS)
 {
     if (eCS == DownloadSettings.DownloadCoordinateSystem.OriginalMap)
     {
         return(ResolutionValue);
     }
     else
     {
         return((ResolutionValue * m_dResolutionConversionFactor) / m_dCellConversionFactor);
     }
 }
Пример #2
0
        /// <summary>
        /// Write out settings for the Grid dataset
        /// </summary>
        /// <param name="oDatasetElement"></param>
        /// <param name="strDestFolder"></param>
        /// <param name="bDefaultResolution"></param>
        /// <returns></returns>
        internal override ExtractSaveResult Save(System.Xml.XmlElement oDatasetElement, string strDestFolder, DownloadSettings.DownloadCoordinateSystem eCS)
        {
            // --- cannot reproject section data ---
            ExtractSaveResult result = base.Save(oDatasetElement, strDestFolder, DownloadSettings.DownloadCoordinateSystem.Native);

            System.Xml.XmlAttribute oPathAttr = oDatasetElement.OwnerDocument.CreateAttribute("file");
            oPathAttr.Value = System.IO.Path.Combine(strDestFolder, System.IO.Path.ChangeExtension(Utility.FileSystem.SanitizeFilename(tbFilename.Text), GRD_EXT));
            oDatasetElement.Attributes.Append(oPathAttr);

            System.Xml.XmlAttribute oResolutionAttr = oDatasetElement.OwnerDocument.CreateAttribute("resolution");
            oResolutionAttr.Value = oResolution.ResolutionValueSpecific(eCS).ToString(CultureInfo.InvariantCulture);
            oDatasetElement.Attributes.Append(oResolutionAttr);

            System.Xml.XmlElement oDisplayElement             = oDatasetElement.OwnerDocument.CreateElement("display_options");
            Options.SectionGrid.DisplayOptions eDisplayOption = (Options.SectionGrid.DisplayOptions)cbDisplayOptions.SelectedIndex;
            oDisplayElement.InnerText = eDisplayOption.ToString();
            oDatasetElement.AppendChild(oDisplayElement);

            return(result);
        }
Пример #3
0
        /// <summary>
        /// Write out settings for the document
        /// </summary>
        /// <param name="oDatasetElement"></param>
        /// <param name="strDestFolder"></param>
        /// <param name="bDefaultResolution"></param>
        /// <returns></returns>
        internal override ExtractSaveResult Save(System.Xml.XmlElement oDatasetElement, string strDestFolder, DownloadSettings.DownloadCoordinateSystem eCS)
        {
            ExtractSaveResult result = base.Save(oDatasetElement, strDestFolder, eCS);

            System.Xml.XmlAttribute oPathAttr = oDatasetElement.OwnerDocument.CreateAttribute("file");
            oPathAttr.Value = System.IO.Path.Combine(strDestFolder, Utility.FileSystem.SanitizeFilename(tbFilename.Text));

            oDatasetElement.Attributes.Append(oPathAttr);

            System.Xml.XmlElement          oDownloadElement = oDatasetElement.OwnerDocument.CreateElement("download_options");
            Options.ArcGIS.DownloadOptions eOption          = (Options.ArcGIS.DownloadOptions)cbDownload.SelectedIndex;
            oDownloadElement.InnerText = eOption.ToString();
            oDatasetElement.AppendChild(oDownloadElement);

            return(result);
        }
Пример #4
0
        /// <summary>
        /// Write out settings for the database
        /// </summary>
        /// <param name="oDatasetElement"></param>
        /// <param name="strDestFolder"></param>
        /// <param name="bDefaultResolution"></param>
        /// <returns></returns>
        internal override ExtractSaveResult Save(System.Xml.XmlElement oDatasetElement, string strDestFolder, DownloadSettings.DownloadCoordinateSystem eCS)
        {
            ExtractSaveResult result = base.Save(oDatasetElement, strDestFolder, eCS);

            System.Xml.XmlAttribute oPathAttr = oDatasetElement.OwnerDocument.CreateAttribute("file");
            oPathAttr.Value = System.IO.Path.Combine(strDestFolder, System.IO.Path.ChangeExtension(Utility.FileSystem.SanitizeFilename(tbFilename.Text), DATABASE_EXT));

            oDatasetElement.Attributes.Append(oPathAttr);

            return(result);
        }
Пример #5
0
        /// <summary>
        /// Write out settings for the HyperMAP dataset
        /// </summary>
        /// <param name="oDatasetElement"></param>
        /// <param name="strDestFolder"></param>
        /// <param name="bDefaultResolution"></param>
        /// <returns></returns>
        internal override ExtractSaveResult Save(System.Xml.XmlElement oDatasetElement, string strDestFolder, DownloadSettings.DownloadCoordinateSystem eCS)
        {
            ExtractSaveResult result = base.Save(oDatasetElement, strDestFolder, eCS);

            System.Xml.XmlAttribute oPathAttr = oDatasetElement.OwnerDocument.CreateAttribute("file");
            oPathAttr.Value = System.IO.Path.Combine(strDestFolder, System.IO.Path.ChangeExtension(Utility.FileSystem.SanitizeFilename(tbFilename.Text), MAP_EXT));

            System.Xml.XmlAttribute oResolutionAttr = oDatasetElement.OwnerDocument.CreateAttribute("resolution");
            oResolutionAttr.Value = oResolution.ResolutionValueSpecific(eCS).ToString(CultureInfo.InvariantCulture);

            System.Xml.XmlAttribute oGroupElement = oDatasetElement.OwnerDocument.CreateAttribute("group");
            oGroupElement.Value = tbGroupName.Text;

            oDatasetElement.Attributes.Append(oPathAttr);
            oDatasetElement.Attributes.Append(oResolutionAttr);
            oDatasetElement.Attributes.Append(oGroupElement);

            return(result);
        }
Пример #6
0
        internal override DownloadOptions.ExtractSaveResult Save(XmlElement oDatasetElement, string strDestFolder, DownloadSettings.DownloadCoordinateSystem eCS)
        {
            bool   blFileExists;
            String strFilename = String.Empty;


            bool openANewMap;

            if (MainForm.MontajInterface.HostHasOpenMap())
            {
                string strSrcCoordinateSystem = m_strLayerProjection;
                if (string.IsNullOrEmpty(strSrcCoordinateSystem))
                {
                    return(ExtractSaveResult.Ignore);
                }
                double dMinX, dMinY, dMaxX, dMaxY;
                if (!MainForm.MontajInterface.GetExtents(m_oDAPLayer.ServerURL, m_oDAPLayer.DatasetName, out dMaxX, out dMinX, out dMaxY, out dMinY))
                {
                    return(ExtractSaveResult.Ignore);
                }

                openANewMap = !IntersectMap(ref dMinX, ref dMinY, ref dMaxX, ref dMaxY, strSrcCoordinateSystem);
            }
            else
            {
                openANewMap = true;
            }


            try
            {
                strFilename = m_oDAPLayer.LocalFilename;
                String strStrippedFilename = StripQualifiers(strFilename);

                blFileExists = File.Exists(strStrippedFilename);
            }
            catch (Exception)
            {
                blFileExists = false;
            }

            if (blFileExists)
            {
                oDatasetElement.SetAttribute("filename", strFilename);
                oDatasetElement.SetAttribute("type", m_oDAPLayer.DAPType);
                oDatasetElement.SetAttribute("id", m_oDAPLayer.DatasetName);
                oDatasetElement.SetAttribute("new_map", openANewMap.ToString());

                return(ExtractSaveResult.Extract);
            }
            else
            {
                if (MessageBox.Show("The local file for dataset " + m_oDAPLayer.Title + " cannot be found. Ignore file and extract other datasets?", "Opening Local Dataset", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    return(ExtractSaveResult.Ignore);
                }
                else
                {
                    return(ExtractSaveResult.Cancel);
                }
            }
        }
Пример #7
0
        /// <summary>
        /// Write out settings for the GIS dataset
        /// </summary>
        /// <param name="oDatasetElement"></param>
        /// <param name="strDestFolder"></param>
        /// <param name="bDefaultResolution"></param>
        /// <returns></returns>
        internal override ExtractSaveResult Save(System.Xml.XmlElement oDatasetElement, string strDestFolder, DownloadSettings.DownloadCoordinateSystem eCS)
        {
            ExtractSaveResult result = base.Save(oDatasetElement, strDestFolder, eCS);

            System.Xml.XmlAttribute oPathAttr = oDatasetElement.OwnerDocument.CreateAttribute("file");
            if (cbOptions.SelectedIndex == SAVE_AS_MAP)
            {
                oPathAttr.Value = System.IO.Path.Combine(strDestFolder, System.IO.Path.ChangeExtension(Utility.FileSystem.SanitizeFilename(tbFilename.Text), MAP_EXT));
            }
            else if (cbOptions.SelectedIndex == SAVE_AS_SHP_IMPORT || cbOptions.SelectedIndex == SAVE_AS_SHP_NOIMPORT)
            {
                // Shape file uses a namespace name, not a file name (produces oodles of files)
                oPathAttr.Value = System.IO.Path.Combine(strDestFolder, System.IO.Path.GetFileNameWithoutExtension(Utility.FileSystem.SanitizeFilename(tbFilename.Text)));
            }
            else if (cbOptions.SelectedIndex == SAVE_AS_TAB_IMPORT || cbOptions.SelectedIndex == SAVE_AS_TAB_NOIMPORT)
            {
                oPathAttr.Value = System.IO.Path.Combine(strDestFolder, System.IO.Path.ChangeExtension(Utility.FileSystem.SanitizeFilename(tbFilename.Text), TAB_EXT));
            }
            oDatasetElement.Attributes.Append(oPathAttr);

            System.Xml.XmlAttribute oGroupAttribute = oDatasetElement.OwnerDocument.CreateAttribute("group");
            oGroupAttribute.Value = Utility.FileSystem.SanitizeFilename(tbGroupName.Text);
            oDatasetElement.Attributes.Append(oGroupAttribute);

            System.Xml.XmlElement         oDownloadElement = oDatasetElement.OwnerDocument.CreateElement("download_options");
            Options.GIS.OMDownloadOptions eOption          = (Options.GIS.OMDownloadOptions)cbOptions.SelectedIndex;
            oDownloadElement.InnerXml = eOption.ToString();
            oDatasetElement.AppendChild(oDownloadElement);

            return(result);
        }
Пример #8
0
 /// <summary>
 /// Write out settings for the acquire dataset
 /// </summary>
 /// <param name="oDatasetElement"></param>
 /// <param name="strDestFolder"></param>
 /// <param name="bDefaultResolution"></param>
 /// <returns></returns>
 internal override ExtractSaveResult Save(System.Xml.XmlElement oDatasetElement, string strDestFolder, DownloadSettings.DownloadCoordinateSystem eCS)
 {
     return(base.Save(oDatasetElement, strDestFolder, eCS));
 }
Пример #9
0
        /// <summary>
        /// Write out settings for the picture dataset
        /// </summary>
        /// <param name="oDatasetElement"></param>
        /// <param name="strDestFolder"></param>
        /// <param name="bDefaultResolution"></param>
        /// <returns></returns>
        internal override ExtractSaveResult Save(System.Xml.XmlElement oDatasetElement, string strDestFolder, DownloadSettings.DownloadCoordinateSystem eCS)
        {
            System.Xml.XmlAttribute oAttr = oDatasetElement.OwnerDocument.CreateAttribute("type");
            oAttr.Value = "geotiff";
            oDatasetElement.Attributes.Append(oAttr);

            oAttr       = oDatasetElement.OwnerDocument.CreateAttribute("title");
            oAttr.Value = m_oNonDapBuilder.Title;
            oDatasetElement.Attributes.Append(oAttr);

            oAttr       = oDatasetElement.OwnerDocument.CreateAttribute("file");
            oAttr.Value = System.IO.Path.Combine(strDestFolder, System.IO.Path.ChangeExtension(Utility.FileSystem.SanitizeFilename(tbFilename.Text), TIF_EXT));
            oDatasetElement.Attributes.Append(oAttr);

            // --- Delete all the files that OM generates, so we don't get invalid projections ---
            try
            {
                if (System.IO.File.Exists(oAttr.Value))
                {
                    System.IO.File.Delete(oAttr.Value);
                }
                if (System.IO.File.Exists(System.IO.Path.ChangeExtension(oAttr.Value, ".ipj")))
                {
                    System.IO.File.Delete(System.IO.Path.ChangeExtension(oAttr.Value, ".ipj"));
                }
                if (System.IO.File.Exists(System.IO.Path.ChangeExtension(oAttr.Value, ".gi")))
                {
                    System.IO.File.Delete(System.IO.Path.ChangeExtension(oAttr.Value, ".gi"));
                }
                if (System.IO.File.Exists(System.IO.Path.ChangeExtension(oAttr.Value, ".tif.xml")))
                {
                    System.IO.File.Delete(System.IO.Path.ChangeExtension(oAttr.Value, ".tif.xml"));
                }
            }
            catch (System.IO.IOException)
            {
                MessageBox.Show("Could not save file " + oAttr.Value + ", please choose a different filename.", "Extraction error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(ExtractSaveResult.Cancel);
            }

            if (m_oNonDapBuilder is GeorefImageLayerBuilder)
            {
                System.IO.File.Copy(((GeorefImageLayerBuilder)m_oNonDapBuilder).FileName, oAttr.Value, true);
            }
            else
            {
                if (!m_oNonDapBuilder.exportToGeoTiff(oAttr.Value))
                {
                    MessageBox.Show(this, "Could not download " + m_oNonDapBuilder.Title + ", data layer's extents do not intersect the viewed area.", "Extraction Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(ExtractSaveResult.Ignore);
                }
            }

            System.Xml.XmlElement          oDisplayElement = oDatasetElement.OwnerDocument.CreateElement("display_options");
            Options.Picture.DisplayOptions eDisplayOption  = (Options.Picture.DisplayOptions)cbDisplayOptions.SelectedIndex;
            oDisplayElement.InnerText = eDisplayOption.ToString();
            oDatasetElement.AppendChild(oDisplayElement);

            WorldWind.GeographicBoundingBox oViewBox = WorldWind.GeographicBoundingBox.FromQuad(MainForm.WorldWindowSingleton.CurrentAreaOfInterest);
            String szViewCRS = Dapple.Extract.Resolution.WGS_84;

            WorldWind.GeographicBoundingBox oMapBox = MainForm.MapAoi;
            String szMapCRS = MainForm.MapAoiCoordinateSystem;

            bool blNewMap;

            if (oMapBox == null)
            {
                blNewMap = true;
            }
            else
            {
                if (MainForm.MontajInterface.ProjectBoundingRectangle(szMapCRS, ref oMapBox.West, ref oMapBox.South, ref oMapBox.East, ref oMapBox.North, szViewCRS))
                {
                    blNewMap = (!oViewBox.Intersects(oMapBox));
                }
                else
                {
                    blNewMap = true;
                }
            }

            oAttr       = oDatasetElement.OwnerDocument.CreateAttribute("new_map");
            oAttr.Value = blNewMap.ToString();
            oDatasetElement.Attributes.Append(oAttr);


            GeographicBoundingBox oGeoTiffBox = oViewBox.Clone() as GeographicBoundingBox;

            if (m_oNonDapBuilder is GeorefImageLayerBuilder)
            {
                oGeoTiffBox = GeorefImageLayerBuilder.GetExtentsFromGeotif(((GeorefImageLayerBuilder)m_oNonDapBuilder).FileName);
            }

            oAttr       = oDatasetElement.OwnerDocument.CreateAttribute("minx");
            oAttr.Value = oGeoTiffBox.West.ToString(CultureInfo.InvariantCulture);
            oDatasetElement.Attributes.Append(oAttr);

            oAttr       = oDatasetElement.OwnerDocument.CreateAttribute("miny");
            oAttr.Value = oGeoTiffBox.South.ToString(CultureInfo.InvariantCulture);
            oDatasetElement.Attributes.Append(oAttr);

            oAttr       = oDatasetElement.OwnerDocument.CreateAttribute("maxx");
            oAttr.Value = oGeoTiffBox.East.ToString(CultureInfo.InvariantCulture);
            oDatasetElement.Attributes.Append(oAttr);

            oAttr       = oDatasetElement.OwnerDocument.CreateAttribute("maxy");
            oAttr.Value = oGeoTiffBox.North.ToString(CultureInfo.InvariantCulture);
            oDatasetElement.Attributes.Append(oAttr);

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

            String szDownloadType = String.Empty;
            String szDownloadUrl  = String.Empty;
            String szLayerId      = String.Empty;

            m_oNonDapBuilder.GetOMMetadata(out szDownloadType, out szDownloadUrl, out szLayerId);

            oAttr       = oDatasetElement.OwnerDocument.CreateAttribute("download_type");
            oAttr.Value = szDownloadType;
            oDatasetElement.Attributes.Append(oAttr);

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

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

            return(ExtractSaveResult.Extract);
        }
Пример #10
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);
        }
Пример #11
0
        /// <summary>
        /// Write out settings for the HyperXYZ dataset
        /// </summary>
        /// <param name="oDatasetElement"></param>
        /// <param name="strDestFolder"></param>
        /// <param name="bDefaultResolution"></param>
        /// <returns></returns>
        internal override ExtractSaveResult Save(System.Xml.XmlElement oDatasetElement, string strDestFolder, DownloadSettings.DownloadCoordinateSystem eCS)
        {
            // --- Always download point data in its native projection when in ArcMap ---
            if (MainForm.Client == Options.Client.ClientType.ArcMAP)
            {
                eCS = DownloadSettings.DownloadCoordinateSystem.Native;
            }

            ExtractSaveResult result = base.Save(oDatasetElement, strDestFolder, eCS);

            System.Xml.XmlAttribute oPathAttr = oDatasetElement.OwnerDocument.CreateAttribute("file");
            oPathAttr.Value = System.IO.Path.Combine(strDestFolder, System.IO.Path.ChangeExtension(Utility.FileSystem.SanitizeFilename(tbFilename.Text), ExtensionForHXYZ));

            oDatasetElement.Attributes.Append(oPathAttr);

            return(result);
        }
Пример #12
0
        /// <summary>
        /// Write out settings for the Grid dataset
        /// </summary>
        /// <param name="oDatasetElement"></param>
        /// <param name="strDestFolder"></param>
        /// <param name="bDefaultResolution"></param>
        /// <returns></returns>
        internal override ExtractSaveResult Save(System.Xml.XmlElement oDatasetElement, string strDestFolder, DownloadSettings.DownloadCoordinateSystem eCS)
        {
            ExtractSaveResult result = base.Save(oDatasetElement, strDestFolder, eCS);

            int    iIndex      = cbDownloadOptions.SelectedIndex;
            string strFileName = Utility.FileSystem.SanitizeFilename(tbFilename.Text);

            if (!String.IsNullOrEmpty(Options.Grid.DownloadOptionExtension[iIndex]))
            {
                strFileName = System.IO.Path.ChangeExtension(strFileName, Options.Grid.DownloadOptionExtension[iIndex]);
            }
            else
            {
                if (String.IsNullOrEmpty(System.IO.Path.GetExtension(strFileName)))
                {
                    strFileName = System.IO.Path.ChangeExtension(strFileName, ".grd");
                }
            }
            strFileName = string.Format(CultureInfo.InvariantCulture, "{0}({1})", strFileName, Options.Grid.DownloadOptionQualifier[iIndex]);

            System.Xml.XmlAttribute oPathAttr = oDatasetElement.OwnerDocument.CreateAttribute("file");
            oPathAttr.Value = System.IO.Path.Combine(strDestFolder, strFileName);
            oDatasetElement.Attributes.Append(oPathAttr);

            System.Xml.XmlAttribute oResolutionAttr = oDatasetElement.OwnerDocument.CreateAttribute("resolution");
            oResolutionAttr.Value = oResolution.ResolutionValueSpecific(eCS).ToString(CultureInfo.InvariantCulture);
            oDatasetElement.Attributes.Append(oResolutionAttr);

            System.Xml.XmlElement       oDisplayElement = oDatasetElement.OwnerDocument.CreateElement("display_options");
            Options.Grid.DisplayOptions eDisplayOption  = (Options.Grid.DisplayOptions)cbDisplayOptions.SelectedIndex;
            oDisplayElement.InnerText = eDisplayOption.ToString();
            oDatasetElement.AppendChild(oDisplayElement);

            return(result);
        }