Skip to content

Commit 03d3123

Browse files
authored
OSGB36 datum and +nadgrids=@null support (#74)
* OSGB36 transform adjustment and variable name fix * OSGB36 datum transform * +nadgrids=@null support * nadgrids null test * EPSG:27700 tests
1 parent 5af1582 commit 03d3123

File tree

6 files changed

+19
-3
lines changed

6 files changed

+19
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Fixed
10+
- Adjustment to OSGB36 datum transform e.g. EPSG: 27700
11+
- +nadgrids=@null support e.g. EPSG: 3857
12+
913
## [1.1.3] - 2021-06-17
1014

1115
### Fixed

src/main/java/org/locationtech/proj4j/Registry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public Registry() {
4747
Datum.HERMANNSKOGEL,
4848
Datum.IRE65,
4949
Datum.NZGD49,
50-
Datum.OSEB36
50+
Datum.OSGB36
5151
};
5252

5353
public Datum getDatum(String code) {

src/main/java/org/locationtech/proj4j/datum/Datum.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public class Datum implements java.io.Serializable {
7272
public static final Datum HERMANNSKOGEL = new Datum("hermannskogel", 577.326, 90.129, 463.919, 5.137, 1.474, 5.297, 2.4232, Ellipsoid.BESSEL, "Hermannskogel");
7373
public static final Datum IRE65 = new Datum("ire65", 482.530, -130.596, 564.557, -1.042, -0.214, -0.631, 8.15, Ellipsoid.MOD_AIRY, "Ireland 1965");
7474
public static final Datum NZGD49 = new Datum("nzgd49", 59.47, -5.04, 187.44, 0.47, -0.1, 1.024, -4.5993, Ellipsoid.INTERNATIONAL, "New Zealand Geodetic Datum 1949");
75-
public static final Datum OSEB36 = new Datum("OSGB36", 446.448, -125.157, 542.060, 0.1502, 0.2470, 0.8421, -20.4894, Ellipsoid.AIRY, "Airy 1830");
75+
public static final Datum OSGB36 = new Datum("OSGB36", 446.448, -125.157, 542.06, 0.15, 0.247, 0.842, -20.489, Ellipsoid.AIRY, "Airy 1830");
7676

7777
static {
7878
Datum temp = new Datum("NAD27", new ArrayList<Grid>(), Ellipsoid.CLARKE_1866, "North_American_Datum_1927");

src/main/java/org/locationtech/proj4j/datum/Grid.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ public static List<Grid> fromNadGrids(String grids) throws IOException {
314314
for (String gridName : grids.split(",")) {
315315
boolean optional = gridName.startsWith("@");
316316
if (optional) gridName = gridName.substring(1);
317+
if (gridName.equals("null")) return null;
317318
try {
318319
mergeGridFile(gridName, gridlist);
319320
} catch (IOException e) {

src/test/java/org/locationtech/proj4j/CoordinateTransformTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ public void testPROJ4() {
215215
checkTransformFromGeo("EPSG:2736", 34.0, -21.0, 603934.39, 7677664.39, 0.1);
216216
checkTransformFromGeo("EPSG:26916", -86.6056, 34.579, 536173.11, 3826428.04, 0.1);
217217
checkTransformFromGeo("EPSG:21781", 8.23, 46.82, 660309.34, 185586.30, 0.1);
218+
checkTransformFromWGS84("EPSG:27700", -8.82, 49.79, -90619.28789678006, 10097.131147458786, 0.0);
219+
checkTransformToWGS84("EPSG:27700", 612435.55, 1234954.16, 1.9200000236235546, 60.93999999543101, 0.0);
220+
checkTransformToWGS84("EPSG:27700", 327420.988668, 690284.547110, -3.1683134533969364, 56.0998025292667, 0.0);
221+
checkTransformFromWGS84("EPSG:3857", -3.1683134533969364, 56.0998025292667, -352695.04030562507, 7578309.225014557, 0.0);
222+
// TODO https://github.com/locationtech/proj4j/issues/32
223+
//checkTransform("EPSG:27700", 327420.988668, 690284.547110, "EPSG:3857", -352695.04030562507, 7578309.225014557, 0.0);
218224
}
219225

220226
@Test

src/test/java/org/locationtech/proj4j/ExampleTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717

1818
import org.junit.Assert;
1919
import org.junit.Test;
20+
import org.locationtech.proj4j.datum.Datum;
2021

2122
import java.io.IOException;
2223

24+
import static org.junit.Assert.assertNull;
2325
import static org.junit.Assert.assertTrue;
2426

2527

@@ -221,12 +223,15 @@ public void latLonToStereBidirectionalTransform() {
221223
@Test
222224
public void epsgWebMercatorLegacyTest() {
223225
CRSFactory csFactory = new CRSFactory();
226+
String parameters = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs";
224227
try {
225-
String code = csFactory.readEpsgFromParameters("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs");
228+
String code = csFactory.readEpsgFromParameters(parameters);
226229
Assert.assertEquals(Integer.parseInt(code), 3857);
227230
} catch (IOException e) {
228231
e.printStackTrace();
229232
}
233+
CoordinateReferenceSystem crs = csFactory.createFromParameters("EPSG:3857", parameters);
234+
assertTrue(crs.getDatum().getTransformType() != Datum.TYPE_GRIDSHIFT);
230235
}
231236

232237
private boolean isInTolerance(ProjCoordinate p, double x, double y, double tolerance) {

0 commit comments

Comments
 (0)