From 88121f8a38704c2189bd45415c69cc6e7c80551f Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Mon, 26 Oct 2026 11:02:15 -0400 Subject: [PATCH 01/10] docs: Add design spec for GeoKey to CRS conformance corpus and table-driven builder Design for making GeoKey -> CRS parsing match GDAL/PROJ: a shared conformance corpus and CT table in geotiff-test-data, and a rewrite of _crs.py that interprets the table with pyproj's typed constructors. Written before any code so the manifest schema, table schema, equality definition and known-failures mechanism can be reviewed first. Co-Authored-By: Claude Fable 5.1 --- ...026-10-26-geokey-crs-conformance-design.md | 693 ++++++++++++++++++ 1 file changed, 693 insertions(+) create mode 100644 dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md diff --git a/dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md b/dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md new file mode 100644 index 0000000..dffd475 --- /dev/null +++ b/dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md @@ -0,0 +1,693 @@ +# GeoKey to CRS conformance: corpus, CT table, and table-driven builder + +- **Date:** 2026-10-26 +- **Status:** Draft, awaiting review +- **Repos:** `developmentseed/geotiff-test-data` (corpus + table), `developmentseed/async-geotiff` (builder + tests) +- **Out of scope:** `developmentseed/deck.gl-raster` (consumes the corpus and table later), anything upstream (pyproj, PROJ, GDAL, async-tiff) without explicit OK +- **Oracle:** whatever GDAL/PROJ reads from a file's GeoKeys, as seen through `rasterio` +- **Reference sources:** libgeotiff `geo_normalize.c` at commit `75cfca539667c6483e796b24b78ecef72e311a1a`; GDAL `frmts/gtiff/gt_wkt_srs.cpp` at tag `v3.12.1`; PROJ `src/iso19111/io.cpp` at tag `9.7.1` +- **Environment facts used here:** async-geotiff `.venv` has pyproj 3.7.2 on PROJ 9.5.1, rasterio 1.5.0 on GDAL 3.12.1 / PROJ 9.7.1, async-tiff 0.7.0. geotiff-test-data pixi env pins gdal 3.12.x, rasterio 1.5.x. + +## 1. Intent + +`src/async_geotiff/_crs.py` hand-builds PROJJSON from GeoKeys. Measured against GDAL on 36 +GDAL-written files, 21 are wrong (see the task brief for the failure classes: rejected CT codes, +wrong Mercator and Polar Stereographic variants, units ignored, origin-key fallbacks missing, `a or +b` zero bugs, HOM variant and grid-angle mistakes, EPSG-coded datum dropped). + +This work replaces guesswork with two shared, language-neutral artifacts and a small interpreter: + +1. A **conformance corpus** in `geotiff-test-data`: GDAL-written GeoTIFFs plus a manifest recording + the GeoKeys GDAL wrote and the CRS GDAL reads back. +2. A **CT table** (`crs/geotiff-ct-methods.json`): how each `ProjCoordTransGeoKey` code maps to a + PROJ/EPSG method and how each parameter is read from GeoKeys, transcribed from libgeotiff and + GDAL with line citations. +3. A rewrite of `_crs.py` that interprets the table and builds the CRS with pyproj's typed + constructors, validated by a parametrized test over the corpus. + +The TypeScript twin in deck.gl-raster will consume (1) and (2) unchanged. + +## 2. Goals, non-goals, anti-goals + +**Goals** + +- Every GeoKey arrangement GDAL 3.12 can write for a user-defined projected or geographic CRS is in + the corpus, and `async_geotiff` reads each one to a CRS that PROJ considers equal to GDAL's. +- The corpus and table are consumable offline by a TS test suite with no PROJ database (hence the + cached `epsg.io` JSON and the normalized core in the manifest). +- The conformance suite is green from the first PR via a known-failures list that can only shrink. + +**Non-goals** + +- Writing GeoKeys. Vertical CRSs, geocentric model type, coordinate epoch. Non-GDAL writers' + quirks (ESRI/Erdas state-plane citations) beyond what already works. +- Matching GDAL's CRS *names* beyond what equality requires (section 5). +- Changing deck.gl-raster in this effort. + +**Anti-goals** (would make this a failure even if tests pass) + +- A table transcribed from memory instead of from `GTIFFetchProjParms` / `GTIFGetOGISDefn`. +- A builder that constructs the conversion as a dict (silent parameter drops, see 6.3). +- A known-failures list that masks regressions: a listed case that starts passing must fail the run. + +## 3. Facts established by probing (shape the design) + +All verified in the async-geotiff `.venv` against GDAL-written files. The implementer can rerun the +probes from the prior session's `gen.py`/`py_probe.py` (copied to the session scratchpad). + +- **Datum names are semantic, with one wildcard.** `pyproj.CRS.equals` and `rasterio.crs.CRS.__eq__` + both return False when only the datum name differs, except that a datum named exactly `unknown` + compares equal to any datum with the same ellipsoid and prime meridian (both PROJ and GDAL). + Ellipsoid names, CRS names and conversion names do not affect equality. pyproj's default datum + name `undefined` is *not* a wildcard. +- **Prime meridian names are semantic.** A PM named `Paris` at 2.33722917° equals GDAL's reading; + the same longitude named `unknown` does not. +- **Parameter units:** `pyproj.CRS.equals` converts parameter units (46.8° vs 52 grad compare + equal); GDAL's `IsSame` does not. The *coordinate system* unit is strict in both (a base + geographic CRS in grads is not equal to one in degrees). Projected CS in US survey feet with + conversion parameters given in metres compares equal to GDAL's reading (which keeps the + parameters in feet). +- **`CoordinateOperation.from_string("+proj=sterea ...")` is unusable:** it yields a "PROJ-based + operation method" with zero parameters. `CRS.from_proj4("+proj=sterea ... +ellps=WGS84") + .coordinate_operation` yields a proper `Oblique Stereographic` (EPSG 9809) conversion with EPSG + parameter ids, and that conversion can be attached to a different geodetic CRS via + `ProjectedCRS(conversion=..., geodetic_crs=...)`. This is the fallback for methods without a + typed class (6.3). +- **PROJJSON validation:** a misspelled parameter name without an `id` is silently dropped + (value becomes 0). With a correct EPSG `id` alongside the misspelled name, PROJ 9.5 honours the + id. The typed-constructor decision stands; the post-build check in 6.3 guards both paths. +- **`Datum.from_epsg(6326)`** returns the WGS 84 ensemble and compares equal to GDAL's reading of + `GeogGeodeticDatumGeoKey = 6326`; `Datum.from_epsg(6267)` matches NAD27. `Ellipsoid.from_epsg`, + `PrimeMeridian.from_epsg` and `CoordinateOperation.from_epsg(16033)` (UTM via + `ProjectionGeoKey`) all produce equal CRSs. +- **Sphere:** `CustomEllipsoid(radius=...)` matches GDAL's reading of equal semi-major and + semi-minor axes. +- **Axes:** GDAL reads CT 27 (TM South Orientated) with axes `Easting/west, Northing/south`; + `Cartesian2DCS(axis="WESTING_SOUTHING")` reproduces that exactly. pyproj also has + `EASTING_NORTHING_FT` and `EASTING_NORTHING_US_FT` presets for the two common foot units. +- **async-tiff (0.7.0, 0.7.2 and current `main`) exposes neither `GeogTOWGS84GeoKey` (2062) + nor `ProjRectifiedGridAngleGeoKey` (3096)**, has no raw access by key id, and + `ifd.other_tags` does not carry the GeoKey tags (34735-34737). GDAL writes 2062 for + `+towgs84=` (read back as a `BoundCRS`) and 3096 for both Hotine Oblique Mercator variants and + `somerc`. Until async-tiff exposes them, the `tmerc_towgs84`, `omerc_variant_a`, + `omerc_variant_b` and `somerc` rows are known failures (open question Q2). +- **GDAL never writes `GeogPrimeMeridianGeoKey` codes**, even from WKT carrying + `AUTHORITY["EPSG","8903"]`; it writes `GeogPrimeMeridianLongGeoKey` plus `Primem = Paris` in the + citation. libgeotiff does read PM codes, so the builder supports them, and one fixture is written + with tifffile to cover it (4.3). +- **GDAL's handling of a prime meridian in grads is internally inconsistent.** For + `+pm=paris` input GDAL writes `GeogAngularUnitsGeoKey = 9105` and a PM longitude key of + `0.0367131` (the degree value multiplied by the grad-to-radian factor), then reads it back as + `0.0267639°` (three successive 0.9 factors). libgeotiff's own `GTIFAngleToDD` applies one factor. + We follow libgeotiff, so this row is a documented permanent known failure (Q3); a grads fixture + with Greenwich PM tests the angular-unit path cleanly. +- **GDAL writes no GeoKeys for methods it cannot encode** (Equal Earth) and instead writes a + `.aux.xml` sidecar. The generator must disable PAM so the manifest records what the TIFF alone + carries. Mollweide and Krovak get an `ESRI PE String` citation under `GTModelTypeGeoKey = 32767` + (already handled by `_esri_pe_string`). +- **GDAL identifies conversions:** TM with `lon_0=129, k=0.9996, x_0=500000` is written as + `ProjectionGeoKey = 16052` (UTM 52N) with no CT key. The corpus keeps such a case deliberately + and otherwise avoids parameters that collapse to EPSG codes. +- **Polar Stereographic variant** is decided by *values*, not by key presence: GDAL always writes + `ProjScaleAtNatOriginGeoKey` for polar files (1.0 when unused) and never `ProjStdParallel1`. + `lat_0 = 71, k = 1` reads back as variant B; `lat_0 = 90, k = 0.994` as variant A. PROJ 9.7.1 + `io.cpp` L4231-L4279 is the deciding code: scale exactly 1 → variant B, else latitude at a pole + → variant A, else a non-EPSG `Polar_Stereographic` method. The brief's stated rule is therefore + replaced by the one in 5.2 (see Q1). + +## 4. Corpus (geotiff-test-data) + +### 4.1 Layout + +``` +crs/ + README.md # what this is, how to regenerate, schema of manifest + table + cases.py # the case list (data only) + generate_crs.py # writes fixtures/, manifest.json, fetches missing epsg/ files + geotiff-ct-methods.json # the CT table (section 5) + manifest.json # one row per fixture + fixtures/.tif # 8x8 uint8, uncompressed, plain GTiff (no overviews, no COG) + epsg/.json # cached https://epsg.io/.json, one per EPSG case +``` + +My calls, deviating from the repo's one-script-per-fixture convention: + +- One table-driven generator instead of ~90 fixture scripts, because the cases are data. +- `pixi run generate-crs` task; `scripts/check.sh` runs it after `generate` so CI verifies the + corpus is reproducible from `cases.py` with the pinned GDAL. +- `scripts/info.sh` skips `crs/` (the manifest documents these files; 90 `_info.md` files add + nothing). +- Fixtures are plain GTiff via `rasterio.open(..., driver="GTiff")`, not `write_cog`, written + inside `rasterio.Env(GDAL_PAM_ENABLED="NO")`. +- The `epsg/` fetch happens only when the file is missing (offline regeneration works); + `--refresh-epsg` refetches. + +### 4.2 Case forms + +Each case in `cases.py` is a dataclass `Case(name, kind, value, note="", tags=())` with +`kind in {"proj", "epsg", "wkt"}`: + +- `proj`: a PROJ string. GDAL converts it to user-defined GeoKeys. The code path under test. +- `epsg`: an EPSG code. GDAL writes coded keys. The generator also caches `epsg/.json`. +- `wkt`: a WKT1 string (ESRI or OGC). Used where a PROJ string cannot express the input (prime + meridian in degrees with a name, grads with Greenwich, Polar Stereographic with + `latitude_of_origin != 90` and `scale != 1`, ESRI-named CRSs). + +### 4.3 Case list + +Seeded from the prior session's `gen.py`, then made systematic. Names are the fixture stems. + +**One per CT code GDAL can write** (write side of `gt_wkt_srs.cpp`, `GTIFSetFromOGISDefnEx`; +CT codes 2, 5 and 6 have no GDAL write or read case and get no fixture): + +| CT | name | input | +|---|---|---| +| 1 | `tmerc` | `+proj=tmerc +lat_0=0 +lon_0=-3.5 +k=0.9996 +x_0=500000 +y_0=0 +ellps=WGS84` | +| 3 | `omerc_variant_a` | `+proj=omerc ... +no_uoff +ellps=WGS84` (prior `omerc_nouoff`) | +| 4 | `labrd` | `+proj=labrd +lat_0=-18.9 +lon_0=46.43722917 +azi=18.9 +k=0.9995 +x_0=400000 +y_0=800000 +ellps=intl` | +| 7 | `merc_1sp` | `+proj=merc +lon_0=10 +k=0.98 +ellps=WGS84` | +| 7 | `merc_2sp` | `+proj=merc +lat_ts=30 +lon_0=10 +ellps=WGS84` | +| 8 | `lcc_2sp` | `+proj=lcc +lat_1=33 +lat_2=45 +lat_0=23 +lon_0=-96 +ellps=WGS84` | +| 9 | `lcc_1sp` | `+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=2.3 +k_0=0.99987742 +x_0=600000 +y_0=2200000 +ellps=clrk80ign` | +| 10 | `laea` | `+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80` | +| 11 | `aea` | `+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +ellps=WGS84` | +| 12 | `aeqd` | `+proj=aeqd +lat_0=40 +lon_0=-100 +ellps=WGS84` | +| 13 | `eqdc` | `+proj=eqdc +lat_1=33 +lat_2=45 +lat_0=23 +lon_0=-96 +ellps=WGS84` | +| 14 | `stere_oblique` | `+proj=stere +lat_0=46.5 +lon_0=-66.5 +k=0.999912 +ellps=WGS84` | +| 15 | `stere_polar_a` | `+proj=stere +lat_0=90 +k=0.994 +lon_0=0 +ellps=WGS84` | +| 15 | `stere_polar_b` | `+proj=stere +lat_0=90 +lat_ts=71 +lon_0=-45 +ellps=WGS84` | +| 15 | `stere_south_a` | `+proj=stere +lat_0=-90 +k=0.994 +lon_0=0 +ellps=WGS84` | +| 15 | `stere_south_b` | `+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +ellps=WGS84` | +| 15 | `stere_polar_scaled_wkt` | WKT1 `Polar_Stereographic` with `latitude_of_origin=71`, `scale_factor=0.9` (pins PROJ's fall-through case in 5.2; flagged, `gdal.proj4` null) | +| 15 | `stere_polar_k1_wkt` | WKT1 `Polar_Stereographic` with `latitude_of_origin=90`, `scale_factor=1` (pins that scale 1 wins over the pole: variant B with `lat_ts = 90`) | +| 16 | `sterea` | `+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel` | +| 17 | `eqc` | `+proj=eqc +lat_ts=30 +lon_0=10 +ellps=WGS84` | +| 18 | `cass` | `+proj=cass +lat_0=10 +lon_0=-61 +ellps=WGS84` | +| 19 | `gnom` | `+proj=gnom +lat_0=40 +lon_0=-100 +ellps=WGS84` | +| 20 | `mill` | `+proj=mill +lon_0=0 +ellps=WGS84` | +| 21 | `ortho` | `+proj=ortho +lat_0=40 +lon_0=-100 +ellps=WGS84` | +| 22 | `poly` | `+proj=poly +lat_0=0 +lon_0=-54 +ellps=WGS84` | +| 23 | `robin` | `+proj=robin +lon_0=0 +ellps=WGS84` | +| 24 | `sinu_sphere` | `+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +R=6371007.181` | +| 25 | `vandg` | `+proj=vandg +lon_0=0 +ellps=WGS84` | +| 26 | `nzmg` | `+proj=nzmg +lat_0=-41 +lon_0=173 +x_0=2510000 +y_0=6023150 +ellps=intl` | +| 27 | `tmso` | `+proj=tmerc +lat_0=0 +lon_0=19 +k=1 +x_0=0 +y_0=0 +axis=wsu +ellps=WGS84` | +| 28 | `cea` | `+proj=cea +lat_ts=31 +lon_0=0 +ellps=WGS84` | +| 9815 | `omerc_variant_b` | `+proj=omerc +lat_0=4 +lonc=102.25 +alpha=323.0257964666666 +gamma=323.1301023611111 +k=0.99984 +x_0=804671 +y_0=0 +ellps=WGS84` | +| 9815 | `somerc` | `+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel` (GDAL writes azimuth 90, reads back `+proj=somerc`) | + +**Units** (linear parameters are written in the projected unit; angular in `GeogAngularUnits`): + +| name | input | +|---|---| +| `lcc_2sp_usft` | `+proj=lcc +lat_1=41.03333 +lat_2=40.66667 +lat_0=40.16667 +lon_0=-74 +x_0=300000 +y_0=0 +ellps=GRS80 +units=us-ft` (prior `tmerc_usft`) | +| `tmerc_ft` | `tmerc` with `+units=ft` (international foot, 9002) | +| `lcc_1sp_grad_wkt` | WKT1 LCC 1SP, `UNIT["grad",0.01570796326794897]`, Greenwich PM | +| `geog_grad_wkt` | WKT1 GEOGCS in grads, Greenwich PM | +| `lcc_1sp_paris_grad` | `lcc_1sp` with `+lon_0=0 +pm=paris` (GDAL writes grads; see Q3) | + +**Datum, ellipsoid, prime meridian variants:** + +| name | input | exercises | +|---|---|---| +| `aea_nad27` | `+proj=aea ... +datum=NAD27` | `GeogGeodeticDatumGeoKey = 6267`, axes present, no ellipsoid key | +| `tmerc_datum_wgs84` | `tmerc` with `+datum=WGS84` | `GeogGeodeticDatumGeoKey = 6326` | +| `tmerc` (above) | | `GeogEllipsoidGeoKey = 7030` plus axes, user-defined datum | +| `sterea`, `nzmg`, `lcc_1sp` | | ellipsoid 32767 with explicit axes (no EPSG match) | +| `sinu_sphere`, `geog_sphere` | `+R=` | semi-minor = semi-major, no inverse flattening | +| `tmerc_towgs84` | `+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=bessel +towgs84=598.1,73.7,418.2,0.202,0.045,-2.455,6.7` | `GeogTOWGS84GeoKey` (Q2) | +| `lcc_1sp_paris_deg_wkt` | WKT1 with `PRIMEM["Paris",2.33722917]`, degrees | PM longitude key + `Primem = Paris` citation | +| `lcc_1sp_pm_user` | `lcc_1sp` with `+lon_0=0 +pm=2.5` | PM longitude key, `Primem = unknown` | +| `lcc_1sp_pm_epsg_tifffile` | written with tifffile: same keys as `lcc_1sp` but `GeogPrimeMeridianGeoKey = 8903`, no PM longitude key | EPSG-coded PM (GDAL never writes one) | +| `longlat_grs80` | `+proj=longlat +ellps=GRS80` | user-defined geographic CRS | +| `utm_bessel` | `+proj=utm +zone=33 +ellps=bessel` | `ProjectionGeoKey = 16033`, no CT key, user-defined datum | + +**Coded and citation forms:** + +| name | input | +|---|---| +| `epsg_` for each of 2039, 2046, 2056, 2057, 2065, 2100, 2154, 21781, 2193, 2263, 26917, 27572, 27700, 28992, 2953, 3031, 3035, 3067, 3088, 31370, 32633, 32661, 32761, 3301, 3310, 3338, 3347, 3375, 3395, 3408, 3410, 3413, 3857, 3975, 3978, 3993, 4087, 4326, 4267, 5070, 5514, 5880, 6318, 6933, 7845, 9377 | `EPSG:` (the prior session's set, which covers one EPSG method each, plus 4267) | +| `moll` | `+proj=moll +lon_0=0 +ellps=WGS84` (ESRI PE String path) | +| `krovak` | `+proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=30.28813972222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel` (PE String) | +| `esri_54009` | `ESRI:54009` (PE String with `GeogGeodeticDatumGeoKey = 6326`) | +| `eqearth` | `+proj=eqearth +lon_0=0 +ellps=WGS84` (GDAL writes no keys; `gdal.projjson` is null; row flagged, not tested) | + +The implementer may add cases; each must document which key arrangement it adds. Before adding a +PROJ-string case, confirm GDAL writes user-defined keys for it (not an EPSG code) by inspecting +the manifest row. + +### 4.4 Manifest schema (`crs/manifest.json`) + +```jsonc +{ + "schema_version": 1, + "generator": {"gdal": "3.12.1", "proj": "9.7.1", "rasterio": "1.5.0", "pyproj": "3.7.2"}, + "cases": [ + { + "name": "lcc_2sp_usft", + "file": "fixtures/lcc_2sp_usft.tif", + "input": {"kind": "proj", "value": "+proj=lcc ... +units=us-ft"}, + "note": "", // free text, e.g. why a row is lossy + "tags": ["ct:8", "linear:9003"], // free-form, for filtering + "geokeys": { // exactly what GDAL wrote, by GeoTIFF key name + "GTModelTypeGeoKey": 1, "GTRasterTypeGeoKey": 1, + "GeographicTypeGeoKey": 32767, "GeogCitationGeoKey": "GCS Name = unknown|...", + "ProjCoordTransGeoKey": 8, "ProjLinearUnitsGeoKey": 9003, + "ProjFalseOriginEastingGeoKey": 984250.0, ... + }, + "gdal": { + "projjson": { ... }, // rasterio read-back, pyproj.CRS.to_json_dict(); null if none + "proj4": "+proj=lcc ... +units=us-ft +no_defs +type=crs", + "roundtrip": true // CRS.from_user_input(input).equals(read-back) + }, + "core": { // normalized, name-free, for implementations without proj.db + "type": "ProjectedCRS", // or GeographicCRS, BoundCRS + "method": {"name": "Lambert Conic Conformal (2SP)", "epsg": 9802}, + "parameters": [ // in degrees / metres / unity, keyed by EPSG parameter code + {"epsg": 8821, "name": "Latitude of false origin", "value": 40.16667}, + {"epsg": 8826, "name": "Easting at false origin", "value": 300000.0}, ... + ], + "ellipsoid": {"a": 6378137.0, "rf": 298.257222101, "b": null}, // b only when rf is null (sphere) + "prime_meridian_deg": 0.0, + "angular_unit_deg": 1.0, // size of the geographic CS unit in degrees + "linear_unit_m": 0.3048006096012192, // size of the projected CS unit in metres (null for geographic) + "axes": "easting_northing", // or westing_southing (CT 27); null for geographic + "towgs84": null // 7 numbers for BoundCRS rows + }, + "point": {"lon": -71.0, "lat": 48.16667, "x": 1722466.6689, "y": 2936519.5336}, + "epsg_json": null // "epsg/2953.json" for kind == "epsg" + } + ] +} +``` + +Rules: + +- `geokeys` is decoded from the raw `GeoKeyDirectoryTag` (34735), `GeoDoubleParamsTag` (34736) + and `GeoAsciiParamsTag` (34737) with tifffile, mapping key id to the GeoTIFF spec name. Reading + raw keys rather than through async-tiff is deliberate: it records keys async-tiff does not yet + expose (TOWGS84) and is independent of either implementation. +- `gdal.projjson` is `pyproj.CRS.from_user_input(rasterio_dataset.crs).to_json_dict()`; `null` + when rasterio reports no CRS. `gdal.proj4` is `null` when PROJ cannot export the CRS (the + off-pole scaled Polar Stereographic case). Rows with either `null` are excluded from equality + tests by both implementations (that is what "flagged rather than tested" means); `note` says + why. +- `core` is derived from `gdal.projjson`, not from the input. Parameter values are converted to + degrees, metres or unity using the unit in the PROJJSON. Method name is PROJ's; `epsg` is null + for non-EPSG methods (`Stereographic`). +- `point` is a lon/lat in degrees from Greenwich near the projection origin (reuse `gen.py`'s + `point_for`), projected with `Transformer.from_crs(base, read_back_crs, always_xy=True)` where + `base` is `+proj=longlat` on the read-back CRS's ellipsoid axes (degrees, Greenwich), so no + datum shift is involved. For geographic rows the transform is still applied, so `(x, y)` is in + the row's own angular unit and prime meridian. Null when `gdal.projjson` is null. +- The manifest is written with `indent=1`, sorted keys, and `cases` sorted by name, so diffs are + reviewable and `check.sh` is stable. + +### 4.5 Tests in geotiff-test-data + +Add `tests/test_crs_corpus.py`: + +- every manifest row's `file` exists and its raw GeoKeys equal the row's `geokeys` (guards against + GDAL upgrades silently changing arrangements, like `test_real_data.py` does); +- every `ProjCoordTransGeoKey` value seen in the manifest has a row in `geotiff-ct-methods.json`; +- every table row that is not `unsupported` has at least one fixture; +- the table validates against the schema in 5.1 (a small hand-written check, no jsonschema dep). + +## 5. CT table (`crs/geotiff-ct-methods.json`) + +### 5.1 Schema + +```jsonc +{ + "schema_version": 1, + "sources": { + "libgeotiff": "https://github.com/OSGeo/libgeotiff/blob/75cfca539667c6483e796b24b78ecef72e311a1a/libgeotiff/geo_normalize.c", + "gdal": "https://github.com/OSGeo/gdal/blob/v3.12.1/frmts/gtiff/gt_wkt_srs.cpp", + "proj": "https://github.com/OSGeo/PROJ/blob/9.7.1/src/iso19111/io.cpp" + }, + "units": { // applied once, outside the table (5.4) + "linear": "ProjLinearUnits / ProjLinearUnitSize -> metres", + "angular": "GeogAngularUnits / GeogAngularUnitSize -> degrees", + "angular_keys": ["ProjStdParallel1", "ProjStdParallel2", "ProjNatOriginLong", "ProjNatOriginLat", + "ProjFalseOriginLong", "ProjFalseOriginLat", "ProjCenterLong", "ProjCenterLat", + "ProjStraightVertPoleLong", "ProjRectifiedGridAngle"], + "linear_keys": ["ProjFalseEasting", "ProjFalseNorthing", "ProjFalseOriginEasting", + "ProjFalseOriginNorthing", "ProjCenterEasting", "ProjCenterNorthing"], + "source": "geo_normalize.c#L2227-L2277" + }, + "methods": { + "": { + "ct_name": "CT_TransverseMercator", // from geo_ctrans.inc + "unsupported": "reason" // present only for 2, 5, 6; no other fields then + "variants": [ // one or more; first whose `when` matches wins; last has no `when` + { + "when": { ... }, // see 5.2; omitted on the default variant + "method": {"name": "Transverse Mercator", "epsg": 9807, "proj": "tmerc"}, + "axes": "easting_northing", // optional; default easting_northing; CT 27 uses westing_southing + "parameters": [ + { + "name": "Latitude of natural origin", // EPSG/PROJ parameter name + "epsg": 8801, // EPSG parameter code; null for non-EPSG methods + "proj": "lat_0", // PROJ string key (for implementations building proj strings) + "kind": "angular", // angular | linear | scale | azimuth + "keys": ["ProjNatOriginLat", "ProjFalseOriginLat", "ProjCenterLat"], // first present wins + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1440-L1443" // the `case CT_...:` in GTIFGetOGISDefn (or PROJ io.cpp for value rules) + } + ], + "libgeotiff": "geo_normalize.c#L1774-L1816" // the `case CT_...:` in GTIFFetchProjParms + } + } +} +``` + +Kinds: `angular` values are scaled by the angular unit factor; `linear` by the linear unit factor; +`scale` and `azimuth` are never scaled (`ProjAzimuthAngleGeoKey` is absent from libgeotiff's +normalization list at L2257-L2266, and GDAL's writer does not convert it either). + +Key names are GeoTIFF spec names without the `GeoKey` suffix. Each implementation maps them to its +own accessors (async-tiff: `proj_nat_origin_lat`, etc.). + +### 5.2 Variant rules (`when`) + +Three rules exist. The grammar is deliberately tiny: + +```jsonc +{"present": "ProjStdParallel1"} // key present in the directory +{"abs_value": {"param": "Latitude of natural origin", "equals": 90}} // after unit normalization +{"value": {"param": "Scale factor at natural origin", "equals": 1}} +{"any": [ ... ]} / {"all": [ ... ]} +``` + +`param` refers to a parameter already resolved by the variant's own `keys`/`default` (rules are +evaluated after parameter resolution; both variants of a method resolve the same raw inputs). + +- **CT 7 Mercator** (gt_wkt_srs.cpp L1450-L1465): `{"present": "ProjStdParallel1"}` selects + `Mercator (variant B)` (EPSG 9805) with `Latitude of 1st standard parallel` from + `ProjStdParallel1`; otherwise `Mercator (variant A)` (9804) with the scale factor. libgeotiff + defaults the scale to 1 only when neither key is present (L1743-L1747); GDAL ignores the scale + when the parallel is present. +- **CT 15 Polar Stereographic**: libgeotiff always yields lat, lon (from + `ProjStraightVertPoleLong` first), scale (default 1), FE, FN (L2064-L2104); GDAL calls `SetPS` + (L1559-L1562) which emits WKT1 `Polar_Stereographic`; PROJ's WKT1 importer picks the EPSG + variant from values (PROJ 9.7.1 `io.cpp` L4231-L4279, verified): + 1. `{"value": {"param": "Scale factor at natural origin", "equals": 1}}` selects + `Polar Stereographic (variant B)` (9829) with `Latitude of standard parallel` = the resolved + latitude and `Longitude of origin` = the resolved longitude. This holds even when the + latitude is ±90 (then `lat_ts = 90`). + 2. Otherwise `{"abs_value": {"param": "Latitude of natural origin", "equals": 90}}` selects + `variant A` (9810) with the scale factor. + 3. Otherwise (scale ≠ 1 and latitude not at a pole) PROJ keeps a non-EPSG WKT1 method named + `Polar_Stereographic` with WKT1 parameter names, and `to_proj4()` raises "CRS cannot be + converted to a PROJ string" (verified with the `stere_polar_scaled_wkt` fixture). The table's + third variant is `{"unrepresentable": "PROJ has no operation for Polar_Stereographic off the + pole with scale != 1"}`; the builder raises `ValueError`; the manifest row has + `gdal.proj4 == null` and is skipped (4.4). + The `equals` form of `value` is added to the grammar above for this rule. +- **CT 3 vs 9815 vs 4** are separate CT codes, not variants: 3 is `Hotine Oblique Mercator + (variant A)` (9812, GDAL `SetHOM`, L1489-L1492), 9815 is `variant B` (9815, `SetHOMAC`, + L1494-L1498), 4 is `Laborde Oblique Mercator` (9813, `SetLOM`, L1500-L1503). All three read the + same keys (libgeotiff L1819-L1870, L1873-L1917); variant B names its false origin parameters + `Easting/Northing at projection centre` (8816/8817), variant A `False easting/northing` + (8806/8807); Laborde has no rectified grid angle. + +### 5.3 Rows to transcribe + +Every row's `keys` order comes from `GTIFFetchProjParms`; every method from the `switch` in +`GTIFGetOGISDefn` (L1438-L1596). Common fallbacks (cite once in the README, repeat in each row): + +- False easting: `ProjFalseEasting`, `ProjCenterEasting`, `ProjFalseOriginEasting` (L1655-L1661); + northing likewise (L1663-L1669). Default 0. +- Longitude: `ProjNatOriginLong`, `ProjFalseOriginLong`, `ProjCenterLong`; latitude: + `ProjNatOriginLat`, `ProjFalseOriginLat`, `ProjCenterLat`. Default 0. Used by every method with + an origin (including HOM, which GDAL writes with `ProjCenter*`). +- Polar Stereographic longitude: `ProjStraightVertPoleLong` first, then the three above (L2066-L2074). +- Scale: `ProjScaleAtNatOrigin`, `ProjScaleAtCenter`, default 1 (L1795-L1800, L1846-L1850, + L1939-L1943, L2084-L2088), except CT 14 Stereographic which reads `ProjScaleAtNatOrigin` only + (L1696-L1698). +- Standard parallels: `ProjStdParallel1` / `ProjStdParallel2` only, default 0. +- Azimuth: `ProjAzimuthAngle`, default 0, kind `azimuth`. Rectified grid angle: + `ProjRectifiedGridAngle`, default 90 (L1842-L1844), kind `angular`. + +| CT | method (EPSG) | parameters (in GDAL `Set*` argument order) | libgeotiff | gdal | +|---|---|---|---|---| +| 1 | Transverse Mercator (9807), `tmerc` | lat_0, lon_0, k, FE, FN | L1774-L1816 | L1440 | +| 2 | unsupported: no GDAL read case (falls to `SetLocalCS`) | | | L1587 | +| 3 | Hotine Oblique Mercator (variant A) (9812), `omerc +no_uoff` | lat_c, lon_c, azimuth, rectified grid angle, k_c, FE, FN | L1819-L1870 | L1489 | +| 4 | Laborde Oblique Mercator (9813), `labrd` | lat_c, lon_c, azimuth, k_c, FE, FN | L1873-L1917 | L1500 | +| 5 | unsupported (no GDAL read case) | | | L1587 | +| 6 | unsupported (no GDAL read case) | | | L1587 | +| 7 | Mercator A (9804) / B (9805), `merc` | see 5.2 | L1717-L1771 | L1450 | +| 8 | Lambert Conic Conformal (2SP) (9802), `lcc` | lat_1, lat_2, lat_0 (false origin), lon_0, FE, FN | L2107-L2149 | L1564 | +| 9 | Lambert Conic Conformal (1SP) (9801), `lcc` | lat_0, lon_0, k, FE, FN | L1774-L1816 | L1569 | +| 10 | Lambert Azimuthal Equal Area (9820), `laea` | lat_0, lon_0, FE, FN | L1962-L1997 | L1537 | +| 11 | Albers Equal Area (9822), `aea` | lat_1, lat_2, lat_0, lon_0, FE, FN | L2152-L2195 | L1574 | +| 12 | Azimuthal Equidistant (1125 / PROJ name), `aeqd` | lat_0, lon_0, FE, FN | L1962-L1997 | L1519 | +| 13 | Equidistant Conic (1119 / PROJ name), `eqdc` | lat_1, lat_2, lat_0, lon_0, FE, FN | L2152-L2195 | L1505 | +| 14 | Stereographic (PROJ, no EPSG code), `stere` | lat_0, lon_0, k, FE, FN | L1678-L1714 | L1484 | +| 15 | Polar Stereographic A (9810) / B (9829), `stere` | see 5.2 | L2064-L2104 | L1559 | +| 16 | Oblique Stereographic (9809), `sterea` | lat_0, lon_0, k, FE, FN | L1774-L1816 | L1479 | +| 17 | Equidistant Cylindrical (1028), `eqc` | lat_0, lon_0, lat_1 (`ProjStdParallel1`), FE, FN | L2000-L2036 | L1527 | +| 18 | Cassini-Soldner (9806), `cass` | lat_0, lon_0, FE, FN (libgeotiff also reads a scale; GDAL ignores it) | L1920-L1959 | L1510 | +| 19 | Gnomonic (PROJ), `gnom` | lat_0, lon_0, FE, FN | L1962-L1997 | L1532 | +| 20 | Miller Cylindrical (PROJ), `mill` | lat_0, lon_0, FE, FN | L1962-L1997 | L1523 | +| 21 | Orthographic (9840), `ortho` | lat_0, lon_0, FE, FN | L1962-L1997 | L1542 | +| 22 | American Polyconic (9818), `poly` | lat_0, lon_0, FE, FN (scale read, ignored) | L1920-L1959 | L1514 | +| 23 | Robinson (PROJ), `robin` | lon_0, FE, FN | L2039-L2061 | L1547 | +| 24 | Sinusoidal (PROJ), `sinu` | lon_0, FE, FN | L2039-L2061 | L1551 | +| 25 | Van Der Grinten (PROJ), `vandg` | lon_0, FE, FN | L2039-L2061 | L1555 | +| 26 | New Zealand Map Grid (9811), `nzmg` | lat_0, lon_0, FE, FN | L1962-L1997 | L1579 | +| 27 | Transverse Mercator (South Orientated) (9808), `tmerc +axis=wsu`; `axes: westing_southing` | lat_0, lon_0, k, FE, FN | L1774-L1816 | L1445 | +| 28 | Lambert Cylindrical Equal Area (9835), `cea` | lat_1 (`ProjStdParallel1`), lon_0, FE, FN | L2198-L2224 | L1584 | +| 9815 | Hotine Oblique Mercator (variant B) (9815), `omerc` | lat_c, lon_c, azimuth, rectified grid angle, k_c, E_c, N_c | L1819-L1870 | L1494 | + +Method names and EPSG codes in the table must be what PROJ 9.7 emits in `gdal.projjson` for the +corresponding fixture (the generator output is the authority; where this spec and the manifest +disagree, fix the table to the manifest and note it in the PR). + +### 5.4 What the table does not contain + +- Unit normalization (one pass over resolved parameters, keyed by `kind`). +- The geographic CRS (datum, ellipsoid, prime meridian, angular unit), the projected CS unit, the + `ProjectionGeoKey` EPSG path, the ESRI PE String path. These are described in section 6 and are + the same for every method. The only per-method CS fact is axis direction (`axes`), because + CT 27 is the one method whose axes point west/south; the manifest `core` records `axes` too. + +## 6. Equality and builder design (async-geotiff) + +### 6.1 Equality definition + +The conformance assertion is + +```python +expected = pyproj.CRS.from_json_dict(row["gdal"]["projjson"]) +assert expected.equals(geotiff.crs) # ignore_axis_order=False +``` + +This is PROJ's `EQUIVALENT` comparison: unit-converting on parameters, strict on datum and prime +meridian names (with the `unknown` wildcard), strict on coordinate-system units, indifferent to +CRS/conversion/ellipsoid names and ids. It is stronger than the normalized core and is what the +Python side uses. The `core` object in the manifest is the TS side's comparison target and the +documented meaning of "equal" for implementations without PROJ. + +Consequences for the builder (all verified in section 3): + +- Datum name: `Datum = ...` from `GeogCitationGeoKey` when present, else the proj.db name for an + EPSG-coded datum, else `unknown`. Never `undefined`. +- Prime meridian name: `Primem = ...` from the citation when present, else proj.db for a coded PM, + else `Greenwich` when longitude is 0, else `unknown`. +- Base geographic CS must carry the file's angular unit (grads files). Projected CS must carry the + file's linear unit. + +### 6.2 Module structure + +`_crs.py` keeps its public surface (`crs_from_geo_keys`, `projjson_from_geo_keys`) and is split +internally: + +``` +_crs.py crs_from_geo_keys / projjson_from_geo_keys; dispatch on model type; + EPSG-coded PCS/GCS; ESRI PE String (unchanged) +_crs_geographic.py geographic CRS from keys: units, ellipsoid, datum, prime meridian, citation parsing +_crs_conversion.py the table interpreter: resolve parameters, pick variant, normalize units, + build the pyproj conversion, post-build validation +_crs_table.py the table, loaded from a JSON file vendored into the package + (src/async_geotiff/data/geotiff-ct-methods.json, copied verbatim from the + submodule by a script and checked for equality in a test) +``` + +My call on vendoring: the installed package cannot read from `fixtures/`, so the JSON is copied +into the package; `tests/test_crs_table.py` asserts the vendored copy equals the submodule copy +so they cannot drift. + +### 6.3 Conversion builder + +Inputs: the `GeoKeyDirectory`, the resolved linear unit factor (metres) and angular unit factor +(degrees) from 6.4. + +1. If `ProjCoordTransGeoKey` is absent and `ProjectionGeoKey` is a code, return + `CoordinateOperation.from_epsg(code)` (existing behaviour; `utm_bessel` covers it). +2. Look up the CT row. `unsupported` raises `ValueError` naming the CT code and reason. +3. For each parameter of the first variant (all variants of a method share raw inputs): take the + first present key in `keys`, else `default`. "Present" means the accessor returns not-None; + `0.0` is present. No `a or b`. The key-name-to-accessor mapping is an explicit dict; a table + key with no accessor (today: `ProjRectifiedGridAngle`) raises `ValueError` naming the key + rather than being treated as absent, because silently defaulting it (to 90) produces a wrong + CRS with no signal. This is what makes the HOM rows known failures until async-tiff exposes + key 3096 (Q2). +4. Scale `angular` by the angular factor and `linear` by the linear factor. `scale` and `azimuth` + untouched. +5. Evaluate `when` rules in order; pick the variant. +6. Build the conversion: + - Methods with a typed class in `pyproj.crs.coordinate_operation` (TM, Mercator A/B, LCC + 1SP/2SP, Albers, LAEA, AEQD, Polar Stereographic A/B, Stereographic, Orthographic, + Equidistant Cylindrical, Sinusoidal, Lambert Cylindrical Equal Area, HOM variant B): call the + class with keyword arguments. A per-class dict maps EPSG parameter code to keyword name, so a + typo is a `TypeError` at import time of the test suite, not a silent drop. + - Everything else (Oblique Stereographic, Cassini-Soldner, Polyconic, NZMG, HOM variant A, + Laborde, TM South Orientated, Equidistant Conic, Gnomonic, Miller, Robinson, Van der + Grinten): build `+proj= += ... +ellps=WGS84` from the row's `proj` names, + `CRS.from_proj4(...)`, take `.coordinate_operation`. The ellipsoid is a placeholder; the + conversion is re-attached to the real geodetic CRS in 6.5. +7. **Post-build validation** (guards both paths against silent drops): for every table parameter, + find it in `conversion.params` by EPSG code when the row has one, else by name, and assert the + value matches after unit conversion to degrees/metres (`math.isclose`, rel 1e-12). Any missing + or mismatched parameter raises `ValueError`. This is cheap and turns the PROJJSON/proj-string + hazard into an error. + +### 6.4 Geographic CRS builder + +Follows `GTIFGetDefn` (geo_normalize.c L2394-L2660) and the GeogCS block of `GTIFGetOGISDefn` +(gt_wkt_srs.cpp L917-L1100): + +- **EPSG-coded GCS** (`GeographicTypeGeoKey` not 32767): `CRS.from_epsg`. Unchanged. +- **Angular unit**: `GeogAngularUnitsGeoKey` code (9101 radian, 9102 degree, 9105 grad, others via + `pyproj` unit lookup) or 32767 with `GeogAngularUnitSizeGeoKey` in radians. Factor in degrees + `UOMAngleInDegrees`. The ellipsoidal CS is built with that unit; for degrees use + `Ellipsoidal2DCS()`, otherwise `CoordinateSystem.from_json_dict` with the unit's name and + conversion factor (the one place a dict is acceptable: it carries no parameters to drop). +- **Linear unit and axes** (projected only): `ProjLinearUnitsGeoKey` code or 32767 with + `ProjLinearUnitSizeGeoKey`. Factor in metres `UOMLengthInMeters`. Use the `Cartesian2DCS` + presets where one exists (`EASTING_NORTHING`, `EASTING_NORTHING_FT` for 9002, + `EASTING_NORTHING_US_FT` for 9003, `WESTING_SOUTHING` for a table row with + `axes: westing_southing`), and `CoordinateSystem.from_json_dict` only for other units (name and + factor from proj.db via pyproj for a code, the raw size for 32767). Do not hardcode unit factors. +- **Ellipsoid**: if `GeogEllipsoidGeoKey` is a code and no axis keys: `Ellipsoid.from_epsg`. + Otherwise `CustomEllipsoid(name, semi_major_axis, inverse_flattening | semi_minor_axis)`; + `radius` when semi-minor equals semi-major and no inverse flattening (sphere). Name from + `Ellipsoid = ...` in the citation, else proj.db name for a code, else `unknown` (names don't + affect equality but keep GDAL's for readability). Axis keys override code-derived values (L2590-L2600). +- **Datum**: `GeogGeodeticDatumGeoKey` code → `Datum.from_epsg`; else `CustomDatum(name, + ellipsoid, prime_meridian)` with the name rule from 6.1. +- **Prime meridian**: `GeogPrimeMeridianGeoKey` code → `PrimeMeridian.from_epsg`; else + `CustomPrimeMeridian(longitude=GeogPrimeMeridianLongGeoKey × UOMAngleInDegrees)` (libgeotiff + `GTIFAngleToDD`, L2616-L2620) with the name rule from 6.1. +- **TOWGS84**: not readable with async-tiff 0.7 (Q2). When it becomes readable, wrap the result in + a `BoundCRS` via `pyproj.crs.CRS.from_json_dict` of the built CRS plus a `ToWGS84Transformation` + (pyproj has a typed class for it). +- Citation parsing: keep `_parse_geog_citation`; also read `AUnits = ...` so a citation-only grads + file (GDAL writes both the code and the citation entry) is consistent. + +### 6.5 Assembly + +```python +geog = GeographicCRS(name=gcs_name, datum=datum, ellipsoidal_cs=ellipsoidal_cs) +if projected: + crs = ProjectedCRS(name=proj_name, conversion=conversion, geodetic_crs=geog, cartesian_cs=cartesian_cs) +``` + +`projjson_from_geo_keys` returns `crs.to_json_dict()`. The PROJJSON-schema test in +`tests/test_crs.py` keeps passing because pyproj emits valid PROJJSON. + +## 7. Tests in async-geotiff + +### 7.1 Conformance test (`tests/test_crs_conformance.py`) + +- Load `fixtures/geotiff-test-data/crs/manifest.json` once (session fixture). +- Parametrize over case names. Rows with `gdal.projjson == null` or `gdal.proj4 == null` are + `pytest.skip`ped with the row's note. +- For each case: `GeoTIFF.open` the fixture, `expected.equals(geotiff.crs)` (6.1), then the point + check, built exactly as the generator builds it (4.4): a degree, Greenwich-PM longlat CRS on + `geotiff.crs.ellipsoid`'s axes (`+proj=longlat +a=... +rf=...` or `+b=...`), then + `Transformer.from_crs(that, geotiff.crs, always_xy=True)` on `(lon, lat)`, compared to `(x, y)` + with `pytest.approx(abs=1e-3)`. Using `geotiff.crs.geodetic_crs` instead would move the point + for grads and non-Greenwich rows. For geographic rows the manifest's `(x, y)` is `(lon, lat)` + and the test transforms the same way (identity for degree/Greenwich bases, a real conversion + otherwise). Both assertions in the same test so a known-failure row covers both. +- **Known failures**: `KNOWN_FAILURES: dict[str, str]` mapping case name to reason, applied as + `pytest.param(name, marks=pytest.mark.xfail(strict=True, reason=...))`. `strict=True` makes an + unexpected pass fail the run, so the list can only shrink. Stage 3 seeds the list with every + row that fails against the current `_crs.py`; stage 4 removes rows as they pass. Rows that + cannot pass without upstream changes (Q2, Q3) stay with a reason that names the blocker. +- Keep `test_crs` over `ALL_TEST_IMAGES` untouched and green throughout. + +### 7.2 Unit tests for the interpreter (`tests/test_crs_conversion.py`) + +Small, synthetic, no fixtures: parameter fallback order (first present wins, `0.0` counts as +present), unit scaling by kind, each `when` rule, `unsupported` raises, post-build validation +raises on a deliberately broken proj-string mapping. These are the red tests to write first in +stage 4. + +### 7.3 Table/vendoring test (`tests/test_crs_table.py`) + +The vendored JSON equals the submodule's; every CT code in the table either is `unsupported` or +has a typed-class mapping or a `proj` name. + +## 8. Staging and PRs + +One PR per stage; stop for review after each. PR text carries the `> [!NOTE]` Claude attribution +at the top and the "Written by Claude Code" footer; `Closes #N` where applicable; never merge. + +1. **geotiff-test-data, corpus**: `crs/` layout, `cases.py`, `generate_crs.py`, fixtures, + `manifest.json`, `epsg/*.json`, pixi task, `check.sh`/`info.sh` changes, `tests/test_crs_corpus.py` + (minus the table checks). Work in a worktree under its existing `.worktrees/`. +2. **geotiff-test-data, CT table**: `geotiff-ct-methods.json`, `README.md` schema docs, the table + checks in `tests/test_crs_corpus.py`. Combined with 1 if review prefers. +3. **async-geotiff, conformance test**: submodule bump, vendored table + test, conformance test with + the seeded known-failures list. No builder changes. Suite green. +4. **async-geotiff, builder**: `_crs_conversion.py`, `_crs_geographic.py`, interpreter unit tests + first (red), then the rewrite; known-failures shrinks to the Q2 rows (`tmerc_towgs84`, + `omerc_variant_a`, `omerc_variant_b`, `somerc`) and the Q3 row. Changelog entry. +5. **Optional, needs Q2 answer**: async-tiff exposes keys 2062 and 3096; async-geotiff bumps its + `async-tiff>=` floor, reads them, and removes the four rows. + +Before stage 4, write an implementation plan via the writing-plans skill into `dev-docs/plans/`. + +## 9. Open questions for Kyle + +- **Q1. Polar Stereographic rule.** The brief's rule (`ProjScaleAtNatOrigin` present or + `ProjStdParallel1` absent → variant A) does not match what GDAL writes and reads (section 3). + I replaced it with PROJ's own value-based rule in 5.2 (read from `io.cpp`) and added two WKT + fixtures to pin it. Flagging because it contradicts a "do not relitigate" decision; OK to + proceed? +- **Q2. Keys async-tiff cannot read.** async-tiff has no accessor for `GeogTOWGS84GeoKey` (2062) + or `ProjRectifiedGridAngleGeoKey` (3096) and no raw-tag fallback, so four corpus rows (TOWGS84 + and the three Hotine Oblique Mercator files) cannot pass from async-geotiff alone, and the + "grid-angle" failure class in the brief cannot be fixed here. Options: (a) an async-tiff PR + adding both keys (your call, it is another repo), then stage 5; (b) leave the four rows listed + as known failures with the reason naming async-tiff. The spec assumes (b) until you say (a). +- **Q3. Prime meridian in grads.** GDAL's write/read of `+pm=paris` is internally inconsistent + (three 0.9 factors on read, one on write). Proposal: follow libgeotiff's single conversion and + keep `lcc_1sp_paris_grad` as a permanent known failure with that reason, rather than replicate + GDAL's chain. Also worth a GDAL issue, but not without your OK. +- **Q4. EPSG case count.** 46 coded cases from the prior session's list. They are cheap (a few KB + each plus the cached JSON) but mostly test pyproj's `from_epsg`. Keep all, or trim to a dozen + spanning the methods? + +## 10. Calls I made (check these while reading) + +- Corpus lives in a top-level `crs/` directory with a single table-driven generator, plain GTiff + fixtures, `check.sh` coverage, and `info.sh` exclusion (4.1). +- Raw GeoKeys in the manifest are decoded with tifffile by key id, not via async-tiff (4.4). +- `pyproj.CRS.equals` is the Python assertion; the manifest's `core` is the TS assertion (6.1). +- Datum naming reproduces GDAL's citation naming with `unknown` as the fallback (6.1). +- Untyped methods use a proj-string CRS's `coordinate_operation`, not + `CoordinateOperation.from_string`, plus post-build parameter validation for all paths (6.3). +- The table JSON is vendored into the package with a drift test (6.2). +- Known failures use `xfail(strict=True)` (7.1). +- A table key with no async-tiff accessor raises instead of defaulting (6.3). +- Axis direction is a per-variant table field (`axes`), present only because CT 27 needs it + (5.1, 5.4); the point check in the test mirrors the generator's degree/Greenwich base (7.1). +- Rows GDAL cannot read back (`gdal.projjson == null`) are skipped, not failed (4.4, 7.1). +- One tifffile-written fixture for an EPSG-coded prime meridian, since GDAL never writes one (4.3). From b8bf46e90905dab47a321e0dd28360d08b572c31 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Mon, 26 Oct 2026 11:09:15 -0400 Subject: [PATCH 02/10] docs: Record review answers in the CRS conformance spec Co-Authored-By: Claude Fable 5.1 --- .../2026-10-26-geokey-crs-conformance-design.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md b/dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md index dffd475..dcb701a 100644 --- a/dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md +++ b/dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md @@ -1,7 +1,7 @@ # GeoKey to CRS conformance: corpus, CT table, and table-driven builder - **Date:** 2026-10-26 -- **Status:** Draft, awaiting review +- **Status:** Approved 2026-10-26 (answers to section 9 recorded there) - **Repos:** `developmentseed/geotiff-test-data` (corpus + table), `developmentseed/async-geotiff` (builder + tests) - **Out of scope:** `developmentseed/deck.gl-raster` (consumes the corpus and table later), anything upstream (pyproj, PROJ, GDAL, async-tiff) without explicit OK - **Oracle:** whatever GDAL/PROJ reads from a file's GeoKeys, as seen through `rasterio` @@ -649,12 +649,18 @@ at the top and the "Written by Claude Code" footer; `Closes #N` where applicable 4. **async-geotiff, builder**: `_crs_conversion.py`, `_crs_geographic.py`, interpreter unit tests first (red), then the rewrite; known-failures shrinks to the Q2 rows (`tmerc_towgs84`, `omerc_variant_a`, `omerc_variant_b`, `somerc`) and the Q3 row. Changelog entry. -5. **Optional, needs Q2 answer**: async-tiff exposes keys 2062 and 3096; async-geotiff bumps its - `async-tiff>=` floor, reads them, and removes the four rows. +5. **async-tiff** (approved, done first since it is small): issue + minimal PR exposing keys + 2062 and 3096. Once released, async-geotiff bumps its `async-tiff>=` floor, reads them in + stage 4, and the four rows leave the known-failures list. Before stage 4, write an implementation plan via the writing-plans skill into `dev-docs/plans/`. -## 9. Open questions for Kyle +## 9. Open questions for Kyle (answered 2026-10-26) + +- Q1: approved, proceed with the PROJ-derived rule. +- Q2: make an issue and a minimal PR in async-tiff (stage 5 above). +- Q3: approved, follow libgeotiff's single conversion; the row stays a known failure. +- Q4: keep all 46 (my call; they are cheap and document the coded-key form for the TS port). - **Q1. Polar Stereographic rule.** The brief's rule (`ProjScaleAtNatOrigin` present or `ProjStdParallel1` absent → variant A) does not match what GDAL writes and reads (section 3). From 2230cf274a5c056cde5cc55a54bd547491651192 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Mon, 26 Oct 2026 11:26:30 -0400 Subject: [PATCH 03/10] docs: Add the implementation plan for the CRS conformance corpus Also records the async-tiff issue/PR in the spec and switches GeoKey names to the no-suffix form and axes to a direction list, so the plan and spec agree. Co-Authored-By: Claude Fable 5.1 --- .../2026-10-26-crs-conformance-corpus.md | 697 ++++++++++++++++++ ...026-10-26-geokey-crs-conformance-design.md | 27 +- 2 files changed, 711 insertions(+), 13 deletions(-) create mode 100644 dev-docs/plans/2026-10-26-crs-conformance-corpus.md diff --git a/dev-docs/plans/2026-10-26-crs-conformance-corpus.md b/dev-docs/plans/2026-10-26-crs-conformance-corpus.md new file mode 100644 index 0000000..8b26e0e --- /dev/null +++ b/dev-docs/plans/2026-10-26-crs-conformance-corpus.md @@ -0,0 +1,697 @@ +# CRS Conformance Corpus and CT Table Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Add a `crs/` directory to geotiff-test-data holding GDAL-written GeoTIFF fixtures, a manifest of what GDAL wrote and reads back, cached epsg.io JSON, and the GeoTIFF CT-code-to-PROJ-method table, all regenerable and CI-checked. + +**Architecture:** A data-only case list (`crs/cases.py`) feeds one generator (`crs/generate_crs.py`) that writes 8x8 GeoTIFFs with rasterio (or tifffile for hand-built GeoKeys), reads them back with rasterio as the GDAL/PROJ oracle, and records raw GeoKeys plus PROJJSON, proj4, a normalized name-free core, and a test point in `crs/manifest.json`. A hand-written `crs/geotiff-ct-methods.json` transcribes libgeotiff and GDAL; pytest checks the manifest against the files and the table against the manifest. + +**Tech Stack:** Python 3.12+, rasterio 1.5 / GDAL 3.12 / PROJ 9.7 (pixi, conda-forge), pyproj 3.7, tifffile, numpy, pytest, pixi tasks. + +**Spec:** `dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md` (in async-geotiff; sections 4 and 5 are this plan's scope) + +## Global Constraints + +- Work in a git worktree of geotiff-test-data under its existing `.worktrees/` directory, branch `kyle/crs-conformance-corpus`, based on `origin/main` (currently `b73b96d`). Never commit on `main`. +- Run everything through pixi (`pixi run ...`); the generator must be deterministic so `scripts/check.sh` passes in CI. +- Fixtures are plain GTiff, 8x8 uint8, one band, no compression, no overviews, written with `GDAL_PAM_ENABLED=NO`; read-back also with `GDAL_PAM_ENABLED=NO`. +- GeoKey names everywhere (manifest `geokeys`, table `keys`, encoder input) are the GeoTIFF spec names without the `GeoKey` suffix: `ProjCoordTrans`, `GeogTOWGS84`, `GTModelType`. +- `manifest.json` is written with `json.dump(..., indent=1, sort_keys=True)` and rows sorted by `name`. +- Rows with `gdal.projjson == null` or `gdal.proj4 == null` are flagged, not tested, and carry a `note`. +- PR text: top `> [!NOTE]` saying Claude wrote it, bottom `🤖 Written by [Claude Code](https://claude.com/claude-code)`. Never merge. +- Ruff with `select = ["I"]` (import sorting) is the only lint; `pytest` from the repo root with `pythonpath = ["."]`. + +## Review Focus + +1. A PROJ-string case that GDAL identifies as an EPSG CRS writes only `ProjectedCSType = ` and silently stops testing the user-defined key path. Pinned in Task 7 (`test_proj_cases_are_user_defined`). +2. A citation string whose terminating `|` is or is not stripped makes `geokeys` disagree with async-tiff's view of the same file. Pinned in Task 1 (`test_decode_existing_fixture`, exact citation values). +3. A `GeogTOWGS84` with three values vs seven must round-trip through the encoder and decoder as a list, not a scalar. Pinned in Task 1 (`test_encode_decode_roundtrip`). +4. Parameters in grads or feet must land in the core in degrees and metres, or the TS side compares the wrong numbers. Pinned in Task 3 (`test_core_of_grads`, `test_core_of_feet`). +5. Regenerating with network blocked must still succeed when `crs/epsg/*.json` already exist. Pinned in Task 4 (`test_fetch_epsg_json_skips_existing`). + +--- + +### Task 1: GeoKey id table, decoder, encoder + +**Files:** +- Create: `crs/__init__.py` (empty docstring module) +- Create: `crs/geokeys.py` +- Test: `tests/test_crs_geokeys.py` +- Modify: `pixi.toml` (add `pyproj = ">=3.7,<4"` under `[pypi-dependencies]`; it is only a transitive dependency today) + +**Interfaces:** +- Produces: `GEOKEY_IDS: dict[str, int]` mapping spec name (no suffix) to key id, covering 1024-1026, 2048-2062, 3072-3096, 4096-4099, 5120 (`CoordinateEpoch`). `GEOKEY_NAMES: dict[int, str]` is its inverse. +- Produces: `decode_geokeys(path: Path) -> dict[str, int | float | str | list[float]]`: reads tags 34735/34736/34737 with tifffile, returns one entry per directory entry keyed by name (`"unknown_"` for ids not in the table); SHORT values as `int`, a single DOUBLE as `float`, several DOUBLEs as `list[float]`, ASCII as `str` with exactly one trailing `|` removed. +- Produces: `encode_geokeys(keys: dict[str, int | float | str | list[float]]) -> list[tuple]`: tifffile `extratags` triples for tags 34735 (SHORT), 34736 (DOUBLE), 34737 (ASCII), in the form `(tag, dtype_code, count, value, True)` with dtype codes 3, 12, 2; entries sorted by key id as the spec requires; ASCII values get the `|` terminator appended; version header `[1, 1, 0, n]`. + +- [ ] **Step 1: Write the failing tests** + +```python +# tests/test_crs_geokeys.py +from pathlib import Path + +import numpy as np +import tifffile + +from crs.geokeys import GEOKEY_IDS, decode_geokeys, encode_geokeys + +REPO_ROOT = Path(__file__).parent.parent + + +def test_geokey_ids_cover_spec(): + assert GEOKEY_IDS["GTModelType"] == 1024 + assert GEOKEY_IDS["GeogTOWGS84"] == 2062 + assert GEOKEY_IDS["ProjRectifiedGridAngle"] == 3096 + assert GEOKEY_IDS["CoordinateEpoch"] == 5120 + assert len(GEOKEY_IDS) == 48 + + +def test_decode_existing_fixture(): + keys = decode_geokeys( + REPO_ROOT / "real_data/source-coop-dataforcanada/O2308000_7586000_cog.tif" + ) + assert keys == { + "GTModelType": 1, + "GTRasterType": 1, + "GTCitation": "NAD83(CSRS) / New Brunswick Stereographic", + "GeographicType": 32767, + "GeogCitation": "GCS Name = NAD83(CSRS)|Primem = Greenwich|", + "GeogGeodeticDatum": 6140, + "GeogAngularUnits": 9102, + "GeogSemiMajorAxis": 6378137.0, + "GeogInvFlattening": 298.257222101, + "GeogPrimeMeridianLong": 0.0, + "ProjectedCSType": 32767, + "Projection": 32767, + "ProjCoordTrans": 16, + "ProjLinearUnits": 9001, + "ProjNatOriginLong": -66.5, + "ProjNatOriginLat": 46.5, + "ProjFalseEasting": 2500000.0, + "ProjFalseNorthing": 7500000.0, + "ProjScaleAtNatOrigin": 0.999912, + } + + +def test_encode_decode_roundtrip(tmp_path: Path): + keys = { + "GTModelType": 1, + "GTRasterType": 1, + "GeographicType": 32767, + "GeogCitation": "GCS Name = unknown|Primem = Paris|", + "GeogPrimeMeridian": 8903, + "GeogSemiMajorAxis": 6378249.2, + "GeogTOWGS84": [598.1, 73.7, 418.2, 0.202, 0.045, -2.455, 6.7], + "ProjCoordTrans": 9, + "ProjRectifiedGridAngle": 90.0, + } + path = tmp_path / "keys.tif" + tifffile.imwrite(path, np.zeros((8, 8), np.uint8), extratags=encode_geokeys(keys)) + assert decode_geokeys(path) == keys + + +def test_decode_three_value_towgs84(tmp_path: Path): + keys = {"GTModelType": 2, "GeogTOWGS84": [0.0, 0.0, 0.0]} + path = tmp_path / "keys.tif" + tifffile.imwrite(path, np.zeros((8, 8), np.uint8), extratags=encode_geokeys(keys)) + assert decode_geokeys(path)["GeogTOWGS84"] == [0.0, 0.0, 0.0] +``` + +- [ ] **Step 2: Run tests to verify they fail** + +Run: `pixi run pytest tests/test_crs_geokeys.py -v` +Expected: FAIL with `ModuleNotFoundError: No module named 'crs'` + +- [ ] **Step 3: Implement `crs/geokeys.py`** + +`GEOKEY_IDS` is a literal dict (the 48 names from libgeotiff `geokeys.inc` / OGC 19-008r4 Annex, minus the `GeoKey` suffix; `GTCitation`, `PCSCitation` keep their spec names). `decode_geokeys` reads `tifffile.TiffFile(path).pages[0].tags[34735].value` and slices 34736/34737 by `(location, count, offset)` as the GeoTIFF spec defines. `encode_geokeys` appends doubles and ASCII into their param arrays as it walks the keys sorted by id. + +- [ ] **Step 4: Run tests to verify they pass** + +Run: `pixi run pytest tests/test_crs_geokeys.py -v` +Expected: 4 passed + +- [ ] **Step 5: Commit** + +```bash +git add crs/__init__.py crs/geokeys.py tests/test_crs_geokeys.py pixi.toml pixi.lock +git commit -m "feat(crs): Add GeoKey id table with raw decoder and encoder" +``` + +### Task 2: Case list + +**Files:** +- Create: `crs/cases.py` +- Test: `tests/test_crs_cases.py` + +**Interfaces:** +- Produces: `@dataclass(frozen=True) class Case: name: str; kind: Literal["proj", "epsg", "wkt", "geokeys"]; value: str | dict[str, int | float | str | list[float]]; note: str = ""; tags: tuple[str, ...] = ()`. +- Produces: `CASES: list[Case]`, every case from spec section 4.3 (CT rows, units, datum/PM variants, 46 EPSG codes, citation forms). `kind == "geokeys"` carries the raw key dict for the tifffile-written fixture. +- Produces: `EPSG_CODES: list[int]` (the 46 codes; `epsg_` cases are generated from it). + +- [ ] **Step 1: Write the failing test** + +```python +# tests/test_crs_cases.py +import re +from collections import Counter + +from crs.cases import CASES, EPSG_CODES, Case + + +def test_case_names_unique_and_well_formed(): + names = [c.name for c in CASES] + assert len(names) == len(set(names)) + assert all(re.fullmatch(r"[a-z0-9_]+", n) for n in names) + + +def test_case_kinds(): + kinds = Counter(c.kind for c in CASES) + assert set(kinds) == {"proj", "epsg", "wkt", "geokeys"} + assert kinds["epsg"] == len(EPSG_CODES) == 46 + assert kinds["geokeys"] == 1 + + +def test_expected_cases_present(): + names = {c.name for c in CASES} + for name in ( + "tmerc", "omerc_variant_a", "omerc_variant_b", "labrd", "somerc", "merc_1sp", + "merc_2sp", "stere_polar_scaled_wkt", "stere_polar_k1_wkt", "tmso", "cea", + "lcc_2sp_usft", "tmerc_ft", "lcc_1sp_grad_wkt", "geog_grad_wkt", "lcc_1sp_paris_grad", + "aea_nad27", "tmerc_datum_wgs84", "sinu_sphere", "geog_sphere", "tmerc_towgs84", + "lcc_1sp_paris_deg_wkt", "lcc_1sp_pm_user", "lcc_1sp_pm_epsg_tifffile", + "longlat_grs80", "utm_bessel", "moll", "krovak", "esri_54009", "eqearth", "epsg_2953", + ): + assert name in names + assert len(CASES) >= 95 + + +def test_geokeys_case_has_epsg_prime_meridian(): + case = next(c for c in CASES if c.kind == "geokeys") + assert isinstance(case.value, dict) + assert case.value["GeogPrimeMeridian"] == 8903 + assert "GeogPrimeMeridianLong" not in case.value +``` + +- [ ] **Step 2: Run test to verify it fails** + +Run: `pixi run pytest tests/test_crs_cases.py -v` +Expected: FAIL with `ModuleNotFoundError: No module named 'crs.cases'` + +- [ ] **Step 3: Implement `crs/cases.py`** + +Transcribe spec 4.3 verbatim. The WKT values the spec names but does not spell out: + +```python +_GEOG_WGS84_DEG = 'GEOGCS["unknown",DATUM["unknown",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]' +_GEOG_CLRK80IGN_GRAD = 'GEOGCS["unknown",DATUM["unknown",SPHEROID["Clarke 1880 (IGN)",6378249.2,293.466021293627]],PRIMEM["Greenwich",0],UNIT["grad",0.01570796326794897]]' +_GEOG_CLRK80IGN_PARIS_DEG = 'GEOGCS["unknown",DATUM["unknown",SPHEROID["Clarke 1880 (IGN)",6378249.2,293.466021293627]],PRIMEM["Paris",2.33722917],UNIT["degree",0.0174532925199433]]' +_LCC_1SP_PARAMS = 'PROJECTION["Lambert_Conformal_Conic_1SP"],PARAMETER["latitude_of_origin",{lat}],PARAMETER["central_meridian",0],PARAMETER["scale_factor",0.99987742],PARAMETER["false_easting",600000],PARAMETER["false_northing",2200000],UNIT["metre",1]' +# stere_polar_scaled_wkt / stere_polar_k1_wkt: +# f'PROJCS["unknown",{_GEOG_WGS84_DEG},PROJECTION["Polar_Stereographic"],PARAMETER["latitude_of_origin",{lat}],PARAMETER["central_meridian",-45],PARAMETER["scale_factor",{k}],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1]]' +# lcc_1sp_grad_wkt: f'PROJCS["unknown",{_GEOG_CLRK80IGN_GRAD},{_LCC_1SP_PARAMS.format(lat=52)}]' +# lcc_1sp_paris_deg_wkt: f'PROJCS["unknown",{_GEOG_CLRK80IGN_PARIS_DEG},{_LCC_1SP_PARAMS.format(lat=46.8)}]' +# geog_grad_wkt: _GEOG_CLRK80IGN_GRAD +``` + +The `geokeys` case (`lcc_1sp_pm_epsg_tifffile`) is the `lcc_1sp` key set GDAL writes (see the `lcc_1sp` manifest row after Task 4, or the prior session's dump) with `GeogPrimeMeridianLong` removed, `GeogPrimeMeridian: 8903` added, and `Primem = Paris` in the citation. Case notes: `eqearth` ("GDAL writes no GeoKeys; sidecar disabled"), `lcc_1sp_paris_grad` ("GDAL PM-in-grads round-trip is lossy; see spec Q3"), `stere_polar_scaled_wkt` ("PROJ keeps a non-EPSG Polar_Stereographic method; not exportable"), `utm_bessel` ("GDAL writes ProjectionGeoKey = 16033, no CT key"), `tmerc_towgs84` ("needs async-tiff >= the release with key 2062"). + +- [ ] **Step 4: Run test to verify it passes** + +Run: `pixi run pytest tests/test_crs_cases.py -v` +Expected: 4 passed + +- [ ] **Step 5: Commit** + +```bash +git add crs/cases.py tests/test_crs_cases.py +git commit -m "feat(crs): Add the conformance corpus case list" +``` + +### Task 3: CRS normalization helpers + +**Files:** +- Create: `crs/normalize.py` +- Test: `tests/test_crs_normalize.py` + +**Interfaces:** +- Produces: `core_of(crs: pyproj.CRS) -> dict` with keys `type` (`crs.type_name` mapped to `"ProjectedCRS" | "GeographicCRS" | "BoundCRS"`), `method` (`{"name": str, "epsg": int | None}` or `None` for geographic), `parameters` (list of `{"epsg": int | None, "name": str, "value": float}`, angular values in degrees, linear in metres, scale as-is, in PROJJSON order), `ellipsoid` (`{"a": float, "rf": float | None, "b": float | None}`, `rf` None and `b` set when `inverse_flattening == 0`), `prime_meridian_deg: float`, `angular_unit_deg: float`, `linear_unit_m: float | None`, `axes: list[str]` (axis directions of the projected CS, or of the geographic CS for a geographic CRS), `towgs84: list[float] | None`. For a BoundCRS the inner CRS is `crs.source_crs` and `towgs84` is `crs.coordinate_operation.towgs84`. +- Produces: `ellipsoid_longlat(crs: pyproj.CRS) -> pyproj.CRS`: `+proj=longlat +a= +rf=` or `+b=` for a sphere, from the inner CRS's ellipsoid. +- Produces: `point_for(core: dict) -> tuple[float, float]`: `(10.0, 40.0)` when `core["method"]` is None; otherwise `(lon0 + 3, lat)` where `lat` moves 8 degrees away from the equator when `abs(lat0) < 80` and 8 degrees towards it otherwise (`lat0 = 0 -> 8`, `lat0 = -41 -> -49`, `lat0 = 90 -> 82`, `lat0 = -90 -> -82`). `lon0` is the first present of parameter names `Longitude of natural origin`, `Longitude of false origin`, `Longitude of projection centre`, `Longitude of origin` else 0; `lat0` the first of `Latitude of natural origin`, `Latitude of false origin`, `Latitude of projection centre`, `Latitude of standard parallel`, `Latitude of 1st standard parallel` else 0. +- Produces: `project_point(crs: pyproj.CRS, lon: float, lat: float) -> tuple[float, float]`: `Transformer.from_crs(ellipsoid_longlat(crs), crs, always_xy=True).transform(lon, lat)`. + +- [ ] **Step 1: Write the failing tests** + +```python +# tests/test_crs_normalize.py +import pytest +from pyproj import CRS + +from crs.normalize import core_of, ellipsoid_longlat, point_for, project_point + +GRAD_WKT = 'PROJCS["unknown",GEOGCS["unknown",DATUM["unknown",SPHEROID["Clarke 1880 (IGN)",6378249.2,293.466021293627]],PRIMEM["Greenwich",0],UNIT["grad",0.01570796326794897]],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],UNIT["metre",1]]' + + +def test_core_of_utm(): + core = core_of(CRS.from_epsg(32633)) + assert core["type"] == "ProjectedCRS" + assert core["method"] == {"name": "Transverse Mercator", "epsg": 9807} + assert core["parameters"] == [ + {"epsg": 8801, "name": "Latitude of natural origin", "value": 0.0}, + {"epsg": 8802, "name": "Longitude of natural origin", "value": 15.0}, + {"epsg": 8805, "name": "Scale factor at natural origin", "value": 0.9996}, + {"epsg": 8806, "name": "False easting", "value": 500000.0}, + {"epsg": 8807, "name": "False northing", "value": 0.0}, + ] + assert core["ellipsoid"] == {"a": 6378137.0, "rf": 298.257223563, "b": None} + assert core["prime_meridian_deg"] == 0.0 + assert core["angular_unit_deg"] == pytest.approx(1.0) + assert core["linear_unit_m"] == 1.0 + assert core["axes"] == ["east", "north"] + assert core["towgs84"] is None + + +def test_core_of_grads(): + core = core_of(CRS.from_wkt(GRAD_WKT)) + assert core["parameters"][0]["value"] == pytest.approx(46.8) + assert core["angular_unit_deg"] == pytest.approx(0.9) + + +def test_core_of_feet(): + core = core_of(CRS.from_proj4("+proj=lcc +lat_1=41.03333 +lat_2=40.66667 +lat_0=40.16667 +lon_0=-74 +x_0=300000 +y_0=0 +ellps=GRS80 +units=us-ft")) + easting = next(p for p in core["parameters"] if p["epsg"] == 8826) + assert easting["value"] == pytest.approx(300000.0) + assert core["linear_unit_m"] == pytest.approx(0.3048006096012192) + + +def test_core_of_bound_crs(): + core = core_of(CRS.from_proj4("+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=bessel +towgs84=598.1,73.7,418.2,0.202,0.045,-2.455,6.7")) + assert core["type"] == "BoundCRS" + assert core["method"]["epsg"] == 9807 + assert core["towgs84"] == [598.1, 73.7, 418.2, 0.202, 0.045, -2.455, 6.7] + + +def test_core_of_sphere_and_geographic(): + core = core_of(CRS.from_proj4("+proj=longlat +R=6371007.181")) + assert core["type"] == "GeographicCRS" + assert core["method"] is None + assert core["ellipsoid"] == {"a": 6371007.181, "rf": None, "b": 6371007.181} + assert core["linear_unit_m"] is None + + +def test_core_of_south_orientated_axes(): + core = core_of(CRS.from_proj4("+proj=tmerc +lat_0=0 +lon_0=19 +k=1 +x_0=0 +y_0=0 +axis=wsu +ellps=WGS84")) + assert core["axes"] == ["west", "south"] + + +def test_point_for(): + assert point_for(core_of(CRS.from_epsg(32633))) == (18.0, 8.0) + assert point_for(core_of(CRS.from_proj4("+proj=stere +lat_0=90 +k=0.994 +lon_0=0 +ellps=WGS84"))) == (3.0, 82.0) + assert point_for(core_of(CRS.from_epsg(4326))) == (10.0, 40.0) + + +def test_project_point(): + assert project_point(CRS.from_epsg(32633), 15.0, 0.0) == pytest.approx((500000.0, 0.0)) + # A grads geographic CRS: degrees in, grads out. + assert project_point(CRS.from_wkt(GRAD_WKT).geodetic_crs, 3.0, 54.8) == pytest.approx((3.3333333333, 60.8888888889)) + + +def test_ellipsoid_longlat_sphere(): + assert ellipsoid_longlat(CRS.from_proj4("+proj=sinu +R=6371007.181")).to_proj4().startswith("+proj=longlat +R=6371007.181") +``` + +- [ ] **Step 2: Run tests to verify they fail** + +Run: `pixi run pytest tests/test_crs_normalize.py -v` +Expected: FAIL with `ModuleNotFoundError: No module named 'crs.normalize'` + +- [ ] **Step 3: Implement `crs/normalize.py`** + +Unit conversion in `core_of`: walk `inner.to_json_dict()["conversion"]["parameters"]`; a `unit` that is a string is `degree`, `metre` or `unity`; a dict has `type` (`AngularUnit` / `LinearUnit` / `ScaleUnit`) and `conversion_factor` (radians per unit or metres per unit); angular value in degrees is `value * factor * 180 / pi`. `angular_unit_deg` comes from `inner.geodetic_crs.axis_info[0].unit_conversion_factor * 180 / pi` (for a geographic CRS, `inner.axis_info`); `linear_unit_m` from `inner.axis_info[0].unit_conversion_factor` when `inner.is_projected`, else None. `prime_meridian_deg` is `pm.longitude * pm.unit_conversion_factor * 180 / pi`. Use `pyproj.CRS.is_bound`, `.source_crs`, `.coordinate_operation.towgs84`. + +- [ ] **Step 4: Run tests to verify they pass** + +Run: `pixi run pytest tests/test_crs_normalize.py -v` +Expected: 9 passed + +- [ ] **Step 5: Commit** + +```bash +git add crs/normalize.py tests/test_crs_normalize.py +git commit -m "feat(crs): Add name-free CRS core, test point, and ellipsoid base helpers" +``` + +### Task 4: Generator: write, read back, manifest row, epsg cache + +**Files:** +- Create: `crs/generate_crs.py` +- Test: `tests/test_crs_generate.py` + +**Interfaces:** +- Consumes: `Case`, `CASES`, `EPSG_CODES` (Task 2); `decode_geokeys`, `encode_geokeys` (Task 1); `core_of`, `point_for`, `project_point` (Task 3). +- Produces: `write_case(case: Case, path: Path) -> None`: `proj`/`epsg`/`wkt` via `rasterio.open(path, "w", driver="GTiff", width=8, height=8, count=1, dtype="uint8", crs=CRS.from_user_input(value), transform=from_origin(0, 0, 10, 10))` inside `rasterio.Env(GDAL_PAM_ENABLED="NO")`, writing zeros; `geokeys` via `tifffile.imwrite(path, zeros((8, 8), uint8), extratags=encode_geokeys(value))`. For `epsg`, `value` is `"EPSG:"`. +- Produces: `read_back(path: Path) -> pyproj.CRS | None`: `rasterio.open` inside `Env(GDAL_PAM_ENABLED="NO")`, `CRS.from_user_input(ds.crs)` or None when `ds.crs` is falsy. +- Produces: `manifest_row(case: Case, path: Path, crs_dir: Path) -> dict` with the exact keys of spec 4.4: `name`, `file` (POSIX path of `path` relative to `crs_dir`), `input` (`{"kind", "value"}`), `note`, `tags` (list), `geokeys`, `gdal` (`{"projjson", "proj4", "roundtrip"}`; `proj4` None when `to_proj4()` raises `CRSError`; `roundtrip` is `CRS.from_user_input(input).equals(read_back)` for non-`geokeys` kinds, None for `geokeys`; all None when read-back is None), `core` (None when read-back is None), `point` (`{"lon", "lat", "x", "y"}` or None when `projjson` or `proj4` is None), `epsg_json` (`"epsg/.json"` for `epsg`, else None). +- Produces: `fetch_epsg_json(code: int, epsg_dir: Path, *, refresh: bool = False) -> Path`: GET `https://epsg.io/.json` with `urllib.request` only when the file is missing or `refresh`; writes it verbatim. +- Produces: `generate(crs_dir: Path, *, refresh_epsg: bool = False) -> dict`: writes every case to `crs_dir / "fixtures" / f"{name}.tif"`, builds rows, fetches epsg JSON, writes `crs_dir / "manifest.json"` with `{"schema_version": 1, "generator": {...}, "cases": rows_sorted_by_name}`; `generator` is `{"gdal": rasterio.__gdal_version__, "proj": rasterio.__proj_version__, "rasterio": rasterio.__version__, "pyproj": pyproj.__version__}`. `main()` parses `--refresh-epsg` and calls `generate(Path(__file__).parent)`. + +- [ ] **Step 1: Write the failing tests** + +```python +# tests/test_crs_generate.py +from pathlib import Path + +from crs.cases import Case +from crs.generate_crs import fetch_epsg_json, manifest_row, read_back, write_case + +TMERC = Case("tmerc", "proj", "+proj=tmerc +lat_0=0 +lon_0=-3.5 +k=0.9996 +x_0=500000 +y_0=0 +ellps=WGS84") + + +def test_write_and_read_back_proj_case(tmp_path: Path): + path = tmp_path / "tmerc.tif" + write_case(TMERC, path) + assert not (tmp_path / "tmerc.tif.aux.xml").exists() + crs = read_back(path) + assert crs is not None + assert crs.coordinate_operation.method_code == "9807" + + +def test_manifest_row_proj_case(tmp_path: Path): + path = tmp_path / "fixtures" / "tmerc.tif" + path.parent.mkdir() + write_case(TMERC, path) + row = manifest_row(TMERC, path, tmp_path) + assert row["file"] == "fixtures/tmerc.tif" + assert row["input"] == {"kind": "proj", "value": TMERC.value} + assert row["geokeys"]["ProjCoordTrans"] == 1 + assert row["geokeys"]["ProjectedCSType"] == 32767 + assert row["gdal"]["roundtrip"] is True + assert row["gdal"]["proj4"].startswith("+proj=tmerc +lat_0=0 +lon_0=-3.5") + assert row["gdal"]["projjson"]["type"] == "ProjectedCRS" + assert row["core"]["method"]["epsg"] == 9807 + assert row["point"]["lon"] == -0.5 and row["point"]["lat"] == 8.0 + assert row["epsg_json"] is None + + +def test_manifest_row_keyless_case(tmp_path: Path): + case = Case("eqearth", "proj", "+proj=eqearth +lon_0=0 +ellps=WGS84", note="no keys") + path = tmp_path / "eqearth.tif" + write_case(case, path) + row = manifest_row(case, path, tmp_path) + assert row["gdal"] == {"projjson": None, "proj4": None, "roundtrip": None} + assert row["core"] is None and row["point"] is None + assert row["note"] == "no keys" + + +def test_manifest_row_geokeys_case(tmp_path: Path): + case = Case("pm_epsg", "geokeys", {"GTModelType": 2, "GTRasterType": 1, "GeographicType": 32767, "GeogGeodeticDatum": 32767, "GeogEllipsoid": 7030, "GeogPrimeMeridian": 8903, "GeogAngularUnits": 9102}) + path = tmp_path / "pm_epsg.tif" + write_case(case, path) + row = manifest_row(case, path, tmp_path) + assert row["geokeys"] == case.value + assert row["gdal"]["roundtrip"] is None + assert row["core"]["prime_meridian_deg"] == pytest.approx(2.33722917) + + +def test_manifest_row_epsg_case(tmp_path: Path): + case = Case("epsg_32633", "epsg", "EPSG:32633") + path = tmp_path / "epsg_32633.tif" + write_case(case, path) + row = manifest_row(case, path, tmp_path) + assert row["geokeys"]["ProjectedCSType"] == 32633 + assert row["epsg_json"] == "epsg/32633.json" + + +def _no_network(*args, **kwargs): + raise AssertionError("network used") + + +def test_fetch_epsg_json_skips_existing(tmp_path: Path, monkeypatch): + existing = tmp_path / "32633.json" + existing.write_text("{}") + monkeypatch.setattr("urllib.request.urlopen", _no_network) + assert fetch_epsg_json(32633, tmp_path) == existing +``` + +(Add `import pytest` for `approx`.) + +- [ ] **Step 2: Run tests to verify they fail** + +Run: `pixi run pytest tests/test_crs_generate.py -v` +Expected: FAIL with `ModuleNotFoundError: No module named 'crs.generate_crs'` + +- [ ] **Step 3: Implement `crs/generate_crs.py`** + +Guard `main()` with `if __name__ == "__main__":`. `point` for a row: `lon, lat = point_for(core)`, `x, y = project_point(crs, lon, lat)`. + +- [ ] **Step 4: Run tests to verify they pass** + +Run: `pixi run pytest tests/test_crs_generate.py -v` +Expected: 6 passed + +- [ ] **Step 5: Commit** + +```bash +git add crs/generate_crs.py tests/test_crs_generate.py +git commit -m "feat(crs): Add the corpus generator" +``` + +### Task 5: Generate the corpus; wire pixi, check.sh, info.sh, README + +**Files:** +- Modify: `pixi.toml` (`[tasks]`: `generate-crs = "python -m crs.generate_crs"`) +- Modify: `scripts/check.sh` (run `pixi run generate-crs` after `pixi run generate`) +- Modify: `scripts/info.sh` (`find . -path ./crs -prune -o -name "*.tif" -type f -print`) +- Modify: `README.md` (one paragraph under Usage pointing at `crs/README.md`) +- Create: `crs/README.md`, `crs/fixtures/*.tif`, `crs/manifest.json`, `crs/epsg/*.json` + +**Interfaces:** +- Consumes: `generate` via the pixi task. + +- [ ] **Step 1: Add the pixi task and script changes** + +- [ ] **Step 2: Generate** + +Run: `pixi run generate-crs` +Expected: `crs/fixtures/` holds one `.tif` per case (about 97 files, each under 2 KB), `crs/epsg/` holds 46 JSON files, `crs/manifest.json` exists, and no `.aux.xml` anywhere under `crs/`. If the network is unavailable, copy the 46 cached files from the prior session's scratchpad (`.../scratchpad/prior/epsg/`) into `crs/epsg/` first. + +- [ ] **Step 3: Check determinism** + +Run: `pixi run generate-crs && git status --porcelain crs/` +Expected: after a second run, `git status` shows only the first run's untracked files (no modified files between runs). Then `bash scripts/check.sh` must pass once everything is committed. + +- [ ] **Step 4: Inspect the manifest for surprises** + +Run: `pixi run python -c "import json; m=json.load(open('crs/manifest.json')); print([c['name'] for c in m['cases'] if c['gdal']['projjson'] is None or c['gdal']['proj4'] is None]); print([c['name'] for c in m['cases'] if c['input']['kind']=='proj' and c['geokeys'].get('ProjectedCSType', 32767) != 32767])"` +Expected: first list is exactly `['eqearth', 'stere_polar_scaled_wkt']`; second list is empty. If a `proj` case was identified as an EPSG code, change its parameters in `cases.py` (spec 4.3) and regenerate. + +- [ ] **Step 5: Write `crs/README.md`** + +Sections: what the corpus is and that GDAL/PROJ is the oracle; how to regenerate (`pixi run generate-crs`, `--refresh-epsg`); case kinds; the manifest schema (copy spec 4.4 with the no-suffix key naming and the `axes` list); the table schema (copy spec 5.1-5.2, including the `when` grammar and the three rules); which rows are flagged and why; links to the libgeotiff/GDAL/PROJ sources with the pinned commit and tag. + +- [ ] **Step 6: Commit** + +```bash +git add pixi.toml scripts/check.sh scripts/info.sh README.md crs/README.md crs/fixtures crs/manifest.json crs/epsg +git commit -m "feat(crs): Generate the conformance corpus and manifest" +``` + +### Task 6: CT table + +**Files:** +- Create: `crs/geotiff-ct-methods.json` +- Test: `tests/test_crs_table.py` + +**Interfaces:** +- Produces: the JSON of spec 5.1-5.3: `schema_version: 1`, `sources`, `units`, `methods` keyed by CT code string for 1-28 and 9815; 2, 5, 6 carry only `ct_name` and `unsupported`; 7 has two variants (`{"present": "ProjStdParallel1"}` first); 15 has three (`{"value": {"param": "Scale factor at natural origin", "equals": 1}}`, then `{"abs_value": {"param": "Latitude of natural origin", "equals": 90}}`, then an `unrepresentable` default); 27 has `"axes": ["west", "south"]`. + +- [ ] **Step 1: Write the failing tests** + +```python +# tests/test_crs_table.py +import json +from pathlib import Path + +TABLE = json.loads((Path(__file__).parent.parent / "crs/geotiff-ct-methods.json").read_text()) +MANIFEST = json.loads((Path(__file__).parent.parent / "crs/manifest.json").read_text()) +KINDS = {"angular", "linear", "scale", "azimuth"} +RULE_KEYS = {"present", "abs_value", "value", "any", "all"} + + +def _rule_ok(rule: dict) -> bool: + (key, body), = rule.items() + if key in ("any", "all"): + return all(_rule_ok(r) for r in body) + if key == "present": + return isinstance(body, str) + return set(body) == {"param", "equals"} and key in RULE_KEYS + + +def test_table_covers_every_ct_code(): + assert set(TABLE["methods"]) == {str(c) for c in range(1, 29)} | {"9815"} + assert {c for c, m in TABLE["methods"].items() if "unsupported" in m} == {"2", "5", "6"} + + +def test_variants_are_well_formed(): + for code, method in TABLE["methods"].items(): + if "unsupported" in method: + assert set(method) == {"ct_name", "unsupported"} + continue + variants = method["variants"] + assert "when" not in variants[-1] + for v in variants[:-1]: + assert _rule_ok(v["when"]) + for v in variants: + if "unrepresentable" in v: + continue + assert set(v["method"]) == {"name", "epsg", "proj"} + for p in v["parameters"]: + assert set(p) >= {"name", "epsg", "proj", "kind", "keys", "default"} + assert p["kind"] in KINDS + assert p["keys"] and all(k in TABLE["units"]["angular_keys"] + TABLE["units"]["linear_keys"] + ["ProjScaleAtNatOrigin", "ProjScaleAtCenter", "ProjAzimuthAngle"] for k in p["keys"]) + assert v.get("axes", ["east", "north"]) in (["east", "north"], ["west", "south"]) + assert "gdal" in v + assert "libgeotiff" in method + + +def test_variant_rules(): + assert TABLE["methods"]["7"]["variants"][0]["when"] == {"present": "ProjStdParallel1"} + assert TABLE["methods"]["15"]["variants"][0]["when"] == {"value": {"param": "Scale factor at natural origin", "equals": 1}} + assert TABLE["methods"]["15"]["variants"][1]["when"] == {"abs_value": {"param": "Latitude of natural origin", "equals": 90}} + assert "unrepresentable" in TABLE["methods"]["15"]["variants"][2] + assert TABLE["methods"]["27"]["variants"][0]["axes"] == ["west", "south"] + + +def test_every_supported_method_has_a_fixture(): + seen = {str(c["geokeys"].get("ProjCoordTrans")) for c in MANIFEST["cases"]} + for code, method in TABLE["methods"].items(): + if "unsupported" not in method: + assert code in seen, code + + +def test_every_fixture_ct_code_is_in_table(): + for c in MANIFEST["cases"]: + ct = c["geokeys"].get("ProjCoordTrans") + if ct is not None: + assert str(ct) in TABLE["methods"], c["name"] + + +def test_table_method_names_match_manifest(): + """For every tested fixture with a CT code, the method GDAL read is one of the table's variants.""" + for c in MANIFEST["cases"]: + ct = c["geokeys"].get("ProjCoordTrans") + if ct is None or c["gdal"]["proj4"] is None: + continue + names = {v["method"]["name"] for v in TABLE["methods"][str(ct)]["variants"] if "method" in v} + assert c["core"]["method"]["name"] in names, (c["name"], c["core"]["method"]["name"]) +``` + +- [ ] **Step 2: Run tests to verify they fail** + +Run: `pixi run pytest tests/test_crs_table.py -v` +Expected: FAIL with `FileNotFoundError` for `geotiff-ct-methods.json` + +- [ ] **Step 3: Write `crs/geotiff-ct-methods.json`** + +Transcribe spec 5.3 row by row, with each parameter's `keys` from the common fallbacks in spec 5.3 and the `kind` from spec 5.1. Method names and EPSG codes must match what `core.method` shows in the manifest for that CT code (the last test enforces this; fix the table, not the manifest). Parameter EPSG codes: 8801-8807 (natural origin, scale, FE, FN), 8821-8827 (false origin, 1st/2nd parallel, E/N at false origin), 8811-8817 (projection centre, azimuth, grid angle, scale, E/N at centre), 8823/8824 for standard parallels, 8832/8833 for Polar B's standard parallel / longitude of origin. Non-EPSG methods (Stereographic, Gnomonic, Miller, Robinson, Sinusoidal, Van Der Grinten, Azimuthal Equidistant and Equidistant Conic if PROJ reports no code) get `"epsg": null` on the method and the parameter names PROJ uses in the manifest. + +- [ ] **Step 4: Run tests to verify they pass** + +Run: `pixi run pytest tests/test_crs_table.py -v` +Expected: 6 passed + +- [ ] **Step 5: Commit** + +```bash +git add crs/geotiff-ct-methods.json tests/test_crs_table.py +git commit -m "feat(crs): Add the GeoTIFF CT code to PROJ method table" +``` + +### Task 7: Corpus integrity tests and PR + +**Files:** +- Create: `tests/test_crs_corpus.py` +- Modify: `crs/README.md` (mention the tests) + +**Interfaces:** +- Consumes: `decode_geokeys` (Task 1), `CASES` (Task 2), `crs/manifest.json` (Task 5). + +- [ ] **Step 1: Write the tests** + +```python +# tests/test_crs_corpus.py +import json +from pathlib import Path + +import pytest + +from crs.cases import CASES +from crs.geokeys import decode_geokeys + +CRS_DIR = Path(__file__).parent.parent / "crs" +MANIFEST = json.loads((CRS_DIR / "manifest.json").read_text()) +ROWS = {c["name"]: c for c in MANIFEST["cases"]} + + +def test_manifest_matches_case_list(): + assert sorted(ROWS) == sorted(c.name for c in CASES) + assert [c["name"] for c in MANIFEST["cases"]] == sorted(ROWS) + + +@pytest.mark.parametrize("name", sorted(ROWS)) +def test_fixture_geokeys_match_manifest(name: str): + row = ROWS[name] + path = CRS_DIR / row["file"] + assert path.exists() + assert not path.with_name(path.name + ".aux.xml").exists() + assert decode_geokeys(path) == row["geokeys"] + + +def test_proj_cases_are_user_defined(): + for row in MANIFEST["cases"]: + if row["input"]["kind"] != "proj" or row["gdal"]["projjson"] is None: + continue + keys = row["geokeys"] + assert keys.get("ProjectedCSType", 32767) == 32767, row["name"] + assert keys.get("GeographicType", 32767) == 32767, row["name"] + + +def test_flagged_rows(): + flagged = {r["name"] for r in MANIFEST["cases"] if r["gdal"]["projjson"] is None or r["gdal"]["proj4"] is None} + assert flagged == {"eqearth", "stere_polar_scaled_wkt"} + assert all(ROWS[n]["note"] for n in flagged) + + +def test_epsg_rows_have_cached_json(): + for row in MANIFEST["cases"]: + if row["input"]["kind"] == "epsg": + assert (CRS_DIR / row["epsg_json"]).exists(), row["name"] + + +def test_point_rows(): + for row in MANIFEST["cases"]: + if row["gdal"]["proj4"] is not None: + assert set(row["point"]) == {"lon", "lat", "x", "y"}, row["name"] +``` + +- [ ] **Step 2: Run the full suite** + +Run: `pixi run test && pixi run ruff check . 2>/dev/null || pixi run python -m ruff check .` +Expected: all tests pass (the per-fixture test runs ~97 times); ruff reports nothing. If `ruff` is not in the pixi env, run it via `uvx ruff check .` as CI's `ruff-action` does. + +- [ ] **Step 3: Run the CI check script** + +Run: `bash scripts/check.sh` +Expected: ends with "All generated files are up to date." + +- [ ] **Step 4: Commit and push** + +```bash +git add tests/test_crs_corpus.py crs/README.md +git commit -m "test(crs): Check fixtures, manifest, and table against each other" +git push -u origin kyle/crs-conformance-corpus +``` + +- [ ] **Step 5: Open the PR** + +Title: `feat: Add a GeoKey-to-CRS conformance corpus and CT method table`. Body: the NOTE attribution line, a summary of the layout, how to regenerate, the two flagged rows and why, the four rows that depend on async-tiff#368, and the footer. Then report that it is ready for review; do not merge. diff --git a/dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md b/dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md index dcb701a..0bf0383 100644 --- a/dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md +++ b/dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md @@ -249,11 +249,11 @@ the manifest row. "input": {"kind": "proj", "value": "+proj=lcc ... +units=us-ft"}, "note": "", // free text, e.g. why a row is lossy "tags": ["ct:8", "linear:9003"], // free-form, for filtering - "geokeys": { // exactly what GDAL wrote, by GeoTIFF key name - "GTModelTypeGeoKey": 1, "GTRasterTypeGeoKey": 1, - "GeographicTypeGeoKey": 32767, "GeogCitationGeoKey": "GCS Name = unknown|...", - "ProjCoordTransGeoKey": 8, "ProjLinearUnitsGeoKey": 9003, - "ProjFalseOriginEastingGeoKey": 984250.0, ... + "geokeys": { // exactly what GDAL wrote, by GeoTIFF key name (no "GeoKey" suffix) + "GTModelType": 1, "GTRasterType": 1, + "GeographicType": 32767, "GeogCitation": "GCS Name = unknown|...", + "ProjCoordTrans": 8, "ProjLinearUnits": 9003, + "ProjFalseOriginEasting": 984250.0, ... }, "gdal": { "projjson": { ... }, // rasterio read-back, pyproj.CRS.to_json_dict(); null if none @@ -271,8 +271,8 @@ the manifest row. "prime_meridian_deg": 0.0, "angular_unit_deg": 1.0, // size of the geographic CS unit in degrees "linear_unit_m": 0.3048006096012192, // size of the projected CS unit in metres (null for geographic) - "axes": "easting_northing", // or westing_southing (CT 27); null for geographic - "towgs84": null // 7 numbers for BoundCRS rows + "axes": ["east", "north"], // axis directions in order; ["west", "south"] for CT 27 + "towgs84": null // 3 or 7 numbers for BoundCRS rows }, "point": {"lon": -71.0, "lat": 48.16667, "x": 1722466.6689, "y": 2936519.5336}, "epsg_json": null // "epsg/2953.json" for kind == "epsg" @@ -343,7 +343,7 @@ Add `tests/test_crs_corpus.py`: { "when": { ... }, // see 5.2; omitted on the default variant "method": {"name": "Transverse Mercator", "epsg": 9807, "proj": "tmerc"}, - "axes": "easting_northing", // optional; default easting_northing; CT 27 uses westing_southing + "axes": ["east", "north"], // optional; default ["east", "north"]; CT 27 uses ["west", "south"] "parameters": [ { "name": "Latitude of natural origin", // EPSG/PROJ parameter name @@ -459,7 +459,7 @@ Every row's `keys` order comes from `GTIFFetchProjParms`; every method from the | 24 | Sinusoidal (PROJ), `sinu` | lon_0, FE, FN | L2039-L2061 | L1551 | | 25 | Van Der Grinten (PROJ), `vandg` | lon_0, FE, FN | L2039-L2061 | L1555 | | 26 | New Zealand Map Grid (9811), `nzmg` | lat_0, lon_0, FE, FN | L1962-L1997 | L1579 | -| 27 | Transverse Mercator (South Orientated) (9808), `tmerc +axis=wsu`; `axes: westing_southing` | lat_0, lon_0, k, FE, FN | L1774-L1816 | L1445 | +| 27 | Transverse Mercator (South Orientated) (9808), `tmerc +axis=wsu`; `axes: ["west", "south"]` | lat_0, lon_0, k, FE, FN | L1774-L1816 | L1445 | | 28 | Lambert Cylindrical Equal Area (9835), `cea` | lat_1 (`ProjStdParallel1`), lon_0, FE, FN | L2198-L2224 | L1584 | | 9815 | Hotine Oblique Mercator (variant B) (9815), `omerc` | lat_c, lon_c, azimuth, rectified grid angle, k_c, E_c, N_c | L1819-L1870 | L1494 | @@ -571,7 +571,7 @@ Follows `GTIFGetDefn` (geo_normalize.c L2394-L2660) and the GeogCS block of `GTI `ProjLinearUnitSizeGeoKey`. Factor in metres `UOMLengthInMeters`. Use the `Cartesian2DCS` presets where one exists (`EASTING_NORTHING`, `EASTING_NORTHING_FT` for 9002, `EASTING_NORTHING_US_FT` for 9003, `WESTING_SOUTHING` for a table row with - `axes: westing_southing`), and `CoordinateSystem.from_json_dict` only for other units (name and + `axes: ["west", "south"]`), and `CoordinateSystem.from_json_dict` only for other units (name and factor from proj.db via pyproj for a code, the raw size for 32767). Do not hardcode unit factors. - **Ellipsoid**: if `GeogEllipsoidGeoKey` is a code and no axis keys: `Ellipsoid.from_epsg`. Otherwise `CustomEllipsoid(name, semi_major_axis, inverse_flattening | semi_minor_axis)`; @@ -649,9 +649,10 @@ at the top and the "Written by Claude Code" footer; `Closes #N` where applicable 4. **async-geotiff, builder**: `_crs_conversion.py`, `_crs_geographic.py`, interpreter unit tests first (red), then the rewrite; known-failures shrinks to the Q2 rows (`tmerc_towgs84`, `omerc_variant_a`, `omerc_variant_b`, `somerc`) and the Q3 row. Changelog entry. -5. **async-tiff** (approved, done first since it is small): issue + minimal PR exposing keys - 2062 and 3096. Once released, async-geotiff bumps its `async-tiff>=` floor, reads them in - stage 4, and the four rows leave the known-failures list. +5. **async-tiff** (done 2026-10-26): issue developmentseed/async-tiff#367 and PR + developmentseed/async-tiff#368 expose keys 2062 and 3096. Once released, async-geotiff bumps + its `async-tiff>=` floor, reads them in stage 4, and the four rows leave the known-failures + list. Before stage 4, write an implementation plan via the writing-plans skill into `dev-docs/plans/`. From 5923803d4d5f8079e4b24de84802666960797137 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Mon, 26 Oct 2026 12:05:15 -0400 Subject: [PATCH 04/10] docs: Correct Mercator scale keys and polar axes in the CRS spec Found by the corpus review: libgeotiff reads only ProjScaleAtNatOrigin for CT 7, and PROJ gives Polar Stereographic south/south or north/north axes by the sign of the latitude. Co-Authored-By: Claude Fable 5.1 --- .../2026-10-26-geokey-crs-conformance-design.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md b/dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md index 0bf0383..2f0cc14 100644 --- a/dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md +++ b/dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md @@ -425,8 +425,9 @@ Every row's `keys` order comes from `GTIFFetchProjParms`; every method from the an origin (including HOM, which GDAL writes with `ProjCenter*`). - Polar Stereographic longitude: `ProjStraightVertPoleLong` first, then the three above (L2066-L2074). - Scale: `ProjScaleAtNatOrigin`, `ProjScaleAtCenter`, default 1 (L1795-L1800, L1846-L1850, - L1939-L1943, L2084-L2088), except CT 14 Stereographic which reads `ProjScaleAtNatOrigin` only - (L1696-L1698). + L1939-L1943, L2084-L2088), except CT 14 Stereographic (L1696-L1698) and CT 7 Mercator + (L1739-L1741), which read `ProjScaleAtNatOrigin` only. (Corrected 2026-10-26 after the corpus + review; the first draft gave CT 7 the fallback.) - Standard parallels: `ProjStdParallel1` / `ProjStdParallel2` only, default 0. - Azimuth: `ProjAzimuthAngle`, default 0, kind `azimuth`. Rectified grid angle: `ProjRectifiedGridAngle`, default 90 (L1842-L1844), kind `angular`. @@ -472,8 +473,13 @@ disagree, fix the table to the manifest and note it in the PR). - Unit normalization (one pass over resolved parameters, keyed by `kind`). - The geographic CRS (datum, ellipsoid, prime meridian, angular unit), the projected CS unit, the `ProjectionGeoKey` EPSG path, the ESRI PE String path. These are described in section 6 and are - the same for every method. The only per-method CS fact is axis direction (`axes`), because - CT 27 is the one method whose axes point west/south; the manifest `core` records `axes` too. + the same for every method. The only per-method CS facts are axis directions: CT 27's axes + point west/south (`axes` field), and CT 15's point both south for a positive latitude and both + north for a negative one (a sign rule the table states in a note and the README spells out; the + corpus pins it). The manifest `core` records `axes` for every row. (Corrected 2026-10-26: the + first draft said CT 27 was the only exception.) In the builder, use pyproj's + `Cartesian2DCS(axis="NORTH_POLE_EASTING_SOUTH_NORTHING_SOUTH")` and + `SOUTH_POLE_EASTING_NORTH_NORTHING_NORTH` presets for CT 15. ## 6. Equality and builder design (async-geotiff) From cea56ebf50cb659a8f8a6a0670556f7bed014acf Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Mon, 26 Oct 2026 12:34:28 -0400 Subject: [PATCH 05/10] chore: Bump geotiff-test-data for the CRS conformance corpus Also adds the stage 3 plan. Co-Authored-By: Claude Fable 5.1 --- .../plans/2026-10-26-crs-conformance-tests.md | 65 +++++++++++++++++++ fixtures/geotiff-test-data | 2 +- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 dev-docs/plans/2026-10-26-crs-conformance-tests.md diff --git a/dev-docs/plans/2026-10-26-crs-conformance-tests.md b/dev-docs/plans/2026-10-26-crs-conformance-tests.md new file mode 100644 index 0000000..0a38a7f --- /dev/null +++ b/dev-docs/plans/2026-10-26-crs-conformance-tests.md @@ -0,0 +1,65 @@ +# CRS Conformance Tests Implementation Plan (stage 3) + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Make async-geotiff's test suite run the geotiff-test-data CRS corpus against the current `_crs.py`, green from day one through a known-failures list that can only shrink. + +**Architecture:** The submodule moves to the commit that merged the corpus. The CT table is vendored into the package (`src/async_geotiff/data/`) with a test that it equals the submodule copy. A parametrized test opens every manifest row's fixture, compares the built CRS to GDAL's PROJJSON with `pyproj.CRS.equals`, then checks the test point; rows in `KNOWN_FAILURES` are `xfail(strict=True)`, flagged rows are skipped. + +**Tech Stack:** pytest, pytest-asyncio, pyproj 3.7, async-geotiff test fixtures (`fixture_store`), uv. + +**Spec:** `dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md`, sections 6.2 (vendoring) and 7 (tests). + +## Global Constraints + +- Branch `kyle/crs-conformance-tests` in the `.claude/worktrees/crs-conformance-spec` worktree; never commit on `main`. +- No changes to `src/async_geotiff/_crs.py` in this stage; the known-failures list records what fails today. +- `tests/test_crs.py` over `ALL_TEST_IMAGES` stays green. +- Ruff `select = ["ALL"]` with the repo's ignores; tests directory has its own per-file ignores. +- PR text with the Claude attribution note and footer; never merge. + +## Review Focus + +1. A listed known failure that starts passing must fail the run (`xfail(strict=True)`), pinned by `test_known_failures_are_listed_cases`. +2. A flagged row (`gdal.projjson` or `gdal.proj4` null) must be skipped, not failed, pinned by the skip marks in `_params()`. +3. The vendored table must not drift from the submodule, pinned by `test_vendored_table_matches_submodule`. +4. The point check must use the manifest's degree/Greenwich base, not `geodetic_crs`, or grads and Paris rows fail for the wrong reason (`_ellipsoid_longlat`). +5. The vendored JSON must ship in the wheel; verified once by listing the built wheel. + +--- + +### Task 1: Submodule bump + +**Files:** Modify: `fixtures/geotiff-test-data` (gitlink) + +- [ ] Point the submodule at geotiff-test-data `main` after #84 merged (`35da663`); `git -C fixtures/geotiff-test-data checkout origin/main`. +- [ ] Run: `uv run pytest -q` → Expected: existing suite still passes. +- [ ] Commit: `chore: Bump geotiff-test-data for the CRS conformance corpus`. + +### Task 2: Vendor the CT table + +**Files:** Create: `src/async_geotiff/data/geotiff-ct-methods.json` (verbatim copy), `src/async_geotiff/data/__init__.py` (docstring only); Test: `tests/test_crs_table.py`. + +- [ ] Write `tests/test_crs_table.py`: `test_vendored_table_matches_submodule` (json-equal to `fixtures/geotiff-test-data/crs/geotiff-ct-methods.json`) and `test_table_methods_have_proj_names` (every non-`unsupported` variant with a `method` has a non-empty `proj`). +- [ ] Run: `uv run pytest tests/test_crs_table.py -q` → Expected: FAIL, vendored file missing. +- [ ] Copy the JSON; add `data/__init__.py`. +- [ ] Run again → Expected: 2 passed. Then `uv build --wheel` and `unzip -l dist/*.whl | grep geotiff-ct-methods` → Expected: one line. +- [ ] Commit: `test: Vendor the GeoTIFF CT method table with a drift test`. + +### Task 3: Conformance test with seeded known failures + +**Files:** Create: `tests/test_crs_conformance.py`. + +**Interfaces:** +- `MANIFEST` loaded at import from `tests/../fixtures/geotiff-test-data/crs/manifest.json`. +- `KNOWN_FAILURES: dict[str, str]` name → reason. +- `_params() -> list[pytest.param]`: one per row, id = name; `pytest.mark.skip(reason=note)` when `gdal.projjson` or `gdal.proj4` is null; `pytest.mark.xfail(strict=True, reason=...)` when listed. +- `test_crs_matches_gdal(fixture_store, row)`: open `geotiff-test-data/crs/`, `expected = CRS.from_json_dict(row["gdal"]["projjson"])`, `assert expected.equals(geotiff.crs)`, then project `(lon, lat)` from a `+proj=longlat` CRS on `geotiff.crs`'s ellipsoid (`+a +rf`, or `+R` for a sphere) with `always_xy=True` and compare to `(x, y)` with `pytest.approx(abs=2e-3)` (the manifest rounds to millimetres). +- `test_known_failures_are_listed_cases()`: every key of `KNOWN_FAILURES` is a manifest name that is not flagged. + +- [ ] Write the test with `KNOWN_FAILURES = {}`. +- [ ] Run: `uv run pytest tests/test_crs_conformance.py -q` → Expected: a mix of passes and failures, 2 skipped (`eqearth`, `stere_polar_scaled_wkt`). +- [ ] Seed `KNOWN_FAILURES` from the failing ids, one reason each, grouped by the failure class from spec section 1 (rejected CT code, wrong variant, units, origin keys, datum, async-tiff keys, GDAL PM-in-grads). +- [ ] Run: `uv run pytest -q` → Expected: whole suite green, with `N xfailed, 2 skipped`. +- [ ] Commit: `test: Add the GeoKey-to-CRS conformance test with a known-failures list`. +- [ ] Push `kyle/crs-conformance-tests`, open the PR (title `test: Add the CRS conformance suite from geotiff-test-data`), report ready. diff --git a/fixtures/geotiff-test-data b/fixtures/geotiff-test-data index 6f40378..35da663 160000 --- a/fixtures/geotiff-test-data +++ b/fixtures/geotiff-test-data @@ -1 +1 @@ -Subproject commit 6f4037861ed474d39ef81d02207b3f252c897d7d +Subproject commit 35da6638fca485c0c5afbb90bd3c46a077ba1859 From 01fe51a6721cf3e47f635c9bbf190470bf4f4809 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Mon, 26 Oct 2026 12:37:28 -0400 Subject: [PATCH 06/10] test: Vendor the GeoTIFF CT method table with a drift test The JSON ships in the wheel under async_geotiff/data for the table-driven builder. pytest now collects only tests/, since the geotiff-test-data submodule carries its own suite with its own dependencies. Co-Authored-By: Claude Fable 5.1 --- pyproject.toml | 4 + src/async_geotiff/data/__init__.py | 1 + .../data/geotiff-ct-methods.json | 2041 +++++++++++++++++ tests/test_crs_table.py | 24 + 4 files changed, 2070 insertions(+) create mode 100644 src/async_geotiff/data/__init__.py create mode 100644 src/async_geotiff/data/geotiff-ct-methods.json create mode 100644 tests/test_crs_table.py diff --git a/pyproject.toml b/pyproject.toml index e11051d..83f6dc8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,6 +72,10 @@ docs = [ requires = ["uv_build>=0.8.8,<0.12.0"] build-backend = "uv_build" +[tool.pytest.ini_options] +# The geotiff-test-data submodule has its own test suite with its own dependencies. +testpaths = ["tests"] + [tool.ruff] extend-exclude = ["fixtures"] diff --git a/src/async_geotiff/data/__init__.py b/src/async_geotiff/data/__init__.py new file mode 100644 index 0000000..4900914 --- /dev/null +++ b/src/async_geotiff/data/__init__.py @@ -0,0 +1 @@ +"""Data files shipped with async-geotiff.""" diff --git a/src/async_geotiff/data/geotiff-ct-methods.json b/src/async_geotiff/data/geotiff-ct-methods.json new file mode 100644 index 0000000..0319576 --- /dev/null +++ b/src/async_geotiff/data/geotiff-ct-methods.json @@ -0,0 +1,2041 @@ +{ + "schema_version": 1, + "description": "How each GeoTIFF ProjCoordTransGeoKey code maps to a PROJ/EPSG method and how its parameters are read from GeoKeys, transcribed from libgeotiff GTIFFetchProjParms and GDAL GTIFGetOGISDefn. See crs/README.md for the schema and the rules.", + "sources": { + "libgeotiff": "https://github.com/OSGeo/libgeotiff/blob/75cfca539667c6483e796b24b78ecef72e311a1a/libgeotiff/geo_normalize.c", + "gdal": "https://github.com/OSGeo/gdal/blob/v3.12.1/frmts/gtiff/gt_wkt_srs.cpp", + "proj": "https://github.com/OSGeo/PROJ/blob/9.7.1/src/iso19111/io.cpp" + }, + "units": { + "angular": "values of angular_keys are multiplied by the GeogAngularUnits (or GeogAngularUnitSize) factor to give degrees", + "linear": "values of linear_keys are multiplied by the ProjLinearUnits (or ProjLinearUnitSize) factor to give metres", + "angular_keys": [ + "ProjStdParallel1", + "ProjStdParallel2", + "ProjNatOriginLong", + "ProjNatOriginLat", + "ProjFalseOriginLong", + "ProjFalseOriginLat", + "ProjCenterLong", + "ProjCenterLat", + "ProjStraightVertPoleLong", + "ProjRectifiedGridAngle" + ], + "linear_keys": [ + "ProjFalseEasting", + "ProjFalseNorthing", + "ProjFalseOriginEasting", + "ProjFalseOriginNorthing", + "ProjCenterEasting", + "ProjCenterNorthing" + ], + "source": "geo_normalize.c#L2227-L2277" + }, + "methods": { + "1": { + "ct_name": "CT_TransverseMercator", + "libgeotiff": "geo_normalize.c#L1774-L1816", + "variants": [ + { + "method": { + "name": "Transverse Mercator", + "epsg": 9807, + "proj": "tmerc" + }, + "parameters": [ + { + "name": "Latitude of natural origin", + "epsg": 8801, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "Scale factor at natural origin", + "epsg": 8805, + "proj": "k_0", + "kind": "scale", + "keys": [ + "ProjScaleAtNatOrigin", + "ProjScaleAtCenter" + ], + "default": 1.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1440-L1443" + } + ] + }, + "2": { + "ct_name": "CT_TransvMercator_Modified_Alaska", + "unsupported": "No case in GTIFGetOGISDefn's switch (gt_wkt_srs.cpp#L1587 falls through to SetLocalCS) and no GDAL writer emits it" + }, + "3": { + "ct_name": "CT_ObliqueMercator", + "libgeotiff": "geo_normalize.c#L1819-L1870", + "variants": [ + { + "method": { + "name": "Hotine Oblique Mercator (variant A)", + "epsg": 9812, + "proj": "omerc" + }, + "parameters": [ + { + "name": "Latitude of projection centre", + "epsg": 8811, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of projection centre", + "epsg": 8812, + "proj": "lonc", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "Azimuth at projection centre", + "epsg": 8813, + "proj": "alpha", + "kind": "azimuth", + "keys": [ + "ProjAzimuthAngle" + ], + "default": 0.0 + }, + { + "name": "Angle from Rectified to Skew Grid", + "epsg": 8814, + "proj": "gamma", + "kind": "angular", + "keys": [ + "ProjRectifiedGridAngle" + ], + "default": 90.0 + }, + { + "name": "Scale factor at projection centre", + "epsg": 8815, + "proj": "k_0", + "kind": "scale", + "keys": [ + "ProjScaleAtNatOrigin", + "ProjScaleAtCenter" + ], + "default": 1.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1489-L1492", + "note": "PROJ string also needs +no_uoff" + } + ] + }, + "4": { + "ct_name": "CT_ObliqueMercator_Laborde", + "libgeotiff": "geo_normalize.c#L1873-L1917", + "variants": [ + { + "method": { + "name": "Laborde Oblique Mercator", + "epsg": 9813, + "proj": "labrd" + }, + "parameters": [ + { + "name": "Latitude of projection centre", + "epsg": 8811, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of projection centre", + "epsg": 8812, + "proj": "lonc", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "Azimuth at projection centre", + "epsg": 8813, + "proj": "alpha", + "kind": "azimuth", + "keys": [ + "ProjAzimuthAngle" + ], + "default": 0.0 + }, + { + "name": "Scale factor at projection centre", + "epsg": 8815, + "proj": "k_0", + "kind": "scale", + "keys": [ + "ProjScaleAtNatOrigin", + "ProjScaleAtCenter" + ], + "default": 1.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1500-L1503", + "note": "PROJ string key for the azimuth is +azi" + } + ] + }, + "5": { + "ct_name": "CT_ObliqueMercator_Rosenmund", + "unsupported": "No case in GTIFGetOGISDefn's switch (gt_wkt_srs.cpp#L1587 falls through to SetLocalCS) and no GDAL writer emits it" + }, + "6": { + "ct_name": "CT_ObliqueMercator_Spherical", + "unsupported": "No case in GTIFGetOGISDefn's switch (gt_wkt_srs.cpp#L1587 falls through to SetLocalCS) and no GDAL writer emits it" + }, + "7": { + "ct_name": "CT_Mercator", + "libgeotiff": "geo_normalize.c#L1717-L1771", + "variants": [ + { + "when": { + "present": "ProjStdParallel1" + }, + "method": { + "name": "Mercator (variant B)", + "epsg": 9805, + "proj": "merc" + }, + "parameters": [ + { + "name": "Latitude of 1st standard parallel", + "epsg": 8823, + "proj": "lat_ts", + "kind": "angular", + "keys": [ + "ProjStdParallel1" + ], + "default": 0.0 + }, + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1450-L1462", + "note": "GDAL ignores ProjScaleAtNatOrigin when the parallel is present" + }, + { + "method": { + "name": "Mercator (variant A)", + "epsg": 9804, + "proj": "merc" + }, + "parameters": [ + { + "name": "Latitude of natural origin", + "epsg": 8801, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "Scale factor at natural origin", + "epsg": 8805, + "proj": "k_0", + "kind": "scale", + "keys": [ + "ProjScaleAtNatOrigin" + ], + "default": 1.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1463-L1465", + "note": "libgeotiff reads ProjScaleAtNatOrigin only for this code (L1739-L1747), not ProjScaleAtCenter" + } + ] + }, + "8": { + "ct_name": "CT_LambertConfConic_2SP", + "libgeotiff": "geo_normalize.c#L2107-L2149", + "variants": [ + { + "method": { + "name": "Lambert Conic Conformal (2SP)", + "epsg": 9802, + "proj": "lcc" + }, + "parameters": [ + { + "name": "Latitude of false origin", + "epsg": 8821, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of false origin", + "epsg": 8822, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "Latitude of 1st standard parallel", + "epsg": 8823, + "proj": "lat_1", + "kind": "angular", + "keys": [ + "ProjStdParallel1" + ], + "default": 0.0 + }, + { + "name": "Latitude of 2nd standard parallel", + "epsg": 8824, + "proj": "lat_2", + "kind": "angular", + "keys": [ + "ProjStdParallel2" + ], + "default": 0.0 + }, + { + "name": "Easting at false origin", + "epsg": 8826, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "Northing at false origin", + "epsg": 8827, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1564-L1567" + } + ] + }, + "9": { + "ct_name": "CT_LambertConfConic_1SP", + "libgeotiff": "geo_normalize.c#L1774-L1816", + "variants": [ + { + "method": { + "name": "Lambert Conic Conformal (1SP)", + "epsg": 9801, + "proj": "lcc" + }, + "parameters": [ + { + "name": "Latitude of natural origin", + "epsg": 8801, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "Scale factor at natural origin", + "epsg": 8805, + "proj": "k_0", + "kind": "scale", + "keys": [ + "ProjScaleAtNatOrigin", + "ProjScaleAtCenter" + ], + "default": 1.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1569-L1572", + "note": "PROJ string also needs +lat_1 equal to +lat_0" + } + ] + }, + "10": { + "ct_name": "CT_LambertAzimEqualArea", + "libgeotiff": "geo_normalize.c#L1962-L1997", + "variants": [ + { + "method": { + "name": "Lambert Azimuthal Equal Area", + "epsg": 9820, + "proj": "laea" + }, + "parameters": [ + { + "name": "Latitude of natural origin", + "epsg": 8801, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1537-L1540" + } + ] + }, + "11": { + "ct_name": "CT_AlbersEqualArea", + "libgeotiff": "geo_normalize.c#L2152-L2195", + "variants": [ + { + "method": { + "name": "Albers Equal Area", + "epsg": 9822, + "proj": "aea" + }, + "parameters": [ + { + "name": "Latitude of false origin", + "epsg": 8821, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of false origin", + "epsg": 8822, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "Latitude of 1st standard parallel", + "epsg": 8823, + "proj": "lat_1", + "kind": "angular", + "keys": [ + "ProjStdParallel1" + ], + "default": 0.0 + }, + { + "name": "Latitude of 2nd standard parallel", + "epsg": 8824, + "proj": "lat_2", + "kind": "angular", + "keys": [ + "ProjStdParallel2" + ], + "default": 0.0 + }, + { + "name": "Easting at false origin", + "epsg": 8826, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "Northing at false origin", + "epsg": 8827, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1574-L1577" + } + ] + }, + "12": { + "ct_name": "CT_AzimuthalEquidistant", + "libgeotiff": "geo_normalize.c#L1962-L1997", + "variants": [ + { + "method": { + "name": "Azimuthal Equidistant", + "epsg": 1125, + "proj": "aeqd" + }, + "parameters": [ + { + "name": "Latitude of natural origin", + "epsg": 8801, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1519-L1521" + } + ] + }, + "13": { + "ct_name": "CT_EquidistantConic", + "libgeotiff": "geo_normalize.c#L2152-L2195", + "variants": [ + { + "method": { + "name": "Equidistant Conic", + "epsg": 1119, + "proj": "eqdc" + }, + "parameters": [ + { + "name": "Latitude of false origin", + "epsg": 8821, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of false origin", + "epsg": 8822, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "Latitude of 1st standard parallel", + "epsg": 8823, + "proj": "lat_1", + "kind": "angular", + "keys": [ + "ProjStdParallel1" + ], + "default": 0.0 + }, + { + "name": "Latitude of 2nd standard parallel", + "epsg": 8824, + "proj": "lat_2", + "kind": "angular", + "keys": [ + "ProjStdParallel2" + ], + "default": 0.0 + }, + { + "name": "Easting at false origin", + "epsg": 8826, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "Northing at false origin", + "epsg": 8827, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1505-L1508" + } + ] + }, + "14": { + "ct_name": "CT_Stereographic", + "libgeotiff": "geo_normalize.c#L1678-L1714", + "variants": [ + { + "method": { + "name": "Stereographic", + "epsg": null, + "proj": "stere" + }, + "parameters": [ + { + "name": "Latitude of natural origin", + "epsg": 8801, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "Scale factor at natural origin", + "epsg": 8805, + "proj": "k_0", + "kind": "scale", + "keys": [ + "ProjScaleAtNatOrigin" + ], + "default": 1.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1484-L1487", + "note": "libgeotiff reads ProjScaleAtNatOrigin only for this code (L1696-L1698)" + } + ] + }, + "15": { + "ct_name": "CT_PolarStereographic", + "libgeotiff": "geo_normalize.c#L2064-L2104", + "variants": [ + { + "when": { + "value": { + "param": "Scale factor at natural origin", + "equals": 1 + } + }, + "method": { + "name": "Polar Stereographic (variant B)", + "epsg": 9829, + "proj": "stere" + }, + "parameters": [ + { + "name": "Latitude of standard parallel", + "epsg": 8832, + "proj": "lat_ts", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of origin", + "epsg": 8833, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjStraightVertPoleLong", + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1559-L1562 (SetPS); variant chosen by PROJ io.cpp#L4231-L4279", + "note": "Scale exactly 1 selects variant B even at the pole; PROJ string also needs +lat_0=+-90. Axes are ['south', 'south'] when the resolved latitude is positive and ['north', 'north'] when negative (PROJ's WKT1 Polar_Stereographic import); the axes field cannot express a sign rule" + }, + { + "when": { + "abs_value": { + "param": "Latitude of natural origin", + "equals": 90 + } + }, + "method": { + "name": "Polar Stereographic (variant A)", + "epsg": 9810, + "proj": "stere" + }, + "parameters": [ + { + "name": "Latitude of natural origin", + "epsg": 8801, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjStraightVertPoleLong", + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "Scale factor at natural origin", + "epsg": 8805, + "proj": "k_0", + "kind": "scale", + "keys": [ + "ProjScaleAtNatOrigin", + "ProjScaleAtCenter" + ], + "default": 1.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1559-L1562 (SetPS); variant chosen by PROJ io.cpp#L4231-L4279", + "note": "Axes are ['south', 'south'] when the resolved latitude is positive and ['north', 'north'] when negative (PROJ's WKT1 Polar_Stereographic import); the axes field cannot express a sign rule" + }, + { + "unrepresentable": "Polar_Stereographic off the pole with scale != 1: PROJ keeps a non-EPSG WKT1 method it cannot operate on (io.cpp#L4231-L4279)" + } + ] + }, + "16": { + "ct_name": "CT_ObliqueStereographic", + "libgeotiff": "geo_normalize.c#L1774-L1816", + "variants": [ + { + "method": { + "name": "Oblique Stereographic", + "epsg": 9809, + "proj": "sterea" + }, + "parameters": [ + { + "name": "Latitude of natural origin", + "epsg": 8801, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "Scale factor at natural origin", + "epsg": 8805, + "proj": "k_0", + "kind": "scale", + "keys": [ + "ProjScaleAtNatOrigin", + "ProjScaleAtCenter" + ], + "default": 1.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1479-L1482" + } + ] + }, + "17": { + "ct_name": "CT_Equirectangular", + "libgeotiff": "geo_normalize.c#L2000-L2036", + "variants": [ + { + "method": { + "name": "Equidistant Cylindrical", + "epsg": 1028, + "proj": "eqc" + }, + "parameters": [ + { + "name": "Latitude of natural origin", + "epsg": 8801, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "Latitude of 1st standard parallel", + "epsg": 8823, + "proj": "lat_ts", + "kind": "angular", + "keys": [ + "ProjStdParallel1" + ], + "default": 0.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1527-L1530", + "note": "PROJ omits Latitude of natural origin from its output when it is 0 (fixture eqc) and keeps it otherwise (fixture eqc_lat0)" + } + ] + }, + "18": { + "ct_name": "CT_CassiniSoldner", + "libgeotiff": "geo_normalize.c#L1920-L1959", + "variants": [ + { + "method": { + "name": "Cassini-Soldner", + "epsg": 9806, + "proj": "cass" + }, + "parameters": [ + { + "name": "Latitude of natural origin", + "epsg": 8801, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1510-L1511", + "note": "libgeotiff reads a scale factor (L1939-L1943) that GDAL ignores" + } + ] + }, + "19": { + "ct_name": "CT_Gnomonic", + "libgeotiff": "geo_normalize.c#L1962-L1997", + "variants": [ + { + "method": { + "name": "Gnomonic", + "epsg": null, + "proj": "gnom" + }, + "parameters": [ + { + "name": "Latitude of natural origin", + "epsg": 8801, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1532-L1535" + } + ] + }, + "20": { + "ct_name": "CT_MillerCylindrical", + "libgeotiff": "geo_normalize.c#L1962-L1997", + "variants": [ + { + "method": { + "name": "Miller Cylindrical", + "epsg": null, + "proj": "mill" + }, + "parameters": [ + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1523-L1525", + "note": "libgeotiff reads a latitude (L1977-L1983) that PROJ drops" + } + ] + }, + "21": { + "ct_name": "CT_Orthographic", + "libgeotiff": "geo_normalize.c#L1962-L1997", + "variants": [ + { + "method": { + "name": "Orthographic", + "epsg": 9840, + "proj": "ortho" + }, + "parameters": [ + { + "name": "Latitude of natural origin", + "epsg": 8801, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1542-L1545" + } + ] + }, + "22": { + "ct_name": "CT_Polyconic", + "libgeotiff": "geo_normalize.c#L1920-L1959", + "variants": [ + { + "method": { + "name": "American Polyconic", + "epsg": 9818, + "proj": "poly" + }, + "parameters": [ + { + "name": "Latitude of natural origin", + "epsg": 8801, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1514-L1516", + "note": "libgeotiff reads a scale factor (L1939-L1943) that GDAL ignores" + } + ] + }, + "23": { + "ct_name": "CT_Robinson", + "libgeotiff": "geo_normalize.c#L2039-L2061", + "variants": [ + { + "method": { + "name": "Robinson", + "epsg": null, + "proj": "robin" + }, + "parameters": [ + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1547-L1549" + } + ] + }, + "24": { + "ct_name": "CT_Sinusoidal", + "libgeotiff": "geo_normalize.c#L2039-L2061", + "variants": [ + { + "method": { + "name": "Sinusoidal", + "epsg": null, + "proj": "sinu" + }, + "parameters": [ + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1551-L1553" + } + ] + }, + "25": { + "ct_name": "CT_VanDerGrinten", + "libgeotiff": "geo_normalize.c#L2039-L2061", + "variants": [ + { + "method": { + "name": "Van Der Grinten", + "epsg": null, + "proj": "vandg" + }, + "parameters": [ + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1555-L1557" + } + ] + }, + "26": { + "ct_name": "CT_NewZealandMapGrid", + "libgeotiff": "geo_normalize.c#L1962-L1997", + "variants": [ + { + "method": { + "name": "New Zealand Map Grid", + "epsg": 9811, + "proj": "nzmg" + }, + "parameters": [ + { + "name": "Latitude of natural origin", + "epsg": 8801, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1579-L1582" + } + ] + }, + "27": { + "ct_name": "CT_TransvMercator_SouthOrientated", + "libgeotiff": "geo_normalize.c#L1774-L1816", + "variants": [ + { + "method": { + "name": "Transverse Mercator (South Orientated)", + "epsg": 9808, + "proj": "tmerc" + }, + "axes": [ + "west", + "south" + ], + "parameters": [ + { + "name": "Latitude of natural origin", + "epsg": 8801, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "Scale factor at natural origin", + "epsg": 8805, + "proj": "k_0", + "kind": "scale", + "keys": [ + "ProjScaleAtNatOrigin", + "ProjScaleAtCenter" + ], + "default": 1.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1445-L1448", + "note": "PROJ string also needs +axis=wsu" + } + ] + }, + "28": { + "ct_name": "CT_CylindricalEqualArea", + "libgeotiff": "geo_normalize.c#L2198-L2224", + "variants": [ + { + "method": { + "name": "Lambert Cylindrical Equal Area", + "epsg": 9835, + "proj": "cea" + }, + "parameters": [ + { + "name": "Latitude of 1st standard parallel", + "epsg": 8823, + "proj": "lat_ts", + "kind": "angular", + "keys": [ + "ProjStdParallel1" + ], + "default": 0.0 + }, + { + "name": "Longitude of natural origin", + "epsg": 8802, + "proj": "lon_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "False easting", + "epsg": 8806, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "False northing", + "epsg": 8807, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1584-L1586" + } + ] + }, + "9815": { + "ct_name": "CT_HotineObliqueMercatorAzimuthCenter", + "libgeotiff": "geo_normalize.c#L1819-L1870", + "variants": [ + { + "method": { + "name": "Hotine Oblique Mercator (variant B)", + "epsg": 9815, + "proj": "omerc" + }, + "parameters": [ + { + "name": "Latitude of projection centre", + "epsg": 8811, + "proj": "lat_0", + "kind": "angular", + "keys": [ + "ProjNatOriginLat", + "ProjFalseOriginLat", + "ProjCenterLat" + ], + "default": 0.0 + }, + { + "name": "Longitude of projection centre", + "epsg": 8812, + "proj": "lonc", + "kind": "angular", + "keys": [ + "ProjNatOriginLong", + "ProjFalseOriginLong", + "ProjCenterLong" + ], + "default": 0.0 + }, + { + "name": "Azimuth at projection centre", + "epsg": 8813, + "proj": "alpha", + "kind": "azimuth", + "keys": [ + "ProjAzimuthAngle" + ], + "default": 0.0 + }, + { + "name": "Angle from Rectified to Skew Grid", + "epsg": 8814, + "proj": "gamma", + "kind": "angular", + "keys": [ + "ProjRectifiedGridAngle" + ], + "default": 90.0 + }, + { + "name": "Scale factor at projection centre", + "epsg": 8815, + "proj": "k_0", + "kind": "scale", + "keys": [ + "ProjScaleAtNatOrigin", + "ProjScaleAtCenter" + ], + "default": 1.0 + }, + { + "name": "Easting at projection centre", + "epsg": 8816, + "proj": "x_0", + "kind": "linear", + "keys": [ + "ProjFalseEasting", + "ProjCenterEasting", + "ProjFalseOriginEasting" + ], + "default": 0.0 + }, + { + "name": "Northing at projection centre", + "epsg": 8817, + "proj": "y_0", + "kind": "linear", + "keys": [ + "ProjFalseNorthing", + "ProjCenterNorthing", + "ProjFalseOriginNorthing" + ], + "default": 0.0 + } + ], + "gdal": "gt_wkt_srs.cpp#L1494-L1498" + } + ] + } + } +} diff --git a/tests/test_crs_table.py b/tests/test_crs_table.py new file mode 100644 index 0000000..1e1bd4f --- /dev/null +++ b/tests/test_crs_table.py @@ -0,0 +1,24 @@ +"""The vendored GeoTIFF CT method table must match the geotiff-test-data copy.""" + +from __future__ import annotations + +import json +from pathlib import Path + +REPO_ROOT = Path(__file__).parent.parent +VENDORED = REPO_ROOT / "src/async_geotiff/data/geotiff-ct-methods.json" +SUBMODULE = REPO_ROOT / "fixtures/geotiff-test-data/crs/geotiff-ct-methods.json" + + +def test_vendored_table_matches_submodule(): + assert json.loads(VENDORED.read_text()) == json.loads(SUBMODULE.read_text()) + + +def test_table_methods_have_proj_names(): + table = json.loads(VENDORED.read_text()) + for method in table["methods"].values(): + if "unsupported" in method: + continue + for variant in method["variants"]: + if "method" in variant: + assert variant["method"]["proj"] From 8cad16a9c0c53f2c345284b297d2202c4ddc5914 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Mon, 26 Oct 2026 12:41:43 -0400 Subject: [PATCH 07/10] test: Add the GeoKey-to-CRS conformance test with a known-failures list Every row of the geotiff-test-data CRS manifest is opened and its CRS compared to GDAL's with pyproj equivalence (ignoring geographic axis order, as rasterio does), then by projecting the manifest's test point with both CRSs. 34 rows fail against the current builder and are listed as strict xfails so the list can only shrink; two EPSG-coded rows differ only by proj.db version and are non-strict. The submodule bump also brought the corrected predictor-2 fixture, which async-tiff 0.7.0 decodes wrongly on partial tiles; the two read tests for it are strict xfails until async-tiff is fixed. Co-Authored-By: Claude Fable 5.1 --- ...026-10-26-geokey-crs-conformance-design.md | 29 +-- tests/test_crs_conformance.py | 177 ++++++++++++++++++ tests/test_read.py | 20 ++ 3 files changed, 214 insertions(+), 12 deletions(-) create mode 100644 tests/test_crs_conformance.py diff --git a/dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md b/dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md index 2f0cc14..757309f 100644 --- a/dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md +++ b/dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md @@ -489,12 +489,16 @@ The conformance assertion is ```python expected = pyproj.CRS.from_json_dict(row["gdal"]["projjson"]) -assert expected.equals(geotiff.crs) # ignore_axis_order=False +assert expected.equals(geotiff.crs, ignore_axis_order=True) ``` -This is PROJ's `EQUIVALENT` comparison: unit-converting on parameters, strict on datum and prime -meridian names (with the `unknown` wildcard), strict on coordinate-system units, indifferent to -CRS/conversion/ellipsoid names and ids. It is stronger than the normalized core and is what the +This is PROJ's `EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS` comparison, the same one rasterio uses: +unit-converting on parameters, strict on datum and prime meridian names (with the `unknown` +wildcard), strict on coordinate-system units and on projected axis directions, indifferent to +the geographic CRS's axis order and to CRS/conversion/ellipsoid names and ids. (Changed +2026-10-26 from strict axis order: a GeoTIFF's raster axes are x/y whatever the CRS declares, +the current builder writes latitude-first bases that rasterio accepts, and strict order would +have doubled the known-failures list for no information.) It is stronger than the normalized core and is what the Python side uses. The `core` object in the manifest is the TS side's comparison target and the documented meaning of "equal" for implementations without PROJ. @@ -613,14 +617,15 @@ if projected: - Load `fixtures/geotiff-test-data/crs/manifest.json` once (session fixture). - Parametrize over case names. Rows with `gdal.projjson == null` or `gdal.proj4 == null` are `pytest.skip`ped with the row's note. -- For each case: `GeoTIFF.open` the fixture, `expected.equals(geotiff.crs)` (6.1), then the point - check, built exactly as the generator builds it (4.4): a degree, Greenwich-PM longlat CRS on - `geotiff.crs.ellipsoid`'s axes (`+proj=longlat +a=... +rf=...` or `+b=...`), then - `Transformer.from_crs(that, geotiff.crs, always_xy=True)` on `(lon, lat)`, compared to `(x, y)` - with `pytest.approx(abs=1e-3)`. Using `geotiff.crs.geodetic_crs` instead would move the point - for grads and non-Greenwich rows. For geographic rows the manifest's `(x, y)` is `(lon, lat)` - and the test transforms the same way (identity for degree/Greenwich bases, a real conversion - otherwise). Both assertions in the same test so a known-failure row covers both. +- For each case: `GeoTIFF.open` the fixture, `expected.equals(geotiff.crs, ignore_axis_order=True)` + (6.1), then the point check: a degree, Greenwich-PM longlat CRS on the expected CRS's ellipsoid + (`+proj=longlat +a=... +rf=...` or `+R=...`), then `(lon, lat)` projected with *both* the expected + and the built CRS in this environment's PROJ, compared with `pytest.approx(abs=1e-3)`. The + manifest's own `(x, y)` is not used by the Python test: it was produced by the generator's PROJ, + and PROJ versions differ in formulas (Equidistant Cylindrical moved 5.9 km between 9.5 and 9.8). + It remains the TS side's reference, with that caveat. Using `geodetic_crs` as the base instead + would move the point for grads and non-Greenwich rows. Both assertions in the same test so a + known-failure row covers both. - **Known failures**: `KNOWN_FAILURES: dict[str, str]` mapping case name to reason, applied as `pytest.param(name, marks=pytest.mark.xfail(strict=True, reason=...))`. `strict=True` makes an unexpected pass fail the run, so the list can only shrink. Stage 3 seeds the list with every diff --git a/tests/test_crs_conformance.py b/tests/test_crs_conformance.py new file mode 100644 index 0000000..34d6634 --- /dev/null +++ b/tests/test_crs_conformance.py @@ -0,0 +1,177 @@ +"""Conformance of `GeoTIFF.crs` against the geotiff-test-data CRS corpus. + +Every row of `crs/manifest.json` is a GDAL-written fixture plus the CRS GDAL +reads back from it. The test asserts PROJ equivalence with that CRS, then a +looser check that a test point projects to the recorded coordinates. + +Rows in `KNOWN_FAILURES` are expected to fail today (`xfail(strict=True)`), so +a fix that makes one pass fails the run until the row is removed: the list can +only shrink. Rows the manifest flags (GDAL read no CRS, or PROJ cannot export +it) are skipped. +""" + +from __future__ import annotations + +import json +from pathlib import Path +from typing import TYPE_CHECKING + +import pytest +from pyproj import CRS, Transformer + +from async_geotiff import GeoTIFF + +if TYPE_CHECKING: + from async_tiff.store import LocalStore + +CRS_DIR = Path(__file__).parent.parent / "fixtures" / "geotiff-test-data" / "crs" +MANIFEST = json.loads((CRS_DIR / "manifest.json").read_text()) +ROWS = {row["name"]: row for row in MANIFEST["cases"]} + +_REJECTED_CT = "CT code rejected by _build_conversion" +_INVALID_PROJJSON = "builder emits PROJJSON that PROJ rejects" +_WRONG_VARIANT = "wrong method variant" +_ORIGIN_KEYS = ( + "origin or scale read from the wrong GeoKey, libgeotiff fallback order not applied" +) +_UNITS = "linear parameters labelled metres instead of the projected unit" +_AXES = "projected axis directions not set (south/south, north/north, or west/south)" +_ASYNC_TIFF = "needs an async-tiff release with keys 2062/3096 (async-tiff#368)" +_PE_STRING = "ESRI PE String read by pyproj differs from GDAL's ESRI morphing" + +KNOWN_FAILURES: dict[str, str] = { + # Rejected CT codes (spec section 1). + "cea": _REJECTED_CT + " (28 Cylindrical Equal Area)", + "eqdc": _REJECTED_CT + " (13 Equidistant Conic)", + "gnom": _REJECTED_CT + " (19 Gnomonic)", + "mill": _REJECTED_CT + " (20 Miller)", + "robin": _REJECTED_CT + " (23 Robinson)", + "vandg": _REJECTED_CT + " (25 Van der Grinten)", + "omerc_variant_b": _REJECTED_CT + " (9815 Hotine Oblique Mercator azimuth centre)", + "somerc": _REJECTED_CT + " (9815 Hotine Oblique Mercator azimuth centre)", + # PROJJSON PROJ rejects outright. + "aea_nad27": _INVALID_PROJJSON + ": EPSG-coded datum without an ellipsoid", + "tmerc_datum_wgs84": _INVALID_PROJJSON + ": EPSG-coded datum without an ellipsoid", + "geog_grad_wkt": _INVALID_PROJJSON + ": angular unit grads", + "lcc_1sp_grad_wkt": _INVALID_PROJJSON + ": angular unit grads", + "lcc_1sp_paris_grad": _INVALID_PROJJSON + + ": angular unit grads (also GDAL PM bug, spec Q3)", + "tmerc_ft": _INVALID_PROJJSON + ": linear unit international foot", + # Wrong variant. + "merc_2sp": _WRONG_VARIANT + ": Mercator with ProjStdParallel1 is variant B", + "stere_polar_a": _WRONG_VARIANT + + ": polar stereographic at the pole with scale is variant A", + "stere_south_a": _WRONG_VARIANT + + ": polar stereographic at the pole with scale is variant A", + "omerc_variant_a": _WRONG_VARIANT + + ": CT 3 is variant A; grid angle read from the azimuth key", + "labrd": _WRONG_VARIANT + + ": CT 4 is Laborde Oblique Mercator, not Hotine variant B", + # Origin and scale keys. + "aeqd": _ORIGIN_KEYS + "; method name maps to Modified Azimuthal Equidistant", + "sterea": _ORIGIN_KEYS, + "stere_oblique": _ORIGIN_KEYS, + "eqc_lat0": _ORIGIN_KEYS + "; latitude of natural origin dropped", + # Units. + "lcc_2sp_usft": _UNITS, + # Axes. + "stere_polar_b": _AXES, + "stere_south_b": _AXES, + "stere_polar_k1_wkt": _AXES, + "tmso": _AXES, + # Datum, prime meridian, TOWGS84. + "lcc_1sp_pm_epsg_tifffile": "EPSG-coded prime meridian read as longitude 0", + "tmerc_towgs84": _ASYNC_TIFF + "; no BoundCRS", + # ESRI PE String citations. + "krovak": _PE_STRING + ": Krovak read as North Orientated", + "moll": _PE_STRING + ": datum keeps its ESRI name", +} +"""Manifest rows that fail against the current builder, with the reason. + +Each entry is `xfail(strict=True)`: when a fix makes a row pass, remove it here. +""" + +_DRIFT = "proj.db drift between this environment's PROJ and the generator's" +REGISTRY_DRIFT: dict[str, str] = { + "epsg_3067": _DRIFT + ": the EPSG:3067 datum is EUREF-FIN in newer registries", + "epsg_3975": _DRIFT + ": EPSG:3975 was corrected from spherical to ellipsoidal CEA", +} +"""EPSG-coded rows whose definition differs between proj.db versions. + +They pass or fail with the installed PROJ, so they are `xfail(strict=False)`. +""" + +POINT_TOLERANCE = 1e-3 +"""Both projections run in the same PROJ, so only rounding noise is expected.""" + + +def _flagged(row: dict) -> bool: + return row["gdal"]["projjson"] is None or row["gdal"]["proj4"] is None + + +def _params() -> list: + params = [] + for name, row in ROWS.items(): + marks = [] + if _flagged(row): + marks.append( + pytest.mark.skip(reason=row["note"] or "flagged in the manifest"), + ) + elif name in KNOWN_FAILURES: + marks.append(pytest.mark.xfail(strict=True, reason=KNOWN_FAILURES[name])) + elif name in REGISTRY_DRIFT: + marks.append(pytest.mark.xfail(strict=False, reason=REGISTRY_DRIFT[name])) + params.append(pytest.param(row, id=name, marks=marks)) + return params + + +def _ellipsoid_longlat(crs: CRS) -> CRS: + """A degree, Greenwich longlat CRS on the same ellipsoid, as the generator uses.""" + ellipsoid = crs.ellipsoid + assert ellipsoid is not None + a = ellipsoid.semi_major_metre + if ellipsoid.inverse_flattening: + return CRS.from_proj4( + f"+proj=longlat +a={a!r} +rf={ellipsoid.inverse_flattening!r}", + ) + return CRS.from_proj4(f"+proj=longlat +R={a!r}") + + +@pytest.mark.asyncio +@pytest.mark.parametrize("row", _params()) +async def test_crs_matches_gdal(fixture_store: LocalStore, row: dict) -> None: + geotiff = await GeoTIFF.open( + path=f"geotiff-test-data/crs/{row['file']}", + store=fixture_store, + ) + ours = geotiff.crs + expected = CRS.from_json_dict(row["gdal"]["projjson"]) + # Geographic axis order is ignored, as rasterio's comparison does: a GeoTIFF's + # raster axes are x/y regardless of the CRS's declared axis order. Projected + # axis directions still count. + assert expected.equals(ours, ignore_axis_order=True), ( + f"\nexpected: {expected.to_wkt(pretty=True)}\nours: {ours.to_wkt(pretty=True)}" + ) + + # The manifest's x/y come from the generator's PROJ, which may use different + # formulas than this environment's (Equidistant Cylindrical changed between + # PROJ 9.5 and 9.8). Project with both CRSs here instead, so only the CRS + # definitions are compared. + point = row["point"] + base = _ellipsoid_longlat(expected) + expected_xy = Transformer.from_crs(base, expected, always_xy=True).transform( + point["lon"], + point["lat"], + ) + ours_xy = Transformer.from_crs(base, ours, always_xy=True).transform( + point["lon"], + point["lat"], + ) + assert ours_xy == pytest.approx(expected_xy, abs=POINT_TOLERANCE) + + +def test_known_failures_are_listed_cases() -> None: + for name in {**KNOWN_FAILURES, **REGISTRY_DRIFT}: + assert name in ROWS, name + assert not _flagged(ROWS[name]), f"{name} is flagged, not a known failure" + assert not KNOWN_FAILURES.keys() & REGISTRY_DRIFT.keys() diff --git a/tests/test_read.py b/tests/test_read.py index 2645a95..5e26348 100644 --- a/tests/test_read.py +++ b/tests/test_read.py @@ -16,6 +16,22 @@ if TYPE_CHECKING: from .conftest import LoadGeoTIFF, LoadRasterio +KNOWN_DECODE_FAILURES: dict[str, str] = { + # geotiff-test-data b7158c4 made write_cog apply the predictor it was asked + # for; this fixture now really carries predictor 2, and async-tiff 0.7.0 + # reverses it wrongly on the partial last tile column (300 wide, 128 tiles). + "uint8_1band_deflate_block128_unaligned_predictor2": ( + "async-tiff 0.7.0 decodes predictor 2 wrongly on partial tiles" + ), +} + + +def _xfail_known_decode_failure(request: pytest.FixtureRequest, file_name: str) -> None: + if file_name in KNOWN_DECODE_FAILURES: + request.applymarker( + pytest.mark.xfail(strict=True, reason=KNOWN_DECODE_FAILURES[file_name]), + ) + @pytest.mark.asyncio @pytest.mark.parametrize( @@ -155,11 +171,13 @@ async def test_read_bounds_validation( ALL_DATA_IMAGES, ) async def test_read_full( + request: pytest.FixtureRequest, load_geotiff: LoadGeoTIFF, load_rasterio: LoadRasterio, variant: str, file_name: str, ) -> None: + _xfail_known_decode_failure(request, file_name) geotiff = await load_geotiff(file_name, variant=variant) array = await geotiff.read() @@ -175,11 +193,13 @@ async def test_read_full( ALL_DATA_IMAGES, ) async def test_read_full_as_masked( + request: pytest.FixtureRequest, load_geotiff: LoadGeoTIFF, load_rasterio: LoadRasterio, variant: str, file_name: str, ) -> None: + _xfail_known_decode_failure(request, file_name) geotiff = await load_geotiff(file_name, variant=variant) array = await geotiff.read() masked_array = array.as_masked() From 314e4ba19f8cf6af1c252aae870e21c87792a496 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Mon, 26 Oct 2026 13:38:40 -0400 Subject: [PATCH 08/10] test: Link the predictor xfail to async-tiff#370 Co-Authored-By: Claude Fable 5.1 --- tests/test_read.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_read.py b/tests/test_read.py index 5e26348..d1b566e 100644 --- a/tests/test_read.py +++ b/tests/test_read.py @@ -20,8 +20,9 @@ # geotiff-test-data b7158c4 made write_cog apply the predictor it was asked # for; this fixture now really carries predictor 2, and async-tiff 0.7.0 # reverses it wrongly on the partial last tile column (300 wide, 128 tiles). + # https://github.com/developmentseed/async-tiff/issues/370 "uint8_1band_deflate_block128_unaligned_predictor2": ( - "async-tiff 0.7.0 decodes predictor 2 wrongly on partial tiles" + "async-tiff 0.7.0 decodes predictor 2 wrongly on partial tiles (async-tiff#370)" ), } From ba0e0264875416824d435a974259c08ad171f0f3 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Mon, 26 Oct 2026 13:49:47 -0400 Subject: [PATCH 09/10] chore: Keep implementation plans out of git Specs are committed under dev-docs/specs; plans are working notes. Co-Authored-By: Claude Fable 5.1 --- .../2026-10-26-crs-conformance-corpus.md | 697 ------------------ .../plans/2026-10-26-crs-conformance-tests.md | 65 -- 2 files changed, 762 deletions(-) delete mode 100644 dev-docs/plans/2026-10-26-crs-conformance-corpus.md delete mode 100644 dev-docs/plans/2026-10-26-crs-conformance-tests.md diff --git a/dev-docs/plans/2026-10-26-crs-conformance-corpus.md b/dev-docs/plans/2026-10-26-crs-conformance-corpus.md deleted file mode 100644 index 8b26e0e..0000000 --- a/dev-docs/plans/2026-10-26-crs-conformance-corpus.md +++ /dev/null @@ -1,697 +0,0 @@ -# CRS Conformance Corpus and CT Table Implementation Plan - -> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. - -**Goal:** Add a `crs/` directory to geotiff-test-data holding GDAL-written GeoTIFF fixtures, a manifest of what GDAL wrote and reads back, cached epsg.io JSON, and the GeoTIFF CT-code-to-PROJ-method table, all regenerable and CI-checked. - -**Architecture:** A data-only case list (`crs/cases.py`) feeds one generator (`crs/generate_crs.py`) that writes 8x8 GeoTIFFs with rasterio (or tifffile for hand-built GeoKeys), reads them back with rasterio as the GDAL/PROJ oracle, and records raw GeoKeys plus PROJJSON, proj4, a normalized name-free core, and a test point in `crs/manifest.json`. A hand-written `crs/geotiff-ct-methods.json` transcribes libgeotiff and GDAL; pytest checks the manifest against the files and the table against the manifest. - -**Tech Stack:** Python 3.12+, rasterio 1.5 / GDAL 3.12 / PROJ 9.7 (pixi, conda-forge), pyproj 3.7, tifffile, numpy, pytest, pixi tasks. - -**Spec:** `dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md` (in async-geotiff; sections 4 and 5 are this plan's scope) - -## Global Constraints - -- Work in a git worktree of geotiff-test-data under its existing `.worktrees/` directory, branch `kyle/crs-conformance-corpus`, based on `origin/main` (currently `b73b96d`). Never commit on `main`. -- Run everything through pixi (`pixi run ...`); the generator must be deterministic so `scripts/check.sh` passes in CI. -- Fixtures are plain GTiff, 8x8 uint8, one band, no compression, no overviews, written with `GDAL_PAM_ENABLED=NO`; read-back also with `GDAL_PAM_ENABLED=NO`. -- GeoKey names everywhere (manifest `geokeys`, table `keys`, encoder input) are the GeoTIFF spec names without the `GeoKey` suffix: `ProjCoordTrans`, `GeogTOWGS84`, `GTModelType`. -- `manifest.json` is written with `json.dump(..., indent=1, sort_keys=True)` and rows sorted by `name`. -- Rows with `gdal.projjson == null` or `gdal.proj4 == null` are flagged, not tested, and carry a `note`. -- PR text: top `> [!NOTE]` saying Claude wrote it, bottom `🤖 Written by [Claude Code](https://claude.com/claude-code)`. Never merge. -- Ruff with `select = ["I"]` (import sorting) is the only lint; `pytest` from the repo root with `pythonpath = ["."]`. - -## Review Focus - -1. A PROJ-string case that GDAL identifies as an EPSG CRS writes only `ProjectedCSType = ` and silently stops testing the user-defined key path. Pinned in Task 7 (`test_proj_cases_are_user_defined`). -2. A citation string whose terminating `|` is or is not stripped makes `geokeys` disagree with async-tiff's view of the same file. Pinned in Task 1 (`test_decode_existing_fixture`, exact citation values). -3. A `GeogTOWGS84` with three values vs seven must round-trip through the encoder and decoder as a list, not a scalar. Pinned in Task 1 (`test_encode_decode_roundtrip`). -4. Parameters in grads or feet must land in the core in degrees and metres, or the TS side compares the wrong numbers. Pinned in Task 3 (`test_core_of_grads`, `test_core_of_feet`). -5. Regenerating with network blocked must still succeed when `crs/epsg/*.json` already exist. Pinned in Task 4 (`test_fetch_epsg_json_skips_existing`). - ---- - -### Task 1: GeoKey id table, decoder, encoder - -**Files:** -- Create: `crs/__init__.py` (empty docstring module) -- Create: `crs/geokeys.py` -- Test: `tests/test_crs_geokeys.py` -- Modify: `pixi.toml` (add `pyproj = ">=3.7,<4"` under `[pypi-dependencies]`; it is only a transitive dependency today) - -**Interfaces:** -- Produces: `GEOKEY_IDS: dict[str, int]` mapping spec name (no suffix) to key id, covering 1024-1026, 2048-2062, 3072-3096, 4096-4099, 5120 (`CoordinateEpoch`). `GEOKEY_NAMES: dict[int, str]` is its inverse. -- Produces: `decode_geokeys(path: Path) -> dict[str, int | float | str | list[float]]`: reads tags 34735/34736/34737 with tifffile, returns one entry per directory entry keyed by name (`"unknown_"` for ids not in the table); SHORT values as `int`, a single DOUBLE as `float`, several DOUBLEs as `list[float]`, ASCII as `str` with exactly one trailing `|` removed. -- Produces: `encode_geokeys(keys: dict[str, int | float | str | list[float]]) -> list[tuple]`: tifffile `extratags` triples for tags 34735 (SHORT), 34736 (DOUBLE), 34737 (ASCII), in the form `(tag, dtype_code, count, value, True)` with dtype codes 3, 12, 2; entries sorted by key id as the spec requires; ASCII values get the `|` terminator appended; version header `[1, 1, 0, n]`. - -- [ ] **Step 1: Write the failing tests** - -```python -# tests/test_crs_geokeys.py -from pathlib import Path - -import numpy as np -import tifffile - -from crs.geokeys import GEOKEY_IDS, decode_geokeys, encode_geokeys - -REPO_ROOT = Path(__file__).parent.parent - - -def test_geokey_ids_cover_spec(): - assert GEOKEY_IDS["GTModelType"] == 1024 - assert GEOKEY_IDS["GeogTOWGS84"] == 2062 - assert GEOKEY_IDS["ProjRectifiedGridAngle"] == 3096 - assert GEOKEY_IDS["CoordinateEpoch"] == 5120 - assert len(GEOKEY_IDS) == 48 - - -def test_decode_existing_fixture(): - keys = decode_geokeys( - REPO_ROOT / "real_data/source-coop-dataforcanada/O2308000_7586000_cog.tif" - ) - assert keys == { - "GTModelType": 1, - "GTRasterType": 1, - "GTCitation": "NAD83(CSRS) / New Brunswick Stereographic", - "GeographicType": 32767, - "GeogCitation": "GCS Name = NAD83(CSRS)|Primem = Greenwich|", - "GeogGeodeticDatum": 6140, - "GeogAngularUnits": 9102, - "GeogSemiMajorAxis": 6378137.0, - "GeogInvFlattening": 298.257222101, - "GeogPrimeMeridianLong": 0.0, - "ProjectedCSType": 32767, - "Projection": 32767, - "ProjCoordTrans": 16, - "ProjLinearUnits": 9001, - "ProjNatOriginLong": -66.5, - "ProjNatOriginLat": 46.5, - "ProjFalseEasting": 2500000.0, - "ProjFalseNorthing": 7500000.0, - "ProjScaleAtNatOrigin": 0.999912, - } - - -def test_encode_decode_roundtrip(tmp_path: Path): - keys = { - "GTModelType": 1, - "GTRasterType": 1, - "GeographicType": 32767, - "GeogCitation": "GCS Name = unknown|Primem = Paris|", - "GeogPrimeMeridian": 8903, - "GeogSemiMajorAxis": 6378249.2, - "GeogTOWGS84": [598.1, 73.7, 418.2, 0.202, 0.045, -2.455, 6.7], - "ProjCoordTrans": 9, - "ProjRectifiedGridAngle": 90.0, - } - path = tmp_path / "keys.tif" - tifffile.imwrite(path, np.zeros((8, 8), np.uint8), extratags=encode_geokeys(keys)) - assert decode_geokeys(path) == keys - - -def test_decode_three_value_towgs84(tmp_path: Path): - keys = {"GTModelType": 2, "GeogTOWGS84": [0.0, 0.0, 0.0]} - path = tmp_path / "keys.tif" - tifffile.imwrite(path, np.zeros((8, 8), np.uint8), extratags=encode_geokeys(keys)) - assert decode_geokeys(path)["GeogTOWGS84"] == [0.0, 0.0, 0.0] -``` - -- [ ] **Step 2: Run tests to verify they fail** - -Run: `pixi run pytest tests/test_crs_geokeys.py -v` -Expected: FAIL with `ModuleNotFoundError: No module named 'crs'` - -- [ ] **Step 3: Implement `crs/geokeys.py`** - -`GEOKEY_IDS` is a literal dict (the 48 names from libgeotiff `geokeys.inc` / OGC 19-008r4 Annex, minus the `GeoKey` suffix; `GTCitation`, `PCSCitation` keep their spec names). `decode_geokeys` reads `tifffile.TiffFile(path).pages[0].tags[34735].value` and slices 34736/34737 by `(location, count, offset)` as the GeoTIFF spec defines. `encode_geokeys` appends doubles and ASCII into their param arrays as it walks the keys sorted by id. - -- [ ] **Step 4: Run tests to verify they pass** - -Run: `pixi run pytest tests/test_crs_geokeys.py -v` -Expected: 4 passed - -- [ ] **Step 5: Commit** - -```bash -git add crs/__init__.py crs/geokeys.py tests/test_crs_geokeys.py pixi.toml pixi.lock -git commit -m "feat(crs): Add GeoKey id table with raw decoder and encoder" -``` - -### Task 2: Case list - -**Files:** -- Create: `crs/cases.py` -- Test: `tests/test_crs_cases.py` - -**Interfaces:** -- Produces: `@dataclass(frozen=True) class Case: name: str; kind: Literal["proj", "epsg", "wkt", "geokeys"]; value: str | dict[str, int | float | str | list[float]]; note: str = ""; tags: tuple[str, ...] = ()`. -- Produces: `CASES: list[Case]`, every case from spec section 4.3 (CT rows, units, datum/PM variants, 46 EPSG codes, citation forms). `kind == "geokeys"` carries the raw key dict for the tifffile-written fixture. -- Produces: `EPSG_CODES: list[int]` (the 46 codes; `epsg_` cases are generated from it). - -- [ ] **Step 1: Write the failing test** - -```python -# tests/test_crs_cases.py -import re -from collections import Counter - -from crs.cases import CASES, EPSG_CODES, Case - - -def test_case_names_unique_and_well_formed(): - names = [c.name for c in CASES] - assert len(names) == len(set(names)) - assert all(re.fullmatch(r"[a-z0-9_]+", n) for n in names) - - -def test_case_kinds(): - kinds = Counter(c.kind for c in CASES) - assert set(kinds) == {"proj", "epsg", "wkt", "geokeys"} - assert kinds["epsg"] == len(EPSG_CODES) == 46 - assert kinds["geokeys"] == 1 - - -def test_expected_cases_present(): - names = {c.name for c in CASES} - for name in ( - "tmerc", "omerc_variant_a", "omerc_variant_b", "labrd", "somerc", "merc_1sp", - "merc_2sp", "stere_polar_scaled_wkt", "stere_polar_k1_wkt", "tmso", "cea", - "lcc_2sp_usft", "tmerc_ft", "lcc_1sp_grad_wkt", "geog_grad_wkt", "lcc_1sp_paris_grad", - "aea_nad27", "tmerc_datum_wgs84", "sinu_sphere", "geog_sphere", "tmerc_towgs84", - "lcc_1sp_paris_deg_wkt", "lcc_1sp_pm_user", "lcc_1sp_pm_epsg_tifffile", - "longlat_grs80", "utm_bessel", "moll", "krovak", "esri_54009", "eqearth", "epsg_2953", - ): - assert name in names - assert len(CASES) >= 95 - - -def test_geokeys_case_has_epsg_prime_meridian(): - case = next(c for c in CASES if c.kind == "geokeys") - assert isinstance(case.value, dict) - assert case.value["GeogPrimeMeridian"] == 8903 - assert "GeogPrimeMeridianLong" not in case.value -``` - -- [ ] **Step 2: Run test to verify it fails** - -Run: `pixi run pytest tests/test_crs_cases.py -v` -Expected: FAIL with `ModuleNotFoundError: No module named 'crs.cases'` - -- [ ] **Step 3: Implement `crs/cases.py`** - -Transcribe spec 4.3 verbatim. The WKT values the spec names but does not spell out: - -```python -_GEOG_WGS84_DEG = 'GEOGCS["unknown",DATUM["unknown",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]' -_GEOG_CLRK80IGN_GRAD = 'GEOGCS["unknown",DATUM["unknown",SPHEROID["Clarke 1880 (IGN)",6378249.2,293.466021293627]],PRIMEM["Greenwich",0],UNIT["grad",0.01570796326794897]]' -_GEOG_CLRK80IGN_PARIS_DEG = 'GEOGCS["unknown",DATUM["unknown",SPHEROID["Clarke 1880 (IGN)",6378249.2,293.466021293627]],PRIMEM["Paris",2.33722917],UNIT["degree",0.0174532925199433]]' -_LCC_1SP_PARAMS = 'PROJECTION["Lambert_Conformal_Conic_1SP"],PARAMETER["latitude_of_origin",{lat}],PARAMETER["central_meridian",0],PARAMETER["scale_factor",0.99987742],PARAMETER["false_easting",600000],PARAMETER["false_northing",2200000],UNIT["metre",1]' -# stere_polar_scaled_wkt / stere_polar_k1_wkt: -# f'PROJCS["unknown",{_GEOG_WGS84_DEG},PROJECTION["Polar_Stereographic"],PARAMETER["latitude_of_origin",{lat}],PARAMETER["central_meridian",-45],PARAMETER["scale_factor",{k}],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1]]' -# lcc_1sp_grad_wkt: f'PROJCS["unknown",{_GEOG_CLRK80IGN_GRAD},{_LCC_1SP_PARAMS.format(lat=52)}]' -# lcc_1sp_paris_deg_wkt: f'PROJCS["unknown",{_GEOG_CLRK80IGN_PARIS_DEG},{_LCC_1SP_PARAMS.format(lat=46.8)}]' -# geog_grad_wkt: _GEOG_CLRK80IGN_GRAD -``` - -The `geokeys` case (`lcc_1sp_pm_epsg_tifffile`) is the `lcc_1sp` key set GDAL writes (see the `lcc_1sp` manifest row after Task 4, or the prior session's dump) with `GeogPrimeMeridianLong` removed, `GeogPrimeMeridian: 8903` added, and `Primem = Paris` in the citation. Case notes: `eqearth` ("GDAL writes no GeoKeys; sidecar disabled"), `lcc_1sp_paris_grad` ("GDAL PM-in-grads round-trip is lossy; see spec Q3"), `stere_polar_scaled_wkt` ("PROJ keeps a non-EPSG Polar_Stereographic method; not exportable"), `utm_bessel` ("GDAL writes ProjectionGeoKey = 16033, no CT key"), `tmerc_towgs84` ("needs async-tiff >= the release with key 2062"). - -- [ ] **Step 4: Run test to verify it passes** - -Run: `pixi run pytest tests/test_crs_cases.py -v` -Expected: 4 passed - -- [ ] **Step 5: Commit** - -```bash -git add crs/cases.py tests/test_crs_cases.py -git commit -m "feat(crs): Add the conformance corpus case list" -``` - -### Task 3: CRS normalization helpers - -**Files:** -- Create: `crs/normalize.py` -- Test: `tests/test_crs_normalize.py` - -**Interfaces:** -- Produces: `core_of(crs: pyproj.CRS) -> dict` with keys `type` (`crs.type_name` mapped to `"ProjectedCRS" | "GeographicCRS" | "BoundCRS"`), `method` (`{"name": str, "epsg": int | None}` or `None` for geographic), `parameters` (list of `{"epsg": int | None, "name": str, "value": float}`, angular values in degrees, linear in metres, scale as-is, in PROJJSON order), `ellipsoid` (`{"a": float, "rf": float | None, "b": float | None}`, `rf` None and `b` set when `inverse_flattening == 0`), `prime_meridian_deg: float`, `angular_unit_deg: float`, `linear_unit_m: float | None`, `axes: list[str]` (axis directions of the projected CS, or of the geographic CS for a geographic CRS), `towgs84: list[float] | None`. For a BoundCRS the inner CRS is `crs.source_crs` and `towgs84` is `crs.coordinate_operation.towgs84`. -- Produces: `ellipsoid_longlat(crs: pyproj.CRS) -> pyproj.CRS`: `+proj=longlat +a= +rf=` or `+b=` for a sphere, from the inner CRS's ellipsoid. -- Produces: `point_for(core: dict) -> tuple[float, float]`: `(10.0, 40.0)` when `core["method"]` is None; otherwise `(lon0 + 3, lat)` where `lat` moves 8 degrees away from the equator when `abs(lat0) < 80` and 8 degrees towards it otherwise (`lat0 = 0 -> 8`, `lat0 = -41 -> -49`, `lat0 = 90 -> 82`, `lat0 = -90 -> -82`). `lon0` is the first present of parameter names `Longitude of natural origin`, `Longitude of false origin`, `Longitude of projection centre`, `Longitude of origin` else 0; `lat0` the first of `Latitude of natural origin`, `Latitude of false origin`, `Latitude of projection centre`, `Latitude of standard parallel`, `Latitude of 1st standard parallel` else 0. -- Produces: `project_point(crs: pyproj.CRS, lon: float, lat: float) -> tuple[float, float]`: `Transformer.from_crs(ellipsoid_longlat(crs), crs, always_xy=True).transform(lon, lat)`. - -- [ ] **Step 1: Write the failing tests** - -```python -# tests/test_crs_normalize.py -import pytest -from pyproj import CRS - -from crs.normalize import core_of, ellipsoid_longlat, point_for, project_point - -GRAD_WKT = 'PROJCS["unknown",GEOGCS["unknown",DATUM["unknown",SPHEROID["Clarke 1880 (IGN)",6378249.2,293.466021293627]],PRIMEM["Greenwich",0],UNIT["grad",0.01570796326794897]],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],UNIT["metre",1]]' - - -def test_core_of_utm(): - core = core_of(CRS.from_epsg(32633)) - assert core["type"] == "ProjectedCRS" - assert core["method"] == {"name": "Transverse Mercator", "epsg": 9807} - assert core["parameters"] == [ - {"epsg": 8801, "name": "Latitude of natural origin", "value": 0.0}, - {"epsg": 8802, "name": "Longitude of natural origin", "value": 15.0}, - {"epsg": 8805, "name": "Scale factor at natural origin", "value": 0.9996}, - {"epsg": 8806, "name": "False easting", "value": 500000.0}, - {"epsg": 8807, "name": "False northing", "value": 0.0}, - ] - assert core["ellipsoid"] == {"a": 6378137.0, "rf": 298.257223563, "b": None} - assert core["prime_meridian_deg"] == 0.0 - assert core["angular_unit_deg"] == pytest.approx(1.0) - assert core["linear_unit_m"] == 1.0 - assert core["axes"] == ["east", "north"] - assert core["towgs84"] is None - - -def test_core_of_grads(): - core = core_of(CRS.from_wkt(GRAD_WKT)) - assert core["parameters"][0]["value"] == pytest.approx(46.8) - assert core["angular_unit_deg"] == pytest.approx(0.9) - - -def test_core_of_feet(): - core = core_of(CRS.from_proj4("+proj=lcc +lat_1=41.03333 +lat_2=40.66667 +lat_0=40.16667 +lon_0=-74 +x_0=300000 +y_0=0 +ellps=GRS80 +units=us-ft")) - easting = next(p for p in core["parameters"] if p["epsg"] == 8826) - assert easting["value"] == pytest.approx(300000.0) - assert core["linear_unit_m"] == pytest.approx(0.3048006096012192) - - -def test_core_of_bound_crs(): - core = core_of(CRS.from_proj4("+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=bessel +towgs84=598.1,73.7,418.2,0.202,0.045,-2.455,6.7")) - assert core["type"] == "BoundCRS" - assert core["method"]["epsg"] == 9807 - assert core["towgs84"] == [598.1, 73.7, 418.2, 0.202, 0.045, -2.455, 6.7] - - -def test_core_of_sphere_and_geographic(): - core = core_of(CRS.from_proj4("+proj=longlat +R=6371007.181")) - assert core["type"] == "GeographicCRS" - assert core["method"] is None - assert core["ellipsoid"] == {"a": 6371007.181, "rf": None, "b": 6371007.181} - assert core["linear_unit_m"] is None - - -def test_core_of_south_orientated_axes(): - core = core_of(CRS.from_proj4("+proj=tmerc +lat_0=0 +lon_0=19 +k=1 +x_0=0 +y_0=0 +axis=wsu +ellps=WGS84")) - assert core["axes"] == ["west", "south"] - - -def test_point_for(): - assert point_for(core_of(CRS.from_epsg(32633))) == (18.0, 8.0) - assert point_for(core_of(CRS.from_proj4("+proj=stere +lat_0=90 +k=0.994 +lon_0=0 +ellps=WGS84"))) == (3.0, 82.0) - assert point_for(core_of(CRS.from_epsg(4326))) == (10.0, 40.0) - - -def test_project_point(): - assert project_point(CRS.from_epsg(32633), 15.0, 0.0) == pytest.approx((500000.0, 0.0)) - # A grads geographic CRS: degrees in, grads out. - assert project_point(CRS.from_wkt(GRAD_WKT).geodetic_crs, 3.0, 54.8) == pytest.approx((3.3333333333, 60.8888888889)) - - -def test_ellipsoid_longlat_sphere(): - assert ellipsoid_longlat(CRS.from_proj4("+proj=sinu +R=6371007.181")).to_proj4().startswith("+proj=longlat +R=6371007.181") -``` - -- [ ] **Step 2: Run tests to verify they fail** - -Run: `pixi run pytest tests/test_crs_normalize.py -v` -Expected: FAIL with `ModuleNotFoundError: No module named 'crs.normalize'` - -- [ ] **Step 3: Implement `crs/normalize.py`** - -Unit conversion in `core_of`: walk `inner.to_json_dict()["conversion"]["parameters"]`; a `unit` that is a string is `degree`, `metre` or `unity`; a dict has `type` (`AngularUnit` / `LinearUnit` / `ScaleUnit`) and `conversion_factor` (radians per unit or metres per unit); angular value in degrees is `value * factor * 180 / pi`. `angular_unit_deg` comes from `inner.geodetic_crs.axis_info[0].unit_conversion_factor * 180 / pi` (for a geographic CRS, `inner.axis_info`); `linear_unit_m` from `inner.axis_info[0].unit_conversion_factor` when `inner.is_projected`, else None. `prime_meridian_deg` is `pm.longitude * pm.unit_conversion_factor * 180 / pi`. Use `pyproj.CRS.is_bound`, `.source_crs`, `.coordinate_operation.towgs84`. - -- [ ] **Step 4: Run tests to verify they pass** - -Run: `pixi run pytest tests/test_crs_normalize.py -v` -Expected: 9 passed - -- [ ] **Step 5: Commit** - -```bash -git add crs/normalize.py tests/test_crs_normalize.py -git commit -m "feat(crs): Add name-free CRS core, test point, and ellipsoid base helpers" -``` - -### Task 4: Generator: write, read back, manifest row, epsg cache - -**Files:** -- Create: `crs/generate_crs.py` -- Test: `tests/test_crs_generate.py` - -**Interfaces:** -- Consumes: `Case`, `CASES`, `EPSG_CODES` (Task 2); `decode_geokeys`, `encode_geokeys` (Task 1); `core_of`, `point_for`, `project_point` (Task 3). -- Produces: `write_case(case: Case, path: Path) -> None`: `proj`/`epsg`/`wkt` via `rasterio.open(path, "w", driver="GTiff", width=8, height=8, count=1, dtype="uint8", crs=CRS.from_user_input(value), transform=from_origin(0, 0, 10, 10))` inside `rasterio.Env(GDAL_PAM_ENABLED="NO")`, writing zeros; `geokeys` via `tifffile.imwrite(path, zeros((8, 8), uint8), extratags=encode_geokeys(value))`. For `epsg`, `value` is `"EPSG:"`. -- Produces: `read_back(path: Path) -> pyproj.CRS | None`: `rasterio.open` inside `Env(GDAL_PAM_ENABLED="NO")`, `CRS.from_user_input(ds.crs)` or None when `ds.crs` is falsy. -- Produces: `manifest_row(case: Case, path: Path, crs_dir: Path) -> dict` with the exact keys of spec 4.4: `name`, `file` (POSIX path of `path` relative to `crs_dir`), `input` (`{"kind", "value"}`), `note`, `tags` (list), `geokeys`, `gdal` (`{"projjson", "proj4", "roundtrip"}`; `proj4` None when `to_proj4()` raises `CRSError`; `roundtrip` is `CRS.from_user_input(input).equals(read_back)` for non-`geokeys` kinds, None for `geokeys`; all None when read-back is None), `core` (None when read-back is None), `point` (`{"lon", "lat", "x", "y"}` or None when `projjson` or `proj4` is None), `epsg_json` (`"epsg/.json"` for `epsg`, else None). -- Produces: `fetch_epsg_json(code: int, epsg_dir: Path, *, refresh: bool = False) -> Path`: GET `https://epsg.io/.json` with `urllib.request` only when the file is missing or `refresh`; writes it verbatim. -- Produces: `generate(crs_dir: Path, *, refresh_epsg: bool = False) -> dict`: writes every case to `crs_dir / "fixtures" / f"{name}.tif"`, builds rows, fetches epsg JSON, writes `crs_dir / "manifest.json"` with `{"schema_version": 1, "generator": {...}, "cases": rows_sorted_by_name}`; `generator` is `{"gdal": rasterio.__gdal_version__, "proj": rasterio.__proj_version__, "rasterio": rasterio.__version__, "pyproj": pyproj.__version__}`. `main()` parses `--refresh-epsg` and calls `generate(Path(__file__).parent)`. - -- [ ] **Step 1: Write the failing tests** - -```python -# tests/test_crs_generate.py -from pathlib import Path - -from crs.cases import Case -from crs.generate_crs import fetch_epsg_json, manifest_row, read_back, write_case - -TMERC = Case("tmerc", "proj", "+proj=tmerc +lat_0=0 +lon_0=-3.5 +k=0.9996 +x_0=500000 +y_0=0 +ellps=WGS84") - - -def test_write_and_read_back_proj_case(tmp_path: Path): - path = tmp_path / "tmerc.tif" - write_case(TMERC, path) - assert not (tmp_path / "tmerc.tif.aux.xml").exists() - crs = read_back(path) - assert crs is not None - assert crs.coordinate_operation.method_code == "9807" - - -def test_manifest_row_proj_case(tmp_path: Path): - path = tmp_path / "fixtures" / "tmerc.tif" - path.parent.mkdir() - write_case(TMERC, path) - row = manifest_row(TMERC, path, tmp_path) - assert row["file"] == "fixtures/tmerc.tif" - assert row["input"] == {"kind": "proj", "value": TMERC.value} - assert row["geokeys"]["ProjCoordTrans"] == 1 - assert row["geokeys"]["ProjectedCSType"] == 32767 - assert row["gdal"]["roundtrip"] is True - assert row["gdal"]["proj4"].startswith("+proj=tmerc +lat_0=0 +lon_0=-3.5") - assert row["gdal"]["projjson"]["type"] == "ProjectedCRS" - assert row["core"]["method"]["epsg"] == 9807 - assert row["point"]["lon"] == -0.5 and row["point"]["lat"] == 8.0 - assert row["epsg_json"] is None - - -def test_manifest_row_keyless_case(tmp_path: Path): - case = Case("eqearth", "proj", "+proj=eqearth +lon_0=0 +ellps=WGS84", note="no keys") - path = tmp_path / "eqearth.tif" - write_case(case, path) - row = manifest_row(case, path, tmp_path) - assert row["gdal"] == {"projjson": None, "proj4": None, "roundtrip": None} - assert row["core"] is None and row["point"] is None - assert row["note"] == "no keys" - - -def test_manifest_row_geokeys_case(tmp_path: Path): - case = Case("pm_epsg", "geokeys", {"GTModelType": 2, "GTRasterType": 1, "GeographicType": 32767, "GeogGeodeticDatum": 32767, "GeogEllipsoid": 7030, "GeogPrimeMeridian": 8903, "GeogAngularUnits": 9102}) - path = tmp_path / "pm_epsg.tif" - write_case(case, path) - row = manifest_row(case, path, tmp_path) - assert row["geokeys"] == case.value - assert row["gdal"]["roundtrip"] is None - assert row["core"]["prime_meridian_deg"] == pytest.approx(2.33722917) - - -def test_manifest_row_epsg_case(tmp_path: Path): - case = Case("epsg_32633", "epsg", "EPSG:32633") - path = tmp_path / "epsg_32633.tif" - write_case(case, path) - row = manifest_row(case, path, tmp_path) - assert row["geokeys"]["ProjectedCSType"] == 32633 - assert row["epsg_json"] == "epsg/32633.json" - - -def _no_network(*args, **kwargs): - raise AssertionError("network used") - - -def test_fetch_epsg_json_skips_existing(tmp_path: Path, monkeypatch): - existing = tmp_path / "32633.json" - existing.write_text("{}") - monkeypatch.setattr("urllib.request.urlopen", _no_network) - assert fetch_epsg_json(32633, tmp_path) == existing -``` - -(Add `import pytest` for `approx`.) - -- [ ] **Step 2: Run tests to verify they fail** - -Run: `pixi run pytest tests/test_crs_generate.py -v` -Expected: FAIL with `ModuleNotFoundError: No module named 'crs.generate_crs'` - -- [ ] **Step 3: Implement `crs/generate_crs.py`** - -Guard `main()` with `if __name__ == "__main__":`. `point` for a row: `lon, lat = point_for(core)`, `x, y = project_point(crs, lon, lat)`. - -- [ ] **Step 4: Run tests to verify they pass** - -Run: `pixi run pytest tests/test_crs_generate.py -v` -Expected: 6 passed - -- [ ] **Step 5: Commit** - -```bash -git add crs/generate_crs.py tests/test_crs_generate.py -git commit -m "feat(crs): Add the corpus generator" -``` - -### Task 5: Generate the corpus; wire pixi, check.sh, info.sh, README - -**Files:** -- Modify: `pixi.toml` (`[tasks]`: `generate-crs = "python -m crs.generate_crs"`) -- Modify: `scripts/check.sh` (run `pixi run generate-crs` after `pixi run generate`) -- Modify: `scripts/info.sh` (`find . -path ./crs -prune -o -name "*.tif" -type f -print`) -- Modify: `README.md` (one paragraph under Usage pointing at `crs/README.md`) -- Create: `crs/README.md`, `crs/fixtures/*.tif`, `crs/manifest.json`, `crs/epsg/*.json` - -**Interfaces:** -- Consumes: `generate` via the pixi task. - -- [ ] **Step 1: Add the pixi task and script changes** - -- [ ] **Step 2: Generate** - -Run: `pixi run generate-crs` -Expected: `crs/fixtures/` holds one `.tif` per case (about 97 files, each under 2 KB), `crs/epsg/` holds 46 JSON files, `crs/manifest.json` exists, and no `.aux.xml` anywhere under `crs/`. If the network is unavailable, copy the 46 cached files from the prior session's scratchpad (`.../scratchpad/prior/epsg/`) into `crs/epsg/` first. - -- [ ] **Step 3: Check determinism** - -Run: `pixi run generate-crs && git status --porcelain crs/` -Expected: after a second run, `git status` shows only the first run's untracked files (no modified files between runs). Then `bash scripts/check.sh` must pass once everything is committed. - -- [ ] **Step 4: Inspect the manifest for surprises** - -Run: `pixi run python -c "import json; m=json.load(open('crs/manifest.json')); print([c['name'] for c in m['cases'] if c['gdal']['projjson'] is None or c['gdal']['proj4'] is None]); print([c['name'] for c in m['cases'] if c['input']['kind']=='proj' and c['geokeys'].get('ProjectedCSType', 32767) != 32767])"` -Expected: first list is exactly `['eqearth', 'stere_polar_scaled_wkt']`; second list is empty. If a `proj` case was identified as an EPSG code, change its parameters in `cases.py` (spec 4.3) and regenerate. - -- [ ] **Step 5: Write `crs/README.md`** - -Sections: what the corpus is and that GDAL/PROJ is the oracle; how to regenerate (`pixi run generate-crs`, `--refresh-epsg`); case kinds; the manifest schema (copy spec 4.4 with the no-suffix key naming and the `axes` list); the table schema (copy spec 5.1-5.2, including the `when` grammar and the three rules); which rows are flagged and why; links to the libgeotiff/GDAL/PROJ sources with the pinned commit and tag. - -- [ ] **Step 6: Commit** - -```bash -git add pixi.toml scripts/check.sh scripts/info.sh README.md crs/README.md crs/fixtures crs/manifest.json crs/epsg -git commit -m "feat(crs): Generate the conformance corpus and manifest" -``` - -### Task 6: CT table - -**Files:** -- Create: `crs/geotiff-ct-methods.json` -- Test: `tests/test_crs_table.py` - -**Interfaces:** -- Produces: the JSON of spec 5.1-5.3: `schema_version: 1`, `sources`, `units`, `methods` keyed by CT code string for 1-28 and 9815; 2, 5, 6 carry only `ct_name` and `unsupported`; 7 has two variants (`{"present": "ProjStdParallel1"}` first); 15 has three (`{"value": {"param": "Scale factor at natural origin", "equals": 1}}`, then `{"abs_value": {"param": "Latitude of natural origin", "equals": 90}}`, then an `unrepresentable` default); 27 has `"axes": ["west", "south"]`. - -- [ ] **Step 1: Write the failing tests** - -```python -# tests/test_crs_table.py -import json -from pathlib import Path - -TABLE = json.loads((Path(__file__).parent.parent / "crs/geotiff-ct-methods.json").read_text()) -MANIFEST = json.loads((Path(__file__).parent.parent / "crs/manifest.json").read_text()) -KINDS = {"angular", "linear", "scale", "azimuth"} -RULE_KEYS = {"present", "abs_value", "value", "any", "all"} - - -def _rule_ok(rule: dict) -> bool: - (key, body), = rule.items() - if key in ("any", "all"): - return all(_rule_ok(r) for r in body) - if key == "present": - return isinstance(body, str) - return set(body) == {"param", "equals"} and key in RULE_KEYS - - -def test_table_covers_every_ct_code(): - assert set(TABLE["methods"]) == {str(c) for c in range(1, 29)} | {"9815"} - assert {c for c, m in TABLE["methods"].items() if "unsupported" in m} == {"2", "5", "6"} - - -def test_variants_are_well_formed(): - for code, method in TABLE["methods"].items(): - if "unsupported" in method: - assert set(method) == {"ct_name", "unsupported"} - continue - variants = method["variants"] - assert "when" not in variants[-1] - for v in variants[:-1]: - assert _rule_ok(v["when"]) - for v in variants: - if "unrepresentable" in v: - continue - assert set(v["method"]) == {"name", "epsg", "proj"} - for p in v["parameters"]: - assert set(p) >= {"name", "epsg", "proj", "kind", "keys", "default"} - assert p["kind"] in KINDS - assert p["keys"] and all(k in TABLE["units"]["angular_keys"] + TABLE["units"]["linear_keys"] + ["ProjScaleAtNatOrigin", "ProjScaleAtCenter", "ProjAzimuthAngle"] for k in p["keys"]) - assert v.get("axes", ["east", "north"]) in (["east", "north"], ["west", "south"]) - assert "gdal" in v - assert "libgeotiff" in method - - -def test_variant_rules(): - assert TABLE["methods"]["7"]["variants"][0]["when"] == {"present": "ProjStdParallel1"} - assert TABLE["methods"]["15"]["variants"][0]["when"] == {"value": {"param": "Scale factor at natural origin", "equals": 1}} - assert TABLE["methods"]["15"]["variants"][1]["when"] == {"abs_value": {"param": "Latitude of natural origin", "equals": 90}} - assert "unrepresentable" in TABLE["methods"]["15"]["variants"][2] - assert TABLE["methods"]["27"]["variants"][0]["axes"] == ["west", "south"] - - -def test_every_supported_method_has_a_fixture(): - seen = {str(c["geokeys"].get("ProjCoordTrans")) for c in MANIFEST["cases"]} - for code, method in TABLE["methods"].items(): - if "unsupported" not in method: - assert code in seen, code - - -def test_every_fixture_ct_code_is_in_table(): - for c in MANIFEST["cases"]: - ct = c["geokeys"].get("ProjCoordTrans") - if ct is not None: - assert str(ct) in TABLE["methods"], c["name"] - - -def test_table_method_names_match_manifest(): - """For every tested fixture with a CT code, the method GDAL read is one of the table's variants.""" - for c in MANIFEST["cases"]: - ct = c["geokeys"].get("ProjCoordTrans") - if ct is None or c["gdal"]["proj4"] is None: - continue - names = {v["method"]["name"] for v in TABLE["methods"][str(ct)]["variants"] if "method" in v} - assert c["core"]["method"]["name"] in names, (c["name"], c["core"]["method"]["name"]) -``` - -- [ ] **Step 2: Run tests to verify they fail** - -Run: `pixi run pytest tests/test_crs_table.py -v` -Expected: FAIL with `FileNotFoundError` for `geotiff-ct-methods.json` - -- [ ] **Step 3: Write `crs/geotiff-ct-methods.json`** - -Transcribe spec 5.3 row by row, with each parameter's `keys` from the common fallbacks in spec 5.3 and the `kind` from spec 5.1. Method names and EPSG codes must match what `core.method` shows in the manifest for that CT code (the last test enforces this; fix the table, not the manifest). Parameter EPSG codes: 8801-8807 (natural origin, scale, FE, FN), 8821-8827 (false origin, 1st/2nd parallel, E/N at false origin), 8811-8817 (projection centre, azimuth, grid angle, scale, E/N at centre), 8823/8824 for standard parallels, 8832/8833 for Polar B's standard parallel / longitude of origin. Non-EPSG methods (Stereographic, Gnomonic, Miller, Robinson, Sinusoidal, Van Der Grinten, Azimuthal Equidistant and Equidistant Conic if PROJ reports no code) get `"epsg": null` on the method and the parameter names PROJ uses in the manifest. - -- [ ] **Step 4: Run tests to verify they pass** - -Run: `pixi run pytest tests/test_crs_table.py -v` -Expected: 6 passed - -- [ ] **Step 5: Commit** - -```bash -git add crs/geotiff-ct-methods.json tests/test_crs_table.py -git commit -m "feat(crs): Add the GeoTIFF CT code to PROJ method table" -``` - -### Task 7: Corpus integrity tests and PR - -**Files:** -- Create: `tests/test_crs_corpus.py` -- Modify: `crs/README.md` (mention the tests) - -**Interfaces:** -- Consumes: `decode_geokeys` (Task 1), `CASES` (Task 2), `crs/manifest.json` (Task 5). - -- [ ] **Step 1: Write the tests** - -```python -# tests/test_crs_corpus.py -import json -from pathlib import Path - -import pytest - -from crs.cases import CASES -from crs.geokeys import decode_geokeys - -CRS_DIR = Path(__file__).parent.parent / "crs" -MANIFEST = json.loads((CRS_DIR / "manifest.json").read_text()) -ROWS = {c["name"]: c for c in MANIFEST["cases"]} - - -def test_manifest_matches_case_list(): - assert sorted(ROWS) == sorted(c.name for c in CASES) - assert [c["name"] for c in MANIFEST["cases"]] == sorted(ROWS) - - -@pytest.mark.parametrize("name", sorted(ROWS)) -def test_fixture_geokeys_match_manifest(name: str): - row = ROWS[name] - path = CRS_DIR / row["file"] - assert path.exists() - assert not path.with_name(path.name + ".aux.xml").exists() - assert decode_geokeys(path) == row["geokeys"] - - -def test_proj_cases_are_user_defined(): - for row in MANIFEST["cases"]: - if row["input"]["kind"] != "proj" or row["gdal"]["projjson"] is None: - continue - keys = row["geokeys"] - assert keys.get("ProjectedCSType", 32767) == 32767, row["name"] - assert keys.get("GeographicType", 32767) == 32767, row["name"] - - -def test_flagged_rows(): - flagged = {r["name"] for r in MANIFEST["cases"] if r["gdal"]["projjson"] is None or r["gdal"]["proj4"] is None} - assert flagged == {"eqearth", "stere_polar_scaled_wkt"} - assert all(ROWS[n]["note"] for n in flagged) - - -def test_epsg_rows_have_cached_json(): - for row in MANIFEST["cases"]: - if row["input"]["kind"] == "epsg": - assert (CRS_DIR / row["epsg_json"]).exists(), row["name"] - - -def test_point_rows(): - for row in MANIFEST["cases"]: - if row["gdal"]["proj4"] is not None: - assert set(row["point"]) == {"lon", "lat", "x", "y"}, row["name"] -``` - -- [ ] **Step 2: Run the full suite** - -Run: `pixi run test && pixi run ruff check . 2>/dev/null || pixi run python -m ruff check .` -Expected: all tests pass (the per-fixture test runs ~97 times); ruff reports nothing. If `ruff` is not in the pixi env, run it via `uvx ruff check .` as CI's `ruff-action` does. - -- [ ] **Step 3: Run the CI check script** - -Run: `bash scripts/check.sh` -Expected: ends with "All generated files are up to date." - -- [ ] **Step 4: Commit and push** - -```bash -git add tests/test_crs_corpus.py crs/README.md -git commit -m "test(crs): Check fixtures, manifest, and table against each other" -git push -u origin kyle/crs-conformance-corpus -``` - -- [ ] **Step 5: Open the PR** - -Title: `feat: Add a GeoKey-to-CRS conformance corpus and CT method table`. Body: the NOTE attribution line, a summary of the layout, how to regenerate, the two flagged rows and why, the four rows that depend on async-tiff#368, and the footer. Then report that it is ready for review; do not merge. diff --git a/dev-docs/plans/2026-10-26-crs-conformance-tests.md b/dev-docs/plans/2026-10-26-crs-conformance-tests.md deleted file mode 100644 index 0a38a7f..0000000 --- a/dev-docs/plans/2026-10-26-crs-conformance-tests.md +++ /dev/null @@ -1,65 +0,0 @@ -# CRS Conformance Tests Implementation Plan (stage 3) - -> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. - -**Goal:** Make async-geotiff's test suite run the geotiff-test-data CRS corpus against the current `_crs.py`, green from day one through a known-failures list that can only shrink. - -**Architecture:** The submodule moves to the commit that merged the corpus. The CT table is vendored into the package (`src/async_geotiff/data/`) with a test that it equals the submodule copy. A parametrized test opens every manifest row's fixture, compares the built CRS to GDAL's PROJJSON with `pyproj.CRS.equals`, then checks the test point; rows in `KNOWN_FAILURES` are `xfail(strict=True)`, flagged rows are skipped. - -**Tech Stack:** pytest, pytest-asyncio, pyproj 3.7, async-geotiff test fixtures (`fixture_store`), uv. - -**Spec:** `dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md`, sections 6.2 (vendoring) and 7 (tests). - -## Global Constraints - -- Branch `kyle/crs-conformance-tests` in the `.claude/worktrees/crs-conformance-spec` worktree; never commit on `main`. -- No changes to `src/async_geotiff/_crs.py` in this stage; the known-failures list records what fails today. -- `tests/test_crs.py` over `ALL_TEST_IMAGES` stays green. -- Ruff `select = ["ALL"]` with the repo's ignores; tests directory has its own per-file ignores. -- PR text with the Claude attribution note and footer; never merge. - -## Review Focus - -1. A listed known failure that starts passing must fail the run (`xfail(strict=True)`), pinned by `test_known_failures_are_listed_cases`. -2. A flagged row (`gdal.projjson` or `gdal.proj4` null) must be skipped, not failed, pinned by the skip marks in `_params()`. -3. The vendored table must not drift from the submodule, pinned by `test_vendored_table_matches_submodule`. -4. The point check must use the manifest's degree/Greenwich base, not `geodetic_crs`, or grads and Paris rows fail for the wrong reason (`_ellipsoid_longlat`). -5. The vendored JSON must ship in the wheel; verified once by listing the built wheel. - ---- - -### Task 1: Submodule bump - -**Files:** Modify: `fixtures/geotiff-test-data` (gitlink) - -- [ ] Point the submodule at geotiff-test-data `main` after #84 merged (`35da663`); `git -C fixtures/geotiff-test-data checkout origin/main`. -- [ ] Run: `uv run pytest -q` → Expected: existing suite still passes. -- [ ] Commit: `chore: Bump geotiff-test-data for the CRS conformance corpus`. - -### Task 2: Vendor the CT table - -**Files:** Create: `src/async_geotiff/data/geotiff-ct-methods.json` (verbatim copy), `src/async_geotiff/data/__init__.py` (docstring only); Test: `tests/test_crs_table.py`. - -- [ ] Write `tests/test_crs_table.py`: `test_vendored_table_matches_submodule` (json-equal to `fixtures/geotiff-test-data/crs/geotiff-ct-methods.json`) and `test_table_methods_have_proj_names` (every non-`unsupported` variant with a `method` has a non-empty `proj`). -- [ ] Run: `uv run pytest tests/test_crs_table.py -q` → Expected: FAIL, vendored file missing. -- [ ] Copy the JSON; add `data/__init__.py`. -- [ ] Run again → Expected: 2 passed. Then `uv build --wheel` and `unzip -l dist/*.whl | grep geotiff-ct-methods` → Expected: one line. -- [ ] Commit: `test: Vendor the GeoTIFF CT method table with a drift test`. - -### Task 3: Conformance test with seeded known failures - -**Files:** Create: `tests/test_crs_conformance.py`. - -**Interfaces:** -- `MANIFEST` loaded at import from `tests/../fixtures/geotiff-test-data/crs/manifest.json`. -- `KNOWN_FAILURES: dict[str, str]` name → reason. -- `_params() -> list[pytest.param]`: one per row, id = name; `pytest.mark.skip(reason=note)` when `gdal.projjson` or `gdal.proj4` is null; `pytest.mark.xfail(strict=True, reason=...)` when listed. -- `test_crs_matches_gdal(fixture_store, row)`: open `geotiff-test-data/crs/`, `expected = CRS.from_json_dict(row["gdal"]["projjson"])`, `assert expected.equals(geotiff.crs)`, then project `(lon, lat)` from a `+proj=longlat` CRS on `geotiff.crs`'s ellipsoid (`+a +rf`, or `+R` for a sphere) with `always_xy=True` and compare to `(x, y)` with `pytest.approx(abs=2e-3)` (the manifest rounds to millimetres). -- `test_known_failures_are_listed_cases()`: every key of `KNOWN_FAILURES` is a manifest name that is not flagged. - -- [ ] Write the test with `KNOWN_FAILURES = {}`. -- [ ] Run: `uv run pytest tests/test_crs_conformance.py -q` → Expected: a mix of passes and failures, 2 skipped (`eqearth`, `stere_polar_scaled_wkt`). -- [ ] Seed `KNOWN_FAILURES` from the failing ids, one reason each, grouped by the failure class from spec section 1 (rejected CT code, wrong variant, units, origin keys, datum, async-tiff keys, GDAL PM-in-grads). -- [ ] Run: `uv run pytest -q` → Expected: whole suite green, with `N xfailed, 2 skipped`. -- [ ] Commit: `test: Add the GeoKey-to-CRS conformance test with a known-failures list`. -- [ ] Push `kyle/crs-conformance-tests`, open the PR (title `test: Add the CRS conformance suite from geotiff-test-data`), report ready. From bb80a8fa03365150a39b96c49c1dfa1597765feb Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Mon, 26 Oct 2026 13:50:41 -0400 Subject: [PATCH 10/10] chore: Require async-tiff 0.7.2, which fixes predictor 2 on partial tiles The corrected predictor-2 fixture from geotiff-test-data decodes correctly with 0.7.2, so the read tests need no xfail. Co-Authored-By: Claude Fable 5.1 --- pyproject.toml | 2 +- tests/test_read.py | 21 --------------------- uv.lock | 37 +++++++++++++++++++------------------ 3 files changed, 20 insertions(+), 40 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 83f6dc8..0cecd7d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ classifiers = [ keywords = ["geotiff", "tiff", "async", "cog", "raster", "gis"] dependencies = [ "affine>=2.4.0", - "async-tiff>=0.7.0", + "async-tiff>=0.7.2", "defusedxml>=0.7.1", "numpy>=2.0", "pyproj>=3.3.0", diff --git a/tests/test_read.py b/tests/test_read.py index d1b566e..2645a95 100644 --- a/tests/test_read.py +++ b/tests/test_read.py @@ -16,23 +16,6 @@ if TYPE_CHECKING: from .conftest import LoadGeoTIFF, LoadRasterio -KNOWN_DECODE_FAILURES: dict[str, str] = { - # geotiff-test-data b7158c4 made write_cog apply the predictor it was asked - # for; this fixture now really carries predictor 2, and async-tiff 0.7.0 - # reverses it wrongly on the partial last tile column (300 wide, 128 tiles). - # https://github.com/developmentseed/async-tiff/issues/370 - "uint8_1band_deflate_block128_unaligned_predictor2": ( - "async-tiff 0.7.0 decodes predictor 2 wrongly on partial tiles (async-tiff#370)" - ), -} - - -def _xfail_known_decode_failure(request: pytest.FixtureRequest, file_name: str) -> None: - if file_name in KNOWN_DECODE_FAILURES: - request.applymarker( - pytest.mark.xfail(strict=True, reason=KNOWN_DECODE_FAILURES[file_name]), - ) - @pytest.mark.asyncio @pytest.mark.parametrize( @@ -172,13 +155,11 @@ async def test_read_bounds_validation( ALL_DATA_IMAGES, ) async def test_read_full( - request: pytest.FixtureRequest, load_geotiff: LoadGeoTIFF, load_rasterio: LoadRasterio, variant: str, file_name: str, ) -> None: - _xfail_known_decode_failure(request, file_name) geotiff = await load_geotiff(file_name, variant=variant) array = await geotiff.read() @@ -194,13 +175,11 @@ async def test_read_full( ALL_DATA_IMAGES, ) async def test_read_full_as_masked( - request: pytest.FixtureRequest, load_geotiff: LoadGeoTIFF, load_rasterio: LoadRasterio, variant: str, file_name: str, ) -> None: - _xfail_known_decode_failure(request, file_name) geotiff = await load_geotiff(file_name, variant=variant) array = await geotiff.read() masked_array = array.as_masked() diff --git a/uv.lock b/uv.lock index 731c960..9704c26 100644 --- a/uv.lock +++ b/uv.lock @@ -92,7 +92,7 @@ docs = [ [package.metadata] requires-dist = [ { name = "affine", specifier = ">=2.4.0" }, - { name = "async-tiff", specifier = ">=0.7.0" }, + { name = "async-tiff", specifier = ">=0.7.2" }, { name = "defusedxml", specifier = ">=0.7.1" }, { name = "morecantile", marker = "extra == 'morecantile'", specifier = ">=7.0,<8.0" }, { name = "numpy", specifier = ">=2.0" }, @@ -128,27 +128,28 @@ docs = [ [[package]] name = "async-tiff" -version = "0.7.0" +version = "0.7.2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "obspec" }, ] -wheels = [ - { url = "https://files.pythonhosted.org/packages/7c/7a/ff9e1887b4090132c7942ec097e0718c836261ed7f97ebf3e3b7bc750709/async_tiff-0.7.0-cp311-abi3-macosx_10_12_x86_64.whl", hash = "sha256:839c2d2d9d4601cc60f0464277496a973e01ef49b83f8ed54fa71198ff8ed804", size = 4122698, upload-time = "2026-03-03T22:32:58.252Z" }, - { url = "https://files.pythonhosted.org/packages/45/23/5364c7119037ecd9d9cf78d1a1b3cbfcdf0458a2575504ca7062f0b14d31/async_tiff-0.7.0-cp311-abi3-macosx_11_0_arm64.whl", hash = "sha256:77ef4c8cb78fbe58c3e1db5449ed67d6b17d3c91bd6a6fdb8cf436d40ca15a01", size = 3841578, upload-time = "2026-03-03T22:32:59.507Z" }, - { url = "https://files.pythonhosted.org/packages/f5/01/000364b81f67b126e080e955ebb1d4267f438a925a356a7a09ce3b495705/async_tiff-0.7.0-cp311-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:2953aa02f79b046455526aa8f52e0e8dcf5c1a7a702fc830da163a68a4840577", size = 4088525, upload-time = "2026-03-03T22:33:01.625Z" }, - { url = "https://files.pythonhosted.org/packages/c6/ba/b6b84d87f9d4970e325ccadd2a976f5c143da1e03bbda7cb28ab8a83d478/async_tiff-0.7.0-cp311-abi3-manylinux_2_28_i686.whl", hash = "sha256:2a9c46292d1874c2aabc0f8c76bbcdeb74043f98296e6c50c2ea53c14d0fc023", size = 4178742, upload-time = "2026-03-03T22:33:02.925Z" }, - { url = "https://files.pythonhosted.org/packages/19/1a/51311cc9dab8a2a3722d2fd4099363d83abc4891f1ddbe0415f18174e702/async_tiff-0.7.0-cp311-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:960a2dfe71b4f5d99fe5e530d4d30f90e14410860fbfbe19e23ea5a3e32d70cc", size = 4338115, upload-time = "2026-03-03T22:33:04.405Z" }, - { url = "https://files.pythonhosted.org/packages/e9/4a/0780e3a0d406b084ab3e1c79b27f231ef64fe2ddd935e63f1325f68b6d0a/async_tiff-0.7.0-cp311-abi3-musllinux_1_2_i686.whl", hash = "sha256:25d8d92f8704a82085e17adc8d588669c24d3e02b0249f715b4b04bbbc74e632", size = 4205497, upload-time = "2026-03-03T22:33:05.612Z" }, - { url = "https://files.pythonhosted.org/packages/e8/38/21bed394bb7022d55cbe4b938e4c13f3c1f421a76d3571934e6afb92ab8b/async_tiff-0.7.0-cp311-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:44d9d607f003ae6726baf1d3996f76e65ffb5ec4415836b654e5327cb8e9dfcd", size = 4474372, upload-time = "2026-03-03T22:33:08.652Z" }, - { url = "https://files.pythonhosted.org/packages/6e/a0/a49020134f3c8f9d974fc3143c66afe9e1320a369828973434026362d1c0/async_tiff-0.7.0-cp311-abi3-win_amd64.whl", hash = "sha256:1ce3dcc3c4f9965e850a5427432fd1eea1fa9c4448e8453b556a6e9f118fd51b", size = 4097755, upload-time = "2026-03-03T22:33:10.16Z" }, - { url = "https://files.pythonhosted.org/packages/25/6f/27b2040b974e191bdc28fd6e17fa2a001f6e4e68b21546b61c3073d5091c/async_tiff-0.7.0-pp311-pypy311_pp73-macosx_10_12_x86_64.whl", hash = "sha256:778930c050f9afa4432732a1172102696c072149a4e619fd497a2075d2008baa", size = 4118161, upload-time = "2026-03-03T22:33:11.648Z" }, - { url = "https://files.pythonhosted.org/packages/ab/a7/3accc40d440b7cf7bdc7e3d49a98a47ef510857830edf18e8d74908a3912/async_tiff-0.7.0-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:76dc7dd7d60371c4884f35d1e7ec54d344dcae16ef9417585d10b8a1102a5a66", size = 3842297, upload-time = "2026-03-03T22:33:13.194Z" }, - { url = "https://files.pythonhosted.org/packages/92/8d/a0fc193eaf7d10085fc65d9b0694a77f1040f7e14def7dda34f73bec315b/async_tiff-0.7.0-pp311-pypy311_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:02b5a351227a4bb86c4e0d2cd0a9d96d57a8289442a1d56fb34ab332e586e607", size = 4087914, upload-time = "2026-03-03T22:33:14.453Z" }, - { url = "https://files.pythonhosted.org/packages/b0/57/e656f488cef397e611f691c28cbd93a4ff53d4afa3e621f6cf48461dcf46/async_tiff-0.7.0-pp311-pypy311_pp73-manylinux_2_28_i686.whl", hash = "sha256:e59966d16409302434f2f38f6ef0b0f6c04400e4ca9113243ade65c9d024ab8c", size = 4173315, upload-time = "2026-03-03T22:33:15.694Z" }, - { url = "https://files.pythonhosted.org/packages/f4/f9/e82c5cbe73ede031b2ca4dbd88856fdca9660c8d727560b6240630fa9da6/async_tiff-0.7.0-pp311-pypy311_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:a18b8ca49d697ad4d014be2d3274241f63b4fe9cc12c3fb5595d3c8003194c6e", size = 4331034, upload-time = "2026-03-03T22:33:16.998Z" }, - { url = "https://files.pythonhosted.org/packages/0a/a1/1ee3b888772c28df8902665c8147385ff8110da88cfd1e0c02bc082843a2/async_tiff-0.7.0-pp311-pypy311_pp73-musllinux_1_2_i686.whl", hash = "sha256:b2c7652467f187689675474c953488485d712b2c3cf4bbb98016fcf2f2a95804", size = 4201299, upload-time = "2026-03-03T22:33:18.403Z" }, - { url = "https://files.pythonhosted.org/packages/03/40/50fb8ede114c44eb05b467d508c7d61bbe70f0425c141fc0b08e34944ebe/async_tiff-0.7.0-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl", hash = "sha256:3e54670934f88e730433c4bd802439805c28152df8ee4ae7df7e5dc36c4b5944", size = 4468348, upload-time = "2026-03-03T22:33:19.711Z" }, +sdist = { url = "https://files.pythonhosted.org/packages/c9/81/6b8198cbf294ab6f50c7b8fd704b773af595c5f40e738358d40c218df236/async_tiff-0.7.2.tar.gz", hash = "sha256:b2eb1f2671de4e331d1eaef1fd5bb3670e1f26ec7465115be488e60349f2dbce", size = 5249708, upload-time = "2026-05-06T19:03:00.261Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6b/8b/1591e69991987b43ccd7faecb843bd601dfb08a35395770c1562aaca73da/async_tiff-0.7.2-cp311-abi3-macosx_10_12_x86_64.whl", hash = "sha256:028e9d629dbe8d830581d8e46b92081a656953db020b424615af3c6e51ed9249", size = 4056302, upload-time = "2026-05-06T19:02:28.816Z" }, + { url = "https://files.pythonhosted.org/packages/c5/58/fc2451333d389da41e8505a8edcc711fcacfb8f038c67a1629d7e87fbdc0/async_tiff-0.7.2-cp311-abi3-macosx_11_0_arm64.whl", hash = "sha256:97d77fcad25824321645c3b83da060b1ece827f30e76fe64db74b4df97e5da1d", size = 3764126, upload-time = "2026-05-06T19:02:30.984Z" }, + { url = "https://files.pythonhosted.org/packages/90/76/342bdaff66caa7b4eb6d224bdf8b5f2815b888c665dd51f9b8f83d45316f/async_tiff-0.7.2-cp311-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:62859389a21dc512f5c37fe17729eeeafb66c445374fcf888c1aa2c64bc79ff7", size = 4023878, upload-time = "2026-05-06T19:02:33.374Z" }, + { url = "https://files.pythonhosted.org/packages/79/ec/2f16e32670e9ade6aba6cc0634cc65f232e8f42cdd46e6a883592d8b59ce/async_tiff-0.7.2-cp311-abi3-manylinux_2_28_i686.whl", hash = "sha256:1fb75527b4405107af587e55f4d34e50e8f2f8fe70bfac615e551fbe156cfe11", size = 4106939, upload-time = "2026-05-06T19:02:35.493Z" }, + { url = "https://files.pythonhosted.org/packages/3e/8f/c8a7c48fd966e13ee7390984d43318f71f0eab76889108b3a9621b6ef62a/async_tiff-0.7.2-cp311-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:84ca597d8a6354d7b1ae46d2c41432e0dad36ffd4ad54f45aa29d11857506e9b", size = 4276382, upload-time = "2026-05-06T19:02:37.424Z" }, + { url = "https://files.pythonhosted.org/packages/aa/26/8382fab4dd930c4d96d3a3d243fb0f90750e472ae2a6bbc2c82343df6167/async_tiff-0.7.2-cp311-abi3-musllinux_1_2_i686.whl", hash = "sha256:ed2ca1842f47714a23623125bb864b858db400f9b7af4cae41dfc04f798f2557", size = 4133568, upload-time = "2026-05-06T19:02:39.651Z" }, + { url = "https://files.pythonhosted.org/packages/89/84/b889e197f51c82a9470cb294b81c4713725e646ffb6716d078d4004b9569/async_tiff-0.7.2-cp311-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:0cb8ec113b5d33ad020556527ae54f2cb86f7e955fedac718779a4b12404688f", size = 4411500, upload-time = "2026-05-06T19:02:41.473Z" }, + { url = "https://files.pythonhosted.org/packages/9f/cc/e106fcee3a8cd98d57c8842ba4ff2839fea6ca736970f0899b3162298fc9/async_tiff-0.7.2-cp311-abi3-win_amd64.whl", hash = "sha256:296647adac8b05ae1bacc69feea2e42ce17220d34df1bc419be0daa94364ebd5", size = 4036094, upload-time = "2026-05-06T19:02:43.421Z" }, + { url = "https://files.pythonhosted.org/packages/3e/5f/83b491bbedf430098aec5c9b57d6a723674297a608817c8fb1dddb8f85a4/async_tiff-0.7.2-pp311-pypy311_pp73-macosx_10_12_x86_64.whl", hash = "sha256:e75dc8f806f60fe738cce85d5f03a014472db48ed4369b5ba03b185396d09772", size = 4055398, upload-time = "2026-05-06T19:02:45.728Z" }, + { url = "https://files.pythonhosted.org/packages/ad/18/509a3541851d014c8a7f4f52032593f8247a28fb7d7ad96e38526222b217/async_tiff-0.7.2-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:49473e043083a532dd7f1210363e626f964e65be9ce68ed986a2645005ae0f0c", size = 3765618, upload-time = "2026-05-06T19:02:47.564Z" }, + { url = "https://files.pythonhosted.org/packages/bc/d2/1bb5fa40d4bdbac4b73e0b52094fd45d77fada866ebe8789c126793a9cc4/async_tiff-0.7.2-pp311-pypy311_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:43b1399633fa5839a705c43b3f01dc9d70de5dd422098130da34a904eb0f5600", size = 4026176, upload-time = "2026-05-06T19:02:49.704Z" }, + { url = "https://files.pythonhosted.org/packages/e0/11/e5919f111e3dd051803c3fc528a0014bd0a25c83688f758de32a75feba03/async_tiff-0.7.2-pp311-pypy311_pp73-manylinux_2_28_i686.whl", hash = "sha256:1b6ab725e061c232e4f0a74cd2aa72024a4459f521deeedc807a82a1408b61e0", size = 4105321, upload-time = "2026-05-06T19:02:51.931Z" }, + { url = "https://files.pythonhosted.org/packages/70/5e/36b4e1aa54be7ecd44f1845ba041f3fb8182c7825639d2e1e051c59bbad1/async_tiff-0.7.2-pp311-pypy311_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:ed74fc8a7368140d1ff56094513ee9e90ef150d83846710e9436e990d4df056b", size = 4271421, upload-time = "2026-05-06T19:02:53.798Z" }, + { url = "https://files.pythonhosted.org/packages/3d/de/15c656564e7a77524b29fc15b825d9b6f37d4f3345c69261ad854ef6803a/async_tiff-0.7.2-pp311-pypy311_pp73-musllinux_1_2_i686.whl", hash = "sha256:3df1bf90c3fa40acc5eef42ca9d927467d4b34d5d1281d9779ec77396bd5a964", size = 4131834, upload-time = "2026-05-06T19:02:55.966Z" }, + { url = "https://files.pythonhosted.org/packages/cb/14/f25529fe0de6d97dfc5e6d292b2334f597aa40276b67e19cbe419d0a0e7b/async_tiff-0.7.2-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl", hash = "sha256:1609c254845ab6ddb2db02466fa0fdad5a7410fc24eb652e4ea44891216dd2d1", size = 4409385, upload-time = "2026-05-06T19:02:58.364Z" }, ] [[package]]