基於Tomcat部署的Geoserver配置Geowebcache,並轉發ArcGIS切片


1、將GeowebCache的war包解壓到tomcat的webapp下,打開war包中的WEB-INF中的web.xml文件,同時創建一個你想保存geowencache的切片的空文件夾,例如我命名叫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文件夾中可以看到

 

 

 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

 

 

網上解釋說高版本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
       });


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM