Skip to content
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

JSON-RPC-2.0 API で NaN と Inf を扱う手段を提供する #54

Closed
usagi opened this issue Jan 10, 2018 · 7 comments
Closed

JSON-RPC-2.0 API で NaN と Inf を扱う手段を提供する #54

usagi opened this issue Jan 10, 2018 · 7 comments

Comments

@usagi
Copy link
Contributor

usagi commented Jan 10, 2018

JSON では規格上 NaNInf を扱えない。特に NaN は巨大な数を与えて擬似的に扱えないこともない Inf と異なり扱う手段が無い。 Javascript においては "NaN""Inf" のように文字列で与える方法が一般に許容されている。

そこで G4 でも "数値が期待される場所" では "NaN" による NaN 値と "+Inf", "-Inf" を扱えるよう機能追加したいと思う。

@usagi
Copy link
Contributor Author

usagi commented Jan 15, 2018

現時点で " NaN が値として意味を持ちかつ正常動作の場合" は GeoObject.SetVertexGlobal の altitude 項のみ。

そこで、本チケットではこの項のみで NaN を試験実装する事にする。

@usagi
Copy link
Contributor Author

usagi commented Jan 15, 2018

理由:

  1. NaN は値として有効なわけではないので NaN を意味のある datum として扱う場合は限られる。
    • 一連の有意な数値群からなる data の datum が無効という場合は data が意味を持たないか、 datum が data にとって不必要ないし存在する理由が無いなどの特異な場合を data 及び datum 自体で自明な場合しか、 data が有効な対象に対しては考えられない。特に現時点においてはなお。
  2. 現時点での実装コストと app としての利点の戦略性に対しあらゆる入力 JSON へのパーサーをラップして NaN Inf へ対応する費用対効果が希薄。

@usagi
Copy link
Contributor Author

usagi commented Jan 15, 2018

SetVertex 系 APIs の座標値のパースでは NaN と Inf を認識するよう実装した。

@usagi
Copy link
Contributor Author

usagi commented Jan 15, 2018

想定される問題: ユーザーが NaN Inf を不正に扱うと G4 が落ちるであろう事。

@usagi
Copy link
Contributor Author

usagi commented Jan 15, 2018

想定される問題については根本的にユーザー入力の validation ではなく内部データ生成系のデータ変換に安全策を噛ませるのがいいだろう。

@usagi
Copy link
Contributor Author

usagi commented Jan 15, 2018

内部データ生成系とGeoObjectのLocation, Rotation制御系に IsFinite による安全対策を施し、 finite ではない値が alt, lat, lon にある場合でも G4 が落ちるような問題が発生しないよう実装した。

@usagi
Copy link
Contributor Author

usagi commented Jan 15, 2018

この変更は 4.0.0.13 へ取り込む。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant