@msign/s3tic
v0.1.2
Published
iServer s3m 静态化 ----
Downloads
2
Readme
iServer s3m 静态化
本工具的功能是将超图s3m
三维缓存场景包静态化生成为iServer
风格的路径文件, 提供可脱离iServer
独立分发的资源目录.
使用方法
NPM 方式
全局安装
npm i -g @msign/s3tic
➜ ~ s3tic -h
Usage: s3tic [options]
Options:
-i, --input [string] SXWU文件路径.
-o, --output [string] 静态化场景包输出路径(/path_to/output/)
-h, --help output usage information
独立可执行文件方式
自行编译
yarn build
yarn release
➜ s3tic git:(master) ✗ yarn build
yarn run v1.19.1
$ tsc
✨ Done in 2.96s.
➜ s3tic git:(master) ✗ yarn release
yarn run v1.19.1
$ pkg . --out-path ./release
> [email protected]
> Targets not specified. Assuming:
node10-linux-x64, node10-macos-x64, node10-win-x64
✨ Done in 16.80s.
可执行文件在./release/
win
./s3tic-win.exe -i ./sample/scene_pack/1.sxwu -o ./sample/output
mac
./s3tic-macos -i ./sample/scene_pack/1.sxwu -o ./sample/output
linux
./s3tic-linux -i ./sample/scene_pack/1.sxwu -o ./sample/output
数据说明
输入数据结构
➜ sample tree .
.
└── scene_pack
...
├── WS_NAME.sxwu
└── SCENE_NAME
└── DATA_DIR
├── DATASET@DATASOURCE
│ ├── Tile_X_Y_Z
│ │ ├── Tile_XX_YY_ZZ.s3m
...
│ └── [email protected]
...
执行过程回显
➜ s3tic ./release/s3tic-macos -i ./sample/scene_pack/1.sxwu -o ./sample/output
ℹ { input: './sample/scene_pack/1.sxwu',
output: './sample/output' }
[场景-0]: SCENE_NAME
[图层-0]: DATASET@DATASOURCE
...
输出数据结构
➜ output tree .
.
├── datas
│ ├── DATASET@DATASOURCE
│ │ ├── config
│ │ └── data
│ │ └── path
│ │ ├── Tile_X_Y_Z
│ │ │ ├── Tile_XX_YY_ZZ.s3m
...
│ │ └── [email protected]
...
├── login
├── login.json
├── scenes
│ ├── SCENE_NAME
│ │ ├── layers
│ │ │ ├── DATASET@DATASOURCE
│ │ │ │ └── extendxml.xml
│ │ └── layers.json
│ └── SCENE_NAME.json
└── scenes.json
生成好的场景包发布方式
可以直接采用 Nginx 分发, 有三个要点需要注意
手动修改scene.json
文件中的path
参数
生成好的文件如下
[
{
"resourceConfigID": "scene",
"supportedMediaTypes": [
"application/xml",
"text/xml",
"application/json",
"application/fastjson",
"application/rjson",
"text/html",
"application/jsonp",
"application/x-java-serialized-object",
"application/realspace",
"application/openrealspace",
"application/scenezip"
],
"path": "/scenes/scene_cache",
"name": "scene_cache",
"resourceType": "ArithmeticResource"
}
]
假设我们发布的网络路径是https://YOUR_STATIC_SERVER/SOME_PATH/rest/realspace
, 将scenes.json
修改至如下
[
{
"resourceConfigID": "scene",
"supportedMediaTypes": [
"application/xml",
"text/xml",
"application/json",
"application/fastjson",
"application/rjson",
"text/html",
"application/jsonp",
"application/x-java-serialized-object",
"application/realspace",
"application/openrealspace",
"application/scenezip"
],
"path": "https://YOUR_STATIC_SERVER/SOME_PATH/rest/realspace/scenes/scene_cache",
"name": "scene_cache",
"resourceType": "ArithmeticResource"
}
]
Supermap-Cesium 是依赖于这个 path 值去加载场景实例的, 理论上这个 scenes.json 也可以从业务系统动态生成. path 指向 CDN 即可.
场景资源发布路径的父级目录必须是rest/realspace/
Supermap-Cesium
中写死了一行字符串匹配, 用于定位login.json
的网络路径.
e.indexOf("rest/realspace") + 14
Nginx 需要设置login
文件的405重定向
Supermap-Cesium
会在场景载入过程中向iServer
提交会话请求
- GET PATH_TO_STATIC/rest/realspace/login.json
- POST PATH_TO_STATIC/rest/realspace/login
这两个请求的返回值已在静态包中生成静态文件. 前者是个普通 json
{"random":"1","jsessionID":"1"}
后者由于是POST请求, Nginx 默认不会返回路径文件(405), 需要修改 Nginx 配置
server {
...
#屏蔽405, 使前端可对静态文件POST
error_page 405 =200 $request_uri;
#顺便加上这个, 以便于方便查看 sample/output/datas/xxx/config 文件. 不影响使用
default_type text/html;
}
修改Nginx配置后POST PATH_TO_STATIC/rest/realspace/login
即可返回
isSucceed : true
注意 这不是JSON.
武运昌隆.