geoserver配置及openlayers应用

geoserver配置及openlayers应用
geoserver配置及openlayers应用

geoserver与OpenLayers配置

目录

1准备工作 (3)

1.1需要用到的程序和资料 (3)

2地图格式转换方式(一) (4)

3地图格式转换方式(二) ................................................................................. 错误!未定义书签。

3.1解压地图 ............................................................................................... 错误!未定义书签。

3.2打开地图 ............................................................................................... 错误!未定义书签。

3.3导出图层 ............................................................................................... 错误!未定义书签。

3.4转换MIF格式为SHP格式 .................................................................... 错误!未定义书签。4GEOSERVER安装配置. (4)

4.1G EO S ERVER安装 (4)

4.2配置地图 (4)

4.2.1登录geoserver (4)

4.2.2配置数据 (5)

4.2.3新建数据集 (6)

4.2.4新建Feature Type (8)

4.2.5应用保存配置 (9)

4.2.6访问地图 (12)

5OPENLAYERS配置 (13)

5.1测试页面 (13)

5.2部署示例 (18)

5.3查看效果 (18)

5.4加上GOOGLEMAP图层 (18)

5.4.1申请Google 地图API 的key (18)

5.4.1.1将域名映射到本地 (18)

5.4.2编辑html (19)

5.4.3查看效果 (19)

6GEOSERVER高级设置 (20)

6.1自定义图层的S TYLE (20)

6.2查看图层的字段信息 (23)

6.3在T OMCA T上部署G EO S ERVER (24)

6.4自定义名称空间 (25)

7参考资料 (28)

1准备工作

相关资料文件下载

1.1 需要用到的程序和资料

1.JDK 1.6 :

https://www.360docs.net/doc/9812695373.html,/software/java_se/jdk-6u3-windows-i586-p.exe

安装好JDK1.6

2.MapInfo Professional 6.4 SCP中文版或者8.5 /9.5/10.0英文版

安装好Mapinfo

3.geoserver 1.5.4 或者1.6.0 Rc2或者2.0.2

https://www.360docs.net/doc/9812695373.html,/sourceforge/geoserver/geoserver-1.5.4a.bin.zip

https://www.360docs.net/doc/9812695373.html,/sourceforge/geoserver/geoserver-1.5.4a.src.zip

https://www.360docs.net/doc/9812695373.html,/sourceforge/geoserver/geoserver-1.5.4a.war.zip

https://www.360docs.net/doc/9812695373.html,/sourceforge/geoserver/geoserver-1.6.0-RC2-war.zip

https://www.360docs.net/doc/9812695373.html,/sourceforge/geoserver/geoserver-1.6.0-RC2-pyramid-plugin.zip https://www.360docs.net/doc/9812695373.html,/sourceforge/geoserver/geoserver-1.6.0-RC2-mysql-plugin.zip 来源:https://www.360docs.net/doc/9812695373.html,/display/GEOS/Download

4.Openalyers 2.5

https://www.360docs.net/doc/9812695373.html,/download/OpenLayers-2.5.zip

来源:https://www.360docs.net/doc/9812695373.html,/

5.地图一份

来源:各个现场提供的mapinfo地图或者ESRI公司的shapfile文件

6.地图格式转换工具【选用】

https://www.360docs.net/doc/9812695373.html,/Download/download/2006/datatransfer.rar

来源:https://www.360docs.net/doc/9812695373.html,/Download/Showsoft.asp?Type=1&ID=216

7.Apache Tomcat 6.0.14【选用】

https://www.360docs.net/doc/9812695373.html,/tomcat/tomcat-6/v6.0.14/bin/apache-tomcat-6.0.14.zip https://www.360docs.net/doc/9812695373.html,/tomcat/tomcat-6/v6.0.14/src/apache-tomcat-6.0.14-src.zip 来源:https://www.360docs.net/doc/9812695373.html,/

2地图格式转换方式(一)

Mapinfo 8.5中,主菜单--> Tools -->Universal Translator--> Universal Translator Source file 中选择要被转换的所有tab文件,类型为mapinfo;

Target file 选择shapfile文件格式,选中文件存放的路径

3GeoServer安装配置

GeoServer1.5和最新的2.0.2操作基本类似,现以1.5为来讲解。

3.1 GeoServer安装

解压geoserver-1.5.4a.bin.zip到E:\gis\geoserver,

运行E:\gis\geoserver\bin\startup.bat

3.2 配置地图

打开浏览器,访问:http://localhost:8080/geoserver/

3.2.1登录geoserver

点“配置”,在登录界面输入用户名'admin',密码'geoserver'

3.2.2配置数据

登录成功之后,再点“配置”。在配置界面,点“数据”。

在数据配置界面,点“数据库”。

3.2.3新建数据集

在Feature数据集配置界面,点“新建”

在新建界面,Feature 数据描述类型,选择Shaperfile,Feature数据集ID,输入“szmap_bingguanjiudian”,点“新建”

(此时,由于地图信息还没部署,因此,先将shape格式的数据文件复制到E:\gis\geoserver\data_dir\data\szmapnew。)

在数据文件配置界面中,url填写为:file:data/szmapnew/bingguanjiudian_custom_point.shp (表示对应E:\gis\geoserver\data_dir\data\szmapnew\bingguanjiudian_custom_point.shp) Charset填写为:GBK,点“提交”。

3.2.4新建Feature Type

文件加载成功,进入Feature Type编辑界面,样式选择point,SRS填写为4326,点生成.

再点“提交”。(千万不要勾上启用缓存,我就是勾上它,结果导致创建的FeaTure Type无法保存,走了弯路)

3.2.5应用保存配置然后先点左上角的“应用”,

再点“保存”。

重复上述步骤可配置多个图层。

数据集的信息保存在

E:\gis\geoserver\data_dir\ catalog.xml

featureTypes信息保存在E:\gis\geoserver\data_dir\featureTypes

catalog.xml内容节选为:

(文件重新加载保存之后,原有的注释说明不见了。)

3.2.6访问地图

回到首页欢迎界面,点“Mapbuilder 客户端”

找到topp:bingguanjiudian_custom_point,点Openlayers。

把地图缩放比例拉到最小,然后点其中一个标注点,网页下面会显示出查询到的信息。

4Openlayers配置

4.1 测试页面

编写测试页面,内容如下:

OpenLayers map preview

Untiled

Tiled

Click on the map to get feature infos

4.2 部署示例

将该页面保存到E:\gis\geoserver\webapps\geoserver\5.htm

4.3 查看效果

访问http://localhost:8080/geoserver/5.htm拖动图层,并可点击数据

4.4 加上googlemap图层

4.4.1申请Google 地图API 的key

https://www.360docs.net/doc/9812695373.html,/intl/zh-CN/apis/maps/signup.html

申请的url填写为:https://www.360docs.net/doc/9812695373.html,:8080/

4.4.1.1 将域名映射到本地

编辑hosts文件,将https://www.360docs.net/doc/9812695373.html,映射为127.0.0.1.否则在本地加载不了google map.

4.4.2编辑html

参考E:\gis\tools\OpenLayers\examples\google.html

增加google map的js引用

增加图层

var googlesatellite = new https://www.360docs.net/doc/9812695373.html,yer.Google( "Google Satellite" , {type: G_SATELLITE_MAP, 'maxZoomLevel':18} );

map.addLayers([googlesatellite]);

var googlebybrid = new https://www.360docs.net/doc/9812695373.html,yer.Google( "Google Hybrid" , {type: G_HYBRID_MAP });

map.addLayers([googlebybrid]);

var GMapsStreets = new https://www.360docs.net/doc/9812695373.html,yer.Google( "Google Steets" , {type: G_NORMAL_MAP, 'maxZoomLevel':18} );

map.addLayers([GMapsStreets]);

4.4.3查看效果

从图上可以看出mapinfo地图数据和google的卫星照片没有对齐。

5GeoServer高级设置

5.1 自定义图层的Style

参考E:\gis\geoserver\data_dir\styles\ poi.sld,我自己定义了一个mypoi的样式,但是由于geoserver直接显示中文存在问题,于是先将显示的名称定义成了拼音。

Mypoi.sld的内容如下:

xsi:schemaLocation="https://www.360docs.net/doc/9812695373.html,/sld StyledLayerDescriptor.xsd"

xmlns="https://www.360docs.net/doc/9812695373.html,/sld" xmlns:ogc="https://www.360docs.net/doc/9812695373.html,/ogc"

xmlns:xlink="https://www.360docs.net/doc/9812695373.html,/1999/xlink"

xmlns:xsi="https://www.360docs.net/doc/9812695373.html,/2001/XMLSchema-instance">

poi

circle

#FF0000

1.0

11

相关主题
相关文档
最新文档