Skip to content

Commit

Permalink
Merge pull request #147 from ebocher/fix_some_crs_defs
Browse files Browse the repository at this point in the history
Fix HERMANNSKOGEL and POSTDAM datum transformations
  • Loading branch information
ebocher authored Jan 11, 2023
2 parents bb67eb7 + b43ec33 commit 290a81b
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 14 deletions.
4 changes: 3 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## Changelog for v1.7.0

+ Fix javadoc build errors.
+ Remove OrbisParent dependency
+ Remove OrbisParent dependency
+ Fix HERMANNSKOGEL DATUM , add seven parameters transformation
+ Fix POSTDAM DATUM, add seven parameters transformation
13 changes: 7 additions & 6 deletions src/main/java/org/cts/datum/GeodeticDatum.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public class GeodeticDatum extends AbstractDatum {


// Original NAD83 datum. For topographic purposes.
// To get pecise transformation from NAD83(1986) to NAD83(HARN) and be
// To get precise transformation from NAD83(1986) to NAD83(HARN) and be
// consistent with WGS, one must use extended NADCON grids (5-6 cm accuracy)
// NADCON grids are not yet implemented in CTS library.
public final static GeodeticDatum NAD83 = new GeodeticDatum(
Expand Down Expand Up @@ -247,14 +247,15 @@ public class GeodeticDatum extends AbstractDatum {
PrimeMeridian.GREENWICH, Ellipsoid.GRS80, null,
new GeographicExtent("Greece - onshore", 34.88, 41.75, 19.57, 28.3), "", "1987");

public final static GeodeticDatum HERMANNSKOGEL = new GeodeticDatum(
new Identifier("EPSG", "4312", "Militar-Geographische Institut", "MGI"),
PrimeMeridian.GREENWICH, Ellipsoid.BESSEL1841, null,
public final static GeodeticDatum HERMANNSKOGEL = new GeodeticDatum( new Identifier("EPSG", "4312",
"Militar-Geographische Institut", "MGI"),
PrimeMeridian.GREENWICH, Ellipsoid.BESSEL1841,
SevenParameterTransformation.createBursaWolfTransformation(577.326,90.129,463.919,5.1366,1.4742,5.2970,2.4232),
new GeographicExtent("Austria", 46.4, 49.02, 9.53, 17.17), "", "");

public final static GeodeticDatum POSTDAM = new GeodeticDatum(
new Identifier("EPSG", "4314", "Deutsches Hauptdreiecksnetz", "DHDN"),
PrimeMeridian.GREENWICH, Ellipsoid.BESSEL1841, null,
PrimeMeridian.GREENWICH, Ellipsoid.BESSEL1841,
SevenParameterTransformation.createBursaWolfTransformation(598.1,73.7,418.2,0.202,0.045,-2.455,6.7),
new GeographicExtent("Germany - states of former West Germany onshore", 47.27, 55.09, 5.87, 13.84), "", "");

public final static GeodeticDatum CARTHAGE = new GeodeticDatum(
Expand Down
71 changes: 68 additions & 3 deletions src/test/java/org/cts/op/EPSGTransformTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import org.cts.crs.CoordinateReferenceSystem;
import org.cts.crs.GeodeticCRS;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -105,9 +106,73 @@ void testFrenchEPSGCodeFrom4326To27700() throws Exception {
double[] result = transform((GeodeticCRS) inputCRS, (GeodeticCRS) outputCRS, pointSource);
assertTrue(checkEquals2D("EPSG:4326 to EPSG:27700", result, pointDest, tolerance));
}

//TODO : Fix me
//@Test

@Test
void testEPSGCodeFrom31256To4326() throws Exception {
String csNameSrc = "EPSG:31256"; //Input EPSG
double[] pointSource = new double[]{-38048.66 , 389405.66};
String csNameDest = "EPSG:4326"; //Target EPSG
double[] pointDest = new double[]{15.815805676616735 ,48.64153355841612};
double tolerance = 0.0001;
CoordinateReferenceSystem inputCRS = cRSFactory.getCRS(csNameSrc);
CoordinateReferenceSystem outputCRS = cRSFactory.getCRS(csNameDest);
verbose = false;
double[] result = transform((GeodeticCRS) inputCRS, (GeodeticCRS) outputCRS, pointSource);
assertTrue(checkEquals2D("EPSG:31256 to EPSG:4326 ", result, pointDest, tolerance));
}


@Test
void testEPSGCodeFrom4326To31467() throws Exception {
String csNameSrc = "EPSG:4326"; //Input EPSG
double[] pointSource = new double[]{9, 51};
String csNameDest = "EPSG:31467"; //Target EPSG
double[] pointDest = new double[]{3500073.57463, 5651645.88247};
double tolerance = 0.01;
CoordinateReferenceSystem inputCRS = cRSFactory.getCRS(csNameSrc);
CoordinateReferenceSystem outputCRS = cRSFactory.getCRS(csNameDest);
verbose = false;
double[] result = transform((GeodeticCRS) inputCRS, (GeodeticCRS) outputCRS, pointSource);
assertTrue(checkEquals2D("EPSG:4326 to EPSG:31467 ", result, pointDest, tolerance));
}


@Test
void testEPSGCodeFrom25832To31467() throws Exception {
//See https://epsg.io/transform#s_srs=25832&t_srs=31467&x=604740.8835930&y=7992968.2448370
String csNameSrc = "EPSG:25832"; //Input EPSG
double[] pointSource = new double[]{604740.883593, 7992968.244837};
String csNameDest = "EPSG:31467"; //Target EPSG
double[] pointDest = new double[]{3604831.5221369416,7995714.14172839};
double tolerance = 0.001;
CoordinateReferenceSystem inputCRS = cRSFactory.getCRS(csNameSrc);
CoordinateReferenceSystem outputCRS = cRSFactory.getCRS(csNameDest);
verbose = false;
double[] result = transform((GeodeticCRS) inputCRS, (GeodeticCRS) outputCRS, pointSource);
assertTrue(checkEquals2D("EPSG:25832 to EPSG:31467 ", result, pointDest, tolerance));
}


//TODO : Fix me add support to NADGRID
@Disabled
@Test
void testEPSGCodeFrom2249To4326() throws Exception {
String csNameSrc = "EPSG:2249"; //Input EPSG
double[] pointSource = new double[]{743238 , 2967416};
String csNameDest = "EPSG:4326"; //Target EPSG
double[] pointDest = new double[]{-71.1776848522251, 42.39028965129018};
double tolerance = 0.0001;
CoordinateReferenceSystem inputCRS = cRSFactory.getCRS(csNameSrc);
CoordinateReferenceSystem outputCRS = cRSFactory.getCRS(csNameDest);
verbose = false;
double[] result = transform((GeodeticCRS) inputCRS, (GeodeticCRS) outputCRS, pointSource);
assertTrue(checkEquals2D("EPSG:2249 to EPSG:4326 ", result, pointDest, tolerance));
}


//TODO : Fix me add support to NADGRID
@Disabled
@Test
void testFrenchEPSGCodeFrom4326To2232() throws Exception {
String csNameSrc = "EPSG:4326"; //Input EPSG
double[] pointSource = new double[]{-105,40};
Expand Down
40 changes: 37 additions & 3 deletions src/test/java/org/cts/parser/prj/PrjParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.*;

/**
*
Expand Down Expand Up @@ -285,4 +283,40 @@ void testNAD_1983_StatePlane_Iowa_South_FIPS_1402_Feet_PRJ() throws Exception {
assertEquals(6378137.0, Double.parseDouble(params.get("a")), 0.001);
assertEquals(500000, Double.parseDouble(params.get("x_0")), 0.001);
}

@Test
void testCompareCRS_PRJ() throws Exception {
CRSFactory cRSFactory = new CRSFactory();
String prj = "GEOCCS[\"WGS 84 (geocentric)\",\n"
+ " DATUM[\"World Geodetic System 1984\",\n"
+ " SPHEROID[\"WGS 84\",6378137.0,298.257223563,\n"
+ " AUTHORITY[\"EPSG\",\"7030\"]],\n"
+ " AUTHORITY[\"EPSG\",\"6326\"]],\n"
+ " PRIMEM[\"Greenwich\",0.0,\n"
+ " AUTHORITY[\"EPSG\",\"8901\"]],\n"
+ " UNIT[\"m\",1.0],\n"
+ " AXIS[\"Geocentric X\",OTHER],\n"
+ " AXIS[\"Geocentric Y\",EAST],\n"
+ " AXIS[\"Geocentric Z\",NORTH],\n"
+ " AUTHORITY[\"EPSG\",\"4328\"]]";
CoordinateReferenceSystem crs = cRSFactory.createFromPrj(prj);
assertNotNull(crs);

String prj2 = "PROJCS[\"NTF (Paris) / Lambert zone II\",GEOGCS[\"NTF (Paris)\","
+ "DATUM[\"Nouvelle_Triangulation_Francaise_Paris\","
+ "SPHEROID[\"Clarke 1880 (IGN)\",6378249.2,293.4660212936269,"
+ "AUTHORITY[\"EPSG\",\"7011\"]],TOWGS84[-168,-60,320,0,0,0,0],"
+ "AUTHORITY[\"EPSG\",\"6807\"]],PRIMEM[\"Paris\",2.33722917,"
+ "AUTHORITY[\"EPSG\",\"8903\"]],UNIT[\"grad\",0.01570796326794897,"
+ "AUTHORITY[\"EPSG\",\"9105\"]],AUTHORITY[\"EPSG\",\"4807\"]],UNIT[\"metre\",1,"
+ "AUTHORITY[\"EPSG\",\"9001\"]],PROJECTION[\"Lambert_Conformal_Conic_1SP\"],"
+ "PARAMETER[\"latitude_of_origin\",52],PARAMETER[\"central_meridian\",0],"
+ "PARAMETER[\"scale_factor\",0.99987742],PARAMETER[\"false_easting\",600000],"
+ "PARAMETER[\"false_northing\",2200000],"
+ "AUTHORITY[\"EPSG\",\"27572\"],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]]";

CoordinateReferenceSystem crs2 = cRSFactory.createFromPrj(prj2);
assertNotNull(crs);
assertFalse(crs.equals(crs2));
}
}
19 changes: 19 additions & 0 deletions src/test/java/org/cts/parser/prj/PrjWriterTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.cts.parser.prj;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -60,4 +61,22 @@ void testPrettyRoundingSpecialValues() {
assertEquals("-0.39269908169872414", PrjWriter.prettyRound(-22.5*Math.PI/180.0, 1E-11));
assertEquals("-0.39269908169872414", PrjWriter.prettyRound(-0.39269908169872, 1E-11));
}

@Test
@Disabled
void testFormatPRJ() {
String prj = "GEOCCS[\"WGS 84 (geocentric)\",\n"
+ " DATUM[\"World Geodetic System 1984\",\n"
+ " SPHEROID[\"WGS 84\",6378137.0,298.257223563,\n"
+ " AUTHORITY[\"EPSG\",\"7030\"]],\n"
+ " AUTHORITY[\"EPSG\",\"6326\"]],\n"
+ " PRIMEM[\"Greenwich\",0.0,\n"
+ " AUTHORITY[\"EPSG\",\"8901\"]],\n"
+ " UNIT[\"m\",1.0],\n"
+ " AXIS[\"Geocentric X\",OTHER],\n"
+ " AXIS[\"Geocentric Y\",EAST],\n"
+ " AXIS[\"Geocentric Z\",NORTH],\n"
+ " AUTHORITY[\"EPSG\",\"4328\"]]";
assertEquals(prj, PrjWriter.formatWKT(prj));
}
}
4 changes: 3 additions & 1 deletion src/test/resources/org/cts/op/crstransform.csv
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,6 @@ id;csNameSrc;csNameSrc_X;csNameSrc_Y;csNameDest;csNameDest_X;csNameDest_Y;tolera
49;EPSG:4326;-7.899170;52.831312;EPSG:4299;-7.89842402505289;52.8310168494995;0.0000001
52;EPSG:4326;-7.899170;52.831312;EPSG:29900;206845.456303112;175560.736757651;0.01
54;EPSG:4326;-7.899170;52.831312;EPSG:29902;206845.456303112;175560.736757651;0.01
55;EPSG:4326;-3.0;55.0;EPSG:27700;336128.74;567727.11;0.01
55;EPSG:4326;-3.0;55.0;EPSG:27700;336128.74;567727.11;0.01
56;EPSG:4326; 3.8142776; 51.285914;EPSG:23031;556878.9016076007; 5682145.166264554;0.1
57;EPSG:4269; -142.0; 56.50833333333333;ESRI:102632;1640416.667; 916074.825; 0.1

0 comments on commit 290a81b

Please sign in to comment.