示例#1
0
 internal void FullExtent()
 {
     if (myMap.LayerNum != 0)
     {
         MyRectangle mbr = myMap.GetMBR();
         centerLngLat = new PointF(((float)mbr.MaxX + (float)mbr.MinX) * 0.5F, ((float)mbr.MaxY + (float)mbr.MinY) * 0.5F);
         double x      = ETCProjection.Longitude2X(mbr.MaxX) - ETCProjection.Longitude2X(mbr.MinX);
         double y      = ETCProjection.Latitude2Y(mbr.MaxY) - ETCProjection.Latitude2Y(mbr.MinY);
         double scale1 = x / Width;
         double scale2 = y / Height;
         Ratio      = Math.Max(scale1, scale2);
         scaleIndex = maxZoomLevel;
         UpdateMapImg();
     }
 }
示例#2
0
        /// <summary>
        /// 绘制栅格数据
        /// </summary>
        /// <param name="g"></param>
        /// <param name="bounds"></param>
        /// <param name="centerPos"></param>
        /// <param name="scale"></param>
        internal void DrawSpaceData(Graphics g, Rectangle bounds, PointF centerPos, double scale)
        {
            double x1 = ETCProjection.Longitude2X(minX);
            double x2 = ETCProjection.Longitude2X(maxX);
            double y1 = ETCProjection.Latitude2Y(minY);
            double y2 = ETCProjection.Latitude2Y(maxY);

            double width  = (x2 - x1) / scale;
            double height = (y2 - y1) / scale;

            PointF centerXY = ETCProjection.LngLat2XY(centerPos);

            float      dx       = (centerXY.X - (float)x1) / (float)scale;
            float      dy       = (centerXY.Y - (float)y2) / (float)scale;
            RectangleF boundary = new RectangleF((float)bounds.Width * 0.5F - dx, (float)bounds.Height * 0.5F + dy, (float)width, (float)height);

            g.DrawImage(mapBmp, boundary);
        }
示例#3
0
        /// <summary>
        /// 增加Shapefile图层
        /// </summary>
        /// <param name="shp"></param>
        internal void AddLayer(Shapefile shp)
        {
            myMap.AddLayer(new MyLayer(shp));
            TreeNode layerNode = new TreeNode(shp.Name, 2, 2);

            layerNode.Checked = true;
            centerLngLat      = shp.CenterPos;
            centerXY          = ETCProjection.LngLat2XY(centerLngLat); //同步更新屏幕中心点投影坐标系坐标
            treeViewLayers.Nodes[0].Nodes.Insert(0, layerNode);
            treeViewLayers.ExpandAll();
            double x      = ETCProjection.Longitude2X(shp.Xmax) - ETCProjection.Longitude2X(shp.Xmin);
            double y      = ETCProjection.Latitude2Y(shp.Ymax) - ETCProjection.Latitude2Y(shp.Ymin);
            double scale1 = x / Width;
            double scale2 = y / Height;

            Ratio      = Math.Max(scale1, scale2);
            scaleIndex = maxZoomLevel;
            UpdateMapImg();
        }
示例#4
0
        /// <summary>
        /// 增加栅格图层
        /// </summary>
        /// <param name="grid"></param>
        internal void AddLayer(MyGrid grid)
        {
            myMap.AddLayer(new MyLayer(grid));
            TreeNode layerNode = new TreeNode(grid.Name, 2, 2);

            layerNode.Checked = true;
            treeViewLayers.Nodes[0].Nodes.Insert(0, layerNode);
            treeViewLayers.ExpandAll();
            centerLngLat = new PointF(((float)grid.MaxX + (float)grid.MinX) * 0.5F, ((float)grid.MaxY + (float)grid.MinY) * 0.5F);
            centerXY     = ETCProjection.LngLat2XY(centerLngLat); //同步更新屏幕中心点投影坐标系坐标
            double x      = ETCProjection.Longitude2X(grid.MaxX) - ETCProjection.Longitude2X(grid.MinX);
            double y      = ETCProjection.Latitude2Y(grid.MaxY) - ETCProjection.Latitude2Y(grid.MinY);
            double scale1 = x / Width;
            double scale2 = y / Height;

            Ratio      = Math.Max(scale1, scale2);
            scaleIndex = maxZoomLevel;
            UpdateMapImg();
        }