@mapcatch/util 2.0.3 → 2.0.5-a

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.
Files changed (74) hide show
  1. package/.eslintrc.js +54 -0
  2. package/.husky/pre-commit +1 -0
  3. package/.prettierrc +4 -0
  4. package/.vscode/settings.json +2 -0
  5. package/CHANGELOG.md +5 -1
  6. package/README.md +44 -0
  7. package/debug/app.js +26 -0
  8. package/debug/index.html +55 -0
  9. package/debug/libs/vue.global.js +16159 -0
  10. package/debug/my_icon.png +0 -0
  11. package/docs/Catolog.md +24 -0
  12. package/docs/Constant.md +92 -0
  13. package/docs/Event.md +90 -0
  14. package/docs/Util.md +345 -0
  15. package/package.json +2 -2
  16. package/src/constants/crs.js +42098 -42098
  17. package/src/constants/default_layers.js +102 -11
  18. package/src/constants/index.js +1 -0
  19. package/src/constants/layer_groups_multispectral.js +34 -0
  20. package/src/constants/layer_icons.js +1 -0
  21. package/src/gl-operations/constants.js +9 -9
  22. package/src/gl-operations/default_options.js +97 -97
  23. package/src/gl-operations/index.js +532 -520
  24. package/src/gl-operations/reglCommands/contours.js +27 -27
  25. package/src/gl-operations/reglCommands/default.js +45 -43
  26. package/src/gl-operations/reglCommands/hillshading.js +340 -332
  27. package/src/gl-operations/reglCommands/index.js +6 -6
  28. package/src/gl-operations/reglCommands/multiLayers.js +303 -301
  29. package/src/gl-operations/reglCommands/transitions.js +111 -109
  30. package/src/gl-operations/reglCommands/util.js +71 -71
  31. package/src/gl-operations/renderer.js +209 -192
  32. package/src/gl-operations/shaders/fragment/convertDem.js +25 -25
  33. package/src/gl-operations/shaders/fragment/convolutionSmooth.js +54 -54
  34. package/src/gl-operations/shaders/fragment/diffCalc.js +33 -33
  35. package/src/gl-operations/shaders/fragment/drawResult.js +46 -41
  36. package/src/gl-operations/shaders/fragment/hillshading/hsAdvAmbientShadows.js +78 -78
  37. package/src/gl-operations/shaders/fragment/hillshading/hsAdvDirect.js +59 -54
  38. package/src/gl-operations/shaders/fragment/hillshading/hsAdvFinalBaselayer.js +30 -30
  39. package/src/gl-operations/shaders/fragment/hillshading/hsAdvFinalColorscale.js +60 -55
  40. package/src/gl-operations/shaders/fragment/hillshading/hsAdvMergeAndScaleTiles.js +26 -26
  41. package/src/gl-operations/shaders/fragment/hillshading/hsAdvNormals.js +25 -25
  42. package/src/gl-operations/shaders/fragment/hillshading/hsAdvSmooth.js +53 -53
  43. package/src/gl-operations/shaders/fragment/hillshading/hsAdvSoftShadows.js +80 -80
  44. package/src/gl-operations/shaders/fragment/hillshading/hsPregen.js +54 -49
  45. package/src/gl-operations/shaders/fragment/interpolateColor.js +65 -62
  46. package/src/gl-operations/shaders/fragment/interpolateColorOnly.js +49 -46
  47. package/src/gl-operations/shaders/fragment/interpolateValue.js +136 -123
  48. package/src/gl-operations/shaders/fragment/multiAnalyze1Calc.js +35 -35
  49. package/src/gl-operations/shaders/fragment/multiAnalyze2Calc.js +45 -45
  50. package/src/gl-operations/shaders/fragment/multiAnalyze3Calc.js +53 -53
  51. package/src/gl-operations/shaders/fragment/multiAnalyze4Calc.js +61 -61
  52. package/src/gl-operations/shaders/fragment/multiAnalyze5Calc.js +69 -69
  53. package/src/gl-operations/shaders/fragment/multiAnalyze6Calc.js +77 -77
  54. package/src/gl-operations/shaders/fragment/single.js +93 -88
  55. package/src/gl-operations/shaders/transform.js +21 -21
  56. package/src/gl-operations/shaders/util/computeColor.glsl +85 -84
  57. package/src/gl-operations/shaders/util/getTexelValue.glsl +10 -10
  58. package/src/gl-operations/shaders/util/isCloseEnough.glsl +9 -9
  59. package/src/gl-operations/shaders/util/rgbaToFloat.glsl +17 -17
  60. package/src/gl-operations/shaders/vertex/double.js +16 -16
  61. package/src/gl-operations/shaders/vertex/multi3.js +19 -19
  62. package/src/gl-operations/shaders/vertex/multi4.js +22 -22
  63. package/src/gl-operations/shaders/vertex/multi5.js +25 -25
  64. package/src/gl-operations/shaders/vertex/multi6.js +28 -28
  65. package/src/gl-operations/shaders/vertex/single.js +13 -13
  66. package/src/gl-operations/shaders/vertex/singleNotTransformed.js +11 -11
  67. package/src/gl-operations/texture_manager.js +141 -141
  68. package/src/gl-operations/util.js +336 -336
  69. package/src/measure/index.js +14 -8
  70. package/src/transform.js +3 -0
  71. package/src/util.js +14 -6
  72. package/vite.config.js +58 -0
  73. package/dist/catchUtil.min.esm.js +0 -112833
  74. package/dist/catchUtil.min.js +0 -2922
@@ -160,19 +160,14 @@ class Measurement {
160
160
 
161
161
  while (!triangles.length && projs.length) { // 寻找可成功分解的投影平面
162
162
  flatCoordinates = projs.shift()
163
- flatCoordinates.pop() // 去掉最后一个重复的点
163
+ flatCoordinates = this._reduceCoordinates(flatCoordinates)
164
164
  let edges = []
165
165
  flatCoordinates.forEach((coord, index) => {
166
- let edge = null
167
166
  if (index === flatCoordinates.length - 1) {
168
- edge = [index, 0]
167
+ edges.push([index, 0])
169
168
  } else {
170
- edge = [index, index + 1]
169
+ edges.push([index, index + 1])
171
170
  }
172
- if (_.isEqual(flatCoordinates[edge[0]], flatCoordinates[edge[1]])) {
173
- return
174
- }
175
- edges.push(edge)
176
171
  })
177
172
  triangles = cdt2d(flatCoordinates, edges, { exterior: false })
178
173
  }
@@ -198,6 +193,17 @@ class Measurement {
198
193
  let c = this.getDistance3D([p3, p1])
199
194
  return Math.sqrt((a + b + c) * (a + b - c) * (a + c - b) * (b + c - a)) / 4
200
195
  }
196
+
197
+ _reduceCoordinates (coords) { // 去重
198
+ for(let i = 0;i < coords.length; i++) {
199
+ let nextIndex = i === coords.length - 1 ? 0 : (i + 1)
200
+ if (_.isEqual(coords[i], coords[nextIndex])) {
201
+ coords.splice(i, 1)
202
+ i--
203
+ }
204
+ }
205
+ return coords
206
+ }
201
207
  }
202
208
 
203
209
  export default Measurement
package/src/transform.js CHANGED
@@ -11,6 +11,9 @@ import { crsList, crsTypes } from './constants'
11
11
  export function getWKTString (crs) {
12
12
  let {type, epsg_code} = crs
13
13
  for(let i = 0;i < crsList.length;i++) {
14
+ if (!crsTypes[crsList[i].type]) {
15
+ continue
16
+ }
14
17
  let typeCode = crsTypes[crsList[i].type].code
15
18
  if (typeCode !== type) {
16
19
  continue
package/src/util.js CHANGED
@@ -370,12 +370,20 @@ export function getLineLabelFeature (lineFeature) {
370
370
  * @param {*} icons 要添加的图标列表,包含图标的url以及是否作为sdf符号
371
371
  */
372
372
  export function addIcons2Map (map, icons) {
373
- icons.forEach(({url, sdf}) => {
374
- map.loadImage(url, (error, image) => {
375
- let iconName = url.split('/').pop().split('.')[0]
376
- if(map.hasImage(iconName)) return
377
- if (error) throw error
378
- map.addImage(iconName, image, {sdf})
373
+ return new Promise((resolve, reject) => {
374
+ let cnt = icons.length
375
+ icons.forEach(({url, sdf}) => {
376
+ map.loadImage(url, (error, image) => {
377
+ cnt--
378
+ let iconName = url.split('/').pop().split('.')[0]
379
+ if(map.hasImage(iconName)) return
380
+ if (error) {
381
+ reject(error)
382
+ return
383
+ }
384
+ map.addImage(iconName, image, {sdf})
385
+ if (cnt <= 0) resolve(true)
386
+ })
379
387
  })
380
388
  })
381
389
  }
package/vite.config.js ADDED
@@ -0,0 +1,58 @@
1
+ import { defineConfig } from "vite";
2
+ import glslify from 'vite-plugin-glslify'
3
+
4
+ const path = require("path");
5
+
6
+ const config = defineConfig({
7
+
8
+ plugins: [glslify()],
9
+ server: {
10
+ port: 5173,
11
+ },
12
+ build: {
13
+ target: "es2015",
14
+ outDir: path.resolve(__dirname, "./dist"),
15
+ lib: {
16
+ entry: path.resolve(__dirname, "./src/index.js"),
17
+ name: "catchUtil",
18
+ },
19
+ rollupOptions: {
20
+ context: "globalThis",
21
+ preserveEntrySignatures: "strict",
22
+ output: [
23
+ {
24
+ format: "umd",
25
+ exports: "named",
26
+ sourcemap: false,
27
+ entryFileNames: "catchUtil.min.js",
28
+ chunkFileNames: "[name].js",
29
+ assetFileNames: "[name].[ext]",
30
+ namespaceToStringTag: true,
31
+ inlineDynamicImports: false,
32
+ manualChunks: undefined
33
+ },
34
+ {
35
+ format: "es",
36
+ exports: "named",
37
+ sourcemap: false,
38
+ entryFileNames: "catchUtil.min.esm.js",
39
+ chunkFileNames: "[name].js",
40
+ assetFileNames: "[name].[ext]",
41
+ namespaceToStringTag: true,
42
+ inlineDynamicImports: false,
43
+ manualChunks: undefined
44
+ },
45
+ ],
46
+ },
47
+ },
48
+ optimizeDeps: {
49
+ esbuildOptions: {
50
+ target: 'es2015',
51
+ },
52
+ },
53
+ resolve: {
54
+ extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"],
55
+ },
56
+ });
57
+
58
+ export default config;