Ejemplo n.º 1
0
        /// <summary>
        ///  新建坡度-------多线CUT------OK
        /// </summary>
        /// <param name="inIMGPath"></param>
        /// <param name="jiao"></param>
        /// <returns></returns>
        public static string poDuM(string inIMGPath, int Lev)
        {
            Console.WriteLine("开始切图!");
            //提高分辨率
            //string reProjectIMG = StaticTools.tempFilePath("img", "reProjectIMG");
            //CutImg.ImgReProject(inIMGPath, reProjectIMG);

            List <string> cutFiles = CutImg.getSubImg(inIMGPath);

            lock (@"D:\TEMPFORGETDATATOOLS\log")
            { cutFiles.writeInLog("subDSM"); }

            Console.WriteLine("切图完毕,开始多线程计算坡度线");

            subPdPoly.Clear();
            subPdLine.Clear();
            //分发任务
            for (int t = 0; t < Lev; t++)
            {
                for (int i = 0; i < cutFiles.Count; i++)
                {
                    GetSlopeFile(
                        cutFiles[i],     //subDSM
                        (85 - t * 5),    // 一级减5度
                        i + 1,           //序列
                        cutFiles.Count); //总数量
                }
                while (aRound != cutFiles.Count)
                {
                    Console.Write("*");
                    Thread.Sleep(2000);
                }
                aRound = 0;
            }
            while (subPdPoly.Count != cutFiles.Count * Lev)
            {
                Console.Write(".");
                Thread.Sleep(2000);
            }

            Console.WriteLine("开始整合坡度线");

            string res = CutImg.zhengHePdx(subPdPoly);

            CutImg.zhengHePdLine(subPdLine);

            Console.WriteLine("坡度线整合完成!");

            return(res);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 新建坡度-------单线CUT------OK
        /// </summary>
        public static string poDu(string inIMGPath, int jiao)
        {
            //用来放sub坡度线的
            List <string> subPdPoly = new List <string>();
            List <string> subPdLine = new List <string>();


            Console.WriteLine("开始切图!");
            //提高分辨率
            //string reProjectIMG = StaticTools.tempFilePath("img", "reProjectIMG");
            //CutImg.ImgReProject(inIMGPath, reProjectIMG);
            List <string> cutFiles = CutImg.getSubImg(inIMGPath);

            cutFiles.writeInLog("subDSM");

            Console.WriteLine("切图完毕,开始单线程计算坡度线");
            for (int i = 0; i < cutFiles.Count; i++)
            {
                Console.WriteLine("开始处理第{0}个图,共{1}个", i + 1, cutFiles.Count);

                string inSubfile = cutFiles[i];
                string slopeMap  = StaticTools.tempFilePath("img", "slop");
                string slopePoly = StaticTools.tempFilePath("shp", "slopPoly");
                string slopLine  = StaticTools.tempFilePath("shp", "shpLine");

                slopeMap.writeInLog("slopMap");
                (new SlopeDem()).Slope(inSubfile, slopeMap);
                (new SlopeDem()).CreatePolygon(inSubfile, slopeMap, slopePoly, slopLine, 80);
                subPdPoly.Add(slopePoly);
                subPdLine.Add(slopLine);

                Console.WriteLine("第{0}个图处理完成,共{1}个", i + 1, cutFiles.Count);
            }

            Console.WriteLine("开始整合坡度线");

            string res = CutImg.zhengHePdx(subPdPoly);

            CutImg.zhengHePdLine(subPdLine);
            Console.WriteLine("坡度线整合完成!");


            return(res);
        }
Ejemplo n.º 3
0
        public static string addPdx(string point, string inDSM, int lev)
        {
            //读取点ID
            OSGeo.OGR.Ogr.RegisterAll();
            OSGeo.OGR.Driver     dr         = OSGeo.OGR.Ogr.GetDriverByName("ESRI shapefile");
            OSGeo.OGR.DataSource pointDs    = dr.Open(point, 0);
            OSGeo.OGR.Layer      pointLayer = pointDs.GetLayerByIndex(0);
            int pointCount = pointLayer.GetFeatureCount(0);

            for (int i = 0; i < pointCount; i++)
            {
                pointIds.Add(i);
            }

            //提升分辨率,计算坡度图
            List <string> subSlop = new List <string>();

            string upDataDSM = StaticTools.tempFilePath("img", "UpDataDSM");

            CutImg.ImgReProject(inDSM, upDataDSM, 2);
            string addSolpeMap = StaticTools.tempFilePath("img", "addSolpeMap");

            SlopeDem.Instance.Sloping(upDataDSM, addSolpeMap);

            //循环坡度下限值
            for (int i = 0; i < lev; i++)
            {
                //没点了就退出
                if (pointIds.Count == 0)
                {
                    Console.WriteLine("所有目标都已找到匹配元素!");
                    break;
                }
                Console.WriteLine("【开始第{0}次循环,还有{1}个点待提取!】", i, pointIds.Count);
                string _outShpPath = StaticTools.tempFilePath("shp", "SlopAdd" + i.ToString() + "Times");
                GetOutlines.Instance.MyGetOutlines(upDataDSM, addSolpeMap, _outShpPath, 80 - i * 5);
                补充要素.AddFeatuer.selectFromPoint(point, _outShpPath);
                subSlop.Add(_outShpPath);
            }
            Console.WriteLine("还有{0}个目标没有找到对应要素!", pointIds.Count.ToString());

            return(OutLine.CutImg.zhengHePdx(subSlop, 10));
        }
Ejemplo n.º 4
0
        //new
        public static string poDuM(string inIMGPath, int Lev)
        {
            Gdal.AllRegister();
            Ogr.RegisterAll();

            string _outFilePath = StaticTools.tempFilePath("img", "SolpeMap");

            _outFilePath.writeInLog("SolpeMap");
            SlopeDem.Instance.Sloping(inIMGPath, _outFilePath);

            List <string> levelFiles = new List <string>();

            for (int i = 0; i < Lev; i++)
            {
                Stopwatch ssw         = new Stopwatch(); ssw.Start(); Console.WriteLine("开始计算第{0}级SlopePolygon" + i + 1);
                string    _outShpPath = StaticTools.tempFilePath("shp", "SolpePolyLev" + i.ToString());
                GetOutlines.Instance.MyGetOutlines(inIMGPath, _outFilePath, _outShpPath, 80 - i * 5);
                levelFiles.Add(_outShpPath);
                ssw.Stop(); Console.WriteLine("第{0}级SlopePolygon完成,用时{1}!", i + 1, ssw.Elapsed.ToString());
            }
            string res = CutImg.zhengHePdx(levelFiles);

            return(res);
        }