Пример #1
0
 public static IMosaicLayer FindMyMosaicLayer(IMap inMap, string inName)
 {
     string isfound = "false";
     ILayer tempLayer;
     IMosaicLayer goodMLayer = new MosaicLayerClass();
     for (int i = 0; i < inMap.LayerCount; i++)
     {
         tempLayer = inMap.get_Layer(i);
         if (tempLayer is IMosaicLayer)
         {
             if (tempLayer.Name == inName)
             {
                 isfound = "true";
                 goodMLayer = tempLayer as IMosaicLayer;
             }
         }
     }
     if (isfound == "true")
     {
         return goodMLayer;
     }
     else
     {
         return null;
     }
 }
Пример #2
0
        public static IMosaicLayer FindMyMosaicLayer(IMap inMap, string inName)
        {
            string       isfound = "false";
            ILayer       tempLayer;
            IMosaicLayer goodMLayer = new MosaicLayerClass();

            for (int i = 0; i < inMap.LayerCount; i++)
            {
                tempLayer = inMap.get_Layer(i);
                if (tempLayer is IMosaicLayer)
                {
                    if (tempLayer.Name == inName)
                    {
                        isfound    = "true";
                        goodMLayer = tempLayer as IMosaicLayer;
                    }
                }
            }
            if (isfound == "true")
            {
                return(goodMLayer);
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
        public static void OpenMosaicDataset(AxMapControl MapControl,
                                             IMosaicDatasetName pMdName, ListView listview1)
        {
            MapControl.ClearLayers();
            MapControl.SpatialReference = null;
            listview1.Items.Clear();
            listview1.Columns.Clear();
            IDatasetName pDsName = pMdName as IDatasetName;
            string       sName   = pDsName.Name;

            IName pName = pMdName as IName;

            IMosaicDataset pMds = pName.Open() as IMosaicDataset;
            IFeatureClass  pFc  = pMds.Catalog;

            listview1.Items.Clear();
            listview1.Columns.Clear();
            LoadListView(pFc, listview1);

            IFeatureCursor pCursor = pFc.Search(null, false);
            IFeature       pfea    = pCursor.NextFeature();
            int            j       = 0;

            while (pfea != null)
            {
                ListViewItem lv = new ListViewItem();

                for (int i = 0; i < pfea.Fields.FieldCount; i++)
                {
                    string sFieldName = pfea.Fields.get_Field(i).Name;
                    lv.SubItems.Add(FeatureHelper.GetFeatureValue(pfea, sFieldName).ToString());
                }

                lv.Tag = pfea;
                if (j % 2 == 0)
                {
                    lv.BackColor = System.Drawing.Color.GreenYellow;
                }
                listview1.Items.Add(lv);
                pfea = pCursor.NextFeature();
                j++;
            }
            LSGISHelper.OtherHelper.ReleaseObject(pCursor);
            IMosaicLayer pML = new MosaicLayerClass();

            pML.CreateFromMosaicDataset(pMds);

            MapControl.AddLayer(pML as ILayer);
            MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
        }
Пример #4
0
        public static void OpenMosaicDataset(AxMapControl MapControl, IMosaicDatasetName pMdName, DataTable dt = null)
        {
            MapControl.ClearLayers();
            MapControl.SpatialReference = null;
            IDatasetName   pDsName = pMdName as IDatasetName;
            string         sName   = pDsName.Name;
            IName          pName   = pMdName as IName;
            IMosaicDataset pMds    = pName.Open() as IMosaicDataset;

            if (null != dt)
            {
                IFeatureClass pFc = pMds.Catalog;
                InitDataTable(pFc, dt);

                IFeatureCursor pCursor = pFc.Search(null, false);
                IFeature       pfea    = pCursor.NextFeature();
                int            j       = 0;
                while (pfea != null)
                {
                    DataRow dataRow = dt.NewRow();

                    for (int i = 0; i < pfea.Fields.FieldCount; i++)
                    {
                        dataRow[i] = pfea.get_Value(i).ToString();
                    }

                    dt.Rows.Add(dataRow);
                    pfea = pCursor.NextFeature();
                    j++;
                }

                ComReleaser.ReleaseCOMObject(pCursor);
            }
            IMosaicLayer pML = new MosaicLayerClass();

            pML.CreateFromMosaicDataset(pMds);

            MapControl.AddLayer(pML as ILayer);
            MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
        }
 private void btnExecute_Click(object sender, EventArgs e)
 {
     string rstNm = txtOutNm.Text;
     esriMosaicMethod mMethod = (esriMosaicMethod)Enum.Parse(typeof(esriMosaicMethod),cmbMethod.Text);
     rstMosaicOperatorType mType = (rstMosaicOperatorType)Enum.Parse(typeof(rstMosaicOperatorType), cmbType.Text);
     if (rstNm == null || rstNm == "")
     {
         MessageBox.Show("You must specify a output name","No Output",MessageBoxButtons.OK,MessageBoxIcon.Error);
         return;
     }
     if (outWks == null)
     {
         MessageBox.Show("You must specify an output workspace", "No Workspace", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (lsbRaster.Items.Count < 1)
     {
         MessageBox.Show("You must select at least on Raster", "No Rasters", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     List<IRaster> rsLst = new List<IRaster>();
     for (int i = 0; i < lsbRaster.Items.Count; i++)
     {
         rsLst.Add(rstDic[lsbRaster.Items[i].ToString()]);
     }
     this.Visible = false;
     esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
     DateTime dt = DateTime.Now;
     rp.addMessage("Building Mosaic Raster. This may take a while...");
     rp.stepPGBar(10);
     rp.Show();
     rp.TopMost = true;
     if (chbOverview.Checked)
     {
         rp.addMessage("Building overviews will take additional time...");
     }
     try
     {
         outraster = rsUtil.mosaicRastersFunction(outWks,rstNm,rsLst.ToArray(),mMethod,mType,chbFootprint.Checked,chbBoundary.Checked,chbSeamlines.Checked,chbOverview.Checked);
         rp.addMessage("Adding mosaic dataset to the map");
         if (mp != null&&addToMap)
         {
             rp.Show();
             rp.Refresh();
             IMosaicLayer rstLyr = new MosaicLayerClass();
             rstLyr.CreateFromMosaicDataset((IMosaicDataset)((IRaster2)outraster).RasterDataset);
             mp.AddLayer((ILayer)rstLyr);
         }
         outrastername = rstNm;
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         rp.addMessage(ex.ToString());
     }
     finally
     {
         DateTime dt2 = DateTime.Now;
         TimeSpan ts = dt2.Subtract(dt);
         string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
         rp.stepPGBar(100);
         rp.addMessage("Finished Mosaic Raster" + t);
         rp.enableClose();
         this.Close();
     }
 }
Пример #6
0
        public static void OpenMosaicDataset(AxMapControl MapControl,
           IMosaicDatasetName pMdName, ListView listview1)
        {
            MapControl.ClearLayers();
            MapControl.SpatialReference = null;
            listview1.Items.Clear();
            listview1.Columns.Clear();
            IDatasetName pDsName = pMdName as IDatasetName;
            string sName = pDsName.Name;

            IName pName = pMdName as IName;

            IMosaicDataset pMds = pName.Open() as IMosaicDataset;
            IFeatureClass pFc = pMds.Catalog;
            listview1.Items.Clear();
            listview1.Columns.Clear();
            LoadListView(pFc, listview1);

            IFeatureCursor pCursor = pFc.Search(null, false);
            IFeature pfea = pCursor.NextFeature();
            int j = 0;
            while (pfea != null)
            {
                ListViewItem lv = new ListViewItem();

                for (int i = 0; i < pfea.Fields.FieldCount; i++)
                {
                    string sFieldName = pfea.Fields.get_Field(i).Name;
                    lv.SubItems.Add(FeatureHelper.GetFeatureValue(pfea, sFieldName).ToString());
                }

                lv.Tag = pfea;
                if (j % 2 == 0)
                {
                    lv.BackColor = System.Drawing.Color.GreenYellow;
                }
                listview1.Items.Add(lv);
                pfea = pCursor.NextFeature();
                j++;
            }
            LSGISHelper.OtherHelper.ReleaseObject(pCursor);
            IMosaicLayer pML = new MosaicLayerClass();
            pML.CreateFromMosaicDataset(pMds);

            MapControl.AddLayer(pML as ILayer);
            MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
        }
Пример #7
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string                rstNm   = txtOutNm.Text;
            esriMosaicMethod      mMethod = (esriMosaicMethod)Enum.Parse(typeof(esriMosaicMethod), cmbMethod.Text);
            rstMosaicOperatorType mType   = (rstMosaicOperatorType)Enum.Parse(typeof(rstMosaicOperatorType), cmbType.Text);

            if (rstNm == null || rstNm == "")
            {
                MessageBox.Show("You must specify a output name", "No Output", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (outWks == null)
            {
                MessageBox.Show("You must specify an output workspace", "No Workspace", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (lsbRaster.Items.Count < 1)
            {
                MessageBox.Show("You must select at least on Raster", "No Rasters", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            List <string> rsLst  = new List <string>();
            IEnvelope     cmbEnv = new EnvelopeClass();

            for (int i = 0; i < lsbRaster.Items.Count; i++)
            {
                string    nm = rstDic[lsbRaster.Items[i].ToString()];
                string    bnd;
                IDataset  dSet  = (IDataset)rsUtil.openRasterDataset(nm, out bnd);
                IEnvelope rsEnv = ((IGeoDataset)dSet).Extent;
                cmbEnv.Union(rsEnv);
                string fPath = dSet.Workspace.PathName + dSet.BrowseName;
                //MessageBox.Show("Raster name = " + fPath);
                rsLst.Add(fPath);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(dSet);
            }
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Building Mosaic Raster. This may take a while...");
            rp.stepPGBar(10);
            rp.Show();
            rp.TopMost = true;
            if (chbOverview.Checked)
            {
                rp.addMessage("Building overviews will take additional time...");
            }
            try
            {
                outraster = rsUtil.mosaicRastersFunction(outWks, rstNm, rsLst.ToArray(), cmbEnv, mMethod, mType, chbFootprint.Checked, chbBoundary.Checked, chbSeamlines.Checked, chbOverview.Checked);
                rp.addMessage("Adding mosaic dataset to the map");
                if (mp != null && addToMap)
                {
                    rp.Show();
                    rp.Refresh();
                    IMosaicLayer rstLyr = new MosaicLayerClass();
                    rstLyr.CreateFromMosaicDataset((IMosaicDataset)((IRaster2)outraster).RasterDataset);
                    mp.AddLayer((ILayer)rstLyr);
                }
                outrastername     = rstNm;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished Mosaic Raster" + t);
                rp.enableClose();
                this.Close();
            }
        }