当前位置: 首页>>代码示例>>C#>>正文


C# ESRI.Project方法代码示例

本文整理汇总了C#中ESRI.Project方法的典型用法代码示例。如果您正苦于以下问题:C# ESRI.Project方法的具体用法?C# ESRI.Project怎么用?C# ESRI.Project使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ESRI的用法示例。


在下文中一共展示了ESRI.Project方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: fillDbRaster

        public string fillDbRaster(IImageServerLayer imSvLyr, IWorkspace wks,ESRI.ArcGIS.Geometry.IEnvelope ext,ISpatialReference sr, out IRaster outrs)
        {
            if (ext.SpatialReference.FactoryCode != sr.FactoryCode)
            {
                ext.Project(sr);
            }
            StringBuilder msg = new StringBuilder();
            if (wks == null)
            {
                wks = servWks;
            }
            outrs = null;
            Forms.RunningProcess.frmRunningProcessDialog rp = new Forms.RunningProcess.frmRunningProcessDialog(false);
            rp.addMessage("Downloading images please be patient...");
            rp.Show();
            //rp.showInSepperateProcess();
            rp.TopMost = true;
            rp.stepPGBar(10);
            rp.Refresh();
            DateTime dtS = DateTime.Now;
            try
            {
                rasterUtil rsUtil = new rasterUtil();
                int minX = System.Convert.ToInt32(ext.XMin);
                int maxX = System.Convert.ToInt32(ext.XMax);
                int minY = System.Convert.ToInt32(ext.YMin);
                int maxY = System.Convert.ToInt32(ext.YMax);
                int xDiff = System.Convert.ToInt32(ext.Width);
                int yDiff = System.Convert.ToInt32(ext.Height);
                int tile = 1;
                IRaster rast = rsUtil.createRaster(((IRaster2)imSvLyr.Raster).RasterDataset);
                ISaveAs saveas = (ISaveAs)rast;
                IRasterProps rasterProps = (IRasterProps)rast;
                imSvLyr.SpatialReference = sr;
                string nm = "T" + System.Guid.NewGuid().ToString().Substring(0, 3);
                string svImgNm = imSvLyr.ServiceInfo.Name;
                string rNm = nm;
                int mCols = System.Convert.ToInt32(imSvLyr.ServiceInfo.MaxNCols * .90);
                int mRows = System.Convert.ToInt32(imSvLyr.ServiceInfo.MaxNRows * .90);
                if (xDiff < mCols) mCols = xDiff;
                if (yDiff < mRows) mRows = yDiff;
                List<IRaster> tileLst = new List<IRaster>();
                for (int i = minX; i < maxX; i += mRows)
                {
                    for (int j = minY; j < maxY; j += mCols)
                    {

                        IEnvelope clipEnvelope = new EnvelopeClass();
                        clipEnvelope.PutCoords(i, j, i + mRows, j + mCols);
                        rasterProps.Extent = clipEnvelope;
                        rasterProps.Width = mRows;
                        rasterProps.Height = mCols;
                        rasterProps.SpatialReference = sr;
                        string r = rNm + tile.ToString();
                        if (r.Length > 12)
                        {
                            rp.addMessage("Too many tiles. Ending at Tile: " + tile);
                            msg.AppendLine("Too many tiles. Ending at Tile: " + tile);
                            //outrs = rsUtil.mosaicRastersFunction(wks, rNm, tileLst.ToArray(),esriMosaicMethod.esriMosaicNone,rstMosaicOperatorType.MT_FIRST,true,true,false,true);
                            return msg.ToString();
                        }
                        if (((IWorkspace2)wks).get_NameExists(esriDatasetType.esriDTRasterDataset, r))
                        {
                            r = rsUtil.getSafeOutputName(wks, r);
                            //Console.WriteLine("Deleting Raster " + r);
                            //((IRasterWorkspaceEx)wks).DeleteRasterDataset(r);
                        }
                        rp.addMessage("Creating tile " + r);
                        rp.stepPGBar(5);
                        rp.Refresh();
                        //Console.WriteLine("TestLength  = " + testLng.ToString());
                        tileLst.Add(rsUtil.returnRaster((IRasterDataset)saveas.SaveAs(r, wks, "GDB")));
                        msg.AppendLine("Added Tile " + r);
                        tile++;
                    }
                }
                rp.addMessage("Merging rasters...");
                rp.Refresh();
                //outrs = rsUtil.mosaicRastersFunction(wks, rNm, tileLst.ToArray(), esriMosaicMethod.esriMosaicNone, rstMosaicOperatorType.MT_FIRST, true, true, false, true);
            }
            catch (Exception e)
            {
                string x = e.ToString();
                msg.AppendLine(x);
                Console.WriteLine("Error: " + x);
            }
            finally
            {
                DateTime dtE = DateTime.Now;
                TimeSpan ts = dtE.Subtract(dtS);
                msg.AppendLine("Finished process in " + ts.TotalMinutes + " minutes.");
                rp.addMessage("Finished process in " + ts.TotalMinutes + " minutes.");
                rp.stepPGBar(100);
                rp.enableClose();
                rp.TopMost = false;
                rp.Close();
            }
            return msg.ToString();
        }
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:99,代码来源:mapserviceutility.cs


注:本文中的ESRI.Project方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。