Esempio n. 1
0
        private void button11_Click(object sender, EventArgs e)
        {
            IRasterDataProvider prd = GetRasterDataProvider();
            string fname            = prd.fileName;
            //
            IContourGenerateTool tool = new ContourGenerateTool();

            double[] contourValues = new double[] { 0.15d };
            //
            Stopwatch sw = new Stopwatch();

            sw.Start();
            //
            ContourLine[] cLines = tool.Generate(prd.GetRasterBand(1), contourValues,
                                                 (pro, stip) =>
            {
                Text = pro.ToString() + "%," + stip;
            }
                                                 );
            //
            sw.Stop();
            Text = "GenerateContour: " + sw.ElapsedMilliseconds.ToString();
            //
            DrawContourLine(prd, cLines);
            //
            prd.Dispose();
            //
            Text = "GenerateContour: " + sw.ElapsedMilliseconds.ToString() + ",and drawed.";
        }
Esempio n. 2
0
 public void DoGenerateContourLines(IRasterDataProvider dataProvider, int bandNo, int[] aoi, double[] contourValues, int sample, string shpFileName)
 {
     try
     {
         try
         {
             IContourGenerateTool tool = new ContourGenerateTool();
             tool.IsOutputUncompleted = false;
             tool.Sample = sample;
             ContourLine[] cntLines = tool.Generate(dataProvider.GetRasterBand(bandNo), contourValues, aoi, _progressTracker);
             if (cntLines == null || cntLines.Length == 0)
             {
                 PrintInfo("不存在符合指定条件的等值线!");
                 return;
             }
             if (shpFileName != null)
             {
                 TryExport2ShapeFile(dataProvider, cntLines, shpFileName);
             }
         }
         finally
         {
         }
     }
     finally
     {
     }
 }
Esempio n. 3
0
        private void DoGenerateContourLines(ICanvas canvas, double resX, double resY, frmPointContour.ContourItem[] contourItems, bool isNeedDisplay, bool isNeedLabel, IDW_Interpolation interpolate, string shpFileName)
        {
            IProgressMonitor progress = _smartSession.ProgressMonitorManager.DefaultProgressMonitor;

            try
            {
                progress.Reset("正在生成等值线...", 100);
                progress.Start(false);
                ContourGenerateTool tool = new ContourGenerateTool();
                double[]            cvs  = ToContourValues(contourItems);

                ContourLine[] cntLines = tool.Generate(resX, resY, enumDataType.Float, cvs, interpolate, (idx, tip) => { progress.Boost(idx, tip); });
                if (cntLines == null || cntLines.Length == 0)
                {
                    MsgBox.ShowInfo("不存在符合指定条件的等值线!");
                    return;
                }

                double dMinX = interpolate.CoordPointXArr.Min();
                double dMaxY = interpolate.CoordPointYArr.Max();
                for (int i = 0; i < cntLines.Count(); i++)
                {
                    ContourLine cntLine    = cntLines[i];
                    ContourLine newCntLine = new ContourLine(cntLine.ContourValue);
                    PointF[]    pts        = cntLine.Points;
                    for (int j = 0; j < pts.Count(); j++)
                    {
                        pts[j].X = Convert.ToSingle(dMinX + resX * pts[j].X);
                        pts[j].Y = Convert.ToSingle(dMaxY - resY * pts[j].Y);
                    }
                    newCntLine.AddPoints(pts);
                    newCntLine.UpdateEnvelope();
                    cntLines[i] = newCntLine;
                }
                if (shpFileName != null)
                {
                    TryExport2ShapeFile(canvas, cntLines, shpFileName, progress, isNeedDisplay);
                }
                if (isNeedDisplay)
                {
                    TryDisplay(cntLines, contourItems, isNeedLabel);
                }
            }
            finally
            {
                progress.Finish();
            }
        }
Esempio n. 4
0
 private void DoGenerateContourLines(IRasterDataProvider dataProvider, bool isNew, int bandNo, int[] aoi, frmContourSettings.ContourItem[] contourItems, bool isNeedDisplay, bool isNeedLabel, bool isNeedFillColor, int sample, string shpFileName)
 {
     try
     {
         IProgressMonitor progress = _smartSession.ProgressMonitorManager.DefaultProgressMonitor;
         try
         {
             progress.Reset("正在生成等值线...", 100);
             progress.Start(false);
             IContourGenerateTool tool = new ContourGenerateTool();
             tool.Sample = sample;
             double[]      cvs      = ToContourValues(contourItems);
             ContourLine[] cntLines = tool.Generate(dataProvider.GetRasterBand(bandNo),
                                                    cvs, aoi,
                                                    (idx, tip) => { progress.Boost(idx, tip); });
             if (cntLines == null || cntLines.Length == 0)
             {
                 MsgBox.ShowInfo("不存在符合指定条件的等值线!");
                 return;
             }
             if (shpFileName != null)
             {
                 TryExport2ShapeFile(dataProvider, cntLines, shpFileName, progress, isNeedDisplay);
             }
             if (isNeedDisplay)
             {
                 TryDisplay(cntLines, contourItems, isNeedLabel, isNeedFillColor, isNew, dataProvider);
             }
         }
         finally
         {
             progress.Finish();
         }
     }
     finally
     {
         if (isNew && !isNeedDisplay)
         {
             dataProvider.Dispose();
         }
     }
 }