Пример #1
0
        /// <summary>
        /// 构建碎片
        /// </summary>
        private void BindFragments()
        {
            this.MapFragments = new List<MapFragment>();
            float xCount = this.End.X - this.Start.X;
            float yCount = this.End.Y - this.Start.Y;

            //垂直方向碎片总数
            int VerticalSizeCount = (int)Math.Abs(yCount);
            //水平方向总数
            int HorizontalSizeCount = (int)Math.Abs(xCount);

            //初始化瓦片拼接图像大小
            this.AreaSize = new Map.Size()
            {
                Width = HorizontalSizeCount * (int)this.FragmentSize.Width,
                Height = VerticalSizeCount * (int)this.FragmentSize.Height
            };

            //圆点坐标:左下角
            //行单位总数循环
            for (int i = 0; i < HorizontalSizeCount; i++)
            {
                //列单位总数循环
                for (int j = 0; j < VerticalSizeCount; j++)
                {
                    #region 构建碎片请求Url地址
                    MapFragment fragment = new MapFragment();
                    fragment.FragmentSize = this.FragmentSize;

                    float x = 0;
                    float y = 0;

                    //水平方向循环
                    if (xCount < 0)
                    {
                        //水平向左步进
                        x = this.Start.X - (i + 1);
                    }
                    else
                    {
                        //水平向右步进
                        x = this.Start.X + (i + 1);
                    }

                    //垂直方向循环
                    if (yCount < 0)
                    {
                        //垂直向下步进
                        y = this.Start.Y - (j + 1);
                    }
                    else
                    {
                        //垂直向上步进
                        y = this.Start.Y + (j + 1);
                    }

                    //替换Url模板标签x,y
                    string tempUrlTemplate = this.UrlTemplate;
                    tempUrlTemplate = tempUrlTemplate.Replace("{POINTX}", x.ToString());
                    tempUrlTemplate = tempUrlTemplate.Replace("{POINTY}", y.ToString());
                    fragment.DownloadUrl = tempUrlTemplate;

                    this.MapFragments.Add(fragment);
                    #endregion
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 构建碎片
        /// </summary>
        private void BindFragments(string savepath)
        {
            this.MapFragments = new List <MapFragment>();
            float xCount = this.End.X - this.Start.X;
            float yCount = this.End.Y - this.Start.Y;

            //垂直方向碎片总数
            int VerticalSizeCount = (int)Math.Abs(yCount);
            //水平方向总数
            int HorizontalSizeCount = (int)Math.Abs(xCount);

            //初始化瓦片拼接图像大小
            this.AreaSize = new Map.Size()
            {
                Width  = HorizontalSizeCount * (int)this.FragmentSize.Width,
                Height = VerticalSizeCount * (int)this.FragmentSize.Height
            };

            //圆点坐标:左下角
            //行单位总数循环
            for (int i = 0; i < HorizontalSizeCount; i++)
            {
                //列单位总数循环
                for (int j = 0; j < VerticalSizeCount; j++)
                {
                    #region 构建碎片请求Url地址
                    MapFragment fragment = new MapFragment();
                    fragment.FragmentSize = this.FragmentSize;

                    float x = 0;
                    float y = 0;

                    //水平方向循环
                    if (xCount < 0)
                    {
                        //水平向左步进
                        x = this.Start.X - (i + 1);
                    }
                    else
                    {
                        //水平向右步进
                        x = this.Start.X + (i + 1);
                    }

                    //垂直方向循环
                    if (yCount < 0)
                    {
                        //垂直向下步进
                        y = this.Start.Y - (j + 1);
                    }
                    else
                    {
                        //垂直向上步进
                        y = this.Start.Y + (j + 1);
                    }

                    //替换Url模板标签x,y
                    string tempUrlTemplate = this.UrlTemplate;
                    tempUrlTemplate      = tempUrlTemplate.Replace("{POINTX}", x.ToString());
                    tempUrlTemplate      = tempUrlTemplate.Replace("{POINTY}", y.ToString());
                    fragment.DownloadUrl = tempUrlTemplate;

                    /*瓦片图片索引文件名称*/
                    fragment.Format   = ImageFormat.Png;
                    fragment.FileName = string.Format("{0}-{1}.{2}", x.ToString(), y.ToString(), fragment.Format.ToString());
                    fragment.SavePath = savepath;

                    this.MapFragments.Add(fragment);
                    #endregion
                }
            }
        }