6
7

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 3 years have passed since last update.

CesiumAdvent Calendar 2017

Day 4

CZMLでポイントオブジェクトを時系列移動

Last updated at Posted at 2017-12-04

ポイントオブジェクト時系列の移動

Cesiumの強みである時系列表示制御機能を試してみます。
Cesiumのオブジェクトの表示制御を行うデータ形式である、CZML(JSON)にパラメータを記載することで実現可能です。

今回の成果物 http://jsdo.it/tkama/eYt3
t1.gif

CZMLの仕様

日本語では、CZML入門というサイトが非常に分かりやすいです。

CesiumのSandcastleを参考に時系列データを描画してみます。

//CZML抜粋
 {
    "id" : "point",
    //表示時間範囲
    "availability" :"2012-08-04T16:00:00Z/2012-08-04T16:05:00Z",
    "position" : {
        "epoch" : "2012-08-04T16:00:00Z", //開始時刻
        "cartographicDegrees" : [
            0,   140.0, 35.0, 100,     //経過時間(秒),経度,緯度,標高(m)
            100, 140.1, 35.1, 100,
            200, 140.2, 35.2, 100,
            300, 140.3, 35.3, 100
        ]
    },

デモ: 上越新幹線を平均時速200kmで走行させる

 
国土数値情報 鉄道データより、上越新幹線の線路形状を抽出し、線路形状を1本の線分に変換し、補間点間の距離差から秒速55mの移動体の経過時間を抽出しました。

抽出用クエリ

WITH base AS (
  SELECT  ST_DumpPoints( ST_Reverse( ST_LineMerge( ST_Union( geom ) ) )) AS dp, n02_003 AS lname 
  FROM public.rail
  WHERE n02_003 = '上越新幹線'
  GROUP BY 2
 )
 SELECT
	  s ||',' ||  ST_X( geom ) || ',' ||  ST_y( geom ) || ',100,' AS cartographicDegrees
 FROM 
	 (
	 SELECT
	 * , SUM(diff_time)OVER(ORDER BY id rows unbounded preceding ) :: int AS s
	 FROM 
	 (
	 SELECT 
	  lname , ((dp).path)[1] AS id,  (dp).geom  
	  , ST_Distance( ((dp).geom)::geography   , lag( ((dp).geom)::geography ) OVER(PARTITION BY lname ORDER BY ((dp).path)[1] ))
	  , ST_Distance( ((dp).geom)::geography   , lag( ((dp).geom)::geography ) OVER(PARTITION BY lname ORDER BY ((dp).path)[1] )) / 55.5555 AS diff_time
	 FROM base 
	 ) AS t1
) AS t2
WHERE diff_time > 1
ORDER  BY id

CZMLを作成し表示

CesiumでCZMLを表示するにはdataSources.add()で実現できます。

var czml ="CZML文字列";
var viewer = new Cesium.Viewer('cesiumContainer');
viewer.dataSources.add(Cesium.CzmlDataSource.load(czml));

成果物公開先: http://jsdo.it/tkama/eYt3

6
7
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
6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?