MarshalTWKB fails for Z or M geometries when the XY precision is negative
まだ誰も着手していません。
評価
調査の方向性
ZとMの精度のデフォルト値は、simplefeaturesパッケージのTWKBエンコードコードにあるMarshalTWKBで設定されています。まずそこから始め、検証メッセージ 'TWKB got precZ = -1, expected it to be between 0 and +7' を確認してください。precXYが-1の状態でPOINT Z (10 20 3) を使って再現し、precXYが負の場合にデフォルト値が0になることを確認してください。その呼び出しが成功し、明示的なTWKBPrecisionZ(-1)が引き続き拒否され、デフォルト値を示すようにdocコメントが更新されていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
MarshalTWKB returns an error for a geometry with Z or M when precXY is negative, unless the caller also passes TWKBPrecisionZ or TWKBPrecisionM. This reproduces on master at a5aec8d.
g, _ := geom.UnmarshalWKT("POINT Z (10 20 3)")
_, err := geom.MarshalTWKB(g, -1)
// TWKB got precZ = -1, expected it to be between 0 and +7
b, _ := geom.MarshalTWKB(g, -1, geom.TWKBPrecisionZ(0))
// b is 110801020406
A geometry with M fails the same way on precM. Empty geometries with Z or M fail too, although no coordinates are written for them.
Cause
The Z and M precisions default to precXY. The XY precision can be between -8 and +7, but the Z and M precisions have to be between 0 and +7, so a negative precXY gives a default that fails validation.
Likely fix
Default the Z and M precisions to zero when precXY is negative. Zero is the closest valid value, and it is the default for prec_z and prec_m in PostGIS's ST_AsTWKB. The defaults are assigned before the options are applied, so an explicit TWKBPrecisionZ(-1) would still be rejected.
The doc comment on MarshalTWKB doesn't say what the Z and M precisions default to, and the fix could add that.
Interaction with #723
Before #723, UnmarshalTWKB returned XY for some empty Z/M geometries, so the result could be passed back to MarshalTWKB at a negative precision. With #723 they keep Z and M and reach this error. For example, 131801 decodes as POLYGON Z EMPTY with #723 and as POLYGON EMPTY without it, and MarshalTWKB(g, -1) fails on the first.
- 主要言語
- Go
- スター
- 176
- フォーク
- 27
- 平均マージ
- 1日 14時間
- マージ済み PR(30日)
- 4
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
peterstace/simplefeatures のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
peterstace/simplefeatures#725 ·
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
peterstace/simplefeatures#724 ·
-
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 日以内に返信