¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | |
| | | } |
| | | } |