示例#1
0
        public override bool Equals(object obj)
        {
            if (!(obj is GeorefImageLayerBuilder))
            {
                return(false);
            }
            GeorefImageLayerBuilder castObj = obj as GeorefImageLayerBuilder;

            // -- Equal if they're the same local file --
            return(this.m_strFileName.Equals(castObj.m_strFileName));
        }
示例#2
0
        internal override RenderableObject GetLayer()
        {
            if (m_blnIsChanged)
            {
                try
                {
                    GeographicBoundingBox extents = GeorefImageLayerBuilder.GetExtentsFromGeotif(m_strFileName);
                    if (extents != null)
                    {
                        // Convert Geotif right here to save lockup in update thread due to slow GDI+ to DirectX texture stream
                        if (!File.Exists(m_strCacheFileName) || File.GetLastWriteTime(m_strCacheFileName) < File.GetLastWriteTime(m_strFileName))
                        {
                            using (Image img = Image.FromFile(m_strFileName))
                            {
                                Directory.CreateDirectory(Path.GetDirectoryName(m_strCacheFileName));
                                img.Save(m_strCacheFileName, System.Drawing.Imaging.ImageFormat.Png);
                            }
                        }

                        m_Layer                = new ImageLayer(m_szTreeNodeText, m_oWorldWindow.CurrentWorld, 0.0, m_strCacheFileName, extents.South, extents.North, extents.West, extents.East, m_bOpacity, m_oWorldWindow.CurrentWorld.TerrainAccessor);
                        m_Layer.IsOn           = m_IsOn;
                        m_Layer.Opacity        = m_bOpacity;
                        m_Layer.RenderPriority = RenderPriority.TerrainMappedImages;
                    }
                }
                catch
                {
                    if (File.Exists(m_strCacheFileName))
                    {
                        File.Delete(m_strCacheFileName);
                    }
                    m_Layer = null;
                }
                m_blnIsChanged = false;
            }
            return(m_Layer);
        }
示例#3
0
        private void AddGeoTiff(string strGeoTiff, string strGeoTiffName, bool bTmp, bool bGoto)
        {
            LayerBuilder builder = new GeorefImageLayerBuilder(strGeoTiffName, strGeoTiff, bTmp, c_oWorldWindow, null);

            Cursor = Cursors.WaitCursor;
            if (builder.GetLayer() != null)
            {
                Cursor = Cursors.Default;

                // If the file is already there remove it
                c_oLayerList.CmdRemoveGeoTiff(strGeoTiff);

                // If there is already a layer by that name find unique name
                if (strGeoTiffName.Length > 0)
                {
                    int iCount = 0;
                    string strNewName = strGeoTiffName;
                    bool bExist = true;
                    while (bExist)
                    {
                        bExist = false;
                        foreach (LayerBuilder container in c_oLayerList.AllLayers)
                        {
                            if (container.Title == strNewName)
                            {
                                bExist = true;
                                break;
                            }
                        }

                        if (bExist)
                        {
                            iCount++;
                            strNewName = strGeoTiffName + "_" + iCount.ToString(CultureInfo.InvariantCulture);
                        }
                    }
                    strGeoTiffName = strNewName;
                }

                if (bTmp) builder.Opacity = 128;
                else builder.Opacity = 255;
                builder.Visible = true;
                builder.Temporary = bTmp;

                c_oLayerList.AddLayer(builder);

                if (bGoto)
                    GoTo(builder, false);
            }
            else
            {
                Cursor = Cursors.Default;
                string strMessage = "Error adding the file: '" + strGeoTiff + "'.\nOnly WGS 84 geographic images can be displayed at this time.";
                string strGeoInfo = GeorefImageLayerBuilder.GetGeorefInfoFromGeotif(strGeoTiff);
                if (strGeoInfo.Length > 0)
                {
                    strMessage += "\nThis image is:\n\n" + strGeoInfo;
                }

                Program.ShowMessageBox(
                    strMessage,
                    "Open GeoTIFF Image",
                    MessageBoxButtons.OK,
                    MessageBoxDefaultButton.Button1,
                    MessageBoxIcon.Error);
            }
        }