Esempio n. 1
0
        public void Render(object sender, IDrawArgs drawArgs)
        {
            if (_bitmap == null || _coordEnvelope == null)
            {
                return;
            }
            CoordEnvelope evp = _coordEnvelope.Clone();

            if (_isGeoCoord)
            {
                (sender as ICanvas).CoordTransform.Geo2Prj(evp);
            }
            double x1 = evp.MinX;
            double y1 = evp.MinY;
            double x2 = evp.MaxX;
            double y2 = evp.MaxY;

            drawArgs.QuickTransformArgs.Transform(ref x1, ref y1);
            drawArgs.QuickTransformArgs.Transform(ref x2, ref y2);

            /*
             * 以下两句为了解决:
             * 在缩放过程中因浮点取整导致边界1-2个像元没有被遮住的问题
             */
            x1 -= 1;
            y2 -= 1;
            Graphics g = drawArgs.Graphics as Graphics;

            //g.DrawImage(_bitmap,
            //    RectangleF.FromLTRB((float)Math.Min(x1, x2), (float)Math.Min(y1, y2), (float)Math.Max(x1, x2), (float)Math.Max(y1, y2)));
            g.DrawImage(_bitmap, new PointF[] { new PointF((float)x1, (float)y2), new PointF((float)x2, (float)y2), new PointF((float)x1, (float)y1) },
                        new RectangleF(0, 0, _bitmap.Width, _bitmap.Height), GraphicsUnit.Pixel, _ia);
        }
Esempio n. 2
0
 public void To(ILinkableViewer fromViewer, GeoDo.RSS.Core.DrawEngine.CoordEnvelope viewport)
 {
     foreach (ILinkableViewer v in _viewers)
     {
         if (!v.Equals(fromViewer))
         {
             v.To(viewport.Clone());
         }
     }
 }
Esempio n. 3
0
        private void SetEnvelope()
        {
            GeoDo.RSS.Core.DF.CoordEnvelope evp = _dataProvider.CoordEnvelope;
            switch (_dataProvider.CoordType)
            {
            case enumCoordType.Raster:
            case enumCoordType.PrjCoord:
                if (evp == null)
                {
                    evp = new DF.CoordEnvelope(new DF.CoordPoint(0, 0), _dataProvider.Width, _dataProvider.Height);
                }
                _envelope = new DrawEngine.CoordEnvelope(evp.MinX, evp.MaxX, evp.MinY, evp.MaxY);
                if (_dataProvider.SpatialRef != null)
                {
                    _projectionTransform = ProjectionTransformFactory.GetProjectionTransform(SpatialReference.GetDefault(), _dataProvider.SpatialRef);
                }
                _canvas.CoordTransform.DataCoordType = enumDataCoordType.Prj;
                break;

            case enumCoordType.GeoCoord:
                //这里未处理其他坐标系统//???
                _projectionTransform = ProjectionTransformFactory.GetDefault();
                double[] xs = new double[] { evp.MinX, evp.MaxX };
                double[] ys = new double[] { evp.MinY, evp.MaxY };
                _projectionTransform.Transform(xs, ys);
                _envelope = new DrawEngine.CoordEnvelope(xs[0], xs[1], ys[0], ys[1]);
                _canvas.CoordTransform.DataCoordType = enumDataCoordType.Geo;
                break;
            }
            _originalEnvelope    = _envelope.Clone();
            _originalResolutionX = (float)(_originalEnvelope.Width / _dataProvider.Width);
            _originalResolutionY = (float)(_originalEnvelope.Height / _dataProvider.Height);
            //
            if (_dataProvider.SpatialRef == null)
            {
                _canvas.CoordTransform.SpatialRefOfViewer = new SpatialReference(new GeographicCoordSystem());
            }
            else
            {
                _canvas.CoordTransform.SpatialRefOfViewer = _dataProvider.SpatialRef.Clone();
            }
        }
Esempio n. 4
0
 public void To(GeoDo.RSS.Core.DrawEngine.CoordEnvelope viewport)
 {
     if (_session.SmartWindowManager.ActiveCanvasViewer != null && _session.SmartWindowManager.ActiveCanvasViewer.IsPrimaryLinkWnd)
     {
         GeoDo.RSS.Core.DrawEngine.CoordEnvelope ev = viewport.Clone();
         ICanvas c = _session.SmartWindowManager.ActiveCanvasViewer.Canvas;
         if (c != null)
         {
             double prjX1 = ev.MinX, prjY1 = ev.MaxY, prjX2 = ev.MaxX, prjY2 = ev.MinY;
             double geoX1, geoY1, geoX2, geoY2;
             c.CoordTransform.Prj2Geo(prjX1, prjY1, out geoX1, out geoY1);
             c.CoordTransform.Prj2Geo(prjX2, prjY2, out geoX2, out geoY2);
             ev = new CoordEnvelope(geoX1, geoX2, geoY2, geoY1);
             double lon  = ev.Center.X;
             double lat  = ev.Center.Y;
             double span = (ev.MaxX - ev.MinX) > (ev.MaxY - ev.MinY) ?
                           (ev.MaxX - ev.MinX) : (ev.MaxY - ev.MinY);
             double alt = 6357000 * Math.Sin(span / 2 * Angle.DegreeToRadians);
             EarthGoto(lat, lon, alt);
         }
     }
 }