Example #1
0
        private static GeoDo.RSS.Core.DF.CoordEnvelope PrjToGeoCoordEvp(Core.DrawEngine.CoordEnvelope viewPrjEvp, ICoordinateTransform tans)
        {
            double minX = 0;
            double minY = 0;
            double maxX = 0;
            double maxY = 0;

            tans.Prj2Geo(viewPrjEvp.MinX, viewPrjEvp.MinY, out minX, out minY);
            tans.Prj2Geo(viewPrjEvp.MaxX, viewPrjEvp.MaxY, out maxX, out maxY);
            return(new GeoDo.RSS.Core.DF.CoordEnvelope(minX, maxX, minY, maxY));
        }
Example #2
0
        private void PrjToGeo(CoordPoint pt, ICoordinateTransform coordTran)
        {
            double prjX = 0, prjY = 0;

            coordTran.Prj2Geo(pt.X, pt.Y, out prjX, out prjY);
            pt.X = prjX;
            pt.Y = prjY;
        }
Example #3
0
        private CoordPoint SrceenToGeo(PointF pt, ICoordinateTransform coordTran)
        {
            double prjX = 0, prjY = 0;
            double geoX = 0, geoY = 0;

            coordTran.Screen2Prj(pt.X, pt.Y, out prjX, out prjY);
            coordTran.Prj2Geo(prjX, prjY, out geoX, out geoY);
            return(new CoordPoint(geoX, geoY));
        }
Example #4
0
        private static Size GetMaxDataSize(ICanvas canvas, Core.DrawEngine.CoordEnvelope viewPrjEvp, IRasterDataProvider prd,
                                           out GeoDo.RSS.Core.DF.CoordEnvelope viewGeoEvp)
        {
            viewGeoEvp = null;
            if (prd == null)
            {
                return(Size.Empty);
            }
            viewGeoEvp = null;
            ICoordinateTransform tans = canvas.CoordTransform;

            viewGeoEvp = PrjToGeoCoordEvp(viewPrjEvp, tans);
            if (prd.CoordType == enumCoordType.PrjCoord)
            {
                return(new Size((int)(viewPrjEvp.Width / prd.ResolutionX), (int)(viewPrjEvp.Height / prd.ResolutionY)));
            }
            else
            {
                double wid = 0;
                double hei = 0;
                tans.Prj2Geo(viewPrjEvp.Width, viewPrjEvp.Height, out wid, out hei);
                return(new Size((int)(wid / prd.ResolutionX), (int)(hei / prd.ResolutionY)));
            }
        }
Example #5
0
 private void DrawLabel(Graphics g, QuickTransform quickTran)
 {
     if (!_enableLabling)
     {
         return;
     }
     try
     {
         int    idx = 0;
         int    firstLine = -1;
         double geoX, geoY;
         string labelGeoX = string.Empty, labelGeoY = string.Empty;
         PointF pt;
         //label lonlines
         int endLon = Math.Min(_lonLines, _gridLines.Count);
         for (int iLine = 0; iLine < endLon; iLine += _lonLabelStep)
         {
             idx = ComputeLabelLocationOfLon(_gridLines[iLine]);
             if (idx == -1)
             {
                 continue;
             }
             if (firstLine == -1)
             {
                 firstLine = iLine;
             }
             pt   = _allPixelPoints[idx];
             geoX = _allPrjPoints[idx].X;
             geoY = _allPrjPoints[idx].Y;
             _coordTransfrom.Prj2Geo(geoX, geoY, out geoX, out geoY);
             if (double.IsInfinity(geoX) || double.IsNaN(geoX) || double.IsInfinity(geoY) || double.IsNaN(geoY))
             {
                 continue;
             }
             float dlt = 0.005f;
             if (geoX < 0)
             {
                 dlt = -0.005f;
             }
             geoX     += dlt;
             labelGeoX = LabelFormatLon(geoX);
             //避免-180和90重叠
             if (iLine == firstLine)
             {
                 pt.X += _fontSize.Height;
             }
             pt.Y = (20 - _fontSize.Height) / 2;
             if (!_enableMaskColor || _maskBrush == null)
             {
                 g.DrawString(labelGeoX, _labelFont, _labelBrush, pt);
             }
             else
             {
                 DrawStringWithBorder(labelGeoX, g, pt, _labelFont, _labelBrush, _maskBrush);
             }
         }
         //label latlines
         firstLine = -1;
         int begin  = Math.Min(_latLines + _lonLines, _gridLines.Count);
         int endLat = Math.Min(_lonLines, _gridLines.Count);
         for (int iLine = begin - 1; iLine > endLat; iLine -= _latLabelStep)
         {
             idx = ComputeLabelLocationOfLat(_gridLines[iLine]);
             if (idx == -1)
             {
                 continue;
             }
             if (firstLine == -1)
             {
                 firstLine = iLine;
             }
             pt   = _allPixelPoints[idx];
             geoX = _allPrjPoints[idx].X;
             geoY = _allPrjPoints[idx].Y;
             _coordTransfrom.Prj2Geo(geoX, geoY, out geoX, out geoY);
             if (double.IsInfinity(geoX) || double.IsNaN(geoX) || double.IsInfinity(geoY) || double.IsNaN(geoY))
             {
                 continue;
             }
             float dlt = 0.005f;
             if (geoY < 0)
             {
                 dlt = -0.005f;
             }
             geoY     += dlt;
             labelGeoY = LabelFormatLat(geoY);
             //避免90和-180重叠
             if (iLine == firstLine)
             {
                 pt.Y += _fontSize.Height;
             }
             pt.X = (20 - _fontSize.Width) / 2;
             SizeF stringSize = g.MeasureString(labelGeoY, _labelFont);
             g.TranslateTransform(stringSize.Width / 2, stringSize.Height / 2); //设置旋转中心为文字中心
             g.RotateTransform(90f);                                            //旋转
             if (!_enableMaskColor || _maskBrush == null)
             {
                 g.DrawString(labelGeoY, _labelFont, _labelBrush, pt);
             }
             else
             {
                 DrawStringWithBorder(labelGeoY, g, pt, _labelFont, _labelBrush, _maskBrush);
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }