示例#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
        /// <summary>
        /// Rednders contained features
        /// </summary>
        /// <param name="g"></param>
        /// <param name="Rect"></param>
        /// <param name="oCC"></param>
        public void draw(Graphics g, Rectangle Rect, CoordConverter oCC)
        {
            if (boundsOK == false)
            {
                calculateBounds();
            }

            // calculate Bound in Layer Coordsys
            double xmin, xmax, ymin, ymax;  // bounds of current viewport (in map coordsys)

            // TODO: respoct rotation of coordsys
            oCC.ConvertInverse(Rect.Left, Rect.Top);
            xmin = oCC.X;
            ymin = oCC.Y;
            oCC.ConvertInverse(Rect.Right, Rect.Bottom);
            xmax = oCC.X;
            ymax = oCC.Y;

            if (ymin > ymax)
            {
                double t = ymin;
                ymin = ymax;
                ymax = t;
            }

            DRect rectScreenInLayer = new DRect(xmin, ymin, xmax, ymax);

            // refresh value of Feature.MBR
            for (int i = 0; i < m_oFeatures.Count; i++)
            {
                Feature feature = m_oFeatures[i];
                if (feature != null)
                {
                    int pixelMargin = feature.pixelMargin();

                    if (feature.MBR.X2 >= xmin - pixelMargin &&
                        feature.MBR.X1 <= xmax + pixelMargin &&
                        feature.MBR.Y2 >= ymin - pixelMargin &&
                        feature.MBR.Y1 <= ymax + pixelMargin)
                    {
                        drawMapFeature(g, Rect, rectScreenInLayer, oCC, feature, false);
                    }
                }
            }
        }
示例#4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">Graphics na ktorym robimy rysunek w ukladzie wspolrzenych screen</param>
        /// <param name="Rect">Obszar ekranu do odrysowania we wsp. screen</param>
        /// <param name="oCC">obsolete</param>
        /// <param name="oCC1">converter layer->screen</param>
        public override void Draw(Graphics g, System.Drawing.Rectangle Rect, CoordConverter oCC)
        {
            base.Draw(g, Rect, oCC);

            // produce a list of needed tiles

            // ustal dla jakiego zoom wyswietlac bedziemy kafelki

            if (oCC.atMaster.IsRotating()) return; //can not display
            double scale = oCC.atMaster.A;
            //System.Diagnostics.Debug.Print("Scale={0}", scale);
            // scale = 1,2,4,8

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

            // ustal uklad wsp. w jakim są przechowywane kafelki
            // jest to inny uklad w kazdym zoomie
            // zoom=0 -> 0;0 - 256;256 (2^0=1)   0x100
            // zoom=1 -> 0;0 - 512;512 (2^1=2)   0x200
            // zoom=2 -> 0;0 - 1024;1024 (2^2=4) 0x400
            // ...
            // zoom=17 -> 0;0 - 33554432;33554432 (2^17=131072) 0x02000000 (32bit)
            // zoom=18 ->
            // zoom=19 ->

            // oblicz prostokat widocznosci w ukladzie kafelkow (z Display Coordsys do Layer Coordsys)
            int x1, y1;
            oCC.ConvertInverse(Rect.X, Rect.Y);
            x1 = (int)oCC.X;
            y1 = (int)oCC.Y;
            int x2, y2;
            oCC.ConvertInverse(Rect.X + Rect.Width, Rect.Y + Rect.Height);
            x2 = (int)oCC.X;
            y2 = (int)oCC.Y;

            if (x1 > x2) { int tmp = x1; x1 = x2; x2 = tmp; }
            if (y1 > y2) { int tmp = y1; y1 = y2; y2 = tmp; }

            // zoom=0 -> 256
            // zoom=1 -> 128
            // zoom=2 -> 64

            int tileSizePx = (int)Math.Round(256.0 / scale);  // zoom=0 -> 256 * zoomElevate
            if (tileSizePx < 1) return;

            // okresl liste kafelkow do wyswietlenia
            int xx1 = (x1 / tileSizePx) * tileSizePx;
            int yy1 = (y1 / tileSizePx) * tileSizePx;

            int xx2 = (x2 / tileSizePx) * tileSizePx + tileSizePx;
            int yy2 = (y2 / tileSizePx) * tileSizePx + tileSizePx;

            int max = (int)(scale * zoomElevateUpscale);

            int count = 0;
            for (int x = xx1; x < xx2; x += tileSizePx)
            {
                for (int y = yy1; y < yy2; y += tileSizePx)
                {
                    int picx = x / tileSizePx;
                    int picy = y / tileSizePx;
                    int picZoom = zoom;

                    if (count < 66 && picx >= 0 && picy >= 0 && picx < max && picy < max)
                    {
                        DrawImageGMap(x, y, (int)(tileSizePx), (int)(tileSizePx), g, oCC, picx, picy, picZoom);
                    }
                    //DrawEllipse(x, y, tileSizePx, tileSizePx, g, oCC1);
                    count++;
                }
            }
        }
