Skip to content

Tracking: terrio-crs as coordinate engine and a coordinate system per layer #2032

Open

Description

@pick2510

Tracking issue for replacing proj4rs, crs-definitions and RustGIS's own CRS tables with terrio-crs, then keeping every feature layer in its own coordinate system with the map reprojecting on the fly. The terrio side is done in opengeos/terrio#936.

Where we are

Rule for every PR

Nothing from the past breaks. Old projects, files and behaviour keep working. The only intended changes are reference values where terrio-crs agrees with PROJ and proj4rs didn't; each such change is checked against cs2cs/projinfo.

Phase A: engine swap

Phase B: any system to any system

  • B1+B2, merged in feat(data,map): convert between any two coordinate systems; draw layers from their own (#2032 B1+B2) #2448: Crs::to converts points, geometry and extents between any two systems (through WGS 84 for now), with a fast path when both are the same, and the map draws each layer from its own system. Area-of-use clipping and rasters on the same path follow in C2.
  • B3, merged in feat(crs): convert between two systems by their direct operation (#2032 B3) #2498: A direct operation between two systems, instead of two steps through WGS 84. Between two systems on the same datum other than WGS 84 (ETRS89 UTM to ETRS89 LAEA, two NAD27 systems), a datum shift there and back cancels only where both steps pick the same transformation, which fails near a grid's edge or an area of use. Between two datums, chaining two transformations can lose accuracy that the best operation for the pair keeps. Crs::to holds one terrio-crs transformer per pair of systems, built once and kept like the others, with values checked against cs2cs. Nothing changes today, since every layer is in lon/lat and every conversion that runs has WGS 84 on one side. It comes before C1e and C2, so that their exports and native layers convert directly from the start.

Phase C: a coordinate system per layer

Phase D: hooks for 3D (#726)

I'll do the PRs in this order. Pieces of C1 can be taken by others once B is in; say so here first.

Related: #726, #1853 (project format 2), opengeos/terrio#936, opengeos/terrio#1012.

Activity

  1. 93 remaining items

  2. Mavrick-F commented on Nov 25, 2026

    @Mavrick-F
    Member

    @pick2510 two things from profiling the 25 November benchmark touch coordinate conversion, so I wanted to check with you first.

    Exporting a projected layer converts every vertex to lon/lat twice, on one thread: once in lonlat_extent for the extent, then again in project_each_leaving_out to write it. For 100,000 buffered UTM points (12.9 million vertices) that's about 80% of an 8.4 s run. I'd take the extent from the converted features and do the conversion on several threads. The file written should come out identical.

    raster.project converts every output cell's position exactly, through lon/lat, and that's about a third of its time. gdalwarp converts a few points per row exactly and interpolates between them, keeping the error under 0.125 of a cell. Doing the same would shift output values slightly, within that bound.

    Neither changes which coordinate system a layer or an export uses, which stays with C3a part 2. Would either get in the way of what's left of C2e or C3? If not, I'll send the export fix as a small PR now and the warp change after C2e lands.

  3. pick2510 commented on Nov 25, 2026

    @pick2510
    ContributorAuthor

    @Mavrick-F Neither gets in the way. C2e and C3a part 2 are both merged, and nothing I have open touches export or raster.project, so the warp change doesn't need to wait either.

    Export: fine with me. Two things: the extent from the converted features has to leave out features that couldn't be converted (NaN), as lonlat_extent does today, and the web build needs a one-thread path. Cancel should still reach the threaded conversion.

    Warp: also fine, as long as the PR lists the value shifts. Please go through Crs::to (the direct operation from the source to the target system) rather than lon/lat. Between datums that's also the more accurate path. And fall back to exact conversion near a projection's edge or the poles, where the 0.125-cell bound can't hold.

  4. Mavrick-F commented on Dec 1, 2026

    @Mavrick-F
    Member

    Hi @pick2510, when Join Field's target is in longitude/latitude, RustGIS also converts the join layer's shapes, though the join only uses its attributes. For a layer of 448,000 polygons, skipping that saves 1.7 GB of memory and takes the join from 5.7 s to 1.6 s.

    I have a fix ready. It still converts the join layer when it's also the target, or when its definition query measures shapes. Your #2611 already skips this for projected targets. Did you leave longitude/latitude out for a reason, or is it something you're changing in #2032?

  5. pick2510 commented on Dec 1, 2026

    @pick2510
    ContributorAuthor

    Hi @Mavrick-F, no particular reason. #2611 only changed the path for tools working in a projected system and left the longitude/latitude path as it was. Nothing left in #2032 touches it, so go ahead.

    Note that the lon/lat exclusion is in two places in gp.rs (let unread = if work == Crs::LonLat … in the input setup and in inputs_in). Both need to change, otherwise Inputs::dataset won't hand the join layer out unconverted. The join layer then also shouldn't show up in the notice about features read without geometry. Tests for your two exceptions (join layer = target, definition query measuring shapes) would be good.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions