Skip to content

fix: read plain tabular JSON and write null-geometry GeoDataFrames - #119

Open
fredj wants to merge 5 commits into
mainfrom
json-geojson-handling
Open

fix: read plain tabular JSON and write null-geometry GeoDataFrames#119
fredj wants to merge 5 commits into
mainfrom
json-geojson-handling

Conversation

@fredj

@fredj fredj commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Detects and correctly handles plain tabular JSON and non-spatial GeoJSON during ingestion:

  • _read_file_encoded reads .json files as a table directly via pandas, without touching .geojson handling.
  • A .geojson file/URL source whose geometry is null on every feature is now rejected with a clear error, instead of being silently imported as a non-spatial table — this usually signals a malformed or unintended export. The check reads the geometry column once for the whole file, so chunking doesn't affect the verdict. OGC WFS/OAPIF services keep their own deliberate null-geometry-to-tabular handling (some feature services legitimately return "geometry": null for non-spatial layers), and other geospatial formats (Shapefile, GeoPackage, database sources) keep the existing fallback in write_data_to_postgis.
  • get_staging_metadata reports the actual file_type (json vs geojson) based on the resulting staging table, not just the source extension.

Also dedupes repeated test setup into shared fixtures/conftest.

fredj added 3 commits August 28, 2026 17:36
_read_file_encoded reads .json files as a table directly via pandas,
without touching the .geojson code path.

write_data_to_postgis now writes a GeoDataFrame with an entirely-null
geometry column as a plain table instead of crashing in to_postgis()
("No valid geometries in the data.").
The extension-based guess at submission time can be wrong for these two.
get_staging_metadata now checks the staging table for a "geom" column
(same check read_data_from_postgis already uses) and reports what the
data actually turned out to be. Other file types are untouched.
Moved the repeated six @patch decorators into a staging_metadata_deps
fixture in a new conftest.py, shared by test_staging_database.py and
test_staging_api.py.
@fredj
fredj force-pushed the json-geojson-handling branch from cccdd28 to 6f50bf5 Compare August 28, 2026 15:37
@fredj
fredj marked this pull request as ready for review August 31, 2026 06:14
@fredj
fredj marked this pull request as draft August 31, 2026 07:35
fredj added 2 commits August 31, 2026 10:08
…file

Checks every feature's geometry once, via a separate geometry-only read of
the whole file, so chunking doesn't affect the verdict. OGC WFS/OAPIF
services keep their own null-geometry handling, unaffected.
Adds the jq PyPI package (bundles libjq, no system dependency) and runs
raw JSON text through it before parsing, seeded with the fixed identity
filter "." for now. This is the seam a future editable filter plugs into.

Frontend shows a disabled "JQ filter" field prefilled with "." next to
the dataset title, for json sources only. No editing or persistence yet.
@fredj
fredj marked this pull request as ready for review September 1, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant