Repository navigation
fix(data): keep GeoPackage rows without geometry #1673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
8911ef7
2334e48
d7eb5ab
d0d1c3d
c587620
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,9 +4,21 @@ | |
| use crate::FieldType; | ||
| use rustgis_geom::Extent; | ||
|
|
||
| /// A GeoPackage geometry blob flagged empty: valid, with nothing to draw. | ||
| /// A GeoPackage geometry blob flagged empty: valid, with nothing to draw. Its header must be | ||
| /// whole (8 bytes and the envelope its flags give); a cut-off one is unreadable, not empty. | ||
| pub(crate) fn is_empty_blob(b: &[u8]) -> bool { | ||
| b.starts_with(b"GP") && b.get(3).is_some_and(|f| f & 0b1_0000 != 0) | ||
| b.starts_with(b"GP") && b.get(3).is_some_and(|&f| f & 0b1_0000 != 0 && envelope_len(f).is_some_and(|n| b.len() >= 8 + n)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Behaviour change outside the readers (Bugs, medium confidence).
Failing the save may well be the right outcome for a malformed row, and it matches the "unusable results are errors" rule. But it is a change to the write path that the PR description doesn't mention and no test covers. Either scope the stricter check to the readers and keep the editor's predicate as it was, or add an editor test for a cut-off empty blob (attribute edit on that row, and an R-tree maintenance check) and say in the PR what the user now sees.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. Fixed in d7eb5ab: |
||
| } | ||
|
|
||
| /// The length of the envelope a header's flags give; `None` for a code the standard doesn't define. | ||
| fn envelope_len(flags: u8) -> Option<usize> { | ||
| match (flags >> 1) & 0b111 { | ||
| 0 => Some(0), | ||
| 1 => Some(32), | ||
| 2 | 3 => Some(48), | ||
| 4 => Some(64), | ||
| _ => None, | ||
| } | ||
| } | ||
|
|
||
| /// A GeoPackage geometry blob: the header's envelope (if any) and the WKB after it. | ||
|
|
@@ -18,13 +30,7 @@ pub(crate) fn split_blob(b: &[u8]) -> Option<(Option<Extent>, &[u8])> { | |
| } | ||
| let &flags = rest.get(1)?; | ||
| let little = flags & 1 == 1; | ||
| let env_len = match (flags >> 1) & 0b111 { | ||
| 0 => 0, | ||
| 1 => 32, | ||
| 2 | 3 => 48, | ||
| 4 => 64, | ||
| _ => return None, | ||
| }; | ||
| let env_len = envelope_len(flags)?; | ||
| if flags & 0b1_0000 != 0 { | ||
| // The empty flag. | ||
| return None; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.