@mapcatch/util 2.0.3 → 2.0.5
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/CHANGELOG.md +5 -1
- package/dist/catchUtil.min.esm.js +4053 -3888
- package/dist/catchUtil.min.js +42 -36
- package/package.json +2 -2
- package/src/constants/default_layers.js +102 -11
- package/src/constants/index.js +1 -0
- package/src/constants/layer_groups_multispectral.js +34 -0
- package/src/constants/layer_icons.js +1 -0
- package/src/gl-operations/index.js +14 -2
- package/src/gl-operations/reglCommands/default.js +2 -0
- package/src/gl-operations/reglCommands/hillshading.js +10 -2
- package/src/gl-operations/reglCommands/multiLayers.js +3 -1
- package/src/gl-operations/reglCommands/transitions.js +2 -0
- package/src/gl-operations/renderer.js +21 -4
- package/src/gl-operations/shaders/fragment/drawResult.js +6 -1
- package/src/gl-operations/shaders/fragment/hillshading/hsAdvDirect.js +6 -1
- package/src/gl-operations/shaders/fragment/hillshading/hsAdvFinalColorscale.js +6 -1
- package/src/gl-operations/shaders/fragment/hillshading/hsPregen.js +6 -1
- package/src/gl-operations/shaders/fragment/interpolateColor.js +7 -4
- package/src/gl-operations/shaders/fragment/interpolateColorOnly.js +7 -4
- package/src/gl-operations/shaders/fragment/interpolateValue.js +18 -5
- package/src/gl-operations/shaders/fragment/single.js +6 -1
- package/src/gl-operations/shaders/util/computeColor.glsl +5 -4
- package/src/measure/index.js +14 -8
- package/src/transform.js +3 -0
- package/src/util.js +14 -6
package/src/measure/index.js
CHANGED
|
@@ -160,19 +160,14 @@ class Measurement {
|
|
|
160
160
|
|
|
161
161
|
while (!triangles.length && projs.length) { // 寻找可成功分解的投影平面
|
|
162
162
|
flatCoordinates = projs.shift()
|
|
163
|
-
flatCoordinates.
|
|
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
|
-
|
|
167
|
+
edges.push([index, 0])
|
|
169
168
|
} else {
|
|
170
|
-
|
|
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
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
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
|
}
|