1.检查mysql版本,应在8以上
2.下载geoserver及mysql拓展(版本需在2.19.x以上,2.21.2版本测试可行)
3.将mysql拓展中的jar包放到[container]/webapps/geoserver/WEB-INF/lib/路径下
4.在[container]/bin/startup.bat中重启geoserver
5.存储仓库-mysql连接数据库
6.发布图层,根据数据库数据设置坐标系
ps:
1.数据库创建示例:
Mysql加入测试数据
创建表:
CREATE
TABLE `points` (
`id` int NULL ,
`name` varchar(255) NULL ,
`x` varchar(255) NULL ,
`y` varchar(255) NULL ,
`location` point NULL
);
插入测试数据:
INSERT INTO `points` VALUES (1, '圆明园', '116.310558',
'40.014033', ST_GeomFromText('POINT(116.311 40.014)'));
INSERT INTO `points` VALUES (2, '清华大学', '116.335279',
'40.010497', ST_GeomFromText('POINT(116.335 40.0105)'));
INSERT INTO `points` VALUES (3, '颐和园', '116.277787',
'116.277787', ST_GeomFromText('POINT(116.278 40.0065)'));
INSERT INTO `points` VALUES (4, '天安门', '116.404844',
'39.915378', ST_GeomFromText('POINT(116.405 39.9154)'));
INSERT INTO `points` VALUES (5, '北京站', '116.434164',
'39.910065', ST_GeomFromText('POINT(116.434 39.9101)'));
INSERT INTO `points` VALUES (6, '卢沟桥', '116.224895',
'39.85647', ST_GeomFromText('POINT(116.225 39.8565)'));
INSERT INTO `points` VALUES (7, '北京西站', '116.32723',
'39.901652', ST_GeomFromText('POINT(116.327 39.9025)'));
INSERT INTO `points` VALUES (8, '北京首都国际机场', '116.612388',
'40.085613', ST_GeomFromText('POINT(116.612 39.9025)'));
2.geoserver asWKB does no exist
参考:geoserver asWKB does no exist_aswkb does not exist_胡云台的博客-CSDN博客
一般需升级geoserver的版本,mysql拓展版本与geoserver版本需一致
3.ST_GeomFromText
参考:ST_GeomFromText—帮助 | ArcGIS Desktop
点:
st_geomfromtext ('point (10.02 20.01)')
st_geomfromtext ('point (10.02 20.01)', 4326)
线:
st_geomfromtext('linestring (10.01 20.01, 10.01 30.01, 10.01 40.01)')
st_geomfromtext('linestring (10.01 20.01, 10.01 30.01, 10.01 40.01)', 4326)
面:
st_geomfromtext('polygon ((10.02 20.01, 11.92 35.64, 25.02 34.15, 19.15 33.94, 10.02 20.01))')
st_geomfromtext('polygon ((10.02 20.01, 11.92 35.64, 25.02 34.15, 19.15 33.94, 10.02 20.01))', 4326)
多点:
st_geomfromtext('multipoint (10.02 20.01, 10.32 23.98, 11.92 25.64)') ;
st_geomfromtext('multipoint (10.02 20.01, 10.32 23.98, 11.92 25.64)', 4326);
多线:
st_geomfromtext ('multilinestring ((10.02 20.01, 10.32 23.98, 11.92 25.64), (9.55 23.75, 15.36 30.11))')
st_geomfromtext ('multilinestring ((10.02 20.01, 10.32 23.98, 11.92 25.64), (9.55 23.75, 15.36 30.11))', 4326)
多面:
st_geomfromtext ('multipolygon (((10.02 20.01, 11.92 35.64, 25.02 34.15, 19.15 33.94, 10.02 20.01), (51.71 21.73, 73.36 27.04, 71.52 32.87, 52.43 31.90, 51.71 21.73)))')
st_geomfromtext ('multipolygon (((10.02 20.01, 11.92 35.64, 25.02 34.15, 19.15 33.94, 10.02 20.01), (51.71 21.73, 73.36 27.04, 71.52 32.87, 52.43 31.90, 51.71 21.73)))', 4326)