@abi-software/flatmap-viewer 2.6.0-a.1 → 2.6.0
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/README.rst +2 -2
- package/package.json +24 -10
- package/src/controls/annotation.js +27 -10
- package/src/flatmap-viewer.js +50 -2
- package/src/interactions.js +89 -116
- package/src/layers/filter.js +310 -0
- package/src/layers/index.js +132 -45
- package/src/layers/paths3d.js +60 -10
- package/src/main.js +1 -4
- package/src/layers/filter.ts +0 -187
package/src/layers/paths3d.js
CHANGED
|
@@ -26,6 +26,7 @@ import GL from '@luma.gl/constants'
|
|
|
26
26
|
//==============================================================================
|
|
27
27
|
|
|
28
28
|
import {pathColourArray} from '../pathways'
|
|
29
|
+
import {PropertiesFilter} from './filter'
|
|
29
30
|
|
|
30
31
|
//==============================================================================
|
|
31
32
|
|
|
@@ -60,6 +61,7 @@ class ArcMapLayer extends ArcLayer
|
|
|
60
61
|
shaders.vs = `#version 300 es\n${shaders.vs}`
|
|
61
62
|
return shaders
|
|
62
63
|
}
|
|
64
|
+
|
|
63
65
|
setDataProperty(featureId, key, enabled)
|
|
64
66
|
//======================================
|
|
65
67
|
{
|
|
@@ -139,10 +141,12 @@ export class Paths3DLayer
|
|
|
139
141
|
#deckOverlay = null
|
|
140
142
|
#dimmed = false
|
|
141
143
|
#enabled = false
|
|
144
|
+
#featureFilter = new PropertiesFilter()
|
|
142
145
|
#featureToLayer = new Map()
|
|
143
146
|
#knownTypes = []
|
|
144
147
|
#map
|
|
145
148
|
#pathData
|
|
149
|
+
#pathFilters
|
|
146
150
|
#pathManager
|
|
147
151
|
#pathStyles
|
|
148
152
|
#ui
|
|
@@ -162,7 +166,27 @@ export class Paths3DLayer
|
|
|
162
166
|
&& 'pathEndPosition' in ann)
|
|
163
167
|
.map(ann => [ann.featureId, ann]))
|
|
164
168
|
this.#pathStyles = new Map(this.#pathManager.pathStyles().map(s => [s.type, s]))
|
|
165
|
-
|
|
169
|
+
const knownTypes = [...this.#pathStyles.keys()].filter(t => t !== 'other')
|
|
170
|
+
this.#pathFilters = new Map(
|
|
171
|
+
[...this.#pathStyles.keys()]
|
|
172
|
+
.map(pathType => [pathType, new PropertiesFilter({
|
|
173
|
+
OR: [{
|
|
174
|
+
AND: [
|
|
175
|
+
{kind: knownTypes},
|
|
176
|
+
{kind: pathType}
|
|
177
|
+
],
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
AND: [
|
|
181
|
+
{
|
|
182
|
+
NOT: {kind: knownTypes}
|
|
183
|
+
},
|
|
184
|
+
(pathType === 'other')
|
|
185
|
+
]
|
|
186
|
+
}]
|
|
187
|
+
})
|
|
188
|
+
])
|
|
189
|
+
)
|
|
166
190
|
}
|
|
167
191
|
|
|
168
192
|
enable(enable=true)
|
|
@@ -223,6 +247,30 @@ export class Paths3DLayer
|
|
|
223
247
|
}
|
|
224
248
|
}
|
|
225
249
|
|
|
250
|
+
setFilter(featureFilter)
|
|
251
|
+
//======================
|
|
252
|
+
{
|
|
253
|
+
this.#featureFilter = featureFilter
|
|
254
|
+
if (this.#deckOverlay) {
|
|
255
|
+
const updatedLayers = new Map()
|
|
256
|
+
for (const [pathType, layer] of this.#arcLayers.entries()) {
|
|
257
|
+
layer.featureIds.forEach(id => this.#featureToLayer.delete(+id))
|
|
258
|
+
const pathStyle = this.#pathStyles.get(pathType)
|
|
259
|
+
if (pathStyle) {
|
|
260
|
+
const updatedLayer = pathStyle.dashed
|
|
261
|
+
? new ArcDashedLayer(this.#layerOptions(pathType))
|
|
262
|
+
: new ArcMapLayer(this.#layerOptions(pathType))
|
|
263
|
+
updatedLayer.featureIds.forEach(id => this.#featureToLayer.set(+id, layer))
|
|
264
|
+
updatedLayers.set(pathType, updatedLayer)
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
this.#arcLayers = updatedLayers
|
|
268
|
+
this.#deckOverlay.setProps({
|
|
269
|
+
layers: [...this.#arcLayers.values()]
|
|
270
|
+
})
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
226
274
|
setPaint(options)
|
|
227
275
|
//===============
|
|
228
276
|
{
|
|
@@ -236,11 +284,14 @@ export class Paths3DLayer
|
|
|
236
284
|
#addArcLayer(pathType)
|
|
237
285
|
//====================
|
|
238
286
|
{
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
287
|
+
const pathStyle = this.#pathStyles.get(pathType)
|
|
288
|
+
if (pathStyle) {
|
|
289
|
+
const layer = pathStyle.dashed
|
|
290
|
+
? new ArcDashedLayer(this.#layerOptions(pathType))
|
|
291
|
+
: new ArcMapLayer(this.#layerOptions(pathType))
|
|
292
|
+
layer.featureIds.forEach(id => this.#featureToLayer.set(+id, layer))
|
|
293
|
+
this.#arcLayers.set(pathType, layer)
|
|
294
|
+
}
|
|
244
295
|
}
|
|
245
296
|
|
|
246
297
|
#removeArcLayer(pathType)
|
|
@@ -283,13 +334,12 @@ export class Paths3DLayer
|
|
|
283
334
|
}
|
|
284
335
|
}
|
|
285
336
|
|
|
286
|
-
|
|
287
337
|
#layerOptions(pathType)
|
|
288
338
|
//=====================
|
|
289
339
|
{
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
340
|
+
const filter = this.#pathFilters.get(pathType)
|
|
341
|
+
const pathData = (filter ? [...this.#pathData.values()].filter(ann => filter.match(ann))
|
|
342
|
+
: []).filter(ann => this.#featureFilter.match(ann))
|
|
293
343
|
return {
|
|
294
344
|
id: `arc-${pathType}`,
|
|
295
345
|
data: pathData,
|
package/src/main.js
CHANGED
|
@@ -64,10 +64,7 @@ class DrawControl
|
|
|
64
64
|
//================
|
|
65
65
|
{
|
|
66
66
|
console.log(event)
|
|
67
|
-
|
|
68
|
-
this._flatmap.showPopup(event.feature.id, '<div>event</div>')
|
|
69
|
-
|
|
70
|
-
if (this._idField) {
|
|
67
|
+
if (this._idField && event.type !== 'modeChanged' && event.type !== 'selectionChanged') {
|
|
71
68
|
this._idField.innerText = `Annotation ${event.type}, Id: ${event.feature.id}`
|
|
72
69
|
this._lastEvent = event
|
|
73
70
|
}
|
package/src/layers/filter.ts
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/******************************************************************************
|
|
2
|
-
|
|
3
|
-
Flatmap viewer and annotation tool
|
|
4
|
-
|
|
5
|
-
Copyright (c) 2019 - 2024 David Brooks
|
|
6
|
-
|
|
7
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
you may not use this file except in compliance with the License.
|
|
9
|
-
You may obtain a copy of the License at
|
|
10
|
-
|
|
11
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
See the License for the specific language governing permissions and
|
|
17
|
-
limitations under the License.
|
|
18
|
-
|
|
19
|
-
******************************************************************************/
|
|
20
|
-
|
|
21
|
-
type FilterExpression = Record<string, any>
|
|
22
|
-
|
|
23
|
-
//==============================================================================
|
|
24
|
-
|
|
25
|
-
export class FeatureFilter
|
|
26
|
-
{
|
|
27
|
-
#filter: FilterExpression
|
|
28
|
-
|
|
29
|
-
constructor(filter: FilterExpression)
|
|
30
|
-
{
|
|
31
|
-
this.#filter = filter
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
makeStyleFilter()
|
|
35
|
-
//===============
|
|
36
|
-
{
|
|
37
|
-
return this.#makeStyleFilter(this.#filter)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
#makeStyleFilter(filter: FilterExpression): Array<any>
|
|
41
|
-
//====================================================
|
|
42
|
-
{
|
|
43
|
-
// We expect an object, so check and warn...
|
|
44
|
-
if (!filter || filter.constructor !== Object) {
|
|
45
|
-
console.warn(`makeFilter: Invalid filter expression: ${filter}`)
|
|
46
|
-
return []
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const styleFilter = []
|
|
50
|
-
for (const [key, expr] of Object.entries(filter)) {
|
|
51
|
-
if (key === 'AND' || key === 'OR') {
|
|
52
|
-
if (Array.isArray(expr) && expr.length >= 2) {
|
|
53
|
-
styleFilter.push((key === 'AND') ? 'all' : 'any',
|
|
54
|
-
...expr.map(e => this.#makeStyleFilter(e)))
|
|
55
|
-
} else {
|
|
56
|
-
console.warn(`makeFilter: Invalid ${key} operands: ${expr}`)
|
|
57
|
-
}
|
|
58
|
-
} else if (key === 'HAS') {
|
|
59
|
-
styleFilter.push('has', expr)
|
|
60
|
-
} else if (key === 'NOT') {
|
|
61
|
-
const filterExpr = this.#makeStyleFilter(expr)
|
|
62
|
-
if (filterExpr.length === 2 && ['has', '!has'].includes(filterExpr[0])) {
|
|
63
|
-
if (filterExpr[0] === 'has') {
|
|
64
|
-
styleFilter.push('!has', filterExpr[1])
|
|
65
|
-
} else {
|
|
66
|
-
styleFilter.push('has', filterExpr[1])
|
|
67
|
-
}
|
|
68
|
-
} else if (filterExpr.length === 3 && ['==', '!='].includes(filterExpr[0])) {
|
|
69
|
-
if (filterExpr[0] === '==') {
|
|
70
|
-
styleFilter.push('!=', filterExpr[1], filterExpr[2])
|
|
71
|
-
} else {
|
|
72
|
-
styleFilter.push('==', filterExpr[1], filterExpr[2])
|
|
73
|
-
}
|
|
74
|
-
} else {
|
|
75
|
-
styleFilter.push('!', filterExpr)
|
|
76
|
-
}
|
|
77
|
-
} else {
|
|
78
|
-
if (Array.isArray(expr)) {
|
|
79
|
-
styleFilter.push('any', ...expr.map(e => ['==', key, e]))
|
|
80
|
-
} else {
|
|
81
|
-
styleFilter.push('==', key, expr)
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return styleFilter
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
//==============================================================================
|
|
91
|
-
|
|
92
|
-
function testFilter(f: FilterExpression)
|
|
93
|
-
//======================================
|
|
94
|
-
{
|
|
95
|
-
const featureFilter = new FeatureFilter(f)
|
|
96
|
-
console.log(f, '--->', featureFilter.makeStyleFilter())
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export function testFilters()
|
|
100
|
-
//===========================
|
|
101
|
-
{
|
|
102
|
-
/*
|
|
103
|
-
{ HAS: 'prop' } ---> [ 'has', 'prop' ]
|
|
104
|
-
{ prop: 1 } ---> [ '==', 'prop', 1 ]
|
|
105
|
-
{ NOT: { prop: 1 } } ---> [ '!=', 'prop', 1 ]
|
|
106
|
-
{ NOT: { prop: [ 1, 2 ] } } ---> [ '!', [ 'any', [ '==', 'prop', 1 ], [ '==', 'prop', 2 ] ] ]
|
|
107
|
-
{ OR: [ { prop1: 10 }, { prop2: 11 } ] } ---> [ 'any', [ '==', 'prop1', 10 ], [ '==', 'prop2', 11 ] ]
|
|
108
|
-
{ AND: [ { prop1: 10 }, { prop2: 11 } ] } ---> [ 'all', [ '==', 'prop1', 10 ], [ '==', 'prop2', 11 ] ]
|
|
109
|
-
{ OR: [ { AND: [Array] }, { AND: [Array] } ] } ---> [
|
|
110
|
-
'any',
|
|
111
|
-
[ 'all', [ '!=', 'prop1', 10 ], [ '==', 'prop2', 11 ] ],
|
|
112
|
-
[ 'all', [ '==', 'prop3', 10 ], [ '==', 'prop4', 11 ] ]
|
|
113
|
-
]
|
|
114
|
-
{ NOT: { OR: [ [Object], [Object] ] } } ---> [
|
|
115
|
-
'!',
|
|
116
|
-
[ 'any', [ 'all', [Array], [Array] ], [ 'all', [Array], [Array] ] ]
|
|
117
|
-
]
|
|
118
|
-
*/
|
|
119
|
-
|
|
120
|
-
testFilter({
|
|
121
|
-
"HAS": "prop"
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
testFilter({
|
|
125
|
-
"prop": 1
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
testFilter({
|
|
129
|
-
"NOT": {
|
|
130
|
-
"prop": 1
|
|
131
|
-
}
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
testFilter({
|
|
135
|
-
"NOT": {
|
|
136
|
-
"prop": [1, 2]
|
|
137
|
-
}
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
testFilter({
|
|
141
|
-
"OR": [
|
|
142
|
-
{"prop1": 10},
|
|
143
|
-
{"prop2": 11}
|
|
144
|
-
]
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
testFilter({
|
|
148
|
-
"AND": [
|
|
149
|
-
{"prop1": 10},
|
|
150
|
-
{"prop2": 11}
|
|
151
|
-
]
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
testFilter({
|
|
155
|
-
"OR": [{
|
|
156
|
-
"AND": [
|
|
157
|
-
{ "NOT": {"prop1": 10}},
|
|
158
|
-
{"prop2": 11}
|
|
159
|
-
]}, {
|
|
160
|
-
"AND": [
|
|
161
|
-
{"prop3": 10},
|
|
162
|
-
{"prop4": 11}
|
|
163
|
-
]}
|
|
164
|
-
]
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
testFilter({
|
|
168
|
-
"NOT": {
|
|
169
|
-
"OR": [{
|
|
170
|
-
"AND": [
|
|
171
|
-
{"prop1": 10},
|
|
172
|
-
{"prop2": 11}
|
|
173
|
-
]}, {
|
|
174
|
-
"AND": [
|
|
175
|
-
{"prop3": 10},
|
|
176
|
-
{"prop4": 11}
|
|
177
|
-
]}
|
|
178
|
-
]
|
|
179
|
-
}
|
|
180
|
-
})
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
//==============================================================================
|
|
184
|
-
|
|
185
|
-
//testFilters()
|
|
186
|
-
|
|
187
|
-
//==============================================================================
|