@mesh3d/cesium-vectortile-gl 0.4.4 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +11 -0
- package/.gitconfig +3 -0
- package/.husky/pre-commit +1 -0
- package/.prettierignore +5 -0
- package/.vscode/settings.json +25 -0
- package/LICENSE.md +203 -203
- package/README.md +202 -167
- package/Source/Cesium.d.ts +2692 -2691
- package/Source/VectorTileLOD.js +720 -532
- package/Source/VectorTileRenderList.js +70 -70
- package/Source/VectorTileset.js +473 -447
- package/Source/layers/BackgroundRenderLayer.js +91 -89
- package/Source/layers/FillRenderLayer.js +18 -18
- package/Source/layers/IRenderLayer.js +160 -152
- package/Source/layers/LineRenderLayer.js +104 -94
- package/Source/layers/SymbolRenderLayer.js +30 -31
- package/Source/layers/index.js +23 -16
- package/Source/layers/registerRenderLayer.js +24 -24
- package/Source/layers/visualizers/FillLayerVisualizer.js +542 -426
- package/Source/layers/visualizers/ILayerVisualizer.js +90 -94
- package/Source/layers/visualizers/LineLayerVisualizer.js +702 -571
- package/Source/layers/visualizers/SymbolLayerVisualizer.js +514 -244
- package/Source/sources/GeoJSONSource.js +53 -46
- package/Source/sources/ISource.js +39 -39
- package/Source/sources/VectorSource.js +94 -52
- package/Source/sources/granularitySettings.js +23 -20
- package/Source/sources/index.js +6 -11
- package/Source/sources/registerSource.js +17 -19
- package/Source/style/StyleLayer.js +43 -43
- package/Source/style/StyleLayerProperties.js +44 -43
- package/Source/style/index.js +2 -2
- package/Source/symbol/SymbolPlacements.js +117 -88
- package/Source/workers/VectorTileWorker.js +41 -0
- package/Source/workers/ellipsoid.js +47 -0
- package/Source/workers/processTileTask.js +329 -0
- package/Source/workers/styleEvaluator.js +168 -0
- package/benchmark.html +148 -0
- package/dist/cvt-gl-worker.js +9274 -0
- package/dist/cvt-gl-worker.js.map +1 -0
- package/dist/cvt-gl.js +2570 -2001
- package/dist/cvt-gl.js.map +1 -1
- package/dist/cvt-gl.min.js +3 -3
- package/dist/cvt-gl.min.js.map +1 -1
- package/eslint.config.mjs +58 -0
- package/index.js +9 -6
- package/mlt.html +26 -25
- package/package.json +64 -41
- package/prettier.config.mjs +30 -0
- package/vite.config.mjs +43 -0
- package/vite.worker.config.mjs +31 -0
- package/worker.html +26 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint 扁平配置(Flat Config)
|
|
3
|
+
* @see https://eslint.org/docs/latest/use/configure/configuration-files
|
|
4
|
+
*/
|
|
5
|
+
import js from '@eslint/js'
|
|
6
|
+
import prettier from 'eslint-config-prettier'
|
|
7
|
+
|
|
8
|
+
export default [
|
|
9
|
+
{
|
|
10
|
+
ignores: [
|
|
11
|
+
'dist/**',
|
|
12
|
+
'node_modules/**',
|
|
13
|
+
'*.config.js',
|
|
14
|
+
'*.config.mjs',
|
|
15
|
+
'*.config.cjs',
|
|
16
|
+
'vite.config.js',
|
|
17
|
+
'Cesium.d.ts'
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
js.configs.recommended,
|
|
21
|
+
prettier,
|
|
22
|
+
{
|
|
23
|
+
files: ['**/*.js'],
|
|
24
|
+
languageOptions: {
|
|
25
|
+
ecmaVersion: 'latest',
|
|
26
|
+
sourceType: 'module',
|
|
27
|
+
globals: {
|
|
28
|
+
Cesium: 'readonly',
|
|
29
|
+
// 浏览器 / 运行环境全局
|
|
30
|
+
window: 'readonly',
|
|
31
|
+
document: 'readonly',
|
|
32
|
+
fetch: 'readonly',
|
|
33
|
+
console: 'readonly',
|
|
34
|
+
requestAnimationFrame: 'readonly',
|
|
35
|
+
devicePixelRatio: 'readonly',
|
|
36
|
+
URL: 'readonly',
|
|
37
|
+
performance: 'readonly',
|
|
38
|
+
setTimeout: 'readonly'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
rules: {
|
|
42
|
+
// 代码风格由 Prettier 统一处理
|
|
43
|
+
'no-unused-vars': [
|
|
44
|
+
'warn',
|
|
45
|
+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' }
|
|
46
|
+
],
|
|
47
|
+
'no-empty': ['warn', { allowEmptyCatch: true }]
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
files: ['Source/workers/**/*.js'],
|
|
52
|
+
languageOptions: {
|
|
53
|
+
globals: {
|
|
54
|
+
self: 'readonly'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
]
|
package/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export { VectorTileLOD } from
|
|
5
|
-
export { VectorTileRenderList } from
|
|
6
|
-
export { VectorTileset } from
|
|
1
|
+
export * from './Source/sources'
|
|
2
|
+
export * from './Source/style'
|
|
3
|
+
export * from './Source/layers'
|
|
4
|
+
export { VectorTileLOD } from './Source/VectorTileLOD'
|
|
5
|
+
export { VectorTileRenderList } from './Source/VectorTileRenderList'
|
|
6
|
+
export { VectorTileset } from './Source/VectorTileset'
|
|
7
|
+
|
|
8
|
+
/** 构建产物中 Worker 脚本文件名,用于构造 workerUrl(与 cvt-gl.js 同目录) */
|
|
9
|
+
export const DEFAULT_WORKER_FILENAME = 'cvt-gl-worker.js'
|
package/mlt.html
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
<html lang="zh-cn">
|
|
2
|
-
|
|
3
|
-
<
|
|
4
|
-
<meta
|
|
5
|
-
<
|
|
6
|
-
<
|
|
7
|
-
<link
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
</
|
|
1
|
+
<html lang="zh-cn">
|
|
2
|
+
<head>
|
|
3
|
+
<meta charset="UTF-8" />
|
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
5
|
+
<title>CesiumJS 开源矢量瓦片渲染库</title>
|
|
6
|
+
<link rel="shortcut icon" href="./logo.svg" type="image/svg" />
|
|
7
|
+
<link
|
|
8
|
+
rel="stylesheet"
|
|
9
|
+
href="./node_modules/cesium/Build/Cesium/Widgets/widgets.css"
|
|
10
|
+
/>
|
|
11
|
+
<script src="./node_modules/cesium/Build/CesiumUnminified/Cesium.js"></script>
|
|
12
|
+
<style>
|
|
13
|
+
html,
|
|
14
|
+
body {
|
|
15
|
+
width: 100%;
|
|
16
|
+
height: 100%;
|
|
17
|
+
margin: 0;
|
|
18
|
+
padding: 0;
|
|
19
|
+
}
|
|
20
|
+
</style>
|
|
21
|
+
</head>
|
|
22
|
+
|
|
23
|
+
<body>
|
|
24
|
+
<script type="module" src="./examples/index-mlt.js"></script>
|
|
25
|
+
</body>
|
|
26
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,41 +1,64 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@mesh3d/cesium-vectortile-gl",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "CesiumJS 矢量瓦片渲染库",
|
|
5
|
-
"main": "dist/cvt-gl.js",
|
|
6
|
-
"module": "index.js",
|
|
7
|
-
"private": false,
|
|
8
|
-
"publishConfig": {
|
|
9
|
-
"access": "public"
|
|
10
|
-
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "vite build",
|
|
13
|
-
"dev": "vite dev",
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@mesh3d/cesium-vectortile-gl",
|
|
3
|
+
"version": "0.4.6",
|
|
4
|
+
"description": "CesiumJS 矢量瓦片渲染库",
|
|
5
|
+
"main": "dist/cvt-gl.js",
|
|
6
|
+
"module": "index.js",
|
|
7
|
+
"private": false,
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "vite build && vite build --config vite.worker.config.mjs",
|
|
13
|
+
"dev": "vite dev",
|
|
14
|
+
"lint": "eslint .",
|
|
15
|
+
"lint:fix": "eslint . --fix",
|
|
16
|
+
"format": "prettier --write .",
|
|
17
|
+
"format:check": "prettier --check .",
|
|
18
|
+
"prepare": "husky",
|
|
19
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
20
|
+
},
|
|
21
|
+
"lint-staged": {
|
|
22
|
+
"*.js": [
|
|
23
|
+
"eslint --fix",
|
|
24
|
+
"prettier --write"
|
|
25
|
+
],
|
|
26
|
+
"*.{json,jsonc,geojson,md,html,css,less,yml,yaml}": [
|
|
27
|
+
"prettier --write"
|
|
28
|
+
],
|
|
29
|
+
"*.{mjs,cjs}": [
|
|
30
|
+
"prettier --write"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/mesh-3d/cesium-vectortile-gl.git"
|
|
36
|
+
},
|
|
37
|
+
"author": {
|
|
38
|
+
"name": "mesh-3d",
|
|
39
|
+
"url": "https://github.com/mesh-3d"
|
|
40
|
+
},
|
|
41
|
+
"license": "Apache-2.0",
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@eslint/js": "^9.15.0",
|
|
44
|
+
"cesium": "^1.136.0",
|
|
45
|
+
"eslint": "^9.15.0",
|
|
46
|
+
"eslint-config-prettier": "^9.1.0",
|
|
47
|
+
"husky": "^9.1.7",
|
|
48
|
+
"lint-staged": "^15.4.3",
|
|
49
|
+
"prettier": "^3.4.2",
|
|
50
|
+
"vite": "^7.3.0",
|
|
51
|
+
"vite-plugin-license": "^0.0.2"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@mapbox/vector-tile": "^2.0.4",
|
|
55
|
+
"@maplibre/maplibre-gl-style-spec": "^24.4.1",
|
|
56
|
+
"@maplibre/vt-pbf": "^4.2.0",
|
|
57
|
+
"geojson-vt": "^4.0.2",
|
|
58
|
+
"maplibre-gl": "^5.15.0",
|
|
59
|
+
"pbf": "^4.0.1"
|
|
60
|
+
},
|
|
61
|
+
"maintainers": [
|
|
62
|
+
"weixiuyong"
|
|
63
|
+
]
|
|
64
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* prettier 配置文件
|
|
3
|
+
* @see https://prettier.io/docs/en/options.html
|
|
4
|
+
* @type {import("prettier").Config}
|
|
5
|
+
*/
|
|
6
|
+
const config = {
|
|
7
|
+
arrowParens: 'avoid',
|
|
8
|
+
bracketSpacing: true,
|
|
9
|
+
endOfLine: 'lf', // 统一为 LF(可选:crlf | auto)
|
|
10
|
+
|
|
11
|
+
// 为 JSON/JSONC 文件单独配置(兼容 JSON 语法)
|
|
12
|
+
overrides: [
|
|
13
|
+
{
|
|
14
|
+
files: ['*.json', '*.jsonc', '*.geojson'], // 匹配 JSON/JSONC 文件
|
|
15
|
+
options: {
|
|
16
|
+
parser: 'json', // 指定 JSON 解析器
|
|
17
|
+
singleQuote: false, // JSON 必须用双引号,禁用单引号
|
|
18
|
+
trailingComma: 'none' // 避免 JSON 末尾逗号报错
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
printWidth: 80,
|
|
23
|
+
semi: false,
|
|
24
|
+
singleQuote: true,
|
|
25
|
+
tabWidth: 2,
|
|
26
|
+
trailingComma: 'none',
|
|
27
|
+
useTabs: false
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default config
|
package/vite.config.mjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineConfig } from 'vite'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import { fileURLToPath } from 'url'
|
|
4
|
+
import license from 'vite-plugin-license'
|
|
5
|
+
|
|
6
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
7
|
+
|
|
8
|
+
// https://vitejs.dev/config/
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
resolve: {
|
|
11
|
+
alias: {
|
|
12
|
+
'@': path.resolve(__dirname, 'Source')
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
define: {
|
|
16
|
+
'process.env': {}
|
|
17
|
+
},
|
|
18
|
+
build: {
|
|
19
|
+
outDir: './dist',
|
|
20
|
+
lib: {
|
|
21
|
+
entry: path.resolve(__dirname, 'index.js'),
|
|
22
|
+
name: 'CVT',
|
|
23
|
+
fileName(format) {
|
|
24
|
+
if (format == 'es') {
|
|
25
|
+
return 'cvt-gl.js'
|
|
26
|
+
} else {
|
|
27
|
+
return 'cvt-gl.min.js'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
sourcemap: true
|
|
32
|
+
},
|
|
33
|
+
esbuild: {
|
|
34
|
+
drop: ['debugger']
|
|
35
|
+
},
|
|
36
|
+
plugins: [
|
|
37
|
+
license({
|
|
38
|
+
thirdParty: {
|
|
39
|
+
output: './dist/THIRD-PARTY-LICENSES.txt'
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
]
|
|
43
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineConfig } from 'vite'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import { fileURLToPath } from 'url'
|
|
4
|
+
|
|
5
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
6
|
+
|
|
7
|
+
/** 仅构建 Vector Tile Worker,输出到 dist/cvt-gl-worker.js */
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
resolve: {
|
|
10
|
+
alias: {
|
|
11
|
+
'@': path.resolve(__dirname, 'Source')
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
define: {
|
|
15
|
+
'process.env': {}
|
|
16
|
+
},
|
|
17
|
+
build: {
|
|
18
|
+
outDir: './dist',
|
|
19
|
+
emptyOutDir: false,
|
|
20
|
+
lib: {
|
|
21
|
+
entry: path.resolve(__dirname, 'Source/workers/VectorTileWorker.js'),
|
|
22
|
+
name: 'VectorTileWorker',
|
|
23
|
+
fileName: () => 'cvt-gl-worker.js',
|
|
24
|
+
formats: ['es']
|
|
25
|
+
},
|
|
26
|
+
sourcemap: true
|
|
27
|
+
},
|
|
28
|
+
esbuild: {
|
|
29
|
+
drop: ['debugger']
|
|
30
|
+
}
|
|
31
|
+
})
|
package/worker.html
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<html lang="zh-cn">
|
|
2
|
+
<head>
|
|
3
|
+
<meta charset="UTF-8" />
|
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
5
|
+
<title>矢量瓦片 - Web Worker 示例</title>
|
|
6
|
+
<link rel="shortcut icon" href="./logo.svg" type="image/svg" />
|
|
7
|
+
<link
|
|
8
|
+
rel="stylesheet"
|
|
9
|
+
href="./node_modules/cesium/Build/Cesium/Widgets/widgets.css"
|
|
10
|
+
/>
|
|
11
|
+
<script src="./node_modules/cesium/Build/CesiumUnminified/Cesium.js"></script>
|
|
12
|
+
<style>
|
|
13
|
+
html,
|
|
14
|
+
body {
|
|
15
|
+
width: 100%;
|
|
16
|
+
height: 100%;
|
|
17
|
+
margin: 0;
|
|
18
|
+
padding: 0;
|
|
19
|
+
}
|
|
20
|
+
</style>
|
|
21
|
+
</head>
|
|
22
|
+
|
|
23
|
+
<body>
|
|
24
|
+
<script type="module" src="./examples/index-worker.js"></script>
|
|
25
|
+
</body>
|
|
26
|
+
</html>
|