Пример #1
0
        public override void MouseClick(object sender, MouseEventArgs e)
        {
            if (map.InsertionLayer == null) return;

            CoordSys layerCoordsys = map.InsertionLayer.LayerCoordSys;

            CoordConverter oCC = new CoordConverter();
            oCC.Init(layerCoordsys, map.DisplayCoordSys);

            // this atPan converts DisplayCoordSys into Screen CoordSys[px]
            // DisplayCoordSys has Y axis up (unless its AT does not change it)
            // Screen Y axis is down
            AffineTransform atPan = new AffineTransform();
            atPan.OffsetInPlace((double)map.MapOffsetX, (double)map.MapOffsetY);
            atPan.MultiplyInPlace(map.MapScale, -map.MapScale);

            // add screen scale and offset transformation
            oCC.atMaster = oCC.atMaster.Compose(atPan);

            oCC.ConvertInverse(e.X, e.Y);

            DPoint pt = new DPoint(oCC.X, oCC.Y);
            // szukaj w tym miejscu feature
            List<Feature> ftrs = map.InsertionLayer.Search(pt);

            if (ftrs.Count == 0)
            {
                Feature oF = FeatureFactory.CreateSymbol(oCC.X, oCC.Y);
                map.InsertionLayer.FeaturesAdd(oF);
            }

            MapControl.Globals.Instance.MapControl.InvalidateMap();
        }
Пример #2
0
        public override void MouseMove(object sender, MouseEventArgs e)
        {
            base.MouseMove(sender, e);

            // highlight polilines and points

            if (map.InsertionLayer == null) return;

            CoordSys layerCoordsys = map.InsertionLayer.LayerCoordSys;

            CoordConverter oCC = new CoordConverter();
            oCC.Init(layerCoordsys, map.DisplayCoordSys);

            // this atPan converts DisplayCoordSys into Screen CoordSys[px]
            // DisplayCoordSys has Y axis up (unless its AT does not change it)
            // Screen Y axis is down
            AffineTransform atPan = new AffineTransform();
            atPan.OffsetInPlace((double)map.MapOffsetX, (double)map.MapOffsetY);
            atPan.MultiplyInPlace(map.MapScale, -map.MapScale);

            // add screen scale and offset transformation
            oCC.atMaster = oCC.atMaster.Compose(atPan);

            int margin = 5;

            oCC.ConvertInverse(e.X, e.Y);
            DPoint pt_center = new DPoint(oCC.X, oCC.Y);
            oCC.ConvertInverse(e.X - margin, e.Y - margin);
            DPoint pt1 = new DPoint(oCC.X, oCC.Y);
            oCC.ConvertInverse(e.X + margin, e.Y + margin);
            DPoint pt2 = new DPoint(oCC.X, oCC.Y);
            // szukaj w tym miejscu feature
            //List<Feature> ftrs = map.InsertionLayer.Search(pt);

            // construct search rectangle (10px wide)
            DRect rect = new DRect(pt1.X, pt2.Y, pt2.X, pt1.Y);

            //map.InsertionLayer.SelectWithinRectangle(rect);
        }
Пример #3
0
        private double zoomElevateUpscale = 1024 * 8; //1024;

        #endregion Fields

        #region Constructors

        public LayerTiles()
        {
            Datum datumWGS84Sphere = CoordSysFactory.CreateDatum(Ellipsoid.Sphere, 0, 0, 0, 0, 0, 0, 0, 0);

            double r = datumWGS84Sphere.SemiMajorAxis;

            // scale =256/360, offset=128, this is calculated for zoom=0 (one tile)
            // converts merc deg (-180;180 , -90;90) into pixels (0;256 , 0;256)
            AffineTransform affineTransform = new AffineTransform();
            //zoomElevate = 1024; // zwieksz gestosc wspolrzednych o 10 pozomow zoom
            //            affineTransform.MultiplyInPlace(256.0 / 360.0 * zoomElevateUpscale, -256.0 / 360.0 * zoomElevateUpscale);
            //            affineTransform.OffsetInPlace(-128, 128);

            affineTransform.MultiplyInPlace(256.0 / (2.0 * Math.PI * r) * zoomElevateUpscale, -256.0 / (2.0 * Math.PI * r) * zoomElevateUpscale);
            affineTransform.OffsetInPlace(128 * zoomElevateUpscale, 128 * zoomElevateUpscale);

            layerCoordSys = new CoordSys(CoordSysType.Mercator, datumWGS84Sphere, affineTransform);

            // depending o tile zoom lever (1,2,3,...,17) there is different AT

            // tiles loader
            WindowsFormsImageProxy wimg = new WindowsFormsImageProxy();
            GMaps.Instance.ImageProxy = wimg;
        }
