Skip to content

Commit

Permalink
Extra overloads for Mercator conversion methods that take Coordinate
Browse files Browse the repository at this point in the history
  • Loading branch information
smirnovegorv committed Apr 26, 2023
1 parent e195457 commit 877f403
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/main/java/ru/itmo/idu/geometry/ProjectionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,16 @@ public static Geometry transformToMercator(Geometry geometry) {
}
}

public static Coordinate transformToMercator(Coordinate coordinate) {
try {
Coordinate dest = new Coordinate();
return JTS.transform(coordinate, dest, latLonToXY);
} catch (TransformException e) {
log.error("Failed to transform", e);
return coordinate;
}
}

public static Geometry transformToLocalCRS(Geometry geometry) throws FactoryException, TransformException {
if (geometry.isEmpty()){
return geometry;
Expand Down Expand Up @@ -313,11 +323,21 @@ public static Geometry transformFromMercator(Geometry geometry) {
try {
return JTS.transform(geometry, xyToLatLon);
} catch (TransformException e) {
log.error("Failed to transsform", e);
log.error("Failed to transform", e);
return geometry;
}
}

public static Coordinate transformFromMercator(Coordinate coordinate) {
try {
Coordinate dest = new Coordinate();
return JTS.transform(coordinate, dest, xyToLatLon);
} catch (TransformException e) {
log.error("Failed to transform", e);
return coordinate;
}
}

public static MinimumDiameter getProjectedDiameter(Geometry g) {
Geometry projected = null;
try {
Expand Down

0 comments on commit 877f403

Please sign in to comment.