OpenGIS

GeoWebCache发布切片数据

2018-01-31  本文已影响167人  王顼

自己写了个小工具,用于下载网络地图的切片数据,一直都是将下载好的切片发布到ArcGIS Server上去,今年决定拥抱开源,尝试使用GeoWebCache发布切片。


机器环境

Oracle JDK8
Tomcat 8.5
GeoWebCache 1.12.1
ArcMap 10.2

1.GeoWebCache基本配置

<context-param>    
  <param-name>GEOWEBCACHE_CACHE_DIR</param-name>    
  <param-value>E:\\myTile</param-value>    
</context-param> 

2.切片发布

    <arcgisLayer>
        <name>map</name>
        <tilingScheme>E:\\map\\Conf.xml</tilingScheme>
        <tileCachePath>E:\\map\\_alllayers\\</tileCachePath>
    </arcgisLayer>

3.切片预览

<!DOCTYPE html>
<html>
  <head>
    <title>WMTS</title>
    <link rel="stylesheet" href="https://openlayers.org/en/v4.6.4/css/ol.css" type="text/css">
    <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
    <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
    <script src="https://openlayers.org/en/v4.6.4/build/ol.js"></script>
  </head>
  <body>
    <div id="map" class="map"></div>
    <script>
      var projection = ol.proj.get('EPSG:3857');
      var projectionExtent = projection.getExtent();
      var size = ol.extent.getWidth(projectionExtent) / 256;
      var resolutions = new Array(14);
      var matrixIds = new Array(14);
      for (var z = 0; z < 14; ++z) {
        // generate resolutions and matrixIds arrays for this WMTS
        resolutions[z] = size / Math.pow(2, z);
        matrixIds[z] = 'EPSG:900913_map:'+z;
      }

      var map = new ol.Map({
        layers: [
          new ol.layer.Tile({
            opacity: 0.7,
            source: new ol.source.WMTS({
              attributions: 'GeoWebCache Tiles ©',
              url: 'http://localhost:9080/geowebcache/service/wmts',
              layer: 'map',
              matrixSet: 'EPSG:900913_map',
              format: 'image/png',
              projection: projection,
              tileGrid: new ol.tilegrid.WMTS({
                origin: ol.extent.getTopLeft(projectionExtent),
                resolutions: resolutions,
                matrixIds: matrixIds
              }),
              style: 'default',
              wrapX: true
            })
          })
        ],
        target: 'map',
        controls: ol.control.defaults({
          attributionOptions: {
            collapsible: false
          }
        }),
        view: new ol.View({
          center: [8375524, 4573882],
          zoom: 5
        })
      });
    </script>
  </body>
</html>
上一篇下一篇

猜你喜欢

热点阅读