npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@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提交会话请求

  1. GET PATH_TO_STATIC/rest/realspace/login.json
  2. 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.

武运昌隆.