亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法使用 tomcat 獲得 CRS:

無法使用 tomcat 獲得 CRS:

慕勒3428872 2021-07-02 14:01:08
我有一個奇怪的情況。我使用 geotools 來投影柵格,例如它的工作原理CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:3857");GridCoverage2D projectedImage = (GridCoverage2D) Operations.DEFAULT.resample(gridCoverageImage,                        targetCRS);現在我使用完全相同的代碼將我的進程移到了 Web 服務器控制器中:public ResponseEntity<InputStreamResource> getProjectedImage(@RequestParam String filename, @RequestParam String targetCrs){     File file = new File(filename);     CoordinateReferenceSystem targetCRS = CRS.decode(targetCrs);     /** Some process to return file /**}我有:org.opengis.referencing.NoSuchAuthorityCodeException: No code "EPSG:3857"from authority "EPSG" found for object of type "EngineeringCRS"我的 pom.xml   <dependency>        <groupId>org.geotools</groupId>        <artifactId>gt-shapefile</artifactId>        <version>18.2</version>    </dependency>    <dependency>        <groupId>org.geotools</groupId>        <artifactId>gt-epsg-hsql</artifactId>        <version>18.2</version>    </dependency>       <dependency>        <groupId>org.geotools</groupId>        <artifactId>gt-coverage</artifactId>        <version>18.2</version>    </dependency>         <dependency>        <groupId>org.geotools</groupId>        <artifactId>gt-geotiff</artifactId>        <version>18.2</version>    </dependency>       <dependency>        <groupId>org.geotools</groupId>        <artifactId>gt-image</artifactId>        <version>18.2</version>    </dependency>    <dependency>        <groupId>org.geotools</groupId>        <artifactId>gt-wms</artifactId>        <version>18.2</version>    </dependency> 當我查看 WEB-INF/lib 時,所有 jar 都在這里,包括依賴項(gt-reference、gt-metadata .....)Tomcat:8.0 Java 8 地理工具:18.2當我不在 servlet 容器中時它工作正常。此外,來自 geotools 的其他實用程序運行良好。例如,裁剪或 GridCoverage2D 轉換在這個 servlet 容器中工作。你能幫我理解發生了什么嗎?
查看完整描述

2 回答

?
波斯汪

TA貢獻1811條經驗 獲得超4個贊

您的問題很可能是 Tomcat(或運行它的用戶)沒有寫入權限,java.io.tmpdir這是 GeoTools 在第一次查找 EPSG 代碼時將 H2 EPSG 數據庫解壓到的地方。

您可以更改臨時目錄的權限以允許 tomcat 在那里寫入,或者您可以通過更改或 中的CATALINA_TMPDIR變量來更改它使用的位置,或者簡單地添加到您的啟動腳本中。catalina.shcatalina.batDjava.io.tmpdir=c:\{yourDir}

這個問題也有一些可能有幫助的答案。


查看完整回答
反對 回復 2021-07-07
?
開心每一天1111

TA貢獻1836條經驗 獲得超13個贊

我找到了一個解決方法,即使它不能解決最初的問題(與 geotools 的依賴關系和部署到 Tomcat 中有關)


不要使用 gt-epsg-hsql,這會導致您的應用搜索 EPSG 代碼以解碼到 HSQL 數據庫中。


而不是CRS.decode(targetCrs); 與


CRS.parseWKT("PROJCS[\"WGS 84 / Plate Carree (deprecated)\",\r\n" + 

                "    GEOGCS[\"WGS 84\",\r\n" + 

                "        DATUM[\"WGS_1984\",\r\n" + 

                "            SPHEROID[\"WGS 84\",6378137,298.257223563,\r\n" + 

                "                AUTHORITY[\"EPSG\",\"7030\"]],\r\n" + 

                "            AUTHORITY[\"EPSG\",\"6326\"]],\r\n" + 

                "        PRIMEM[\"Greenwich\",0,\r\n" + 

                "            AUTHORITY[\"EPSG\",\"8901\"]],\r\n" + 

                "        UNIT[\"degree\",0.0174532925199433,\r\n" + 

                "            AUTHORITY[\"EPSG\",\"9122\"]],\r\n" + 

                "        AUTHORITY[\"EPSG\",\"4326\"]],\r\n" + 

                "    PROJECTION[\"Equirectangular\"],\r\n" + 

                "    UNIT[\"metre\",1,\r\n" + 

                "        AUTHORITY[\"EPSG\",\"9001\"]],\r\n" + 

                "    AXIS[\"X\",EAST],\r\n" + 

                "    AXIS[\"Y\",NORTH],\r\n" + 

                "    AUTHORITY[\"EPSG\",\"32662\"]]");

您可以在此處找到與每個 EPSG 代碼相關的所有 WKT


如果有人對原始問題有答案或解釋,我很樂意閱讀它:)


查看完整回答
反對 回復 2021-07-07
  • 2 回答
  • 0 關注
  • 630 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號