【GIS】矢量瓦片,GeoServer+Mapbox

项目需要,要用Mapbox渲染较大量的建筑数据,考虑到数据加载(下载)的效率需要采用瓦片的形式
总体方案为本地有shp或geojson数据,用Geoserver切片和发布服务,Mapbox调用

数据介绍

处理后的OSM数据,曼哈顿街区范围,保留高度字段,加个是否显示的标记用于测试filter功能


GeoServer

Tips:
Publishing a GeoServer Layer for use with Mapbox Styles
本文用GeoServer 2.13.0版本
注意安装Geoserver需要安装了JRE
注意制作切片需要切片扩展,将jar包复制到...\GeoServer 2.13.0\webapps\geoserver\WEB-INF\lib下
安装成功后,先Start GeoServer,再打开Admin Page
跨域问题:https://blog.csdn.net/longshengguoji/article/details/53352888
(待考证)Mapbox矢量切片目前仅支持EPSG:900913

流程:安装Geoserver(及JRE、矢量切片扩展)——新建工作区——添加数据/发布——编辑数据Tile Caching——跨域问题——mapbox调用


GeoServer+切片扩展
切片扩展
需要JRE
start
Admin Page
新建工作区
添加数据
编辑图层
切片图层
切片预览
跨域问题

Mapbox调用示例

<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8' />
    <title>Join local JSON data with vector tile geometries</title>
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
    <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.45.0/mapbox-gl.js'></script>
    <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.45.0/mapbox-gl.css' rel='stylesheet' />
    <style>
        body { margin:0; padding:0; }
        #map { position:absolute; top:0; bottom:0; width:100%; }
    </style>
</head>
<body>
<div id='map'>
</div>
<script>
    mapboxgl.accessToken =<your token>;
    var map = new mapboxgl.Map({
        container: 'map', 
        style: 'mapbox://styles/mapbox/streets-v9', 
        center: [-73.95, 40.78], 
        zoom: 13
    });
    map.on('load', function() {
        map.addSource('xixi',{
            'type':'vector',
            'scheme':'tms',
            'tiles':['http://localhost:8080/geoserver/gwc/service/tms/1.0.0/myTest%3AbigBuildings@EPSG:900913@pbf/{z}/{x}/{y}.pbf']
        });

        map.addLayer({
            'id': '3d-buildings',
            'source': 'xixi',
            'source-layer':'bigBuildings',
            'type': 'fill-extrusion',
            'paint': {
                'fill-extrusion-color': [
                    'interpolate',
                    ['linear'],
                    ['get', 'height'],
                    0, 'rgb(255,255,191)',
                    75, 'rgb(253,174,97)',
                    150, "rgb(215,25,28)",
                ],
                'fill-extrusion-height': ['get', 'height'],
                'fill-extrusion-opacity': .8
            }
        });
    });
</script>

</body>
</html>

非常重要!
注意地址:

        map.addSource('xixi',{
            'type':'vector',
            'scheme':'tms',
            'tiles':['http://localhost:8080/geoserver/gwc/service/tms/1.0.0/myTest%3AbigBuildings@EPSG:900913@pbf/{z}/{x}/{y}.pbf']
        });

这个地址可以从主页tms1.0.0处获得


image.png

image.png
image.png
image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,982评论 19 139
  • //我所经历的大数据平台发展史(三):互联网时代 • 上篇http://www.infoq.com/cn/arti...
    葡萄喃喃呓语阅读 51,329评论 10 200
  • 现在很多的父母都给孩子充分的自由,觉得“只要他喜欢就好。” 但越来越多的事实证明,养成良好的习惯是一个人独立于社会...
    一生所求8阅读 388评论 0 1
  • 07年,柳州火车站。长沙到柳州。刚下火车的我肚子唱起了空城计,于是在熙熙攘攘的人群中找到一家螺蛳粉店子。店子里...
    桌子的生活观阅读 1,034评论 2 2
  • 亲爱的孩子,今天我们一起去学校开学报名了,你和妈妈说,太想去上学了!有想法,付诸行动,一切不是问题,新的学期,我们...
    Cindycindycindy阅读 103评论 0 1