國產(chǎn)化軟件開始后,導(dǎo)致以前用的windows一套都被拋棄了冬筒,開始轉(zhuǎn)向linux恐锣,最近發(fā)布arcgis切片時,發(fā)現(xiàn)UOS系統(tǒng)中arcgis server安裝不上舞痰。于是另尋它法土榴,看到網(wǎng)上很多人用geowebcatch,于是拿來研究一番响牛,真可以玷禽,在此記錄一下赫段,記憶力差了,怕忘記矢赁。
軟件組合:UOS 20 SP1專業(yè)版糯笙、jdk8、tomcat9撩银、GeoWebCache
系統(tǒng)是UOS 20 SP1專業(yè)版给涕,查看系統(tǒng)內(nèi)核 $ uname -a
jdk安裝
發(fā)現(xiàn)是 arm64的處理器,安裝相應(yīng)版本的jdk额获,筆者用的 jdk-8u301-linux-aarch64.tar.gz够庙,沒有直接去官網(wǎng)下載即可,沒有帳號直接郵箱申請一個抄邀,不麻煩耘眨;
將壓縮包拷貝并解壓到 /usr/local 目錄
拷貝命令: cp -r dir/firle dir
解壓命令: tar -zxvf jdk-8u181-linux-x64.tar.gz
刪除命令: rm -f jdk-8u181-linux-x64.tar.gz
配置jdk環(huán)境變量
/etc/profile文件的改變會涉及到系統(tǒng)的環(huán)境,也就是有關(guān)Linux環(huán)境變量的東西所以撤摸,我們要將jdk配置到/etc/profile,才可以在任何一個目錄訪問jdk褒纲,編輯此文件命令:vim /etc/profile准夷,按i進(jìn)入編輯,在profile文件尾部添加如下內(nèi)容:
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}
Esc --> :wq
保存并退出編輯
通過命令讓profile文件立即生效: [root@localhost local]# source /etc/profile
測試是否安裝成功
[root@localhost local]# javac
[root@localhost local]# java -version
出現(xiàn)幫助和版本號說明linux下jdk8安裝成功莺掠。
tomcat9安裝
筆者用的版本是9.0.52,直接官網(wǎng)下載的
將壓縮包拷貝并接到/usr/local文件夾中
在/etc/profile文件后面添加環(huán)境變量:
export TOMCAT_HOME=/usr/software/apache-tomcat-9.0.8
我最終的profile環(huán)境變量配置截圖:
執(zhí)行source profile 使得環(huán)境變量立即生效
進(jìn)入tomcat的bin目錄衫嵌,執(zhí)行./startup.sh 命令啟動tomcat,./shutdown.sh命令停止服務(wù)彻秆,打開服務(wù)默認(rèn)端口是8080,即可訪問tomcat網(wǎng)站楔绞。
跨域?qū)崿F(xiàn):
1、需要下載cors-filter-1.8.jar唇兑,Java-property-utils-1.9.jar這兩個庫文件放在lib目錄下
2酒朵、打開資源部署的tomcat安裝目錄 -> 打開 conf 目錄 -> 打開web.xml文件,
尾部添加配置:
<filter>
<filter-name>CORS</filter-name>
<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
<init-param>
<param-name>cors.allowOrigin</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.supportedMethods</param-name>
<param-value>GET, POST, HEAD, PUT, DELETE</param-value>
</init-param>
<init-param>
<param-name>cors.supportedHeaders</param-name>
<param-value>Accept, Origin, X-Requested-With, Content-Type, Last-Modified</param-value>
</init-param>
<init-param>
<param-name>cors.exposedHeaders</param-name>
<param-value>Set-Cookie</param-value>
</init-param>
<init-param>
<param-name>cors.supportsCredentials</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CORS</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
我的配置如圖:
Geowebcache安裝
去官網(wǎng)下載最新版本的war包扎附,直接放到tomcat的webapps文件夾中蔫耽,啟動tomcat,webapps中出現(xiàn)一個geowebcache文件夾留夜。
進(jìn)入geowebcache的web-inf目錄下匙铡,修改web-inf文件夾下的文件web.xml,在</context-param>節(jié)點(diǎn)后添加如下節(jié)點(diǎn)
<context-param>
<param-name>GEOWEBCACHE_CACHE_DIR </param-name>
<param-value>/home/tgtf/geowebcachetem</param-value>
</context-param>
param-value為geowebcache的配置目錄碍粥,重啟tomcat鳖眼,配置目錄多出來一些文件,修改其中的geowebcache.xml文件嚼摩,在<layer>…</layer>節(jié)點(diǎn)中添加如下節(jié)點(diǎn)
<arcgisLayer>
<name>naturalearth</name>
<tilingScheme>/home/thtf/kfq/Conf.xml</tilingScheme>
<tileCachePath>/home/thtf/kfq/_alllayers</tileCachePath>
</arcgisLayer>
在文件/usr/local/apache-tomcat-8.5.65/webapps/geowebcache/WEB-INF/geowebcache-core-context.xml 需要加以下代碼
<bean id="gwcArcGIGridsetConfigutation" class="org.geowebcache.arcgis.layer.ArcGISCacheGridsetConfiguration"/>
另外钦讳,將arcgis切片的conf.cdi只保留EnvelopeN節(jié)點(diǎn)矿瘦,刪除SpatialReference、xml節(jié)點(diǎn); conf.xml中刪除LatestWKID蜂厅、LeftLongitude匪凡、PreciseDPI三個節(jié)點(diǎn)。
調(diào)用展示
發(fā)布出來的切片服務(wù)是預(yù)覽不了的掘猿,但是調(diào)用是沒有問題的病游,這里寫2個我自己的切片模板以備后期使用:
worldimg:http://localhost:8080/geowebcache/service/wmts?layer=worldimg&style=&tilematrixset=EPSG%3A4326_worldimg&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fjpeg&TileMatrix=EPSG%3A4326_worldimg%3A1&TileCol=0&TileRow=0
zjimg:http://localhost:8080/geowebcache/service/wmts?layer=zjimg&style=&tilematrixset=EPSG%3A4490_zjimg&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fjpeg&TileMatrix=EPSG%3A4490_zjimg%3A12&TileCol=1718&TileRow=340