Repository navigation
[Feature]: QGIS projects in a geographic coordinate system open in Equirectangular, as QGIS draws them #883
Description
Before you start
- I searched the existing issues and the roadmap and did not find a duplicate request.
What problem does this solve?
Piece 1 of #882. A QGIS project whose coordinate system is geographic opens in RustGIS in Web Mercator. The import adds the note "the project's coordinate system EPSG:4326 (EPSG:4326 is in degrees: pick a projected coordinate system), drawn in Web Mercator". Typical examples are EPSG:4326, ETRS89 (EPSG:4258) and NAD83 (EPSG:4269).
QGIS draws such a project as plate carrée, with longitude and latitude as x and y. That's 9 of the 27 real projects in the audit corpus (#881, the QGIS Training Manual's world.qgs, example.qgs and the processing exercises). In Web Mercator, high latitudes are stretched and the map doesn't look like the one the project was made in.
map.projection refuses a coordinate system in degrees on purpose (crates/map/src/projection.rs). RustGIS already has the projection QGIS uses here: the Equirectangular (Plate Carrée) preset (+proj=eqc), which lays longitude and latitude out on a regular grid the same way.
Proposed solution
In project.importQgis (crates/engine/src/cmd/qgis.rs), when the project's coordinate system is geographic, set the map to the equirectangular preset instead of falling back to Web Mercator:
- An EPSG code whose PROJ definition is
+proj=longlatcounts as geographic. - The importer checks this itself rather than matching
map.projection's error text.
No new command or dependency. map.projection keeps refusing degrees when a user picks one.
What it carries over:
- The view: the project's extent (in degrees) converts to the map's coordinates as for any projection.
- The shape: a plate carrée like QGIS's canvas.
- A small approximation: the preset uses WGS 84, and a project on another geographic datum (ETRS89, NAD83) is drawn on WGS 84. That's sub-metre to a few metres, below what a map at these scales shows. Instead of the current Web Mercator note, the import says "drawn in Equirectangular (WGS 84)" only when the datum differs.
- Scale ranges and reference scales: QGIS computes the scale of a degree-based canvas at the map's centre latitude. The test checks that the visibility ranges of
world.qgsbehave the same at a few zoom levels, and the pull request reports it.
Crates: rustgis-engine (the import); rustgis-map only if a helper to tell geographic codes apart belongs in projection.rs.
Tests:
- An engine test in
crates/engine/src/tests.rs: a project in EPSG:4326 opens with the Equirectangular projection and its extent, without the Web Mercator note; a project in EPSG:4258 opens the same way, with the datum note. every_corpus_file_reads(test(map): a corpus of QGIS projects and styles the importer reads #881) is unchanged. Rendering the Training Manual'sworld.qgsbeside QGIS shows the same layout of the world (screenshots in the pull request, not committed).
Estimated scope
Small: a minor tweak, small UI change, or text adjustment
Alternatives considered
- Let
map.projectionaccept geographic codes and draw them as plate carrée under their own name. Simpler for the importer, but it hides the choice from users who pick a projection, and the map's units would be degrees, which the camera and measurement code don't expect. - Keep Web Mercator and only reword the note. It's the current behaviour, and the map looks unlike QGIS's.
Activity
feat(map): QGIS projects in degrees open in Equirectangular, as QGIS …