首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用tomcat获取CRS : org.opengis.referencing.NoSuchAuthorityCodeException

无法使用tomcat获取CRS : org.opengis.referencing.NoSuchAuthorityCodeException
EN

Stack Overflow用户
提问于 2018-08-08 18:01:01
回答 2查看 537关注 0票数 1

我遇到了一个奇怪的情况。我使用地理工具来投影栅格,例如

代码语言:javascript
复制
CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:3857");

GridCoverage2D projectedImage = (GridCoverage2D) Operations.DEFAULT.resample(gridCoverageImage,
                        targetCRS);

现在,我使用完全相同的代码在web服务器控制器中移动我的进程:

代码语言:javascript
复制
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 /**
}

我有:

代码语言:javascript
复制
org.opengis.referencing.NoSuchAuthorityCodeException: No code "EPSG:3857"
from authority "EPSG" found for object of type "EngineeringCRS"

我的pom.xml

代码语言:javascript
复制
   <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时,所有的jars都在这里,包括依赖项(gt引用,gt元数据.....)

Tomcat :8.0Java8 GeoTools : 18.2

当我不在servlet容器中时,它工作得很好。此外,来自geotools的其他实用程序也工作得很好。例如,裁剪或GridCoverage2D转换在此servlet容器中工作。

你能帮我了解一下发生了什么事吗?

提前感谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-08-10 17:46:59

您的问题很可能是Tomcat (或运行它的用户)没有对java.io.tmpdir的写权限,这是GeoTools在第一次查找H2代码时将EPSG数据库解压到的位置。

您可以更改临时目录的权限以允许tomcat在其中写入内容,也可以通过更改catalina.shcatalina.bat中的CATALINA_TMPDIR变量来更改它使用的位置,或者简单地将Djava.io.tmpdir=c:\{yourDir}添加到您的启动脚本中。

这篇question也有一些可能会有帮助的答案。

票数 1
EN

Stack Overflow用户

发布于 2018-08-08 23:41:58

我找到了一个解决方法,即使它不能解决最初的问题(与地理工具的依赖和部署到Tomcat相关)

不要使用gt- EPSG -hsql,它会导致您的应用程序搜索要解码到HSQL数据库中的EPSG代码。

而不是将CRS.decode(targetCrs);

代码语言:javascript
复制
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代码here相关的WKT

如果有人对原始问题有答案或解释,我很乐意阅读它:)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51743860

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档