示例#5
0
        public void DownloadZoom(int zoom, int enlarge, MapType mapType, CoordConverter oCC, System.Drawing.Rectangle Rect)
        {
            int enlargeMul = 1 << enlarge;

            // produce a list of needed tiles

            // ustal dla jakiego zoom wyswietlac bedziemy kafelki

            if (oCC.atMaster.IsRotating()) return; //can not display
            double scale = oCC.atMaster.A * enlargeMul;
            //System.Diagnostics.Debug.Print("Scale={0}", scale);
            // scale = 1,2,4,8

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

            int tileSizePx = (int)Math.Round(256.0 / scale);  // zoom=0 -> 256 * zoomElevate
            if (tileSizePx < 1) return;

            // ustal uklad wsp. w jakim są przechowywane kafelki
            // jest to inny uklad w kazdym zoomie
            // zoom=0 -> 0;0 - 256;256 (2^0=1)   0x100
            // zoom=1 -> 0;0 - 512;512 (2^1=2)   0x200
            // zoom=2 -> 0;0 - 1024;1024 (2^2=4) 0x400
            // ...
            // zoom=17 -> 0;0 - 33554432;33554432 (2^17=131072) 0x02000000 (32bit)
            // zoom=18 ->
            // zoom=19 ->

            // oblicz prostokat widocznosci w ukladzie kafelkow (z Display Coordsys do Layer Coordsys)
            int x1, y1;
            oCC.ConvertInverse(Rect.X, Rect.Y);
            x1 = (int)oCC.X;
            y1 = (int)oCC.Y;
            int x2, y2;
            oCC.ConvertInverse(Rect.X + Rect.Width, Rect.Y + Rect.Height);
            x2 = (int)oCC.X;
            y2 = (int)oCC.Y;

            if (x1 > x2) { int tmp = x1; x1 = x2; x2 = tmp; }
            if (y1 > y2) { int tmp = y1; y1 = y2; y2 = tmp; }

            // zoom=0 -> 256
            // zoom=1 -> 128
            // zoom=2 -> 64

            // zaokraglij wsp. w ukl mapy do pelnych rozmiarow kafelka
            int xx1 = (x1 / tileSizePx) * tileSizePx;
            int yy1 = (y1 / tileSizePx) * tileSizePx;

            int xx2 = (x2 / tileSizePx) * tileSizePx + tileSizePx;
            int yy2 = (y2 / tileSizePx) * tileSizePx + tileSizePx;

            // cache
            System.Drawing.Rectangle rect = new System.Drawing.Rectangle(
                xx1 / tileSizePx, yy1 / tileSizePx,
                (xx2 - xx1) / tileSizePx, (yy2 - yy1) / tileSizePx);

            int max = (int)(scale * zoomElevateUpscale);

            int xcount = xx2 / tileSizePx - xx1 / tileSizePx ;
            int ycount = yy2 / tileSizePx - yy1 / tileSizePx ;
            int total = xcount * ycount;

            frmTileDownloader frm = new frmTileDownloader();
            frm.Show();

            int count = 0;
            for (int x = xx1; x < xx2; x += tileSizePx)
            {
                for (int y = yy1; y < yy2; y += tileSizePx)
                {
                    int picx = x / tileSizePx;
                    int picy = y / tileSizePx;
                    int picZoom = zoom;

                    if (picx >= 0 && picy >= 0 && picx < max && picy < max)
                    {
            //                        drawOneLayerTile(x, y, (int)(tileSizePx), (int)(tileSizePx), oCC, picx, picy, picZoom, false);
                        drawOneLayerTile(picx, picy, picZoom, mapType);
                    }
                    count++;
                }
                //Debug.Print("progress for zoom {0}: {1}/{2}", zoom, count, total);
                string message = String.Format("progress for zoom {0}: {1}/{2}", zoom1, count, total);
                frm.Update(message, 100 * count  / total);
                if (frm.cancel) break;
            }

            frm.Close();
        }