|
@@ -26,6 +26,7 @@ import org.geotools.data.shapefile.ShapefileDataStore;
|
|
|
import org.geotools.data.shapefile.ShapefileDataStoreFactory;
|
|
import org.geotools.data.shapefile.ShapefileDataStoreFactory;
|
|
|
import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
|
|
import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
|
|
|
import org.geotools.referencing.CRS;
|
|
import org.geotools.referencing.CRS;
|
|
|
|
|
+import org.geotools.referencing.factory.epsg.hsql.ThreadedHsqlEpsgFactory;
|
|
|
import org.locationtech.jts.geom.Geometry;
|
|
import org.locationtech.jts.geom.Geometry;
|
|
|
import org.locationtech.jts.geom.MultiPolygon;
|
|
import org.locationtech.jts.geom.MultiPolygon;
|
|
|
import org.locationtech.jts.geom.Polygon;
|
|
import org.locationtech.jts.geom.Polygon;
|
|
@@ -1105,7 +1106,7 @@ public class ProjectImpl implements ProjectService {
|
|
|
private void writeCycleShapefile(File shpFile, List<CycleShpRow> rows, List<String> fields) throws Exception {
|
|
private void writeCycleShapefile(File shpFile, List<CycleShpRow> rows, List<String> fields) throws Exception {
|
|
|
SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
|
|
SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
|
|
|
typeBuilder.setName("project_cycle");
|
|
typeBuilder.setName("project_cycle");
|
|
|
- CoordinateReferenceSystem crs = CRS.decode("EPSG:4490");
|
|
|
|
|
|
|
+ CoordinateReferenceSystem crs = decodeCgcs2000Crs();
|
|
|
typeBuilder.setCRS(crs);
|
|
typeBuilder.setCRS(crs);
|
|
|
typeBuilder.add("the_geom", MultiPolygon.class);
|
|
typeBuilder.add("the_geom", MultiPolygon.class);
|
|
|
|
|
|
|
@@ -1152,6 +1153,21 @@ public class ProjectImpl implements ProjectService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private CoordinateReferenceSystem decodeCgcs2000Crs() throws Exception {
|
|
|
|
|
+ try {
|
|
|
|
|
+ return CRS.decode("EPSG:4490");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("CRS.decode解析EPSG:4490失败,改用gt-epsg-hsql权威库直接解析", e);
|
|
|
|
|
+ try {
|
|
|
|
|
+ return new ThreadedHsqlEpsgFactory().createCoordinateReferenceSystem("4490");
|
|
|
|
|
+ } catch (Exception hsqlException) {
|
|
|
|
|
+ hsqlException.addSuppressed(e);
|
|
|
|
|
+ log.error("项目生命周期SHP导出解析EPSG:4490失败,请确认运行包已加载gt-epsg-hsql和hsqldb,且运行时没有混入其他版本GeoTools依赖", hsqlException);
|
|
|
|
|
+ throw hsqlException;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private Geometry parseEwkt(String ewkt, WKTReader reader) {
|
|
private Geometry parseEwkt(String ewkt, WKTReader reader) {
|
|
|
if (StringUtils.isBlank(ewkt)) {
|
|
if (StringUtils.isBlank(ewkt)) {
|
|
|
return null;
|
|
return null;
|