Skip to content

Commit

Permalink
Fix the default Krovak projection behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
pomadchin committed Apr 7, 2021
1 parent 0d719d9 commit 3b948fb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fix NZ Map projection and add a test for it [#62](https://github.com/locationtech/proj4j/issues/62)
- Update OrthographicAzimuthalProjection [#63](https://github.com/locationtech/proj4j/pull/63)
- Fix UTM and LCC projections [#71](https://github.com/locationtech/proj4j/pull/71)
- Fix UTM, LCC and Krovak projections [#71](https://github.com/locationtech/proj4j/pull/71)

### Added
- Geocent projection support [#60](https://github.com/locationtech/proj4j/pull/60)
Expand Down
30 changes: 15 additions & 15 deletions src/main/java/org/locationtech/proj4j/proj/KrovakProjection.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
*/
public class KrovakProjection extends Projection {

// TODO: should be set on parsing https://github.com/OSGeo/PROJ/blob/e3d7e18f988230973ced5163fa2581b6671c8755/src/projections/krovak.cpp#L219
boolean czech = false;

public KrovakProjection() {
minLatitude = Math.toRadians(-60);
maxLatitude = Math.toRadians(60);
Expand Down Expand Up @@ -93,12 +96,10 @@ public ProjCoordinate project(double lplam, double lpphi, ProjCoordinate out) {
out.y = ro * cos(eps) / a;
out.x = ro * sin(eps) / a;

// TODO: Is the 'czech' parameter used?
// if( !pj_param(P->ctx, P->params, "tczech").i )
// {
// out.y *= -1.0;
// out.x *= -1.0;
// }
if(!czech) {
out.y *= -1.0;
out.x *= -1.0;
}

return out;
}
Expand Down Expand Up @@ -144,15 +145,14 @@ protected ProjCoordinate projectInverse(double x, double y, ProjCoordinate dst)

/* Transformation */
/* revert y, x*/
xy0=dst.x;
dst.x=dst.y;
dst.y=xy0;

// if( !pj_param(P->ctx, P->params, "tczech").i )
// {
// xy.x *= -1.0;
// xy.y *= -1.0;
// }
xy0 = dst.x;
dst.x = dst.y;
dst.y = xy0;

if(!czech) {
dst.x *= -1.0;
dst.y *= -1.0;
}

ro = sqrt(dst.x * dst.x + dst.y * dst.y);
eps = atan2(dst.y, dst.x);
Expand Down
8 changes: 4 additions & 4 deletions src/test/resources/proj4-epsg.csv
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@
"4326 -> 2062","passing","EPSG","4326","EPSG","2062","1.0","-1.0","0.0","1258119.418827","-4298983.61299","0.0","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 2063","passing","EPSG","4326","EPSG","2063","1.0","-1.0","0.0","2303642.507004","-115006.885056","-93.77219","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 2064","passing","EPSG","4326","EPSG","2064","1.0","-1.0","0.0","1618065.607747","-112238.577068","-93.77219","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 2065","failing","EPSG","4326","EPSG","2065","1.0","-1.0","0.0","-3403171.813904","-6866781.451858","158.074317","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 2065","passing","EPSG","4326","EPSG","2065","1.0","-1.0","0.0","-3403377.810463121","-6866646.72852765","158.074317","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 2066","passing","EPSG","4326","EPSG","2066","1.0","-1.0","0.0","3.4317337166318E7","-7031695.106846","0.0","1.000000","1.000000","1.000000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 2067","passing","EPSG","4326","EPSG","2067","1.0","-1.0","0.0","9876054.028905","-256097.732178","-253.989895","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 2068","passing","EPSG","4326","EPSG","2068","1.0","-1.0","0.0","-693194.855433","-111505.316514","-136.082986","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
Expand Down Expand Up @@ -2019,7 +2019,7 @@
"4326 -> 5128","passing","EPSG","4326","EPSG","5128","1.0","-1.0","0.0","-3086396.944001","-5556051.006767","0.0","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 5129","passing","EPSG","4326","EPSG","5129","1.0","-1.0","0.0","-3212547.349776","-5557223.406762","0.0","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 5130","passing","EPSG","4326","EPSG","5130","1.0","-1.0","0.0","-3339902.765479","-5558457.356322","0.0","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 5221","failing","EPSG","4326","EPSG","5221","1.0","-1.0","0.0","-3403171.813904","-6866781.451858","158.074317","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 5221","passing","EPSG","4326","EPSG","5221","1.0","-1.0","0.0","-3403171.8139043623","-6866781.451857718","158.074317","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 5223","passing","EPSG","4326","EPSG","5223","1.0","-1.0","0.0","-731474.867088","387387.177554","0.0","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 5234","passing","EPSG","4326","EPSG","5234","1.0","-1.0","0.0","-1.3758260606485E7","-1005469.03451","945.386856","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 5235","passing","EPSG","4326","EPSG","5235","1.0","-1.0","0.0","-1.345855967557E7","-705291.382937","849.332431","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
Expand Down Expand Up @@ -2095,8 +2095,8 @@
"4326 -> 5481","passing","EPSG","4326","EPSG","5481","1.0","-1.0","0.0","-1669284.136119","-1.1868078294819E7","0.0","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 5482","passing","EPSG","4326","EPSG","5482","1.0","-1.0","0.0","4783239.204562","-1.1418217653712E7","0.0","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 5490","passing","EPSG","4326","EPSG","5490","1.0","-1.0","0.0","9876408.371062","-255706.192524","0.0","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 5513","failing","EPSG","4326","EPSG","5513","1.0","-1.0","0.0","-3403171.813904","-6866781.451858","158.074317","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 5514","failing","EPSG","4326","EPSG","5514","1.0","-1.0","0.0","-3403171.813904","-6866781.451858","158.074317","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 5513","passing","EPSG","4326","EPSG","5513","1.0","-1.0","0.0","-3403171.813904","-6866781.451858","158.074317","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 5514","passing","EPSG","4326","EPSG","5514","1.0","-1.0","0.0","-3403171.813904","-6866781.451858","158.074317","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 5520","passing","EPSG","4326","EPSG","5520","1.0","-1.0","0.0","1277387.834203","-111056.870189","105.205271","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 5523","passing","EPSG","4326","EPSG","5523","1.0","-1.0","0.0","325154.339023","5387574.863316","0.0","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
"4326 -> 5530","failing","EPSG","4326","EPSG","5530","1.0","-1.0","0.0","1.1121377267748E7","9838205.650141","43.595055","0.100000","0.100000","0.100000","","","","Auto-generated from proj.4 epsg database"
Expand Down

2 comments on commit 3b948fb

@karol-bujacek
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @pomadchin ,

I see EPSG5514 in the changes – are your changes possibly related also to the issue #25 ?

@pomadchin
Copy link
Member Author

@pomadchin pomadchin commented on 3b948fb Apr 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @karol-bujacek a good catch, yes indeed it addresses your issue!

The whole fix was to reverse the sign and align it with the proj4js / osgeo PROJ default behavior; however, this projection supports an extra +czech param (see https://proj.org/operations/projections/krovak.html), and this param proj4j support is not a part of this PR.

Please sign in to comment.