PLATEAU-3DTiles配信チュートリアルの3.1. Cesium.jsでの利用方法に記載されている実装をOracle APEXのアプリケーションに組み込み、建物データ(3D Tiles)をCesium.jsで表示してみます。
建物データの表示はチュートリアルをそのまま実装します。Oracle APEXを使って3D Tiles一覧のURLを置き換える機能を追加します。
アプリケーション作成ウィザードを起動し、空のアプリケーションを作成します。名前はPLATEAU 3DTilesとします。Cesium.jsによる建物データの表示は、デフォルトで作成されるホーム・ページに実装します。
アプリケーションの作成をクリックします。
アプリケーションが作成されたら、ページ・デザイナでホーム・ページを開きます。
Cesium.jsでの利用方法に記載されているサンプルコードを、ホーム・ページにそのまま埋め込みます。
ページ・プロパティのJavaScriptのファイルURLに以下を記載します。CesiumJSのバージョンは新しいものを使用します。
https://cesium.com/downloads/cesiumjs/releases/1.103/Build/Cesium/Cesium.js
ページ・ロード時に実行に、<script>...</script>の間に記述されているJavaScriptのコードを転記します。
CSSのファイルURLに以下を記載します。
https://cesium.com/downloads/cesiumjs/releases/1.103/Build/Cesium/Widgets/widgets.css
CSSのインラインに、<style>...</style>の間に記述されている#cesiumContainerのスタイル定義を転記します。
Cesium.jsを組み込むリージョンを作成します。
識別のタイトルは3D Tiles、タイプに静的コンテンツを選択します。ソースのHTMLコードとして以下を記述します。
<div id="cesiumContainer"></div>
# prefix: plateau
3dtiles
citycode vc6 /nn
type vc8 /nn
url vc200 /nn
lat num
lon num
has_coordinate vc1 /check Y,N
declare | |
l_clob clob; | |
l_array json_array_t; | |
l_object json_object_t; | |
l_citycode plateau_3dtiles.citycode%type; | |
l_type plateau_3dtiles.type%type; | |
l_url plateau_3dtiles.url%type; | |
begin | |
l_clob := apex_web_service.make_rest_request( | |
p_url => 'https://raw.githubusercontent.com/Project-PLATEAU/plateau-streaming-tutorial/main/3dtiles_url.json' | |
,p_http_method => 'GET' | |
); | |
l_array := json_array_t.parse(l_clob); | |
for i in 0..(l_array.get_size()-1) | |
loop | |
l_object := treat(l_array.get(i) as json_object_t); | |
l_citycode := l_object.get_string('CITYCODE'); | |
l_type := l_object.get_string('TYPE'); | |
l_url := l_object.get_string('URL'); | |
insert into plateau_3dtiles(citycode, type, url) values(l_citycode, l_type, l_url); | |
end loop; | |
end; |
declare | |
l_clob clob; | |
l_tile json_object_t; | |
l_properties json_object_t; | |
l_x_lon json_object_t; | |
l_y_lat json_object_t; | |
l_x number; | |
l_y number; | |
l_count pls_integer; | |
begin | |
l_count := 0; | |
for r in (select id, url from plateau_3dtiles where type = 'bldg' and has_coordinate is null) | |
loop | |
/* | |
* タイムアウトを回避するために、少しづつ実施する。 | |
*/ | |
l_count := l_count + 1; | |
if l_count > 20 then | |
exit; | |
end if; | |
/* | |
* 3Dtileの内容から緯度経度を取り出す。 | |
*/ | |
l_clob := apex_web_service.make_rest_request( | |
p_url => r.url | |
,p_http_method => 'GET' | |
); | |
l_tile := json_object_t(l_clob); | |
l_properties := l_tile.get_object('properties'); | |
if l_properties is not null then | |
l_x_lon := l_properties.get_object('_x'); | |
l_y_lat := l_properties.get_object('_y'); | |
if l_x_lon is not null and l_y_lat is not null then | |
l_x := (l_x_lon.get_number('minimum') + l_x_lon.get_number('maximum')) / 2; | |
l_y := (l_y_lat.get_number('minimum') + l_y_lat.get_number('maximum')) / 2; | |
update plateau_3dtiles set lat = l_y, lon = l_x, has_coordinate = 'Y' where id = r.id; | |
continue; | |
end if; | |
end if; | |
update plateau_urls set has_coordinate = 'N' where id = r.id; | |
end loop; | |
/* 処理が必要な残りがあるかどうか確認する。 */ | |
select count(*) into l_count from plateau_3dtiles where type = 'bldg' and has_coordinate is null; | |
dbms_output.put_line('未処理 = ' || l_count); | |
end; |
// Cesium Ionの読み込み指定 | |
Cesium.Ion.defaultAccessToken = "&G_TOKEN."; | |
// Terrainの指定(EGM96、国土数値情報5m標高から生成した全国の地形モデル、5m標高データが無い場所は10m標高で補完している) | |
var viewer = new Cesium.Viewer("cesiumContainer", { | |
terrainProvider: new Cesium.CesiumTerrainProvider({ | |
url: Cesium.IonResource.fromAssetId(&G_ASSET_ID.) | |
}) | |
}); | |
/* | |
* デフォルトとして千代田区を選択する。 | |
*/ | |
if (!apex.items.P1_3DTILES.getValue()) { | |
const defaultUrl = "https://plateau.geospatial.jp/main/data/3d-tiles/bldg/13100_tokyo/13101_chiyoda-ku/notexture/tileset.json"; | |
apex.items.P1_3DTILES.setValue(defaultUrl, defaultUrl, false); | |
apex.items.P1_LAT.setValue(35.6872261, null, true); | |
apex.items.P1_LON.setValue(139.75657399, null, true); | |
} | |
// 建物データ(3D Tiles) | |
var your_3d_tiles = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({ | |
url : apex.items.P1_3DTILES.getValue() | |
})); | |
// カメラの初期位置の指定 | |
viewer.camera.setView({ | |
destination : Cesium.Cartesian3.fromDegrees( | |
apex.items.P1_LON.getValue(), | |
apex.items.P1_LAT.getValue(), | |
5000.0) | |
}); |