Пример #4
0
        void DrawLayer(LayerAbstract oL, Graphics g, Rectangle Rect)
        {
            CoordSys layerCoordsys = oL.LayerCoordSys;

            CoordConverter oCC = new CoordConverter();
            oCC.Init(layerCoordsys, DisplayCoordSys);

            // this atPan converts DisplayCoordSys into Screen CoordSys[px]
            // DisplayCoordSys has Y axis up (unless its AT does not change it)
            // Screen Y axis is down
            AffineTransform atPan = new AffineTransform();
            atPan.OffsetInPlace((double)mapOffsetX, (double)mapOffsetY);
            atPan.MultiplyInPlace(mapScale, -mapScale);

            // add screen scale and offset transformation
            oCC.atMaster = oCC.atMaster.Compose(atPan);

            oL.Draw(g, Rect, oCC);
        }
Пример #5
0
        private void tileDownloaderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // auto download tiles

            // calculate x,y, range
            // calculate zoom range

            CoordSys layerCoordsys = tileLayer.LayerCoordSys;

            CoordConverter oCC = new CoordConverter();
            oCC.Init(layerCoordsys, mapControl1.Map.DisplayCoordSys);

            // this atPan converts DisplayCoordSys into Screen CoordSys[px]
            // DisplayCoordSys has Y axis up (unless its AT does not change it)
            // Screen Y axis is down
            AffineTransform atPan = new AffineTransform();
            atPan.OffsetInPlace((double)mapControl1.Map.MapOffsetX, (double)mapControl1.Map.MapOffsetY);
            atPan.MultiplyInPlace(mapControl1.Map.MapScale, -mapControl1.Map.MapScale);

            // add screen scale and offset transformation
            oCC.atMaster = oCC.atMaster.Compose(atPan);

            double zoomElevateUpscale = 1024 * 8; //1024;
            double scale = oCC.atMaster.A;

            int zoom = (int)Math.Log(scale * zoomElevateUpscale, 2);

            TileDownloader downloader = new TileDownloader();
            downloader.Download(zoom, ((LayerTilesAsynch)tileLayer).MapType, oCC, new System.Drawing.Rectangle(0, 0, mapControl1.Width, mapControl1.Height));
        }
Пример #6
0
        private void mapControl1_MouseMove(object sender, MouseEventArgs e)
        {
            DPoint pt;
            mapControl1.Map.DisplayTransform.FromDisplay(new System.Drawing.Point(e.X, e.Y), out pt);

            // convert mercator to wgs84
            CoordConverter occ = new CoordConverter();
            CoordSys oCSMercator = CoordSysFactory.CreateCoordSys(CoordSysType.Mercator, CoordSysFactory.CreateDatum(DatumID.WGS84), new AffineTransform());
            CoordSys oCSWGS84 = CoordSysFactory.CreateCoordSys(CoordSysType.LatLong, CoordSysFactory.CreateDatum(DatumID.WGS84), new AffineTransform());
            occ.Init(oCSMercator, oCSWGS84);
            occ.Convert(pt.X, pt.Y);

            // calculate zoom
            CoordSys layerCoordsys = tileLayer.LayerCoordSys;

            CoordConverter oCC = new CoordConverter();
            oCC.Init(layerCoordsys, mapControl1.Map.DisplayCoordSys);

            // this atPan converts DisplayCoordSys into Screen CoordSys[px]
            // DisplayCoordSys has Y axis up (unless its AT does not change it)
            // Screen Y axis is down
            AffineTransform atPan = new AffineTransform();
            atPan.OffsetInPlace((double)mapControl1.Map.MapOffsetX, (double)mapControl1.Map.MapOffsetY);
            atPan.MultiplyInPlace(mapControl1.Map.MapScale, -mapControl1.Map.MapScale);

            // add screen scale and offset transformation
            oCC.atMaster = oCC.atMaster.Compose(atPan);

            double zoomElevateUpscale = 1024 * 8; //1024;
            double scale = oCC.atMaster.A;

            int zoom = (int)Math.Log(scale * zoomElevateUpscale, 2);

            lblInfo.Text = string.Format("x={0:0.00000}, y={1:0.00000} Mercator: x={2:0}, y={3:0}, zoom={4}", occ.X, occ.Y, pt.X, pt.Y, zoom);
        }