@jupytergis/base 0.9.0 → 0.9.1
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/lib/mainview/mainView.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { JupyterGISModel, } from '@jupytergis/schema';
|
|
2
13
|
import { showErrorMessage } from '@jupyterlab/apputils';
|
|
3
14
|
import { CommandRegistry } from '@lumino/commands';
|
|
@@ -441,6 +452,7 @@ export class MainView extends React.Component {
|
|
|
441
452
|
this._ready = false;
|
|
442
453
|
this._sourceToLayerMap = new Map();
|
|
443
454
|
this._originalFeatures = {};
|
|
455
|
+
this._featurePropertyCache = new Map();
|
|
444
456
|
this._state = props.state;
|
|
445
457
|
this._formSchemaRegistry = props.formSchemaRegistry;
|
|
446
458
|
this._annotationModel = props.annotationModel;
|
|
@@ -1592,24 +1604,45 @@ export class MainView extends React.Component {
|
|
|
1592
1604
|
case 'VectorTileLayer': {
|
|
1593
1605
|
const geometries = [];
|
|
1594
1606
|
const features = [];
|
|
1607
|
+
let foundAny = false;
|
|
1595
1608
|
this._Map.forEachFeatureAtPixel(e.pixel, (feature) => {
|
|
1609
|
+
var _a, _b;
|
|
1610
|
+
foundAny = true;
|
|
1596
1611
|
let geom;
|
|
1612
|
+
let props = {};
|
|
1597
1613
|
if (feature instanceof RenderFeature) {
|
|
1598
1614
|
geom = toGeometry(feature);
|
|
1599
1615
|
}
|
|
1600
1616
|
else if ('getGeometry' in feature) {
|
|
1601
1617
|
geom = feature.getGeometry();
|
|
1602
1618
|
}
|
|
1603
|
-
const
|
|
1619
|
+
const rawProps = feature.getProperties();
|
|
1620
|
+
const fid = (_b = (_a = feature.getId) === null || _a === void 0 ? void 0 : _a.call(feature)) !== null && _b !== void 0 ? _b : rawProps === null || rawProps === void 0 ? void 0 : rawProps.fid;
|
|
1621
|
+
if (rawProps && Object.keys(rawProps).length > 1) {
|
|
1622
|
+
const { geometry } = rawProps, clean = __rest(rawProps, ["geometry"]);
|
|
1623
|
+
props = clean;
|
|
1624
|
+
if (fid !== null) {
|
|
1625
|
+
// TODO Clean the cache under some condition?
|
|
1626
|
+
this._featurePropertyCache.set(fid, props);
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
else if (fid !== null && this._featurePropertyCache.has(fid)) {
|
|
1630
|
+
props = this._featurePropertyCache.get(fid);
|
|
1631
|
+
}
|
|
1604
1632
|
if (geom) {
|
|
1605
1633
|
geometries.push(geom);
|
|
1606
1634
|
}
|
|
1607
|
-
|
|
1635
|
+
if (props && Object.keys(props).length > 0) {
|
|
1636
|
+
features.push(props);
|
|
1637
|
+
}
|
|
1608
1638
|
return true;
|
|
1609
1639
|
});
|
|
1610
1640
|
if (features.length > 0) {
|
|
1611
1641
|
this._model.syncIdentifiedFeatures(features, this._mainViewModel.id);
|
|
1612
1642
|
}
|
|
1643
|
+
else if (!foundAny) {
|
|
1644
|
+
this._model.syncIdentifiedFeatures([], this._mainViewModel.id);
|
|
1645
|
+
}
|
|
1613
1646
|
if (geometries.length > 0) {
|
|
1614
1647
|
for (const geom of geometries) {
|
|
1615
1648
|
this._model.highlightFeatureSignal.emit(geom);
|
|
@@ -67,34 +67,36 @@ export const IdentifyPanelComponent = ({ model, }) => {
|
|
|
67
67
|
border: ((_a = model === null || model === void 0 ? void 0 : model.localState) === null || _a === void 0 ? void 0 : _a.remoteUser)
|
|
68
68
|
? `solid 3px ${remoteUser === null || remoteUser === void 0 ? void 0 : remoteUser.color}`
|
|
69
69
|
: 'unset',
|
|
70
|
-
} },
|
|
71
|
-
Object.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
React.createElement("span",
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
key,
|
|
95
|
-
"
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
70
|
+
} },
|
|
71
|
+
!Object.keys(features !== null && features !== void 0 ? features : {}).length && (React.createElement("div", { style: { textAlign: 'center' } }, "Please select a layer from the layer list, then \"i\" from the toolbar to start identifying features.")),
|
|
72
|
+
features &&
|
|
73
|
+
Object.values(features).map((feature, featureIndex) => (React.createElement("div", { key: featureIndex, className: "jgis-identify-grid-item" },
|
|
74
|
+
React.createElement("div", { className: "jgis-identify-grid-item-header" },
|
|
75
|
+
React.createElement("span", { onClick: () => toggleFeatureVisibility(featureIndex) },
|
|
76
|
+
React.createElement(LabIcon.resolveReact, { icon: caretDownIcon, className: `jp-gis-layerGroupCollapser${visibleFeatures[featureIndex] ? ' jp-mod-expanded' : ''}`, tag: 'span' }),
|
|
77
|
+
React.createElement("span", null, getFeatureNameOrId(feature, featureIndex))),
|
|
78
|
+
(() => {
|
|
79
|
+
const isRasterFeature = !feature.geometry &&
|
|
80
|
+
!feature._geometry &&
|
|
81
|
+
typeof (feature === null || feature === void 0 ? void 0 : feature.x) !== 'number' &&
|
|
82
|
+
typeof (feature === null || feature === void 0 ? void 0 : feature.y) !== 'number';
|
|
83
|
+
return (React.createElement("button", { className: "jgis-highlight-button", onClick: e => {
|
|
84
|
+
e.stopPropagation();
|
|
85
|
+
highlightFeatureOnMap(feature);
|
|
86
|
+
}, title: isRasterFeature
|
|
87
|
+
? 'Highlight not available for raster features'
|
|
88
|
+
: 'Highlight feature on map', disabled: isRasterFeature },
|
|
89
|
+
React.createElement(FontAwesomeIcon, { icon: faMagnifyingGlass })));
|
|
90
|
+
})()),
|
|
91
|
+
visibleFeatures[featureIndex] && (React.createElement(React.Fragment, null, Object.entries(feature)
|
|
92
|
+
.filter(([key, value]) => typeof value !== 'object' || value === null)
|
|
93
|
+
.sort(([keyA], [keyB]) => keyA.localeCompare(keyB))
|
|
94
|
+
.map(([key, value]) => (React.createElement("div", { key: key, className: "jgis-identify-grid-body" },
|
|
95
|
+
React.createElement("strong", null,
|
|
96
|
+
key,
|
|
97
|
+
":"),
|
|
98
|
+
typeof value === 'string' &&
|
|
99
|
+
/<\/?[a-z][\s\S]*>/i.test(value) ? (React.createElement("span", { dangerouslySetInnerHTML: {
|
|
100
|
+
__html: `${value}`,
|
|
101
|
+
} })) : (React.createElement("span", null, String(value)))))))))))));
|
|
100
102
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupytergis/base",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "A JupyterLab extension for 3D modelling.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jupyter",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@jupyter/collaboration": "^3.1.0",
|
|
45
45
|
"@jupyter/react-components": "^0.16.6",
|
|
46
46
|
"@jupyter/ydoc": "^2.0.0 || ^3.0.0",
|
|
47
|
-
"@jupytergis/schema": "^0.9.
|
|
47
|
+
"@jupytergis/schema": "^0.9.1",
|
|
48
48
|
"@jupyterlab/application": "^4.3.0",
|
|
49
49
|
"@jupyterlab/apputils": "^4.3.0",
|
|
50
50
|
"@jupyterlab/completer": "^4.3.0",
|