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();
            }
        }
Exemple #2
0
        private unsafe void Project(ContourLine cntLine, ICanvas canvas)
        {
            ICoordinateTransform tran = canvas.CoordTransform;

            if (tran == null)
            {
                return;
            }
            int nCount = cntLine.Count;

            fixed(PointF *ptr0 = cntLine.Points)
            {
                PointF *ptr = ptr0;

                for (int i = 0; i < nCount; i++, ptr++)
                {
                    tran.Raster2Prj(ptr);
                }
            }

            cntLine.UpdateEnvelope();
        }