Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ATTRIBUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ of use.
| Shapefile Z/M reader-loss fixtures (`crates/engine/testdata/reading-losses/shp-*`) | The RustGIS project: independently encoded, made-up point and line records following the published Shapefile specification; byte layout in [SHAPEFILE.md](crates/engine/testdata/reading-losses/SHAPEFILE.md) | Apache-2.0 |
| XLSX reader-loss fixtures (`crates/engine/testdata/reading-losses/book-*.xlsx`) | The RustGIS project: made-up one-row workbooks, encoded as Office Open XML with Python standard-library ZIP/XML writing; [fixture notes](crates/engine/testdata/reading-losses/README.md#xlsx) describe their contents | Apache-2.0 |
| ODS reader-loss fixtures (`crates/engine/testdata/reading-losses/book-*.ods`) | The RustGIS project: made-up one-row OpenDocument workbooks, independently encoded with Python standard-library ZIP/XML writing; [fixture notes](crates/engine/testdata/reading-losses/README.md#ods) describe their contents | Apache-2.0 |
| XLS/XLSB reader-loss fixtures (`crates/engine/testdata/reading-losses/book-*.xls`, `book-*.xlsb`) | The RustGIS project: made-up one-row workbooks generated offline with SheetJS CE 0.18.5; XLSB package parts were minimized; except in `book-short.xlsb`, short cell records were independently re-encoded to the published full-cell layout; [fixture notes](crates/engine/testdata/reading-losses/README.md#xls-and-xlsb) describe contents and checks | Apache-2.0 |
| OSM PBF ring-loss fixtures (`crates/engine/testdata/reading-losses/hole-*.osm.pbf`) | The RustGIS project: independently encoded, made-up nodes, ways and relation from the published OSM PBF schema; contents and checksums in [OSM.md](crates/engine/testdata/reading-losses/OSM.md) | Apache-2.0 |
| Interface themes (`crates/ui-egui/themes/light.json`, `dark.json`) | The RustGIS project | Apache-2.0 |
| Sample data (`countries`, `cities`, `rivers`, `lakes` GeoJSON), embedded at build time from [rustgis-assets](https://github.com/opengeos/rustgis-assets/tree/main/data) | Natural Earth 1:110m, attributes trimmed | Public domain |
Expand Down
10 changes: 7 additions & 3 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,18 @@ A result is right, or RustGIS says what it lost or assumed
nodes or ways the file doesn't hold, and inner rings outside every outer one; and the text
readers' losses listed as `Silent` in `crates/engine/tests/never_silent_reading.rs`, among them
each vertex's Z in DXF and unreadable coordinates, holes and parts in KML, GeoRSS, MapInfo and
DXF, plus geometry-collection members in XLSX/ODS and error-valued attribute cells in XLSX. A fix makes
DXF, plus geometry-collection members in XLSX/ODS/XLS/XLSB, error-valued attribute cells in XLSX,
and attribute fields/values in XLSB short-cell workbooks (the original SheetJS 0.18.5 clean
workbook retains its point but no attributes, without a notice). A fix makes
its case `Said` _(open)_.
- Lossy sample files in `never_silent_reading.rs` for the readers it doesn't cover yet:
remaining spreadsheet formats (XLS, XLSB and XLSM). It covers GeoJSON, TopoJSON, CSV,
remaining distinct loss families and parser paths (see the finite
[coverage inventory](crates/engine/testdata/reading-losses/README.md#coverage-boundaries)). It covers GeoJSON, TopoJSON, CSV,
KML, KMZ, GPX, GML, GeoRSS,
DXF, LandXML and MapInfo, with height-loss cases for CityJSON, CityGML, GeoPackage,
FlatGeobuf, GeoParquet and FileGDB, Z/M-loss cases for Shapefile, and ring-loss cases for
OSM PBF, WKT height/member losses for XLSX and ODS, and error-cell losses for XLSX; other loss kinds remain.
OSM PBF, WKT height/member losses for XLSX, ODS, XLS and XLSB, and error-cell losses for XLSX; other loss kinds remain.
XLSM shares the XLSX parser; macros are untested.
Exports are checked by `never_silent_roundtrip.rs` _(open)_.
- A `--strict` option for `rustgis-cli run` that exits non-zero when a loss is reported, for
scheduled jobs. Notices carry a severity but not a kind today (`Notice` in
Expand Down
82 changes: 82 additions & 0 deletions crates/engine/testdata/reading-losses/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,85 @@ reader and `layer.addData`; native reports must also have zero skipped rows and
expected height-loss flag and notice. Valid lossy files must import. WKT uses the
existing reader convention without testing or changing CRS assumptions. This slice does
not certify ODS completeness or cover malformed archives, formulas, dates or error cells.

## XLS and XLSB

Seven made-up workbooks written offline with SheetJS Community Edition `xlsx` 0.18.5:
`utils.aoa_to_sheet([['wkt','id','note'],[wkt,7]])`, appended as `Places`, then
`writeFile` with `bookType: 'biff8'` (XLS) or `'xlsb'` and compression enabled.
The writer is independent of RustGIS and is not needed by tests. No writer code or
third-party data is included. XLS exercises the compound-file/BIFF reader; XLSB
exercises the binary workbook/sheet parser inside ZIP, rather than XLSX's XML parser.

XLS files retain the writer's small compound container. XLSB archives were minimized
offline with Python's standard-library `zipfile`: retain workbook, worksheet and style
binary parts, replace package relationships/content types with only those parts, and
remove the unused theme, document properties and sheet metadata. ZIP timestamps are
1980-01-01. Except in `book-short.xlsb`, the generated XLSB short string/RK cell
records were re-encoded as
full `BrtCellSt`/`BrtCellRk` records with explicit column indexes, following the
published [MS-XLSB Cell layout](https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-xlsb/1e3e0c46-6175-4123-b02b-903643a5cc07).
`book-short.xlsb` preserves the original worksheet records and tests the short-cell loss.
As a check independent of the handwritten full-cell rewrite, SheetJS CE 0.18.5's `readFile`
and `sheet_to_json` read all seven committed XLS/XLSB workbooks back to the documented
headers, WKT and numeric ID. This check uses a parser independent of RustGIS.
No macros, formulas or external links are included.

The original SheetJS 0.18.5 short-cell worksheet, retained in `book-short.xlsb`,
pins a known reader gap: native
`sheets::read` retains `POINT(1 2)` but returns no attribute fields or values,
including the source `id=7`, with zero skipped rows and no messages. Its short
cell records are paired with the full-record `book-clean.xlsb`; both native and
command imports must retain exactly the point with no attribute fields/values or notices.

| Files (`.xls` and `.xlsb` unless stated) | WKT | Current loss classification |
| --- | --- | --- |
| `book-clean` | `POINT(1 2)` | None; no native or command notice |
| `book-z` | `POINT Z(1 2 3)` | Imports with a Z/M-loss notice |
| `book-collection` | `GEOMETRYCOLLECTION(POINT(1 2),POINT(3 4))` | Silent: only the first member remains |
| `book-short.xlsb` (paired with `book-clean.xlsb`) | `POINT(1 2)` | Silent: all attribute fields and values are lost |

The height/member pairs must retain exactly one point at (1, 2), integer `id=7`,
text `note=Null` and both field names/types, through `sheets::read` and `layer.addData`.
Native checks require zero skipped rows, the expected height flag and exactly one
Z/M message for the height variant (none otherwise). Valid lossy fixtures must import.
Dates, error cells, other sheets and broader type/encoding fidelity are not certified.

## Coverage boundaries

The corpus is a list of specific losses, not a format-completeness certificate.
Dispatch is defined by `data::io::{read_layers,read_bytes,read_path}`, `source::EXTENSIONS`
and `sheets::open_checked`. Aliases and sniffed formats share rows below; the table does
not claim that every alias or container has its own paired test. “Gap” means applicable
but not covered here, not necessarily a known bug. CRS assumptions remain separate work
(#2032). The exact tested loss and `Silent`/reported status live in the test case table.

| Reader dispatch | Paired corpus coverage | Remaining applicable families |
| --- | --- | --- |
| GeoJSON | Z, unreadable geometry | M, members/holes, attributes |
| TopoJSON | Z, missing arcs, bad quantized positions, nested members | M, other parts, attributes |
| Delimited text (CSV/TSV/TXT/DAT, gzip wrapper) | CSV WKT Z, bad WKT/XY, later WKT members, extra cells | M, holes/curves, types/names/encoding, wrapper parity |
| Shapefile | Point Z/M, line Z/ZM | Other shapes/parts, attributes; DBF encoding tracked in #2325 |
| Standalone DBF | None | Names/types/encoding; geometry and Z/M inapplicable |
| KML/KMZ | Z, missing geometry, bad coordinate/hole/part, excess point coordinates | Other parts, attributes |
| GPX | Bad waypoint, short track segment | Elevation attributes, other parts, attributes |
| GeoRSS (RSS/Atom/GeoRSS, sniffed XML) | Unreadable place/hole, excess coordinate pairs | GML dimensions, other members, attributes |
| LandXML (including sniffed XML) | Unreadable point, parcel without geometry | Elevations, curves/parts, attributes |
| GML | Z | M, members/holes/curves, attributes |
| CityGML / CityJSON (distinct parsers) | Varying line Z in each | Other dimensions, surfaces/members/holes, attributes |
| DXF | Varying line Z, unreadable entity/vertex | Other entities/curves/parts, attributes |
| MapInfo MIF/MID | Unreadable object, arc, short part/ring | Other geometry and attribute conversion |
| OSM PBF | Missing member/node, unclosed/outside inner ring | Other relations, attributes; native coordinates are XY |
| Feature-service PBF (distinct sniffed PBF parser) | None | Dimensions, geometry members, attributes |
| GeoPackage / FlatGeobuf / GeoParquet / FileGDB (distinct readers) | Z in each | M, members/parts/curves where supported, attributes |
| LAS/LAZ | None in this paired corpus | Sampling, dimensions/attributes; geometry members/holes inapplicable |
| XLSX | WKT Z/members, error-valued attribute | M, other geometry, dates/formulas/names/encoding |
| ODS / XLS (distinct workbook parsers) | WKT Z/members in each | M, other geometry, dates/errors/names/encoding |
| XLSB | WKT Z/members with full cell records; short-cell attribute loss | Pinned silent short-cell loss; M, other geometry, dates/errors/names/encoding remain gaps |
| XLSM | Shared XLSX OOXML implementation only | No distinct fixture; macros and macro fidelity untested |
| Generic ZIP | Delegates to inner readers; KMZ covered above | Other wrapper parity |

XLSM uses the same OOXML parser as XLSX; merely renaming a workbook would not establish
another parser's coverage. Raster/image/grid/PDF fidelity and external program, database
and network-provider losses are outside this local vector/table corpus. Existing tests
elsewhere (including LAS whole-read fidelity) do not count as paired coverage here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added crates/engine/testdata/reading-losses/book-z.xls
Binary file not shown.
Binary file added crates/engine/testdata/reading-losses/book-z.xlsb
Binary file not shown.
74 changes: 61 additions & 13 deletions crates/engine/tests/never_silent_reading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//! their own test, `never_silent_roundtrip.rs`.
//!
//! The table includes text, CityJSON, CityGML, KMZ, GeoPackage, FlatGeobuf, GeoParquet, FileGDB,
//! Shapefile, XLSX, ODS and OSM PBF. More formats and loss kinds remain to add (ROADMAP.md); one loss
//! Shapefile, XLSX, ODS, XLS, XLSB and OSM PBF. More formats and loss kinds remain to add (ROADMAP.md); one loss
//! does not certify a reader.
use rustgis_engine::{Project, Session};
use serde_json::json;
Expand Down Expand Up @@ -396,6 +396,44 @@ fn cases(fixture_dir: &std::path::Path) -> Vec<Case> {
),
]);

out.extend([
case(
"XLS: a height in WKT",
"a.xls",
include_bytes!("../testdata/reading-losses/book-clean.xls"),
include_bytes!("../testdata/reading-losses/book-z.xls"),
Imported("Z or M"),
),
case(
"XLS: a WKT geometry collection's later members",
"a.xls",
include_bytes!("../testdata/reading-losses/book-clean.xls"),
include_bytes!("../testdata/reading-losses/book-collection.xls"),
Silent("only the collection's first member is kept"),
),
case(
"XLSB: a height in WKT",
"a.xlsb",
include_bytes!("../testdata/reading-losses/book-clean.xlsb"),
include_bytes!("../testdata/reading-losses/book-z.xlsb"),
Imported("Z or M"),
),
case(
"XLSB: short cell records lose attribute fields and values",
"a.xlsb",
include_bytes!("../testdata/reading-losses/book-clean.xlsb"),
include_bytes!("../testdata/reading-losses/book-short.xlsb"),
Silent("the point remains but all attribute fields and values are lost"),
),
case(
"XLSB: a WKT geometry collection's later members",
"a.xlsb",
include_bytes!("../testdata/reading-losses/book-clean.xlsb"),
include_bytes!("../testdata/reading-losses/book-collection.xlsb"),
Silent("only the collection's first member is kept"),
),
]);

// MapInfo: the .mid beside each .mif holds one row per object.
let mut mapinfo = |name, clean: &str, lossy: &str, mid: &str, expect| {
let mut c = case(name, "a.mif", mif(clean), mif(lossy), expect);
Expand Down Expand Up @@ -578,17 +616,22 @@ fn check_shapefile_xy(ds: &rustgis_engine::data::Dataset, shape_type: Option<u8>
Ok(())
}

/// All workbook variants retain the same point, row ID and two attribute columns. The
/// error-cell fixture differs from an empty note only in source content, not retained data.
fn check_workbook(ds: &rustgis_engine::data::Dataset) -> std::io::Result<()> {
/// Workbooks retain the point and two attributes except the pinned XLSB short-cell loss,
/// which retains the point but drops every attribute field and value.
fn check_workbook(ds: &rustgis_engine::data::Dataset, short_cells: bool) -> std::io::Result<()> {
use rustgis_engine::data::{Field, FieldType, Geometry, Value};
use rustgis_engine::geom::Coord;
if ds.fields != vec![Field::new("id", FieldType::Integer), Field::new("note", FieldType::Text)]
let fields = if short_cells { vec![] } else { vec![Field::new("id", FieldType::Integer), Field::new("note", FieldType::Text)] };
let attrs = if short_cells { vec![] } else { vec![Value::Int(7), Value::Null] };
Comment on lines +624 to +625

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Likely cargo fmt --check failure (medium confidence, Quality). rustfmt.toml keeps max_width = 140, so these lines fit that limit. The default single_line_if_else_max_width is 50, though, and both if short_cells { … } else { … } expressions are longer than that on one line, so rustfmt will most likely break them. I couldn't run rustfmt in this review, so please confirm with cargo fmt --check. If it does reflow, this is the expected layout:

Suggested change
let fields = if short_cells { vec![] } else { vec![Field::new("id", FieldType::Integer), Field::new("note", FieldType::Text)] };
let attrs = if short_cells { vec![] } else { vec![Value::Int(7), Value::Null] };
let fields = if short_cells {
vec![]
} else {
vec![Field::new("id", FieldType::Integer), Field::new("note", FieldType::Text)]
};
let attrs = if short_cells { vec![] } else { vec![Value::Int(7), Value::Null] };

Note: the attrs line is also over the 50-character if-else limit, so the suggestion above also breaks it onto the same multi-line layout. Adjust the suggestion if rustfmt's own output differs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Confirmed cargo fmt --all --check passes on b493947. The repository sets use_small_heuristics = "Max" alongside max_width = 140, so the default 50-character heuristic does not apply. The exact-head fork CI lint job and commit formatter hook also passed. No reflow is needed.

if ds.fields != fields
|| ds.features.len() != 1
|| ds.features[0].geometry != Some(Geometry::Point(Coord::new(1.0, 2.0)))
|| ds.features[0].attrs != vec![Value::Int(7), Value::Null]
|| ds.features[0].attrs != attrs
{
return Err(std::io::Error::other("spreadsheet fixture didn't retain exactly its point, ID and null note"));
return Err(std::io::Error::other(format!(
"spreadsheet fixture has unexpected retained data: fields={:?}, features={:?}",
ds.fields, ds.features
)));
}
Ok(())
}
Expand All @@ -609,6 +652,7 @@ fn read(dir: &std::path::Path, file: &str, content: &[u8], beside: &[(&str, Vec<
std::fs::write(dir.join(name), bytes)?;
}
let path = dir.join(file);
let short_cells = content == include_bytes!("../testdata/reading-losses/book-short.xlsb");
if file.ends_with(".gdb") {
// The archive is fixture storage only: RustGIS opens the extracted folder. Its ZIP
// importer deliberately refuses FileGDB folders, so do not test that refusal as a loss.
Expand Down Expand Up @@ -643,12 +687,14 @@ fn read(dir: &std::path::Path, file: &str, content: &[u8], beside: &[(&str, Vec<
return Err(std::io::Error::other("native Shapefile fixture skipped a record"));
}
}
if file.ends_with(".xlsx") || file.ends_with(".ods") {
if rustgis_engine::data::sheets::is_sheet_name(file) {
let (native, report) = rustgis_engine::data::sheets::read(content, "a", None, &Default::default())
.map_err(|e| std::io::Error::other(format!("native spreadsheet fixture: {e}")))?;
check_workbook(&native)?;
check_workbook(&native, short_cells)?;
let height = content == include_bytes!("../testdata/reading-losses/book-z.xlsx")
|| content == include_bytes!("../testdata/reading-losses/book-z.ods");
|| content == include_bytes!("../testdata/reading-losses/book-z.ods")
|| content == include_bytes!("../testdata/reading-losses/book-z.xls")
|| content == include_bytes!("../testdata/reading-losses/book-z.xlsb");
if report.skipped != 0
|| native.zm_dropped != height
|| if height { report.messages.len() != 1 || !report.messages[0].contains("Z or M") } else { !report.messages.is_empty() }
Expand All @@ -670,13 +716,15 @@ fn read(dir: &std::path::Path, file: &str, content: &[u8], beside: &[(&str, Vec<
}
check_shapefile_xy(&s.map().layers[0].dataset, content.get(32).copied())?;
}
if file.ends_with(".xlsx") || file.ends_with(".ods") {
if rustgis_engine::data::sheets::is_sheet_name(file) {
if s.map().layers.len() != 1 || !s.project.tables.is_empty() {
return Err(std::io::Error::other("spreadsheet fixture didn't add exactly one layer"));
}
check_workbook(&s.map().layers[0].dataset)?;
check_workbook(&s.map().layers[0].dataset, short_cells)?;
if (content == include_bytes!("../testdata/reading-losses/book-clean.xlsx")
|| content == include_bytes!("../testdata/reading-losses/book-clean.ods"))
|| content == include_bytes!("../testdata/reading-losses/book-clean.ods")
|| content == include_bytes!("../testdata/reading-losses/book-clean.xls")
|| content == include_bytes!("../testdata/reading-losses/book-clean.xlsb"))
&& !s.notices_since(mark).is_empty()
{
return Err(std::io::Error::other("clean spreadsheet fixture gave a notice"));
Expand Down
Loading