rain
2024-06-14 8d9a2d656e4ae007590c622e5f7c228adacdca49
src/main/java/com/dji/sample/territory/utils/CoordinateSystemUtil.java
@@ -3,6 +3,7 @@
import org.geotools.geometry.jts.JTS;
import org.geotools.referencing.CRS;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.io.ParseException;
import org.locationtech.jts.io.WKTReader;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CRSAuthorityFactory;
@@ -60,12 +61,16 @@
            Geometry geometry = reader.read(wkt);
            geometry.setSRID(srid);
            return geometry;
        } catch (ParseException e) {
            System.out.println("WKT解析错误: " + e.getMessage());
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    public static Geometry coordinateTransform(Geometry sourceGeometry, int targetSrid) {
        if (sourceGeometry == null || sourceGeometry.getSRID() == 0 || targetSrid == 0) {
            return null;