文章目录
显示s-57海图 (三)
上一章我们完成了完成切片。本章完成切片导入geoserver。
1. 下载geoserver 2.21.0
https://jaist.dl.sourceforge.net/project/geoserver/GeoServer/2.21.0/geoserver-2.21.0-bin.zip
2. 下载GeoWebCache 1.21.0
https://sourceforge.net/projects/geowebcache/files/geowebcache/1.21.0/
3. 修改Geoserver的GeoWebCache配置
3.1 拷贝文件
拷贝geowebcache/WEB-INF/lib/gwc-arcgiscache-1.21.0.jar至D:\geoserver-2.21.0-bin\webapps\geoserver\WEB-INF\lib目录下;
3.2 解压、拷贝文件
解压D:\geoserver-2.21.0-bin\webapps\geoserver\WEB-INF\lib\gs-gwc-2.21.0.jar至D:\gs-gwc-2.21.0文件夹;
拷贝geowebcache/WEB-INF/geowebcache-arcgiscache-context.xml至D:\gs-gwc-2.21.0文件夹
3.3 编辑geowebcache-core-context.xml文件
打开D:\gs-gwc-2.21.0文件夹下的geowebcache-core-context.xml文件,添加以下代码:
<bean id="gwcArcGIGridsetConfigutation" class="org.geowebcache.arcgis.layer.ArcGISCacheGridsetConfiguration"/>
修改后的完整geowebcache-core-context.xml文件如下
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<description>
Bean configuration file for the gwc-core module
</description>
<bean id="geoWebCacheExtensions" class="org.geowebcache.GeoWebCacheExtensions"/>
<bean id="geoWebCacheEnvironment" class="org.geowebcache.GeoWebCacheEnvironment" depends-on="geoWebCacheExtensions"/>
<bean id="gwcAppCtx" class="org.geowebcache.util.ApplicationContextProvider" />
<bean id="gwcXmlConfigResourceProvider" class="org.geoserver.gwc.config.GeoserverXMLResourceProvider">
<constructor-arg value="geowebcache.xml" />
<constructor-arg ref="resourceStore" />
</bean>
<!-- The location of a static configuration file for GeoWebCache.
By default this lives in WEB-INF/classes/geowebcache.xml -->
<bean id="gwcXmlConfig" class="org.geowebcache.config.XMLConfiguration">
<constructor-arg ref="gwcAppCtx" />
<constructor-arg ref="gwcXmlConfigResourceProvider" />
<property name="template" value="/geowebcache_empty.xml">
<description>Create an empty geoebcache.xml in data_dir/gwc as template</description>
</property>
</bean>
<!-- If you like to automatically configure GWC from a WMS Getcapabilities document,
change the values below. The last constructor-arg lets you specify parameters
that are appended to every WMS request to the backed, for example:
"format_options=regionate_by:auto&bgcolor=0x112233"
You also need to uncomment gwcWMSConfig in the gwcTLDispatcher bean!
-->
<!--bean id="gwcWMSConfig" class="org.geowebcache.config.wms.GetCapabilitiesConfiguration">
<constructor-arg ref="gwcGridSetBroker">
</constructor-arg>
<constructor-arg value="http://demo.mapserver.org/cgi-bin/mapserv?map=/osgeo/mapserver/msautotest/world/world.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities">
<description>The URL to the WMS GetCapabilities document, notice & , port is normally 8080</description>
</constructor-arg>
<constructor-arg value="image/png">
<description>The formats to support for all layers read for the above document</description>
</constructor-arg>
<constructor-arg value="3x3">
<description>Metatiling factors, 3x3 is usually a good compromise for vector data</description>
</constructor-arg>
<constructor-arg value="map=/osgeo/mapserver/msautotest/world/world.map">
<description>
Vendor parameters, these are appended to every request sent to the backend.
If you use MapServer you probably want to set this to "map=name". Leave the value attribute empty if you don't need
to add any vendor specific parameter.
</description>
</constructor-arg>
<constructor-arg value="false">
<description>Whether to allow cached=false to specificed for certain requests</description>
</constructor-arg>
</bean-->
<!-- For each configuration bean above, add them below to activate -->
<bean id="gwcTLDispatcher" class="org.geowebcache.layer.TileLayerDispatcher" depends-on="gwcCatalogConfiguration,geoWebCacheExtensions">
<description>
TileLayerDispatcher serves up TileLayers from the available Configurations in the application context
</description>
<constructor-arg ref="gwcGridSetBroker"/>
</bean>
<bean id="gwcBlobStoreAggregator" class="org.geowebcache.storage.BlobStoreAggregator">
<description>
BlobStoreAggregator serves up BlobStoreInfos from the available Configurations in the application context
</description>
</bean>
<bean id="gwcDefaultStorageFinder" class="org.geowebcache.storage.DefaultStorageFinder">
<constructor-arg ref="gwcAppCtx" />
</bean>
<bean id="gwcBlobStore" class="org.geowebcache.storage.CompositeBlobStore" destroy-method="destroy">
<constructor-arg ref="gwcTLDispatcher"/>
<constructor-arg ref="gwcDefaultStorageFinder" />
<constructor-arg ref="gwcBlobStoreAggregator"/>
<constructor-arg ref="gwcXmlConfig"/>
</bean>
<!-- Static definition of where to put the blobstore.
Note that the directory MUST EXIST when GWC is started. -->
<!-- bean id="gwcBlobStore" class="org.geowebcache.storage.blobstore.file.FileBlobStore" destroy-method="destroy">
<constructor-arg value="/tmp/gwc_blobstore" />
</bean -->
<bean id="gwcStorageBroker" class="org.geowebcache.storage.DefaultStorageBroker" destroy-method="destroy">
<constructor-arg ref="gwcConfigBlobStore" />
<constructor-arg>
<bean class="org.geowebcache.storage.TransientCache">
<constructor-arg index="0" value="100"/>
<constructor-arg index="1" value="1024"/>
<constructor-arg index="2" value="2000"/>
</bean>
</constructor-arg>
</bean>
<bean id="gwcGridSetBroker" class="org.geowebcache.grid.GridSetBroker">
<constructor-arg>
<list>
<bean id="defaultGridsets" class="org.geowebcache.config.DefaultGridsets">
<!-- Should we used EPSG:900913 instead of EPSG:3857 ? -->
<constructor-arg type="boolean" value="TRUE" />
<!--
Should the default grids be named EPSG:4326 and EPSG:900913 (TRUE),
or (FALSE) use the new names similar to what WMTS suggests,
GlobalCRS84Geometric and GoogleMapsCompatible ?
If you say FALSE here, you have to manually
rename the directories and entries in the H2 database.
-->
<constructor-arg type="boolean" value="TRUE" />
</bean>
</list>
</constructor-arg>
</bean>
<bean id="gwcRuntimeStats" class="org.geowebcache.stats.RuntimeStats" destroy-method="destroy">
<!-- The poll interval, the number of seconds until counters are aggregated -->
<constructor-arg type="int" value="3" />
<!-- The intervals (in seconds) for which aggregates are reported.
Each interval must be a multiple of the poll interval above and
listed in ascending order. For example, for a maximum interval
of 60 seconds and 3 second poll interval from above, the amount
of memory consumed is (60 / 3) * 8 = 160 bytes
-->
<constructor-arg>
<list>
<value>3</value>
<value>15</value>
<value>60</value>
</list>
</constructor-arg>
<!-- Descriptive texts for each of the intervals above -->
<constructor-arg>
<list>
<value>3 seconds</value>
<value>15 seconds</value>
<value>60 seconds</value>
</list>
</constructor-arg>
</bean>
<!-- controller for handling all incoming requests -->
<bean id="geowebcacheDispatcher" class="org.geowebcache.GeoWebCacheDispatcher" destroy-method="destroy">
<constructor-arg ref="gwcTLDispatcher"/>
<constructor-arg ref="gwcGridSetBroker"/>
<constructor-arg ref="gwcStorageBroker"/>
<constructor-arg ref="gwcBlobStoreAggregator"/>
<constructor-arg ref="gwcXmlConfig"/>
<constructor-arg ref="gwcRuntimeStats"/>
<property name="defaultStorageFinder" ref="gwcDefaultStorageFinder"/>
<property name="securityDispatcher" ref="gwcSecurityDispatcher"/>
<property name="servletPrefix" value="gwc"/>
</bean>
<!-- Thread pool for seeding -->
<bean id="gwcSeederThreadPoolExec"
class="org.geoserver.gwc.seed.SeederThreadLocalTransferExecutor">
<constructor-arg value="16"/><!-- Size of core pool -->
<constructor-arg value="32"/><!-- Maximum size of pool -->
</bean>
<!-- Breeder (the one that seeds) -->
<bean id="gwcTileBreeder" class="org.geowebcache.seed.TileBreeder">
<property name="tileLayerDispatcher" ref="gwcTLDispatcher"/>
<property name="threadPoolExecutor" ref="gwcSeederThreadPoolExec"/>
<property name="storageBroker" ref="gwcStorageBroker"/>
</bean>
<bean id="gwcProxyDispatcher"
class="org.geowebcache.proxy.ProxyDispatcher"/>
<!-- Lock providers -->
<bean id="noLock" class="org.geowebcache.locks.NoOpLockProvider"/>
<bean id="gwcURLMangler" class="org.geoserver.gwc.ResponseUtilsURLMangler" />
<bean id="gwcSecurityDispatcher" class="org.geowebcache.filter.security.SecurityDispatcher" />
<bean id="memoryLock" class="org.geowebcache.locks.MemoryLockProvider"/>
<bean id="nioLock" class="org.geowebcache.locks.NIOLockProvider">
<constructor-arg ref="gwcDefaultStorageFinder"/>
</bean>
<bean id="globalLock" class="org.geoserver.gwc.GeoServerLockProvider">
<property name="delegate" ref="lockProvider"/>
</bean>
<!-- The tool performing the automatic migration between metastore and fs hashes -->
<bean id="metastoreRemover" class="org.geowebcache.storage.MetastoreRemover">
<constructor-arg ref="gwcDefaultStorageFinder"/>
</bean>
<bean id="cacheConfiguration" class="org.geowebcache.storage.blobstore.memory.CacheConfiguration">
<property name="hardMemoryLimit" value="64"/> <!-- 64 Mb -->
<property name="policy" value="EXPIRE_AFTER_ACCESS"/> <!-- 64 Mb -->
</bean>
<bean id="guavaCacheProvider" class="org.geowebcache.storage.blobstore.memory.guava.GuavaCacheProvider">
<constructor-arg ref="cacheConfiguration"/>
</bean>
<bean id="gwcMemoryBlobStore" class="org.geowebcache.storage.blobstore.memory.MemoryBlobStore" destroy-method="destroy">
<property name="store" ref="gwcBlobStore" />
<property name="cacheProvider" ref="guavaCacheProvider" />
</bean>
<bean id="gwcNullBlobStore" class="org.geowebcache.storage.blobstore.memory.NullBlobStore" destroy-method="destroy"/>
<bean id="gwcConfigBlobStore" class="org.geoserver.gwc.ConfigurableBlobStore" destroy-method="destroy">
<constructor-arg ref="gwcBlobStore" />
<constructor-arg ref="gwcMemoryBlobStore" />
<constructor-arg ref="gwcNullBlobStore" />
</bean>
<bean id="gwcArcGIGridsetConfigutation" class="org.geowebcache.arcgis.layer.ArcGISCacheGridsetConfiguration"/>
</beans>
3.4 编辑geowebcache-servlet.xml文件
打开D:\gs-gwc-2.21.0文件夹下的geowebcache-servlet.xml文件,添加以下代码:
<import resource="geowebcache-arcgiscache-context.xml"/>
修改后的完整geowebcache-servlet.xml文件如下
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<description>
Bean configuration file for the gwc-web module
</description>
<import resource="geowebcache-arcgiscache-context.xml"/>
<import resource="geowebcache-core-context.xml"/>
<import resource="geowebcache-georss-context.xml"/>
<import resource="geowebcache-gmaps-context.xml"/>
<import resource="geowebcache-kmlservice-context.xml"/>
<import resource="geowebcache-rest-context.xml"/>
<import resource="geowebcache-tmsservice-context.xml"/>
<import resource="geowebcache-virtualearth-context.xml"/>
<import resource="geowebcache-wmsservice-context.xml"/>
<import resource="geowebcache-wmtsservice-context.xml"/>
<import resource="geowebcache-diskquota-context.xml"/>
<!--
This mappings are different from the standalone gwc ones in that they prepend the ##/gwc prefix to the context so it
ends up being, for example, /geoserver/gwc/*
-->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="location">
<value>classpath:application.properties</value>
</property>
</bean>
<context:component-scan base-package="org.geoserver.gwc.dispatch"/>
</beans>
3.5 文件夹重新打包成jar,并且覆盖源文件
将D:\gs-gwc-2.21.0文件夹打成jar包,覆盖D:\geoserver-2.21.0-bin\webapps\geoserver\WEB-INF\lib\gs-gwc-2.21.0.jar。
jar cvf gs-gwc-2.21.0.jar -C gs-gwc-2.21.0 .
至此完成修改。
4.切片数据配置
打开D:\geoserver-2.21.0-bin\data_dir\gwc\geowebcache.xml文件,layers节点下添加arcgisLayer节点。
<arcgisLayer>
<name>test</name>
<tilingScheme>D:\arcgis-cut-buffer\mycut\layer\conf.xml</tilingScheme>
<tileCachePath>D:\arcgis-cut-buffer\mycut\layer\_alllayers</tileCachePath>
<hexZoom>false</hexZoom>
</arcgisLayer>
修改后的完整geowebcache.xml文件
<?xml version="1.0" encoding="utf-8"?>
<gwcConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://geowebcache.org/schema/1.8.0"
xsi:schemaLocation="http://geowebcache.org/schema/1.8.0 http://geowebcache.org/schema/1.8.0/geowebcache.xsd">
<version>1.8.0</version>
<backendTimeout>120</backendTimeout>
<!--
<serviceInformation>
<title>GeoWebCache</title>
<description>GeoWebCache is an advanced tile cache for WMS servers. It supports a large variety of protocols and
formats, including WMS-C, WMTS, KML, Google Maps and Virtual Earth.</description>
<keywords>
<string>WFS</string>
<string>WMS</string>
<string>WMTS</string>
<string>GEOWEBCACHE</string>
</keywords>
<serviceProvider>
<providerName>John Smith inc.</providerName>
<providerSite>http://www.example.com/</providerSite>
<serviceContact>
<individualName>John Smith</individualName>
<positionName>Geospatial Expert</positionName>
<addressType>Work</addressType>
<addressStreet>1 Bumpy St.</addressStreet>
<addressCity>Hobart</addressCity>
<addressAdministrativeArea>TAS</addressAdministrativeArea>
<addressPostalCode>7005</addressPostalCode>
<addressCountry>Australia</addressCountry>
<phoneNumber>+61 3 0000 0000</phoneNumber>
<faxNumber>+61 3 0000 0001</faxNumber>
<addressEmail>john.smith@example.com</addressEmail>
</serviceContact>
</serviceProvider>
<fees>NONE</fees>
<accessConstraints>NONE</accessConstraints>
</serviceInformation>
-->
<gridSets>
<!-- Grid Set Example, by default EPSG:900913 and EPSG:4326 are defined -->
<!--
<gridSet>
<name>EPSG:2163</name>
<srs>
<number>2163</number>
</srs>
<extent>
<coords>
<double>-2495667.977678598</double>
<double>-2223677.196231552</double>
<double>3291070.6104286816</double>
<double>959189.3312465074</double>
</coords>
</extent>
<scaleDenominators>
<double>25000000</double>
<double>1000000</double>
<double>100000</double>
<double>25000</double>
</scaleDenominators>
<tileHeight>200</tileHeight>
<tileWidth>200</tileWidth>
</gridSet>
-->
</gridSets>
<layers>
<arcgisLayer>
<name>test</name>
<tilingScheme>D:\arcgis-cut-buffer\mycut\layer\conf.xml</tilingScheme>
<tileCachePath>D:\arcgis-cut-buffer\mycut\layer\_alllayers</tileCachePath>
<hexZoom>false</hexZoom>
</arcgisLayer>
<!--
<wmsLayer>
<name>topp:states</name>
<mimeFormats>
<string>image/gif</string>
<string>image/jpeg</string>
<string>image/png</string>
<string>image/png8</string>
</mimeFormats>
<gridSubsets>
<gridSubset>
<gridSetName>EPSG:2163</gridSetName>
</gridSubset>
</gridSubsets>
<parameterFilters>
<stringParameterFilter>
<key>STYLES</key>
<defaultValue>population</defaultValue>
<values>
<string>population</string>
<string>polygon</string>
<string>pophatch</string>
</values>
</stringParameterFilter>
</parameterFilters>
<wmsUrl>
<string>http://demo.opengeo.org/geoserver/topp/wms</string>
</wmsUrl>
</wmsLayer>
<wmsLayer>
<name>raster test layer</name>
<mimeFormats>
<string>image/gif</string>
<string>image/jpeg</string>
<string>image/png</string>
<string>image/png8</string>
</mimeFormats>
<wmsUrl>
<string>http://demo.opengeo.org/geoserver/wms</string>
</wmsUrl>
<wmsLayers>nurc:Img_Sample</wmsLayers>
</wmsLayer>
<wmsLayer>
<name>img states</name>
<metaInformation>
<title>Nicer title for Image States</title>
<description>This is a description. Fascinating.</description>
</metaInformation>
<mimeFormats>
<string>image/gif</string>
<string>image/jpeg</string>
<string>image/png</string>
<string>image/png8</string>
</mimeFormats>
<gridSubsets>
<gridSubset>
<gridSetName>EPSG:4326</gridSetName>
<extent>
<coords>
<double>-129.6</double>
<double>3.45</double>
<double>-62.1</double>
<double>70.9</double>
</coords>
</extent>
</gridSubset>
</gridSubsets>
<expireCacheList>
<expirationRule minZoom="0" expiration="60" />
</expireCacheList>
<expireClientsList>
<expirationRule minZoom="0" expiration="500" />
</expireClientsList>
<wmsUrl>
<string>http://demo.opengeo.org/geoserver/wms</string>
</wmsUrl>
<wmsLayers>nurc:Img_Sample,topp:states</wmsLayers>
<transparent>false</transparent>
<bgColor>0x0066FF</bgColor>
</wmsLayer>
-->
</layers>
</gwcConfiguration>
5.重启
重新启动geoserver。
下一篇讲解如何解决跨域问题。