From 2f55cebbad3dea187a5f91d16ec80a9677dab699 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 13 十一月 2024 11:16:53 +0800 Subject: [PATCH] 1 --- src/main/java/com/yssh/utils/GisUtil.java | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/yssh/utils/GisUtil.java b/src/main/java/com/yssh/utils/GisUtil.java new file mode 100644 index 0000000..3768793 --- /dev/null +++ b/src/main/java/com/yssh/utils/GisUtil.java @@ -0,0 +1,24 @@ +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 { + 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; + + } +} -- Gitblit v1.9.3