MarshalTWKB drops the Z and M of empty geometries
まだ誰も着手していません。
評価
調査の方向性
Start in writeIsEmptyHeader, the function that writes the empty-geometry metadata header in the TWKB encoder, and compare it with how non-empty geometries write the extended dimensions byte. Check whether #723 is merged first, since the issue says it adds the TWKBTestCases rows with skipEncode: true that this fix depends on. Done means empty Z or M geometries encode with the extended byte (for example 031801 for POLYGON Z EMPTY), those rows pass with the flag removed, and the function's comment is updated.
索引モデルが issue の本文から書いたものです。
説明
MarshalTWKB writes an empty geometry as its type byte followed by a metadata header with only the "is empty" bit set. It doesn't write the extended dimensions byte, so the output doesn't record that the geometry has Z or M. This reproduces on master at a5aec8d.
| Geometry | Output | Decoded by UnmarshalTWKB |
|---|---|---|
POINT Z EMPTY |
0110 |
POINT EMPTY |
POLYGON Z EMPTY |
0310 |
POLYGON EMPTY |
MULTIPOINT M EMPTY |
0410 |
MULTIPOINT EMPTY |
GEOMETRYCOLLECTION Z EMPTY |
0710 |
GEOMETRYCOLLECTION EMPTY |
The other geometry types behave the same way.
Effect inside a GeometryCollection
An empty child of a collection is written the same way, so it decodes as XY. A GeometryCollection takes the lowest common coordinates type of its children, so the Z and M of the non-empty children are dropped as well:
g, _ := geom.UnmarshalWKT("GEOMETRYCOLLECTION Z (POLYGON Z EMPTY,POINT Z (1 2 3))")
b, _ := geom.MarshalTWKB(g, 0)
// b is 070801020310010801020406. The empty polygon is written as 03 10.
back, _ := geom.UnmarshalTWKB(b)
// back is GEOMETRYCOLLECTION(POLYGON EMPTY,POINT(1 2))
Likely fix
writeIsEmptyHeader could set the extended precision bit and write the extended dimensions byte when the geometry has Z or M. That gives 031801 for POLYGON Z EMPTY, and #723 reports that PostGIS 3.5.2 writes empty Z/M geometries this way. The comment in writeIsEmptyHeader says the byte is left out on purpose, so it needs updating too.
UnmarshalTWKB already keeps Z and M from that byte for an empty Point or LineString, and #723 does the same for the other types. #723 also adds TWKBTestCases rows for these encodings with skipEncode: true. I tried the change above on top of #723 and those rows pass with the flag removed.
The fix changes the bytes that MarshalTWKB writes for an empty Z or M geometry. #721 covers two other MarshalTWKB bugs with empty geometries.
- 主要言語
- Go
- スター
- 176
- フォーク
- 27
- 平均マージ
- 1日 14時間
- マージ済み PR(30日)
- 4
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
peterstace/simplefeatures のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
peterstace/simplefeatures#726 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
peterstace/simplefeatures#725 ·
-
cleanup
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
peterstace/simplefeatures#722 ·
-
bug
難易度 3/5 半日 初心者へのやさしさ 45/100
peterstace/simplefeatures#721 ·
-
jtsport
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
peterstace/simplefeatures#700 ·
peterstace/simplefeatures の issue をすべて見る
似ている issue
-
enhancement
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
DaoCloud/DaoCloud-docs#7839 ·
メンテナーはふだん 1 日以内に返信
-
Type: Enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
projectdiscovery/urlfinder#167 ·
メンテナーはふだん 1 日以内に返信
-
area: import bug go good first issue priority: low
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
fukubie/StockLlama#69 ·
-
enhancement help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
cloverworks-hq/rumpty-cli#95 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 10 日以内に返信