MarshalTWKB writes incorrect output for empty geometries
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- go
- Ambito
- data-engineering
Direzione di ricerca
The bug is in the TWKB encoder: start with writeAdditionalHeaders and writeMultiPoint in the TWKB marshalling code, and check how w.isEmpty is set. Reproduce with MarshalTWKB on POINT EMPTY and MULTIPOINT(EMPTY,5 5) and round-trip through UnmarshalTWKB. Done means empty geometries emit no size or bounding box bytes, and the MultiPoint empty-point case is resolved (skip or error) with tests covering the ID-list interaction.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
MarshalTWKB has two bugs involving empty geometries. Both reproduce on master at ce2170a.
Stray size and bounding box bytes after an empty geometry
An empty geometry is written with only the "is empty" bit set in its metadata header, so the header doesn't declare a size or a bounding box. writeAdditionalHeaders still runs afterwards and appends them when TWKBSizeHeader() or TWKBBoundingBoxHeader() is used.
| Geometry | Option | Output | Expected |
|---|---|---|---|
POINT EMPTY |
size | 011000 |
0110 |
POINT EMPTY |
bbox | 011000000000 |
0110 |
GEOMETRYCOLLECTION EMPTY |
bbox | 071000000000 |
0710 |
At the top level the extra bytes trail the geometry and UnmarshalTWKB ignores them. Inside a collection they sit in front of the next child and break parsing:
g, _ := geom.UnmarshalWKT("GEOMETRYCOLLECTION(POINT EMPTY,POINT(1 1))")
b, _ := geom.MarshalTWKB(g, 0, geom.TWKBSizeHeader())
// b is 070209020110000102020202. The empty point is written as 01 10 00.
_, err := geom.UnmarshalTWKB(b)
// TWKB parsing error at byte 12: unsupported geometry type 0
A likely fix is for writeAdditionalHeaders to return early when w.isEmpty is set.
Empty points in a MultiPoint are written as (0 0)
writeMultiPoint writes the coordinates of every point without checking whether the point is empty, so an empty point comes out as zeros:
g, _ := geom.UnmarshalWKT("MULTIPOINT(EMPTY,5 5)")
b, _ := geom.MarshalTWKB(g, 0)
// b is 04000200000a0a
back, _ := geom.UnmarshalTWKB(b)
// back is MULTIPOINT((0 0),(5 5))
With TWKBBoundingBoxHeader() the bounding box is (0 0)-(5 5) instead of (5 5)-(5 5). Once #720 is merged, that box also widens the bounding box of an enclosing GeometryCollection.
TWKB stores a MultiPoint as a count followed by coordinates, so it doesn't have a way to mark one of the points as empty. The options are to skip empty points or to return an error. Skipping changes the point count, which matters when TWKBIDList is used, because the ID list has to match the number of points.
- Lingua principale
- Go
- Stelle
- 176
- Fork
- 27
- Merge medio
- 1g 14h
- PR unite (30g)
- 4
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di peterstace/simplefeatures
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
peterstace/simplefeatures#726 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
peterstace/simplefeatures#725 ·
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
peterstace/simplefeatures#724 ·
-
cleanup
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
peterstace/simplefeatures#722 ·
-
jtsport
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
peterstace/simplefeatures#700 ·
Tutte le issue di peterstace/simplefeatures
Issue simili
-
【文档错误】创建镜像空间步骤中的截图标注与文字描述不一致Apertaenhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
DaoCloud/DaoCloud-docs#7839 ·
I maintainer di solito rispondono entro 1 giorno
-
Type: Enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
projectdiscovery/urlfinder#167 ·
I maintainer di solito rispondono entro 1 giorno
-
area: import bug go good first issue priority: low
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
fukubie/StockLlama#69 ·
-
enhancement help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
cloverworks-hq/rumpty-cli#95 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 10 giorni