Skip to content

String parser: +czech on krovak/mod_krovak sets the base geographic CRS axes to W/S, so the exported conversion negates lat/lon #4931

Open

Description

@mapprehension

AI usage

  • Claude Fable 5.1 supported the creation of this ticket.
  • This ticket has been (mostly) written by myself (human), and is aimed at being read by humans.

Example of problem

+proj=krovak +czech +ellps=bessel +type=crs
  base geographic CRS axes: [Longitude (lon) west] [Latitude (lat) south]
  projected CRS axes      : [Westing () west] [Southing () south]
  conversion as PROJ string: +proj=pipeline +step +inv +proj=axisswap +order=-1,-2 +step +proj=unitconvert +xy_in=deg +xy_out=rad
                             +step +proj=krovak +czech +lat_0=49.5 +lon_0=24.8333333333333 +alpha=30.2881397527778 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel
  (proj_normalize_for_visualization leaves it unchanged)
  normalised conversion fwd (lon 14.42, lat 50.09 deg):        8259804.931   16898811.163
  crs_to_crs from +proj=longlat +ellps=bessel fwd:              742949.431    1042796.966

+proj=krovak +axis=swu +ellps=bessel +type=crs
  base geographic CRS axes: [Longitude (lon) east] [Latitude (lat) north]
  projected CRS axes      : [Southing () south] [Westing () west]
  conversion as PROJ string: +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=krovak +axis=swu +lat_0=49.5 ...
  normalised conversion fwd (lon 14.42, lat 50.09 deg):        1042796.966     742949.431
  crs_to_crs from +proj=longlat +ellps=bessel fwd:             1042796.966     742949.431

bare +proj=krovak +czech +ellps=bessel, proj_trans of the same point:  742949.431  1042796.966
EPSG:5513 base CRS axes: [Geodetic latitude north] [Geodetic longitude east]; projected [Southing (X) south] [Westing (Y) west]

WKT2 of the base CRS of the +czech string:

GEOGCRS["unknown",DATUM["Unknown based on Bessel 1841 ellipsoid",ELLIPSOID["Bessel 1841",6377397.155,299.1528128,
  LENGTHUNIT["metre",1,ID["EPSG",9001]]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8901]],
  CS[ellipsoidal,2],AXIS["longitude",west,ORDER[1],ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]],
  AXIS["latitude",south,ORDER[2],ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]]]

mod_krovak +czech behaves the same (normalised conversion gives 7727742.325, 17611093.672 for the point above).

Problem description

Sorry for the long explanation; this is complicated.
For +proj=krovak +czech ... +type=crs (and mod_krovak), the parser builds a ProjectedCRS whose projected coordinate system is [Westing west, Southing south], as intended since #2200, but it also gives the base GeographicCRS an ellipsoidal CS with axes [Longitude west, Latitude south]. The conversion attached to the CRS then starts with +step +inv +proj=axisswap +order=-1,-2, which negates longitude and latitude before +proj=krovak +czech. Anything that uses the conversion on its own (proj_crs_get_coordoperation, proj_as_proj_string of it, or the WKT of the CRS in another consumer) projects (-lon, -lat). proj_create_crs_to_crs from an ordinary geographic CRS is not affected because the geographic-to-base step negates once more and the two cancel. That’s probably why this has gone unnoticed.

Expected Output

The base CRS of a +czech string should be the ordinary [Longitude east, Latitude north] geographic CRS, as it is for +axis=swu and for EPSG:5513/5514. The projected CS stays [Westing, Southing]. The conversion is then +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=krovak +czech ..., and the three ways of projecting the point agree (742949.431, 1042796.966 as westing, southing).

Environment Information

  • PROJ version (proj): 9.7.0
  • Operation System Information: MacOS 15.7.7

Installation method

  • From C source

Activity

  1. mapprehension commented on Nov 4, 2026

    @mapprehension
    Author

    Proposed fix

        } else if (!isGeographic &&
                   (step.name == "krovak" || step.name == "mod_krovak") &&
                   hasParamValue(step, "czech")) {
            axis[0] = std::move(west);
            axis[1] = std::move(south);
        }

    The buildProjectedCRS branches that map +czech to the Krovak methods (io.cpp 11811-11828) are not affected. A test
    in test/unit/test_io.cpp asserting that the base CRS axes of +proj=krovak +czech +type=crs are east/north, and that the
    exported conversion has no axisswap step before the projection, would keep this from happening again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions