rain
2024-05-06 bc16d0f0fc46ca6cb7d9bfb8496ad8f20ffba677
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;