From 543191c141470c862a7f36ba9bd02c60859e7c24 Mon Sep 17 00:00:00 2001 From: rakow Date: Thu, 16 May 2024 18:38:15 +0200 Subject: [PATCH] recognize EPSG:4326 as equal to WGS84 when using special coordinate transformations (#3276) --- .../prepare/network/CreateGeoJsonNetwork.java | 2 +- .../geometry/transformations/TransformationFactory.java | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/contribs/application/src/main/java/org/matsim/application/prepare/network/CreateGeoJsonNetwork.java b/contribs/application/src/main/java/org/matsim/application/prepare/network/CreateGeoJsonNetwork.java index cad4484624b..42eb4408fe9 100644 --- a/contribs/application/src/main/java/org/matsim/application/prepare/network/CreateGeoJsonNetwork.java +++ b/contribs/application/src/main/java/org/matsim/application/prepare/network/CreateGeoJsonNetwork.java @@ -82,7 +82,7 @@ public Integer call() throws Exception { json.put("type", "FeatureCollection"); // Default CRS assumed to be 4326 - if (!networkCrs.equalsIgnoreCase("epsg:4326")) { + if (!crs.getTargetCRS().equalsIgnoreCase("epsg:4326")) { ObjectNode crs = json.putObject("crs"); putCrs(crs, networkCrs); } diff --git a/matsim/src/main/java/org/matsim/core/utils/geometry/transformations/TransformationFactory.java b/matsim/src/main/java/org/matsim/core/utils/geometry/transformations/TransformationFactory.java index 861a1c1f3cc..5398a117794 100644 --- a/matsim/src/main/java/org/matsim/core/utils/geometry/transformations/TransformationFactory.java +++ b/matsim/src/main/java/org/matsim/core/utils/geometry/transformations/TransformationFactory.java @@ -31,6 +31,7 @@ public abstract class TransformationFactory { public final static String WGS84 = "WGS84"; + public final static String EPSG4326 = "EPSG:4326"; public final static String ATLANTIS = "Atlantis"; public final static String CH1903_LV03 = "CH1903_LV03"; // switzerland public final static String CH1903_LV03_Plus = "CH1903_LV03_Plus"; // switzerland new @@ -40,7 +41,7 @@ public abstract class TransformationFactory { public final static String WGS84_UTM35S = "WGS84_UTM35S"; // South Africa (Gauteng) public final static String WGS84_UTM36S = "WGS84_UTM36S"; // South Africa (eThekwini, Kwazulu-Natal) public final static String WGS84_Albers = "WGS84_Albers"; // South Africa (Africa Albers Equal Conic) - public final static String WGS84_SA_Albers = "WGS84_SA_Albers"; // South Africa (Adapted version of Africa Albers Equal) + public final static String WGS84_SA_Albers = "WGS84_SA_Albers"; // South Africa (Adapted version of Africa Albers Equal) public final static String HARTEBEESTHOEK94_LO19 = "SA_Lo19"; // South Africa adaption of Transverse Mercator. Cape Town public final static String HARTEBEESTHOEK94_LO25 = "SA_Lo25"; // South Africa adaption of Transverse Mercator. Nelson Mandela Bay Metropolitan public final static String HARTEBEESTHOEK94_LO29 = "SA_Lo29"; // South Africa adaption of Transverse Mercator. General for SA as a whole, and Gauteng @@ -57,7 +58,7 @@ public abstract class TransformationFactory { public static final String WGS84_TM = "WGS84_TM"; //Singapore3 public static final String PCS_ITRF2000_TM_UOS = "PCS_ITRF2000_TM_UOS"; // South Korea - but used by University of Seoul - probably a wrong one... public static final String DHDN_SoldnerBerlin = "DHDN_SoldnerBerlin"; // Berlin - + /** * Returns a coordinate transformation to transform coordinates from one * coordinate system to another one. @@ -68,12 +69,12 @@ public abstract class TransformationFactory { */ public static CoordinateTransformation getCoordinateTransformation(final String fromSystem, final String toSystem) { if (fromSystem.equals(toSystem)) return new IdentityTransformation(); - if (WGS84.equals(fromSystem)) { + if (WGS84.equals(fromSystem) || EPSG4326.equalsIgnoreCase(fromSystem)) { if (CH1903_LV03.equals(toSystem)) return new WGS84toCH1903LV03(); if (CH1903_LV03_Plus.equals(toSystem)) return new WGS84toCH1903LV03Plus(); if (ATLANTIS.equals(toSystem)) return new WGS84toAtlantis(); } - if (WGS84.equals(toSystem)) { + if (WGS84.equals(toSystem) || EPSG4326.equalsIgnoreCase(toSystem)) { if (CH1903_LV03.equals(fromSystem)) return new CH1903LV03toWGS84(); if (CH1903_LV03_Plus.equals(fromSystem)) return new CH1903LV03PlustoWGS84(); if (GK4.equals(fromSystem)) return new GK4toWGS84();