From 6320d80adb617e1455243e614820724d16e9b02e Mon Sep 17 00:00:00 2001 From: Li-Sheng Chou <142213184+choupeanut@users.noreply.github.com> Date: Fri, 27 Nov 2026 15:31:21 +0800 Subject: [PATCH 1/2] fix(data): a GeoPackage's BLOB columns and a File Geodatabase's binary and extra geometry columns are said when left out (#2916) --- crates/data/src/filegdb.rs | 23 +++++- crates/data/src/filegdb/tests.rs | 124 ++++++++++++++++++++++------- crates/data/src/source/gpkg.rs | 13 ++- crates/data/src/source/gpkg_mem.rs | 17 +++- crates/data/src/source/mod.rs | 36 +++++---- crates/data/src/source/tests.rs | 46 +++++++++++ docs/user-guide/data-formats.md | 4 +- 7 files changed, 210 insertions(+), 53 deletions(-) diff --git a/crates/data/src/filegdb.rs b/crates/data/src/filegdb.rs index 00f125b966..25150845a2 100644 --- a/crates/data/src/filegdb.rs +++ b/crates/data/src/filegdb.rs @@ -324,9 +324,22 @@ fn read_table(name: &str, t: &[u8], x: &[u8], wkid: Option) -> Result = Vec::new(); let mut columns: Vec = Vec::new(); + // The table's own geometry is its first geometry field; the fields with no type of ours are + // left out, and said below. + let geometry_at = table.fields.iter().position(|f| f.kind == Kind::Geometry); + let mut left_out: Vec<(String, String)> = Vec::new(); for (i, f) in table.fields.iter().enumerate() { let ty = match f.kind { - Kind::Geometry | Kind::Binary | Kind::Raster => continue, + Kind::Geometry if Some(i) == geometry_at => continue, + Kind::Geometry | Kind::Binary | Kind::Raster => { + let kind = match f.kind { + Kind::Geometry => "geometry", + Kind::Binary => "binary", + _ => "raster", + }; + left_out.push((f.name.clone(), kind.to_string())); + continue; + } Kind::Int16 | Kind::Int32 | Kind::Int64 | Kind::ObjectId => FieldType::Integer, Kind::Float32 | Kind::Float64 => FieldType::Double, Kind::Date | Kind::DateTimeOffset => FieldType::DateTime, @@ -337,6 +350,13 @@ fn read_table(name: &str, t: &[u8], x: &[u8], wkid: Option) -> Result) -> Result]) -> (Vec, Vec) f.extend(utf16_bytes(n)); f.push(0); }; + let shape = |f: &mut Vec, field_name: &str, z: bool, wkt: &str| { + name(f, field_name); + f.extend([7, 0, 7]); + let w = utf16_bytes(wkt); + f.extend((w.len() as i16).to_le_bytes()); + f.extend(w); + f.push(if z { 3 } else { 1 }); + for v in [0.0f64, 0.0, 1000.0] { + f.extend(v.to_le_bytes()); + } + if z { + f.extend(0.0f64.to_le_bytes()); + f.extend(1000.0f64.to_le_bytes()); + } + f.extend(0.001f64.to_le_bytes()); + if z { + f.extend(0.001f64.to_le_bytes()); + } + for v in [0.0f64, 0.0, 100.0, 100.0] { + f.extend(v.to_le_bytes()); + } + if layer_flags & 0x8000_0000 != 0 { + f.extend([0.0f64, 100.0].iter().flat_map(|v| v.to_le_bytes())); + } + f.push(0); + f.extend(1u32.to_le_bytes()); + f.extend(10.0f64.to_le_bytes()); + }; for field in fields { match field { F::Oid => { @@ -79,33 +114,11 @@ fn table(layer_flags: u32, fields: &[F], rows: &[Vec]) -> (Vec, Vec) name(&mut f, n); f.extend([*kind, 8, 5, 0]); } - F::Shape { z, wkt } => { - name(&mut f, "SHAPE"); - f.extend([7, 0, 7]); - let w = utf16_bytes(wkt); - f.extend((w.len() as i16).to_le_bytes()); - f.extend(w); - f.push(if *z { 3 } else { 1 }); - for v in [0.0f64, 0.0, 1000.0] { - f.extend(v.to_le_bytes()); - } - if *z { - f.extend(0.0f64.to_le_bytes()); - f.extend(1000.0f64.to_le_bytes()); - } - f.extend(0.001f64.to_le_bytes()); - if *z { - f.extend(0.001f64.to_le_bytes()); - } - for v in [0.0f64, 0.0, 100.0, 100.0] { - f.extend(v.to_le_bytes()); - } - if layer_flags & 0x8000_0000 != 0 { - f.extend([0.0f64, 100.0].iter().flat_map(|v| v.to_le_bytes())); - } - f.push(0); - f.extend(1u32.to_le_bytes()); - f.extend(10.0f64.to_le_bytes()); + F::Shape { z, wkt } => shape(&mut f, "SHAPE", *z, wkt), + F::Shape2(n) => shape(&mut f, n, false, ""), + F::Blob(n) => { + name(&mut f, n); + f.extend([8, 0, 5]); } } } @@ -956,3 +969,58 @@ fn filegdb_temporal_fields_keep_days_offsets_and_null_notices() { } } } + +/// A binary field and a geometry field after the first are left out of the layer, and said, once +/// for the table and by its name; a table without them says nothing (#2916). +#[test] +fn binary_and_extra_geometry_fields_are_said_and_left_out() { + let square = || V::Blob(polygon(&square(0.0, 0.0, 10.0))); + let shape = F::Shape { z: false, wkt: LONLAT }; + let said = |fields: &[F], row: Vec, name: &'static str| { + let files = geodatabase(vec![(name, table(4, fields, &[row]))]); + let layers = read_files(&files).unwrap(); + let (ds, report) = layers.into_iter().next().unwrap(); + let names: Vec = ds.fields.iter().map(|f| f.name.clone()).collect(); + assert!(matches!(&ds.features[0].geometry, Some(Geometry::Polygon(_))), "{:?}", ds.features[0].geometry); + assert_eq!(report.skipped, 0, "{report:?}"); + (names, report.messages.texts().map(str::to_string).collect::>()) + }; + // One binary field: the values after it keep their place. + let (names, messages) = + said(&[F::Oid, shape, F::Blob("scan"), F::Text("name")], vec![square(), V::Blob(vec![1, 2, 3]), V::Text(Some("a"))], "photos"); + assert_eq!(names, ["OBJECTID", "name"]); + assert_eq!(messages, ["photos: 1 column of a type RustGIS has no field for was left out: scan (binary)"]); + // A binary field and a second geometry field, each named with its kind. + let (names, messages) = said( + &[F::Oid, F::Shape { z: false, wkt: LONLAT }, F::Text("name"), F::Blob("scan"), F::Shape2("Shape_2")], + vec![square(), V::Text(Some("a")), V::Blob(vec![9]), square()], + "photos", + ); + assert_eq!(names, ["OBJECTID", "name"]); + assert_eq!(messages, ["photos: 2 columns of types RustGIS has no field for were left out: scan (binary), Shape_2 (geometry)"]); + // Thirteen are counted and the first twelve named. + let blobs: Vec<&'static str> = ["b01", "b02", "b03", "b04", "b05", "b06", "b07", "b08", "b09", "b10", "b11", "b12", "b13"].into(); + let mut fields = vec![F::Oid, F::Shape { z: false, wkt: LONLAT }]; + fields.extend(blobs.iter().map(|n| F::Blob(n))); + let mut row = vec![square()]; + row.extend(blobs.iter().map(|_| V::Blob(Vec::new()))); + let (_, messages) = said(&fields, row, "many"); + let named: Vec = blobs.iter().take(12).map(|n| format!("{n} (binary)")).collect(); + assert_eq!(messages, [format!("many: 13 columns of types RustGIS has no field for were left out: {} and 1 more", named.join(", "))]); + // Nothing left out: nothing said. + let (names, messages) = + said(&[F::Oid, F::Shape { z: false, wkt: LONLAT }, F::Text("name")], vec![square(), V::Text(Some("a"))], "clean"); + assert_eq!(names, ["OBJECTID", "name"]); + assert!(messages.is_empty(), "{messages:?}"); + // Two tables with the same field each say it: the table's name tells them apart. + let one = |name| (name, table(4, &[F::Oid, F::Shape { z: false, wkt: LONLAT }, F::Blob("scan")], &[vec![square(), V::Blob(vec![1])]])); + let layers = read_files(&geodatabase(vec![one("north"), one("south")])).unwrap(); + let all: Vec = layers.iter().flat_map(|(_, r)| r.messages.texts().map(str::to_string)).collect(); + assert_eq!( + all, + [ + "north: 1 column of a type RustGIS has no field for was left out: scan (binary)", + "south: 1 column of a type RustGIS has no field for was left out: scan (binary)" + ] + ); +} diff --git a/crates/data/src/source/gpkg.rs b/crates/data/src/source/gpkg.rs index 441335aab3..106c65959a 100644 --- a/crates/data/src/source/gpkg.rs +++ b/crates/data/src/source/gpkg.rs @@ -280,6 +280,8 @@ impl GpkgSource { // Columns: the primary key, the geometry and the attribute fields. let mut pk = None; let mut fields = Vec::new(); + // The columns with no field type (BLOB), which reading leaves out. + let mut left_out = Vec::new(); { let mut st = conn.prepare(&format!("PRAGMA table_info({})", quote(&table))).map_err(err)?; let cols = st @@ -294,8 +296,9 @@ impl GpkgSource { pk = Some(name); continue; } - if let Some(ty) = field_type(&decl) { - fields.push(Field::new(name, ty)); + match field_type(&decl) { + Some(ty) => fields.push(Field::new(name, ty)), + None => left_out.push((name, "binary".to_string())), } } } @@ -354,7 +357,7 @@ impl GpkgSource { "POLYGON" | "MULTIPOLYGON" | "SURFACE" | "MULTISURFACE" => GeometryType::Polygon, _ => GeometryType::None, }; - let info = SourceInfo { + let mut info = SourceInfo { name: table.clone(), format: "GeoPackage", geometry_type, @@ -368,6 +371,10 @@ impl GpkgSource { notes, zm_dropped: false, }; + info.note_columns( + &left_out, + ["of a type RustGIS has no field for was left out", "of types RustGIS has no field for were left out"], + ); let file = Some((path.to_path_buf(), id)); let mut src = GpkgSource { info, diff --git a/crates/data/src/source/gpkg_mem.rs b/crates/data/src/source/gpkg_mem.rs index f90c216e44..483c41038d 100644 --- a/crates/data/src/source/gpkg_mem.rs +++ b/crates/data/src/source/gpkg_mem.rs @@ -191,13 +191,18 @@ impl GpkgMemSource { .ok_or_else(|| DataError::Format(format!("GeoPackage: no column '{geom}' in {table_name}")))?; let mut fields = Vec::new(); let mut field_cols = Vec::new(); + // The columns with no field type (BLOB), which reading leaves out. + let mut left_out = Vec::new(); for (i, c) in table.columns.iter().enumerate() { if i == geom_col || Some(i) == table.rowid_column { continue; } - if let Some(ty) = super::gpkg_blob::field_type(&c.decl) { - fields.push(Field::new(c.name.clone(), ty)); - field_cols.push(i); + match super::gpkg_blob::field_type(&c.decl) { + Some(ty) => { + fields.push(Field::new(c.name.clone(), ty)); + field_cols.push(i); + } + None => left_out.push((c.name.clone(), "binary".to_string())), } } let contents = meta_rows(&db, &schema, "gpkg_contents").unwrap_or_default(); @@ -211,7 +216,7 @@ impl GpkgMemSource { "POLYGON" | "MULTIPOLYGON" | "SURFACE" | "MULTISURFACE" => GeometryType::Polygon, _ => GeometryType::None, }; - let info = SourceInfo { + let mut info = SourceInfo { name: table_name, format: "GeoPackage", geometry_type, @@ -225,6 +230,10 @@ impl GpkgMemSource { notes, zm_dropped: false, }; + info.note_columns( + &left_out, + ["of a type RustGIS has no field for was left out", "of types RustGIS has no field for were left out"], + ); let mut src = GpkgMemSource { info, db, table, geom_col, field_cols, reproject }; // The extent the file declares, else the envelopes in the geometry headers. let native = match declared.filter(|e| !e.is_empty()) { diff --git a/crates/data/src/source/mod.rs b/crates/data/src/source/mod.rs index 9e587ba986..3af146d1ac 100644 --- a/crates/data/src/source/mod.rs +++ b/crates/data/src/source/mod.rs @@ -189,21 +189,12 @@ impl SourceInfo { } } - /// Notes what happened to some columns in one note, counting them and naming the first 12 - /// with their kind ("price (decimal)"): `what` says it for one column, then for several. - /// Nothing when there are none. + /// Notes what happened to some columns in one note ([`columns_note`]). Nothing when there are + /// none. pub(crate) fn note_columns(&mut self, cols: &[(String, String)], what: [&str; 2]) { - const NAMED: usize = 12; - let [one, several] = what; - let n = cols.len(); - let what = match n { - 0 => return, - 1 => one, - _ => several, - }; - let named: Vec = cols.iter().take(NAMED).map(|(name, kind)| format!("{name} ({kind})")).collect(); - let more = if n > NAMED { format!(" and {} more", n - NAMED) } else { String::new() }; - self.notes.push(format!("{n} column{} {what}: {}{more}", if n == 1 { "" } else { "s" }, named.join(", "))); + if let Some(note) = columns_note(cols, what) { + self.notes.push(note); + } } /// The source's coordinate system, when it isn't longitude/latitude: one known by its EPSG @@ -213,6 +204,23 @@ impl SourceInfo { } } +/// The note of some columns a reader left out, counting them and naming the first 12 with their +/// kind ("photo (binary)"): `what` says it for one column, then for several. `None` when there +/// are none. +pub(crate) fn columns_note(cols: &[(String, String)], what: [&str; 2]) -> Option { + const NAMED: usize = 12; + let [one, several] = what; + let n = cols.len(); + let what = match n { + 0 => return None, + 1 => one, + _ => several, + }; + let named: Vec = cols.iter().take(NAMED).map(|(name, kind)| format!("{name} ({kind})")).collect(); + let more = if n > NAMED { format!(" and {} more", n - NAMED) } else { String::new() }; + Some(format!("{n} column{} {what}: {}{more}", if n == 1 { "" } else { "s" }, named.join(", "))) +} + /// A read: the features intersecting `extent` (longitude/latitude; `None` = all), at most `limit`. /// A zero-limit count may be refused when matching would require a full geometry scan. #[derive(Clone, Copy, Debug, PartialEq)] diff --git a/crates/data/src/source/tests.rs b/crates/data/src/source/tests.rs index 43cb396a54..35daae1eeb 100644 --- a/crates/data/src/source/tests.rs +++ b/crates/data/src/source/tests.rs @@ -3935,6 +3935,52 @@ fn flatgeobuf_binary_columns_are_said_and_left_out() { assert!(src.info().notes.is_empty(), "{:?}", src.info().notes); } +/// A GeoPackage's BLOB columns, which RustGIS has no field type for, are said and left out by the +/// desktop reader and the browser's alike, the columns after them keeping their values; a table +/// without one says nothing (#2916). +#[test] +fn geopackage_blob_columns_are_said_and_left_out() { + let d = tempfile::tempdir().unwrap(); + let blobs = |n: usize| { + let path = d.path().join(format!("blobs{n}.gpkg")); + write_gpkg(&path, false); + let c = rusqlite::Connection::open(&path).unwrap(); + for i in 1..=n { + c.execute_batch(&format!( + "ALTER TABLE \"grid \"\"q\"\"\" ADD COLUMN b{i:02} BLOB; ALTER TABLE \"grid \"\"q\"\"\" ADD COLUMN after{i:02} TEXT;" + )) + .unwrap(); + } + path + }; + let notes = |path: &Path| { + let bytes = Shared(Arc::new(std::fs::read(path).unwrap())); + let mem = gpkg_mem::GpkgMemSource::open_shared(bytes, None).unwrap(); + let sql = open_path(path, None).unwrap(); + let said = |s: &dyn FeatureSource| s.info().notes.texts().map(str::to_string).collect::>(); + assert_eq!(said(&mem), said(sql.as_ref()), "the browser's reader says what the desktop's does"); + let fields: Vec = sql.info().fields.iter().map(|f| f.name.clone()).collect(); + assert_eq!(mem.info().fields, sql.info().fields); + // Read whole, the layer's name goes before it. + let (_, report) = materialize(sql.as_ref()).unwrap(); + (said(sql.as_ref()), fields, report.messages.texts().map(str::to_string).collect::>()) + }; + let one = notes(&blobs(1)); + assert_eq!(one.0, ["1 column of a type RustGIS has no field for was left out: b01 (binary)"]); + assert_eq!(one.1, ["name", "value", "ok", "after01"]); + assert_eq!(one.2, [format!("grid \"q\": {}", one.0[0])]); + let two = notes(&blobs(2)); + assert_eq!(two.0, ["2 columns of types RustGIS has no field for were left out: b01 (binary), b02 (binary)"]); + let many = notes(&blobs(13)); + let named: Vec = (1..=12).map(|i| format!("b{i:02} (binary)")).collect(); + assert_eq!(many.0, [format!("13 columns of types RustGIS has no field for were left out: {} and 1 more", named.join(", "))]); + // The table as the fixture writes it: nothing is left out, nothing said. + let clean = d.path().join("clean.gpkg"); + write_gpkg(&clean, false); + let none = notes(&clean); + assert!(none.0.is_empty() && none.2.is_empty(), "{none:?}"); +} + /// The tables of a GeoPackage, by name. fn gpkg_tables(path: &Path) -> Vec { let c = rusqlite::Connection::open(path).unwrap(); diff --git a/docs/user-guide/data-formats.md b/docs/user-guide/data-formats.md index 74e45c0a7a..642daa5579 100644 --- a/docs/user-guide/data-formats.md +++ b/docs/user-guide/data-formats.md @@ -38,10 +38,10 @@ export names its feature. | AutoCAD DXF | `.dxf` (ASCII) | Add Data › DXF…, drop the file, or upload | Points, lines and polygons layers from the drawing's entities: POINT, LINE, LWPOLYLINE and POLYLINE (bulges drawn as arcs; closed ones stay lines; polyface meshes become polygons), CIRCLE, ARC, ELLIPSE, SPLINE, HELIX, LEADER, MLINE (its centre line), TEXT, MTEXT, ATTRIB and constant ATTDEF (points with their text, at the alignment point of justified text), HATCH boundaries (holes found by nesting), SOLID, TRACE and 3DFACE (polygons). Blocks (named in any case) are drawn where INSERTs place them (scaled, rotated, in arrays, nested up to 8 deep), and so are DIMENSIONs' blocks (a linear dimension without one draws its lines and measured text); `"blocks": false` leaves them out, with a notice of how many. Entities in an object's own coordinate system are turned into the drawing's. Fields: `layer`, `entity`, `color` (ACI, BYLAYER and BYBLOCK resolved), `linetype`, `text`, `height`, `rotation`, `block`, `elevation` and `paperspace`. `elevation` keeps the first placed vertex's height; varying heights are dropped with a counted notice. Unreadable POLYLINE XY vertices are left out with a counted notice. In a 3D POLYLINE, a vertex whose supplied Z cannot be read is also left out; an absent Z still means zero. Spline-path vertices without Y, short HATCH rings and coordinates beyond the per-entity limit in LWPOLYLINE/POLYLINE paths and bulged HATCH boundaries are left out with counted notices. The drawing's layouts (paper space: title blocks, viewport frames) are left out, with a notice, unless `"paperSpace": true`. A drawing never says its coordinate system: give `"crs"` (such as `EPSG:2263`) — the import dialog offers the map's — or its coordinates are kept as they are, with a notice. `"layer"` picks one of the drawing's own layers, and `info.fileLayers` lists them. Text is read as UTF-8, and otherwise in the drawing's `$DWGCODEPAGE` (GBK, Big5, Shift_JIS, Windows-1252…), so Chinese layer names and labels come through; an unknown or missing code page is read as Latin-1, with a notice. Up to 2 million features (500,000 in the web app). Not read: binary DXF, MULTILEADER, WIPEOUT, IMAGE and ACIS solids (3DSOLID, REGION), named in a notice. | | Geotagged photos | `.jpg`, `.jpeg` | Add Data (several at once in the web app), drop them, upload, or `layer.addPhotos` with `"paths"` or a `"folder"` | JPEGs with a GPS position in their EXIF become points in the **Photos** layer (photos added one at a time join it): each with its `name`, `file`, `time` (when it was taken), `altitude`, `direction` (where the camera faced), `camera` and a `thumbnail` of at most 160 pixels, kept with the feature so the project needs no other file. Identify shows the thumbnail. Photos without a position are named in a notice and left out; a layer holds up to 2,000 photos. A JPEG is always read as a photo unless `layer.addData` or `layer.addDataBytes` is given `"as": "scan"` (a phone photo of a paper map, say: see [Scans with no coordinates](#rasters)). | | LiDAR point clouds | `.las`, `.laz` (COPC too) | Add Data, drop the file, upload, or From URL… | LAS 1.0–1.4 (point formats 0–10) and LAZ, on desktop and web: points with `z`, `intensity`, `classification`, `return` and colour (`red`, `green`, `blue`), coloured by ASPRS class or elevation. An evenly spread sample is read once, at most 2 million points (500,000 in the web app); views use that sample, not the COPC spatial index. LAZ decompression reads at most the first 400 million points (40 million on the web), with a notice when capped. Held in the system of the file's WKT or GeoTIFF-key record, as the file holds its points; without one, coordinates are kept as longitude/latitude, with a notice when they aren't. Points with no place in longitude/latitude are kept and counted ([below](#places-with-no-longitudelatitude)); points with a coordinate that isn't a number are left out and counted. A local project keeps the path; uploads keep the file bytes. Remote files download whole. | -| GeoPackage | `.gpkg` | Add Data, or upload in the web app | Local files and browser uploads add every feature table, up to 32 (with the rest counted in `skippedCount` and up to 100 named in `skipped`); `"layer"` picks one, and `info.fileLayers` lists them. Desktop byte uploads and downloads add the first table unless `"layer"` names another. Large local tables use their R-tree. Rows with no geometry (NULL or empty) are kept, with their attributes, in whole reads and exports; a read of an extent leaves them out, as they have no location. A table is read in its coordinate system: by its EPSG code, or, for a system without one (or with a code RustGIS doesn't know), by the WKT definition the file gives it (the WKT2 of GeoPackage 1.2's `definition_12_063` first, as the specification says, else `definition`). The definition also comes before the code when it gives another datum transformation than the code's, or describes another body's system. This holds on the desktop and in the web app alike (an azimuthal equidistant system opens on the desktop only, and the web app says so). Browser tables are scanned, testing each geometry header's envelope first; UTF-16 databases aren't read there. Raster tile tables aren't imported. `DATE` and `DATETIME` columns are read as dates and date-times (ISO 8601 text, as GeoPackage stores them); a value that isn't one is empty and counted in a notice. | +| GeoPackage | `.gpkg` | Add Data, or upload in the web app | Local files and browser uploads add every feature table, up to 32 (with the rest counted in `skippedCount` and up to 100 named in `skipped`); `"layer"` picks one, and `info.fileLayers` lists them. Desktop byte uploads and downloads add the first table unless `"layer"` names another. Large local tables use their R-tree. Rows with no geometry (NULL or empty) are kept, with their attributes, in whole reads and exports; a read of an extent leaves them out, as they have no location. A table is read in its coordinate system: by its EPSG code, or, for a system without one (or with a code RustGIS doesn't know), by the WKT definition the file gives it (the WKT2 of GeoPackage 1.2's `definition_12_063` first, as the specification says, else `definition`). The definition also comes before the code when it gives another datum transformation than the code's, or describes another body's system. This holds on the desktop and in the web app alike (an azimuthal equidistant system opens on the desktop only, and the web app says so). Browser tables are scanned, testing each geometry header's envelope first; UTF-16 databases aren't read there. Raster tile tables aren't imported. A `BLOB` column other than the geometry is left out, with a notice counting such columns and naming the first 12. `DATE` and `DATETIME` columns are read as dates and date-times (ISO 8601 text, as GeoPackage stores them); a value that isn't one is empty and counted in a notice. | | GeoParquet | `.parquet`, `.geoparquet` | Add Data, or upload in the web app | WKB geometry, with the CRS from the file's `geo` metadata. A binary geometry column is required; plain non-spatial Parquet tables and GeoArrow-native geometry encodings aren't read by this importer. Row groups are pruned by the bbox covering. Whole reads and exports retain rows with null geometry and their attributes; extent-filtered reads exclude them because they have no location. Snappy, gzip, LZ4 and zstd compression are read, in the browser too; Brotli isn't. Text, whole-number, floating-point and true/false columns become fields, as do decimals stored as 32- or 64-bit integers (up to 18 digits), read as floating-point numbers. Dates and times stored as 32- or 64-bit integers are read as those whole numbers (such as milliseconds since 1970). Other columns are left out: decimals stored as bytes (how many writers store every decimal), binary, lists, maps, structs, INT96 timestamps and further geometry columns. A notice gives how many were left out and names the first 12, each with its kind; another names the date and time columns with their unit. | | FlatGeobuf | `.fgb` | Add Data, or upload | Read in place by its packed R-tree. Binary columns are left out, with a notice counting them and naming the first 12. Coordinates use the header's EPSG code, else its WKT, as a GeoPackage's system does: the WKT comes first when it gives another datum transformation than the code's, or another body's system, and a grid shift it gives beside the code isn't applied, with a notice. Another organization's code (an `ESRI` one, say) or a negative code without a WKT is read as longitude/latitude, with a notice. Another body's IAU code without a WKT is read with a notice, or refused when its coordinates are projected; with a WKT, the WKT is read (see coordinate systems of other bodies, below). | -| Esri File Geodatabase | `.gdb` folder (desktop) | In Add Data pick a `.gdbtable` file inside it; or double-click the `.gdb` in the Browser, or drop the folder | The native reader loads up to 512 feature classes and tables, up to 2 GiB per table. Feature classes become layers and non-spatial tables standalone tables; dates are text. Coordinates use the EPSG/Esri code, else WKT; the WKT comes first when it gives another datum transformation than an EPSG code's, or another body's system. An Esri-only code still comes first, as ArcGIS keeps transformations apart from the system, with a notice when the WKT gives another one; a grid shift the WKT gives isn't applied, with a notice. `"layer"` picks one; `info.fileLayers` lists them. Multipatches become footprints with `z_min`, `z_max` and `height`; large or wall-only ones may use a convex hull. Curves become straight segments between their ends. Unreadable tables (compressed storage, raster fields or unsupported row indexes) are tried through GDAL when installed; otherwise they are named in a notice. | +| Esri File Geodatabase | `.gdb` folder (desktop) | In Add Data pick a `.gdbtable` file inside it; or double-click the `.gdb` in the Browser, or drop the folder | The native reader loads up to 512 feature classes and tables, up to 2 GiB per table. Feature classes become layers and non-spatial tables standalone tables; dates are text. Coordinates use the EPSG/Esri code, else WKT; the WKT comes first when it gives another datum transformation than an EPSG code's, or another body's system. An Esri-only code still comes first, as ArcGIS keeps transformations apart from the system, with a notice when the WKT gives another one; a grid shift the WKT gives isn't applied, with a notice. `"layer"` picks one; `info.fileLayers` lists them. A binary field, and a geometry field after the first, is left out, with a notice (by the table's name) counting them and naming the first 12; a table with a raster field isn't read natively and is said as not read. Multipatches become footprints with `z_min`, `z_max` and `height`; large or wall-only ones may use a convex hull. Curves become straight segments between their ends. Unreadable tables (compressed storage, raster fields or unsupported row indexes) are tried through GDAL when installed; otherwise they are named in a notice. | | Standalone tables | CSV, or any layer without geometry | Add Data | Listed under the map in Layers; join or relate them to layers. | Text is read as the file has it: spaces around a value are kept, as GeoPackage, GeoParquet and From 0cb7d36cbf471091c749dd508986ee5606c8b7e5 Mon Sep 17 00:00:00 2001 From: Li-Sheng Chou <142213184+choupeanut@users.noreply.github.com> Date: Fri, 27 Nov 2026 15:47:43 +0800 Subject: [PATCH 2/2] fix(data): name each left-out File Geodatabase field kind outright; tidy the docs row (#2916) --- crates/data/src/filegdb.rs | 19 ++++++++++++------- docs/user-guide/data-formats.md | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/crates/data/src/filegdb.rs b/crates/data/src/filegdb.rs index 25150845a2..592f5e51f0 100644 --- a/crates/data/src/filegdb.rs +++ b/crates/data/src/filegdb.rs @@ -331,13 +331,18 @@ fn read_table(name: &str, t: &[u8], x: &[u8], wkid: Option) -> Result continue, - Kind::Geometry | Kind::Binary | Kind::Raster => { - let kind = match f.kind { - Kind::Geometry => "geometry", - Kind::Binary => "binary", - _ => "raster", - }; - left_out.push((f.name.clone(), kind.to_string())); + // A raster field is never read here (`Table::parse` refuses the table), but a kind that + // is left out is named whatever the parser does. + Kind::Geometry => { + left_out.push((f.name.clone(), "geometry".to_string())); + continue; + } + Kind::Binary => { + left_out.push((f.name.clone(), "binary".to_string())); + continue; + } + Kind::Raster => { + left_out.push((f.name.clone(), "raster".to_string())); continue; } Kind::Int16 | Kind::Int32 | Kind::Int64 | Kind::ObjectId => FieldType::Integer, diff --git a/docs/user-guide/data-formats.md b/docs/user-guide/data-formats.md index 642daa5579..cfb77d561d 100644 --- a/docs/user-guide/data-formats.md +++ b/docs/user-guide/data-formats.md @@ -41,7 +41,7 @@ export names its feature. | GeoPackage | `.gpkg` | Add Data, or upload in the web app | Local files and browser uploads add every feature table, up to 32 (with the rest counted in `skippedCount` and up to 100 named in `skipped`); `"layer"` picks one, and `info.fileLayers` lists them. Desktop byte uploads and downloads add the first table unless `"layer"` names another. Large local tables use their R-tree. Rows with no geometry (NULL or empty) are kept, with their attributes, in whole reads and exports; a read of an extent leaves them out, as they have no location. A table is read in its coordinate system: by its EPSG code, or, for a system without one (or with a code RustGIS doesn't know), by the WKT definition the file gives it (the WKT2 of GeoPackage 1.2's `definition_12_063` first, as the specification says, else `definition`). The definition also comes before the code when it gives another datum transformation than the code's, or describes another body's system. This holds on the desktop and in the web app alike (an azimuthal equidistant system opens on the desktop only, and the web app says so). Browser tables are scanned, testing each geometry header's envelope first; UTF-16 databases aren't read there. Raster tile tables aren't imported. A `BLOB` column other than the geometry is left out, with a notice counting such columns and naming the first 12. `DATE` and `DATETIME` columns are read as dates and date-times (ISO 8601 text, as GeoPackage stores them); a value that isn't one is empty and counted in a notice. | | GeoParquet | `.parquet`, `.geoparquet` | Add Data, or upload in the web app | WKB geometry, with the CRS from the file's `geo` metadata. A binary geometry column is required; plain non-spatial Parquet tables and GeoArrow-native geometry encodings aren't read by this importer. Row groups are pruned by the bbox covering. Whole reads and exports retain rows with null geometry and their attributes; extent-filtered reads exclude them because they have no location. Snappy, gzip, LZ4 and zstd compression are read, in the browser too; Brotli isn't. Text, whole-number, floating-point and true/false columns become fields, as do decimals stored as 32- or 64-bit integers (up to 18 digits), read as floating-point numbers. Dates and times stored as 32- or 64-bit integers are read as those whole numbers (such as milliseconds since 1970). Other columns are left out: decimals stored as bytes (how many writers store every decimal), binary, lists, maps, structs, INT96 timestamps and further geometry columns. A notice gives how many were left out and names the first 12, each with its kind; another names the date and time columns with their unit. | | FlatGeobuf | `.fgb` | Add Data, or upload | Read in place by its packed R-tree. Binary columns are left out, with a notice counting them and naming the first 12. Coordinates use the header's EPSG code, else its WKT, as a GeoPackage's system does: the WKT comes first when it gives another datum transformation than the code's, or another body's system, and a grid shift it gives beside the code isn't applied, with a notice. Another organization's code (an `ESRI` one, say) or a negative code without a WKT is read as longitude/latitude, with a notice. Another body's IAU code without a WKT is read with a notice, or refused when its coordinates are projected; with a WKT, the WKT is read (see coordinate systems of other bodies, below). | -| Esri File Geodatabase | `.gdb` folder (desktop) | In Add Data pick a `.gdbtable` file inside it; or double-click the `.gdb` in the Browser, or drop the folder | The native reader loads up to 512 feature classes and tables, up to 2 GiB per table. Feature classes become layers and non-spatial tables standalone tables; dates are text. Coordinates use the EPSG/Esri code, else WKT; the WKT comes first when it gives another datum transformation than an EPSG code's, or another body's system. An Esri-only code still comes first, as ArcGIS keeps transformations apart from the system, with a notice when the WKT gives another one; a grid shift the WKT gives isn't applied, with a notice. `"layer"` picks one; `info.fileLayers` lists them. A binary field, and a geometry field after the first, is left out, with a notice (by the table's name) counting them and naming the first 12; a table with a raster field isn't read natively and is said as not read. Multipatches become footprints with `z_min`, `z_max` and `height`; large or wall-only ones may use a convex hull. Curves become straight segments between their ends. Unreadable tables (compressed storage, raster fields or unsupported row indexes) are tried through GDAL when installed; otherwise they are named in a notice. | +| Esri File Geodatabase | `.gdb` folder (desktop) | In Add Data pick a `.gdbtable` file inside it; or double-click the `.gdb` in the Browser, or drop the folder | The native reader loads up to 512 feature classes and tables, up to 2 GiB per table. Feature classes become layers and non-spatial tables standalone tables; dates are text. Coordinates use the EPSG/Esri code, else WKT; the WKT comes first when it gives another datum transformation than an EPSG code's, or another body's system. An Esri-only code still comes first, as ArcGIS keeps transformations apart from the system, with a notice when the WKT gives another one; a grid shift the WKT gives isn't applied, with a notice. `"layer"` picks one; `info.fileLayers` lists them. Binary fields, and geometry fields after the first, are left out, with a notice (by the table's name) counting them and naming the first 12. Multipatches become footprints with `z_min`, `z_max` and `height`; large or wall-only ones may use a convex hull. Curves become straight segments between their ends. Unreadable tables (compressed storage, raster fields or unsupported row indexes) are tried through GDAL when installed; otherwise they are named in a notice. | | Standalone tables | CSV, or any layer without geometry | Add Data | Listed under the map in Layers; join or relate them to layers. | Text is read as the file has it: spaces around a value are kept, as GeoPackage, GeoParquet and