学习geotools的过程遇到问题一
No code “EPSG:4490” from authority “EPSG” found for object of type “EngineeringCRS”
在使用geotools的过程中,使用CRS或者指定SRID报以下错误时。
org.opengis.referencing.NoSuchAuthorityCodeException: No code "EPSG:4490" from authority "EPSG" found for object of type "EngineeringCRS".
at org.geotools.referencing.factory.epsg.CartesianAuthorityFactory.noSuchAuthorityException(CartesianAuthorityFactory.java:137)
at org.geotools.referencing.factory.epsg.CartesianAuthorityFactory.createEngineeringCRS(CartesianAuthorityFactory.java:129)
at org.geotools.referencing.factory.epsg.CartesianAuthorityFactory.createCoordinateReferenceSystem(CartesianAuthorityFactory.java:120)
at org.geotools.referencing.factory.AuthorityFactoryAdapter.createCoordinateReferenceSystem(AuthorityFactoryAdapter.java:780)
at org.geotools.referencing.factory.FallbackAuthorityFactory.createCoordinateReferenceSystem(FallbackAuthorityFactory.java:625)
at org.geotools.referencing.factory.AuthorityFactoryAdapter.createCoordinateReferenceSystem(AuthorityFactoryAdapter.java:780)
at org.geotools.referencing.factory.ThreadedAuthorityFactory.createCoordinateReferenceSystem(ThreadedAuthorityFactory.java:636)
at org.geotools.referencing.DefaultAuthorityFactory.createCoordinateReferenceSystem(DefaultAuthorityFactory.java:177)
at org.geotools.referencing.CRS.decode(CRS.java:517)
at com.wemap.common.utils.geotools.pg.Geotools.zjggInsertIntoPGFromSHP(Geotools.java:717)
at com.wemap.common.utils.geotools.pg.Geotools.main(Geotools.java:786)
表示项目缺少gt-epsg-hsql包,可在pom文件中引入此包即可。
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-epsg-hsql</artifactId>
<version>${geotools.version}</version>
</dependency>
PS
但是如果项目没有运用maven进行构建,只是单纯外部引入包,这时需要引入的包有:
hsqldb-2.5.0.jar , gt-epsg-hsql-11.1.jar ,只有这两个包都存在,才能够在数据库中找到我们需要的坐标系代码。