优胜从选择开始,我们是您省心的选择!—— 无忧期刊网
帮助中心
期刊发表
您的位置: 主页 > 论文范文 > 电子论文 > 正文

基于图形采集技术的电子地图系统设计

作者: 来源: 日期:2014-09-25 22:31人气:

  摘要:传统的GIS系统是采取对区域的电子地图数据进行分级切割,根据判断所显示区域应显示的切割图的索引号对所访问区域进行地图查看。本文所述基于图形采集技术的电子地图,有别于传统模式,只生成5级地图整图,通过直接对应访问区域的判断,将获取的信息传到用户界面,直接访问,避免让用户重复下载没用的切割图,提高访问速度。

  关键词:图形采集;

  Abstract: the traditional GIS system is taken for regional electronic map data classification cutting, according to determine that display area shall display the cut of the graph visited the index number in the area of the map view. This paper based on the collection of graphics technology, electronic map, which is different from the traditional pattern, and generate only level 5 map the whole figure, through the direct access to the judgment of the corresponding region, will obtain the information to the user interface, direct access, avoid lets users download useless cutting repeat figure, improve access speed.

  Keywords: graphics collecting;

  1、 原理及代码实现

  将需要作为地图的原图通过Photoshop软件进行处理,处理成5种不同分辨率的地图,作为地图的分级查看的底图。

  分别为分辨率从1200x1162到19200x18521的五级底图,其中19200x18581.bmp为底层底图,此图大小为0.99G。一般图像处理软件都无法实现对该图的正常操作,不采取本文所述技术就更不能实现通过Internet对该图的访问了。

  进行对图像的处理,我们已经有了底图,下面就是对通过浏览器访问底图的原理介绍:

  因为我们要对BMP图像进行图形采集,我们先介绍一下BMP图像的特点,分析BMP图像格式的数据结构。典型的BMP图像文件由文件头、位图信息头、颜色信息和图形数据四部分组成。其中文件头的数据结构含有BMP文件的类型、文件大小和位图起始位置等信息,占用14个字节;BMP位图信息头数据用于说明位图的尺寸等信息,占用40字节;颜色表用于说明位图中的颜色,它有若干个表项,每一个表项是一个RGBQUAD类型的结构;位图数据记录了位图的每一个像素值,记录顺序是在扫描行内是从左到右,扫描行之间是从下到上。Windows规定一个扫描行所占的字节数必须是4的倍数(即以long为单位),不足的以0填充。

  下面介绍地图实现的方式和方法:

  首先根据用户传输的界面尺寸高度等信息来判断采用哪级的底图。示例代码如下:

  protected void Page_Load(object sender, EventArgs e)

  {

  intleft=(int)float.Parse(Request.QueryString["left"].ToString());

  int top = (int)float.Parse(Request.QueryString["top"].ToString());

  string mapsize = Request.QueryString["mapsize"].ToString();

  string mapname = Server.MapPath("~/Map/120.bmp");

  int Maxwidth = 1200;

  int Maxheigth = 1162;

  switch (mapsize)

  {

  case "1920": mapname = Server.MapPath("~/Map/1920.bmp"); Maxwidth = 19200; Maxheigth = 18581; break;

  case "960": mapname = Server.MapPath("~/Map/960.bmp"); Maxwidth = 9600; Maxheigth = 9291; break;

  case "480": mapname = Server.MapPath("~/Map/480.bmp"); Maxwidth = 4800; Maxheigth = 4646; break;

  case "240": mapname = Server.MapPath("~/Map/240.bmp"); Maxwidth = 2400; Maxheigth = 2323; break;

  case "120": mapname = Server.MapPath("~/Map/120.bmp"); Maxwidth = 1200; Maxheigth = 1162; break;

  }

  GetCurrentMap(mapname, Maxwidth, Maxheigth, 800, 600, left, top);

  }

  根据BMP数据结构对底图的进行数据采集并正确的输出图形的。示例代码如下:

  public void GetCurrentMap(string filename, int Maxwidth, int Maxheigth, int width, int heigth, int left, int top)

  {

  //读BMP文件

  FileStream fs = File.OpenRead(filename);

  //去掉BMP文件头信息

  int begin = 54;

  Maxwidth = Maxwidth * 3;

  width = width * 3;

  left = left * 3;

  //得到当前可视范围,取出区域的图形序列存入二进制数组

  byte[] bys = new byte[width * heigth];

  fs.Seek(Maxwidth * (Maxheigth - top - heigth) + left + begin, SeekOrigin.Begin);

  fs.Read(bys, 0, width);

  for (int i = heigth - 1; i > 0; i--)

  {

  fs.Seek(Maxwidth - width, SeekOrigin.Current);

  fs.Read(bys, width * i, width);

  }

  for (int i = 0; i < width; i++)

  {

  bys[i] = 255;

  }

  //新建一张图,讲上一步取出的图形序列填充入新图

  Bitmap bmp = new Bitmap(width / 3, heigth, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

  Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);

  System.Drawing.Imaging.BitmapData bmpData =

  bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite,

  bmp.PixelFormat);

  IntPtr ptr = bmpData.Scan0;

  System.Runtime.InteropServices.Marshal.Copy(bys, 0, ptr, bys.Length);

  bmp.UnlockBits(bmpData);

  System.IO.MemoryStream stream = new System.IO.MemoryStream();

  bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png);

  //输出正确的图像

  Response.Clear();

  Response.ContentType = "image/png";

  Response.BinaryWrite(stream.ToArray());

  }

  2、 系统实现效果如下:

  地图首级显示效果 系统五级显示效果

  3、 结语

  通过这种技术,通过Internet访问的电子地图系统,节省了大量的网络资源,极大的提升了系统的访问速度。希望该技术能广泛的应用于电子地图开发。

在线客服:

无忧期刊网 版权所有   

【免责声明】:所提供的信息资源如有侵权、违规,请及时告知。

专业发表机构