Skip to content

Commit 7b20146

Browse files
jsorelalexismanin
authored andcommitted
fix: add support and test case for spherical to projection transform
Fix issue pdssp#10
1 parent 3691350 commit 7b20146

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies {
3131
compileOnly("org.jspecify:jspecify:1.0.0")
3232

3333
// Referencing engine
34-
implementation("org.apache.sis.core:sis-referencing:1.5.0-ALPHA-1")
34+
implementation(libs.apache.sis.referencing)
3535
implementation("org.apache.sis.non-free:sis-embedded-data:1.3")
3636
implementation("org.apache.sis.non-free:sis-epsg:1.3")
3737
implementation("org.apache.derby:derby")
@@ -41,7 +41,7 @@ dependencies {
4141
// For client
4242
testFixturesImplementation(platform(libs.geomatys.backend.bom))
4343
testFixturesImplementation("org.springframework:spring-core")
44-
testFixturesApi("org.apache.sis.core:sis-referencing:1.5.0-ALPHA-1")
44+
testFixturesApi(libs.apache.sis.referencing)
4545
testFixturesImplementation("org.graalvm.js:js:24.1.1")
4646
testFixturesImplementation("org.graalvm.js:js-scriptengine:24.1.1")
4747
testFixturesImplementation("org.python:jython-slim:2.7.4")

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
geomatys-backend = "2025.1"
33
springdoc = "2.8.9"
44
therapi = "0.15.0"
5+
apache-sis = "1.5.0-ALPHA-2"
56

67
[libraries]
8+
apache-sis-referencing = { module = "org.apache.sis.core:sis-referencing", version.ref = "apache-sis" }
79
geomatys-backend-bom = { module = "com.geomatys.backend:downstream-bom", version.ref = "geomatys-backend" }
810
springdoc-starter = { module = "org.springdoc:springdoc-openapi-starter-webmvc-ui", version.ref = "springdoc" }
911
therapi-runtime = { module = "com.github.therapi:therapi-runtime-javadoc", version.ref = "therapi" }

src/main/java/com/geomatys/crsservice/service/DefaultCrsOperationService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,8 @@ private static String toPythonClass(MathTransform trs) {
478478
pythonCode = pythonCode.replaceAll("β", "beta");
479479
//replace ρ
480480
pythonCode = pythonCode.replaceAll("ρ", "rho");
481+
//replace Ω
482+
pythonCode = pythonCode.replaceAll("Ω", "omega");
481483

482484
{//replace NaN
483485
final Pattern objPattern = Pattern.compile("(Number.math.NaN|Number.NaN|NaN)");

src/test/java/com/geomatys/crsservice/client/ClientTest.java

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
/**
1919
*
20-
* @author jsorel
20+
* @author Johann Sorel (Geomatys)
2121
*/
2222
public class ClientTest extends AbstractIntegrationTest {
2323

@@ -43,6 +43,41 @@ public void operationTest() throws Exception {
4343
testTransform(factory, "EPSG:4326", "EPSG:2154", new double[]{48, 2}, true, cartTolerance, geogTolerance);
4444
//Geocentric
4545
testTransform(factory, "EPSG:4326", "EPSG:4978", new double[]{48, 2}, true, cartTolerance, geogTolerance);
46+
//Spherical to projection
47+
final String mars1 =
48+
"GEODCRS[\"Mars (2015) / Ocentric\",\n" +
49+
" DATUM[\"Mars (2015)\",\n" +
50+
" ELLIPSOID[\"Mars (2015)\", 3396190, 169.8944472236118,\n" +
51+
" LENGTHUNIT[\"metre\", 1, ID[\"EPSG\", 9001]]],\n" +
52+
" ANCHOR[\"Viking 1 lander : 47.95137 W\"]],\n" +
53+
" PRIMEM[\"Reference Meridian\", 0,\n" +
54+
" ANGLEUNIT[\"degree\", 0.0174532925199433, ID[\"EPSG\", 9122]]],\n" +
55+
" CS[spherical, 2],\n" +
56+
" AXIS[\"planetocentric latitude (U)\", north,\n" +
57+
" ANGLEUNIT[\"degree\", 0.0174532925199433]],\n" +
58+
" AXIS[\"planetocentric longitude (V)\", east,\n" +
59+
" ANGLEUNIT[\"degree\", 0.0174532925199433]],\n" +
60+
" ID[\"IAU\", 49902, 2015],\n" +
61+
" REMARK[\"Source of IAU Coordinate systems: doi:10.1007/s10569-017-9805-5\"]]";
62+
final String mars2 =
63+
"PROJCRS[\"Mars (2015) / Ocentric / Equirectangular, clon = 0\",\n" +
64+
" BASEGEODCRS[\"Mars (2015) / Ocentric\",\n" +
65+
" DATUM[\"Mars (2015)\",\n" +
66+
" ELLIPSOID[\"Mars (2015)\", 3396190, 169.8944472236118,\n" +
67+
" LENGTHUNIT[\"metre\", 1, ID[\"EPSG\", 9001]]],\n" +
68+
" ANCHOR[\"Viking 1 lander : 47.95137 W\"]],\n" +
69+
" PRIMEM[\"Reference Meridian\", 0,\n" +
70+
" ANGLEUNIT[\"degree\", 0.0174532925199433, ID[\"EPSG\", 9122]]],\n" +
71+
" ID[\"IAU\", 49902, 2015]],\n" +
72+
" CONVERSION[\"Equirectangular, clon = 0\",\n" +
73+
" METHOD[\"Equidistant Cylindrical\", ID[\"EPSG\", 1028]]],\n" +
74+
" CS[Cartesian, 2],\n" +
75+
" AXIS[\"Easting (E)\", east,\n" +
76+
" LENGTHUNIT[\"metre\", 1]],\n" +
77+
" AXIS[\"Northing (N)\", north,\n" +
78+
" LENGTHUNIT[\"metre\", 1]],\n" +
79+
" ID[\"IAU\", 49912, 2015]]";
80+
testTransform(factory, mars1, mars2, new double[]{40, 120}, true, cartTolerance, geogTolerance);
4681

4782
//test PassThroughTransform : Not working yet
4883
CoordinateReferenceSystem crs1 = CRS.compound(CRS.forCode("CRS:84"));

0 commit comments

Comments
 (0)