燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2023-08-08 436e03fe73a19bd485e23f78da5d851bbfe85d25
src/main/java/com/yssh/utils/GisUtil.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,36 @@
package com.yssh.utils;
import org.geotools.geometry.jts.JTS;
import org.geotools.referencing.CRS;
import org.locationtech.jts.geom.Coordinate;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform;
public class GisUtil {
   /**
    * @param srcNo
    *            æºåæ ‡ç³»EPSG代号
    * @param targetNo
    *            ç›®æ ‡åæ ‡ç³»EPSG代号
    * @param x
    *            æºåæ ‡x
    * @param y
    *            æºåæ ‡y
    * @Description: åæ ‡ç³»è½¬æ¢
    */
   public static Coordinate coordinateTransform(String sourceCRS, String targetCRS,
         double x, double y) {
      Coordinate tar = new Coordinate();
      try {
         CoordinateReferenceSystem src = CRS.decode(sourceCRS);
         CoordinateReferenceSystem target = CRS.decode(targetCRS);
         MathTransform transform = CRS.findMathTransform(src, target, true);
         Coordinate sour = new Coordinate(x, y);
         return JTS.transform(sour, tar, transform);
      } catch (Exception e) {
      }
      return tar;
   }
}