0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CesiumAdvent Calendar 2017

Day 5

Cesium で3D三次メッシュ棒グラフ表示

Last updated at Posted at 2017-12-06

3D棒グラフ表現を実現する関数の作成

Cesiumでは、rectangle(矩形)というオブジェクト描画がありますので、メッシュコードからrectangleを定義する関数を作成しました。

成果物イメージと公開先

スクリーンショット 2017-12-06 13.17.22.png

3次メッシュ3D棒グラフ出力関数

getJapan3rdmeshRectangle.js
/**
 * 3次メッシュ3D棒グラフオブジェクト作成関数
 * @param  <Number>  meshcode3rd (required) 3次メッシュコード
 * @param  <Number>  h (required) 高さ(単位メートル)
 * @param  <string>    color_abgr (required)  色
 * @param  <string> description_text (required) オブジェクトの説明文
 * @retrun <object> ans_entities rectangleオブジェクト
 **/
function getJapan3rdmeshRectangle( meshcode3rd , h, color_abgr , description_text ){

    var strMeshcoe = String(meshcode3rd);
    var p = parseInt(strMeshcoe.slice(0,2));
    var u = parseInt(strMeshcoe.slice(2,4));
    var q = parseInt(strMeshcoe.slice(4,5));
    var v = parseInt(strMeshcoe.slice(5,6));
    var r = parseInt(strMeshcoe.slice(6,7));
    var w = parseInt(strMeshcoe.slice(7,8));
    var lat = p / 1.5 + q / 12 + r / 120;
    var lon = u + 100 + v * 0.125 + w * 0.0125;

    console.log(lon +":"+ lat) ;

    var ans_entities = {
            id:meshcode3rd ,
            description : "<p>"+description_text+"</p>",
            rectangle : {
                coordinates : Cesium.Rectangle.fromDegrees( lon , lat , lon+0.0125 , lat+0.008333333 ),
                height : 0,
                extrudedHeight : h,
                material : Cesium.Color.fromRgba( color_abgr )
            }
        };
    return ans_entities ;

}

まとめ

日本の多くの空間統計が標準メッシュをベースとしたものが多く、3次元表示が簡単にできればデータ活用が促進できればと思います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?