Skip to content

fix(geo): keep a wkt-named attribute from taking over the csv geometry - #1208

Merged
KnifeLemon merged 1 commit into
KnifeLemon:mainfrom
mertkayacs:fix/csv-geometry-attribute
Nov 6, 2026
Merged

KnifeLemon merged 1 commit into
KnifeLemon:mainfrom
mertkayacs:fix/csv-geometry-attribute

Conversation

@mertkayacs

Copy link
Copy Markdown
Contributor

What does this change?

Converting points to CSV wrote longitude and latitude columns even when an attribute already had a WKT column name, such as wkt, geometry, the_geom or shape. Reading that CSV back took the attribute as the geometry, so a point at (1, 2) with shape = "POINT (9 9)" came back at (9, 9), and shape = "round" made the read fail with "not valid WKT".

The writer now uses a WKT geometry column in that case, as it already does for longitude and latitude attributes. When an attribute is called wkt_geo or a variant like WKT-GEO, the generated column takes the same normalized name, and because it is the first column the reader still picks it. Reading CSVs from other tools works as before.

Type of change

  • Bug fix
  • New feature or improvement
  • New format or engine
  • Translation
  • Documentation
  • Build, CI or dependencies

How was it tested?

  • dotnet format --verify-no-changes
  • dotnet test
  • Tried it in the app (what you converted or clicked, and on which OS):

New tests in GeoFormatTests: a GeoJSON to CSV to GeoJSON round trip for attributes named shape, wkt, geometry, wkt_geo, WKT-GEO and WKT GEO, one with wkt and wkt_geo together, and one that checks a CSV with shape before wkt still reads wkt as the geometry. The round-trip tests fail on main and pass with this change.

On Linux, the GeoFormatTests filter passes (81), Filee.Cli.Tests passes (85), and the whole Filee.Engines.Tests project has 2,467 passed and 14 failed. Those 14 also fail on main here, since this machine doesn't have the Pandoc, FFmpeg and fonts that CI fetches. I didn't run the App and Setup suites, which CI runs on Windows. The Release build has the same 19 warnings as main.

Screenshots (UI changes)

None, no UI change.

Checklist

  • New UI strings are in all src/Filee.App/Assets/i18n/*.json files (no new strings)
  • New third-party code or binaries are listed in THIRD-PARTY-NOTICES.md (none added)
  • The PR does one thing (unrelated changes go in a separate PR)

A point dataset with a WKT-named attribute could be written so that the
attribute replaced the real geometry when Filee read its own CSV. Names
normalized to wktgeo could also leave the generated header unrecognized
after a collision.

Write these datasets with WKT and give the generated header the reader's
highest-priority normalized name when needed. Collision suffixes preserve
that name, so WKT-like attributes round-trip without changing third-party
read precedence.
@github-actions github-actions Bot added the bug Something isn't working label Nov 6, 2026

@KnifeLemon KnifeLemon left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks, @mertkayacs! A good catch: a wkt-named attribute could take over the geometry on the way back. Writing WKT in that case, with the generated column taking the reader's first name, round-trips each case in the tests.

@KnifeLemon
KnifeLemon merged commit 2fa5955 into KnifeLemon:main Nov 6, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants