天天看點

基于Tomcat部署的Geoserver配置Geowebcache,并轉發ArcGIS切片

1、将GeowebCache的war包解壓到tomcat的webapp下,打開war包中的WEB-INF中的web.xml檔案,同時建立一個你想儲存geowencache的切片的空檔案夾,例如我命名叫arcgis

基于Tomcat部署的Geoserver配置Geowebcache,并轉發ArcGIS切片
基于Tomcat部署的Geoserver配置Geowebcache,并轉發ArcGIS切片
web.xml檔案中 添加<context-param>節點,param-value是你所建的檔案夾

<context-param>
        <param-name>GEOWEBCACHE_CACHE_DIR</param-name>
        <param-value>D:\Program Files\Apache Tomcat\webapps\geowebcache\WEB-INF\arcgis</param-value>
</context-param>      

2、在重新開機動tomcat 之後我們在arcgis檔案夾中可以看到

基于Tomcat部署的Geoserver配置Geowebcache,并轉發ArcGIS切片

 3、打開webwebcache.xml檔案,在<layer>…</layer>節點中添加如下節點:

<arcgisLayer> 
     <name>arcgis_cache</name>
       <tilingScheme>E:\\tile\\arcgis\\Layers\\conf.xml</tilingScheme>
      <tileCachePath>E:\\tile\\arcgis\Layers\\_alllayers</tileCachePath>
      <hexZoom>false</hexZoom>
</arcgisLayer>      

4、配置完以後我發現我無法啟動geowebcache,日志報錯

10 四月 18:12:15 (main) WARN [support.XmlWebApplicationContext] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gwcXmlConfig' defined in ServletContext resource [/WEB-INF/geowebcache-core-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: No ArcGISCacheGridsetConfiguration could be found
10 四月 18:12:15 (main) ERROR [context.ContextLoader] - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gwcXmlConfig' defined in ServletContext resource [/WEB-INF/geowebcache-core-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: No ArcGISCacheGridsetConfiguration could be found
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1745)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)      

網上找到了解決方法

找到geowebcache-core-context檔案,往裡面添加

<bean id="gwcArcGIGridsetConfigutation" class="org.geowebcache.arcgis.layer.ArcGISCacheGridsetConfiguration"/>       

5、加完之後可以在geowebcache的list中檢視到自己添加的瓦片,但是卻不能預覽,比例尺也是1:NAN

基于Tomcat部署的Geoserver配置Geowebcache,并轉發ArcGIS切片

網上解釋說高版本geowebcache可能無法預覽,檢視他的預覽頁面發現是OL3的庫,因為我用的是OL4的庫,不影響OL或者leaflet加載

6、重新開機一下服務,重新整理一下

var format = 'image/png';
       var tiled = new ol.layer.Tile({
           //visible: false,
           source: new ol.source.TileWMS({
               url: 'http://localhost:8888/geowebcache/service/wms',
               params: {
                   'FORMAT': format,
                   'VERSION': '1.0.0',
                    tiled: true,
                   "LAYERS": 'arcgis_cache',
                   "exceptions": 'application/vnd.ogc.se_inimage',
                   
               }
           })
       });
       var view = new ol.View({
           projection:"EPSG:4326",
           zoom: 13,
           center: [113.33, 34.01]
       });
       var map = new ol.Map({
           target: 'map',
           layers: [tiled],
           view:view
       });      

繼續閱讀