在使用gt-epsg-hsql进行坐标转换时,某些遥感数据会出现Error in “PROJCS”: Parameter “EXTENSION” was not expected.报错的原因是我们需要获取原始遥感影像的坐标系信息,所以使用了CRS.parseWKT(wkt),而我们wkt通过osr库处理过都带上了EXTENSION信息,导致报错。

PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m [email protected] +wktext +no_defs"],AUTHORITY["EPSG","3857"]]

目前官方已经记录了这个问题,并且会在将来24-RC版本中进行修复。目前版本只能通过正则替换掉该附加信息。

wkt = wkt.replaceFirst(",EXTENSION\\[.*?\\]", "");