Skip to content

LCC ProjectInverse adjustment, BasicCoordinateTransform.transform cleanup #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- LCC ProjectInverse adjustment, BasicCoordinateTransform.transform cleanup [#117](https://github.com/locationtech/proj4j/pull/117)

### Added
- GeoAPI wrappers for PROJ4J [#115](https://github.com/locationtech/proj4j/pull/115)

## [1.3.0] - 2023-05-30

### Added
Expand Down
2 changes: 1 addition & 1 deletion HOWTORELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ General Notes

Cheat sheet:
- All commands are can be described via the following template:
mvn -P{eclipse | central} {-Dmaven.test.skip=true | } {-pl <module> | } {install, deploy, ...}
mvn -P{eclipse | central} {-Dmaven.test.skip=true | } {-pl <module> | } {install, deploy, ...} {-Dmaven.install.skip={false|true}}

The description of the Sonatype publish process:
- Snaphots:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ public ProjCoordinate transform(ProjCoordinate src, ProjCoordinate tgt)

srcCRS.getProjection().getPrimeMeridian().toGreenwich(tgt);

// 'fix' commented out, see https://github.com/locationtech/proj4j/issues/116
// fixes bug where computed Z value sticks around
tgt.clearZ();
// tgt.clearZ();

if (doDatumTransform) {
datumTransform(tgt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,21 @@ public ProjCoordinate project(double x, double y, ProjCoordinate out) {
}

public ProjCoordinate projectInverse(double x, double y, ProjCoordinate out) {
// https://github.com/OSGeo/PROJ/blob/9.6/src/projections/lcc.cpp#L49-L53
x /= scaleFactor;
y /= scaleFactor;
double rho = ProjectionMath.distance(x, y = rho0 - y);
y = rho0 - y;
double rho = ProjectionMath.distance(x, y);
if (rho != 0) {
if (n < 0.0) {
rho = -rho;
x = -x;
y = -y;
}
if (spherical)
out.y = 2.0 * Math.atan(Math.pow(c / rho, 1.0/n)) - ProjectionMath.HALFPI;
out.y = 2.0 * Math.atan(Math.pow(c / rho, 1.0 / n)) - ProjectionMath.HALFPI;
else
out.y = ProjectionMath.phi2(Math.pow(rho / c, 1.0/n), e);
out.y = ProjectionMath.phi2(Math.pow(rho / c, 1.0 / n), e);
out.x = Math.atan2(x, y) / n;
} else {
out.x = 0.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,14 @@ public void testEPSG_27250() {
"+proj=tmerc +lat_0=-36.87986527777778 +lon_0=174.7643393611111 +k=0.9999 +x_0=300000 +y_0=700000 +datum=nzgd49 +units=m +towgs84=59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993 +nadgrids=nzgd2kgrid0005.gsb +no_defs", 301062.2010778899, 210376.65974323952,
0.001);
}

// https://github.com/locationtech/proj4j/issues/116
@Test
public void testEPSG_2994() {
checkTransform(
"EPSG:2994", new ProjCoordinate(635788, 850485, 81),
"+proj=geocent +datum=WGS84",
new ProjCoordinate(-2505627.3608, -3847384.25836, 4412472.6628),
0.001);
}
}