概况
GeoServer是基于Java的软件服务器,允许用户查看和编辑地理空间数据。 使用开放地理空间联盟(OGC)提出的开放标准,GeoServer在地图创建和数据共享方面具有极大的灵活性。这是官方的介绍,其实看它的名字,不难理解,是一种服务,它可以创建各种格式的地图,根据数据可以呈现为png/jpeg格式的图片,使数据可视化。
接触地图,使用openlayers挺长时间,请求了很多GeoServer的图层,但是GeoServer如何发布图层?确实是不懂,最近有点时间,来学习一下GeoServer部署和图层发布。
一、环境部署
1、JDK安装,还是看看别人的吧[捂脸] 附上JDK安装链接
二、GeoServer部署
(1)首先GeoServer官网下载,我下载的是中间这个,稳定版。

点进去可以看到第一个【Packages】,再进去就是这样的,右下角会弹出一个框,需要注册,按步骤注册就可以下载了(如果不需要就忽略)


下载下来解压后的目录是这样

找到【bin】目录里面有【startup.bat】文件,双击,就可以启动GeoServer服务了。


需要等待几分钟,直到停止,默认的端口是8080,需要改变端口的可以在这里修改


启动完之后打开【http://localhost:8080/geoserver/web/】

输入账号密码,默认账号:admin 密码:geoserver,登录之后就是这样啦

三、发布图层
数据准备
发布图层需要数据,找了一圈,下载了一个太乐地图下载器,下载地址http://www.uzzf.com/soft/144096.html,下载完之后点击.exe文件一步一步安装,我装在D盘,安装完之后可以看到目录下面有AZMap.exe,双击就可以启动。

之后可以看到界面,左上角的【地图切换】,你可以根据自己的需求来下载自己想要的地图。

比如我下载了百度地图广东省广州市的卫星图

选择行政区划->下载地图->选择级别(免费试用版最大可以下载15级别)->确定->到下载任务->下载完之后右下角弹出【是否导出】选择【是】->导出选项选择图片格式、级别、压缩算法(选择超级无损压缩)




我在data_dir文件夹下面建了一个gd文件夹,把这个L15.tif文件放进来

到目前为止,我们的环境部署,数据资源全部都已经准备完成了,接下载就是真正进入到GeoServer发布图层了
发布图层有三个步骤
1. 添加工作区



2. 添加数据存储




2. 发布图层



可以在【Layer Preview】查看发布图层



添加到地图上,下载的地图有水印,因为我用的是免费试用版【口袋空空】(网上应该有破解版,大家可以下载破解版)


四、扩展:创建样式并应用到图层上


去到【图层】选择一个图层,切换到【发布】


滚动到下面的【WMS Settings】【Default Style】选择刚刚创建的样式,点击保存即可

五、总结
其实在真正开发过程中,很多时候发布图层,是通过连接数据库发布,一般发布的方式有两种PostGIS 和Shapefile,但是数据库,我也不大了解,以后有机会吧。
网友评论