@vcmap/core 5.0.0-rc.28 → 5.0.0-rc.29
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.md +9 -3
- package/build/postinstall.js +13 -2
- package/index.d.ts +155 -106
- package/package.json +9 -4
- package/src/category/category.js +71 -32
- package/src/category/categoryCollection.js +27 -18
- package/src/cesium/cesiumVcsCameraPrimitive.js +13 -5
- package/src/cesium/entity.js +3 -1
- package/src/cesium/wallpaperMaterial.js +4 -2
- package/src/classRegistry.js +11 -4
- package/src/featureProvider/abstractFeatureProvider.js +43 -22
- package/src/featureProvider/tileProviderFeatureProvider.js +11 -5
- package/src/featureProvider/wmsFeatureProvider.js +37 -15
- package/src/interaction/abstractInteraction.js +5 -1
- package/src/interaction/coordinateAtPixel.js +34 -12
- package/src/interaction/eventHandler.js +63 -23
- package/src/interaction/featureAtPixelInteraction.js +96 -32
- package/src/interaction/featureProviderInteraction.js +23 -8
- package/src/interaction/interactionChain.js +19 -9
- package/src/interaction/interactionType.js +23 -26
- package/src/layer/cesium/cesiumTilesetCesiumImpl.js +45 -15
- package/src/layer/cesium/clusterContext.js +10 -3
- package/src/layer/cesium/dataSourceCesiumImpl.js +13 -4
- package/src/layer/cesium/openStreetMapCesiumImpl.js +7 -3
- package/src/layer/cesium/rasterLayerCesiumImpl.js +6 -2
- package/src/layer/cesium/singleImageCesiumImpl.js +14 -3
- package/src/layer/cesium/terrainCesiumImpl.js +3 -2
- package/src/layer/cesium/tmsCesiumImpl.js +15 -3
- package/src/layer/cesium/vectorCesiumImpl.js +69 -25
- package/src/layer/cesium/vectorContext.js +25 -5
- package/src/layer/cesium/vectorRasterTileCesiumImpl.js +15 -5
- package/src/layer/cesium/vectorTileImageryProvider.js +51 -13
- package/src/layer/cesium/wmsCesiumImpl.js +15 -3
- package/src/layer/cesium/wmtsCesiumImpl.js +18 -6
- package/src/layer/cesium/x3dmHelper.js +4 -1
- package/src/layer/cesiumTilesetLayer.js +55 -26
- package/src/layer/czmlLayer.js +11 -5
- package/src/layer/dataSourceLayer.js +25 -17
- package/src/layer/featureLayer.js +33 -18
- package/src/layer/featureStoreLayer.js +161 -99
- package/src/layer/featureStoreLayerChanges.js +57 -17
- package/src/layer/featureVisibility.js +89 -59
- package/src/layer/geojsonHelpers.js +70 -29
- package/src/layer/geojsonLayer.js +17 -11
- package/src/layer/globalHider.js +14 -4
- package/src/layer/layer.js +77 -44
- package/src/layer/layerImplementation.js +12 -4
- package/src/layer/oblique/layerObliqueImpl.js +3 -1
- package/src/layer/oblique/obliqueHelpers.js +75 -30
- package/src/layer/oblique/vectorObliqueImpl.js +175 -69
- package/src/layer/openStreetMapLayer.js +34 -20
- package/src/layer/openlayers/layerOpenlayersImpl.js +37 -15
- package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/singleImageOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/tileDebugOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/tmsOpenlayersImpl.js +6 -3
- package/src/layer/openlayers/vectorOpenlayersImpl.js +14 -4
- package/src/layer/openlayers/vectorTileOpenlayersImpl.js +12 -5
- package/src/layer/openlayers/wmsOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/wmtsOpenlayersImpl.js +12 -5
- package/src/layer/pointCloudLayer.js +21 -10
- package/src/layer/rasterLayer.js +73 -22
- package/src/layer/singleImageLayer.js +10 -7
- package/src/layer/terrainHelpers.js +30 -19
- package/src/layer/terrainLayer.js +16 -7
- package/src/layer/tileLoadedHelper.js +9 -4
- package/src/layer/tileProvider/mvtTileProvider.js +10 -4
- package/src/layer/tileProvider/staticGeojsonTileProvider.js +10 -4
- package/src/layer/tileProvider/tileProvider.js +163 -87
- package/src/layer/tileProvider/urlTemplateTileProvider.js +10 -4
- package/src/layer/tmsLayer.js +7 -6
- package/src/layer/vectorHelpers.js +34 -25
- package/src/layer/vectorLayer.js +77 -36
- package/src/layer/vectorProperties.js +245 -74
- package/src/layer/vectorSymbols.js +3 -1
- package/src/layer/vectorTileLayer.js +121 -70
- package/src/layer/wfsLayer.js +19 -8
- package/src/layer/wmsHelpers.js +11 -6
- package/src/layer/wmsLayer.js +36 -14
- package/src/layer/wmtsLayer.js +35 -20
- package/src/map/baseOLMap.js +57 -31
- package/src/map/cameraLimiter.js +67 -18
- package/src/map/cesiumMap.js +307 -95
- package/src/map/obliqueMap.js +84 -34
- package/src/map/openlayersMap.js +40 -19
- package/src/map/vcsMap.js +21 -8
- package/src/oblique/helpers.js +212 -64
- package/src/oblique/obliqueCollection.js +111 -48
- package/src/oblique/obliqueDataSet.js +53 -21
- package/src/oblique/obliqueImage.js +50 -17
- package/src/oblique/obliqueImageMeta.js +7 -6
- package/src/oblique/obliqueProvider.js +75 -27
- package/src/oblique/obliqueView.js +18 -7
- package/src/oblique/obliqueViewDirection.js +3 -2
- package/src/oblique/parseImageJson.js +57 -23
- package/src/ol/feature.js +8 -3
- package/src/ol/geom/circle.js +12 -3
- package/src/ol/geom/geometryCollection.js +11 -4
- package/src/ol/render/canvas/canvasTileRenderer.js +11 -9
- package/src/overrideClassRegistry.js +13 -3
- package/src/style/arcStyle.js +129 -36
- package/src/style/arrowStyle.js +57 -22
- package/src/style/declarativeStyleItem.js +107 -62
- package/src/style/shapesCategory.js +8 -6
- package/src/style/styleFactory.js +4 -1
- package/src/style/styleHelpers.js +17 -8
- package/src/style/styleItem.js +28 -10
- package/src/style/vectorStyleItem.js +160 -74
- package/src/style/writeStyle.js +5 -7
- package/src/util/clipping/clippingObject.js +72 -38
- package/src/util/clipping/clippingObjectManager.js +53 -19
- package/src/util/clipping/clippingPlaneHelper.js +120 -53
- package/src/util/collection.js +12 -6
- package/src/util/editor/createFeatureSession.js +21 -6
- package/src/util/editor/editFeaturesSession.js +41 -15
- package/src/util/editor/editGeometrySession.js +55 -30
- package/src/util/editor/editorHelpers.js +114 -29
- package/src/util/editor/editorSessionHelpers.js +8 -3
- package/src/util/editor/interactions/createBBoxInteraction.js +11 -3
- package/src/util/editor/interactions/createCircleInteraction.js +7 -2
- package/src/util/editor/interactions/createLineStringInteraction.js +7 -2
- package/src/util/editor/interactions/createPolygonInteraction.js +7 -2
- package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +7 -5
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +8 -3
- package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +4 -2
- package/src/util/editor/interactions/insertVertexInteraction.js +17 -6
- package/src/util/editor/interactions/mapInteractionController.js +31 -14
- package/src/util/editor/interactions/removeVertexInteraction.js +4 -1
- package/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +19 -10
- package/src/util/editor/interactions/selectMultiFeatureInteraction.js +33 -20
- package/src/util/editor/interactions/selectSingleFeatureInteraction.js +14 -8
- package/src/util/editor/selectFeaturesSession.js +37 -21
- package/src/util/editor/transformation/create2DHandlers.js +82 -37
- package/src/util/editor/transformation/create3DHandlers.js +187 -84
- package/src/util/editor/transformation/extrudeInteraction.js +20 -5
- package/src/util/editor/transformation/rotateInteraction.js +29 -16
- package/src/util/editor/transformation/scaleInteraction.js +31 -15
- package/src/util/editor/transformation/transformationHandler.js +23 -8
- package/src/util/editor/transformation/transformationTypes.js +8 -4
- package/src/util/editor/transformation/translateInteraction.js +86 -32
- package/src/util/editor/validateGeoemetry.js +3 -1
- package/src/util/exclusiveManager.js +6 -3
- package/src/util/extent.js +20 -10
- package/src/util/featureconverter/arcToCesium.js +46 -12
- package/src/util/featureconverter/circleToCesium.js +61 -27
- package/src/util/featureconverter/convert.js +85 -13
- package/src/util/featureconverter/extent3D.js +69 -28
- package/src/util/featureconverter/featureconverterHelper.js +232 -79
- package/src/util/featureconverter/lineStringToCesium.js +107 -35
- package/src/util/featureconverter/pointHelpers.js +117 -45
- package/src/util/featureconverter/pointToCesium.js +128 -31
- package/src/util/featureconverter/polygonToCesium.js +50 -16
- package/src/util/fetch.js +3 -1
- package/src/util/geometryHelpers.js +15 -10
- package/src/util/indexedCollection.js +7 -3
- package/src/util/isMobile.js +8 -2
- package/src/util/layerCollection.js +28 -12
- package/src/util/mapCollection.js +37 -18
- package/src/util/math.js +35 -19
- package/src/util/overrideCollection.js +57 -32
- package/src/util/projection.js +21 -5
- package/src/util/urlHelpers.js +5 -3
- package/src/util/viewpoint.js +66 -33
- package/src/vcsApp.js +133 -69
- package/src/vcsModule.js +3 -2
- package/src/vcsModuleHelpers.js +24 -9
- package/src/vcsObject.js +3 -2
- package/tests/data/dynamicPointCzml.json +24 -35
- package/tests/data/oblique/imageData/imagev34.json +56 -272
- package/tests/data/oblique/imageData/imagev35.json +272 -19
- package/tests/data/oblique/imageData/imagev35PerImageSize.json +299 -19
- package/tests/data/oblique/tiledImageData/12/2199/1342.json +11056 -1
- package/tests/data/oblique/tiledImageData/12/2199/1343.json +11236 -1
- package/tests/data/oblique/tiledImageData/12/2199/1344.json +11077 -1
- package/tests/data/oblique/tiledImageData/12/2200/1342.json +11036 -1
- package/tests/data/oblique/tiledImageData/12/2200/1343.json +11277 -1
- package/tests/data/oblique/tiledImageData/12/2200/1344.json +11131 -1
- package/tests/data/oblique/tiledImageData/12/2201/1342.json +10870 -1
- package/tests/data/oblique/tiledImageData/12/2201/1343.json +11492 -1
- package/tests/data/oblique/tiledImageData/12/2201/1344.json +10909 -1
- package/tests/data/oblique/tiledImageData/image.json +70 -1
- package/tests/data/terrain/layer.json +121 -130
- package/tests/data/testGeoJSON.json +4 -16
- package/tests/unit/helpers/cesiumHelpers.js +58 -33
- package/tests/unit/helpers/helpers.js +10 -2
- package/tests/unit/helpers/imageHelpers.js +8 -4
- package/tests/unit/helpers/obliqueData.js +39 -13
- package/tests/unit/helpers/obliqueHelpers.js +12 -9
- package/tests/unit/helpers/openlayersHelpers.js +4 -1
- package/tests/unit/helpers/terrain/terrainData.js +8 -7
package/README.md
CHANGED
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
> Part of the [VC Map Project](https://github.com/virtualcitySYSTEMS/map-ui)
|
|
4
4
|
|
|
5
5
|
## Getting Started
|
|
6
|
+
|
|
6
7
|
- clone Repo
|
|
7
8
|
- npm install
|
|
8
9
|
|
|
9
10
|
# Coding Conventions
|
|
11
|
+
|
|
10
12
|
### Exporting from a module
|
|
13
|
+
|
|
11
14
|
- You should export all variables, functions, class etc. from a module
|
|
12
15
|
which are required to use the API.
|
|
13
16
|
- Make sure the names of exports have _meaning outside of their module_. E.g. a
|
|
@@ -19,14 +22,16 @@
|
|
|
19
22
|
* Resets the foo. Exported for testing
|
|
20
23
|
* @private
|
|
21
24
|
*/
|
|
22
|
-
export function resetFooInstance() {}
|
|
25
|
+
export function resetFooInstance() {}
|
|
23
26
|
```
|
|
24
27
|
|
|
25
28
|
### TS & Typesafety
|
|
29
|
+
|
|
26
30
|
- You should use the imported name in your doclets, e.g.:
|
|
31
|
+
|
|
27
32
|
```javascript
|
|
28
33
|
import Vector from 'ol/source/Vector.js';
|
|
29
|
-
|
|
34
|
+
|
|
30
35
|
/**
|
|
31
36
|
* @param {Vector} source
|
|
32
37
|
* @returns {Array<import("ol").Feature<import("ol/geom/Geometry").default>>}
|
|
@@ -38,7 +43,8 @@
|
|
|
38
43
|
return [];
|
|
39
44
|
}
|
|
40
45
|
```
|
|
41
|
-
|
|
46
|
+
|
|
47
|
+
- You should use dump file imports where possible (WebStorm cannot generate
|
|
42
48
|
Intelisensse from default imports). Thus `@param {import("ol/Feature").default}`
|
|
43
49
|
would become: `@param {import("ol").Feature}`.
|
|
44
50
|
- You will need to import library own classes use `@param {import("@vcmap/core").CesiumMap}`.
|
package/build/postinstall.js
CHANGED
|
@@ -15,7 +15,13 @@ async function fixCesiumTypes() {
|
|
|
15
15
|
) {
|
|
16
16
|
console.log('Moving cesium engine index.d.ts');
|
|
17
17
|
await fs.promises.cp(
|
|
18
|
-
path.join(
|
|
18
|
+
path.join(
|
|
19
|
+
process.cwd(),
|
|
20
|
+
'node_modules',
|
|
21
|
+
'@vcmap-cesium',
|
|
22
|
+
'engine',
|
|
23
|
+
'index.d.ts',
|
|
24
|
+
),
|
|
19
25
|
path.join(process.cwd(), 'build', 'types', 'Cesium_module.d.ts'),
|
|
20
26
|
{ force: true },
|
|
21
27
|
);
|
|
@@ -27,7 +33,12 @@ async function fixCesiumTypes() {
|
|
|
27
33
|
* @returns {Promise<void>}
|
|
28
34
|
*/
|
|
29
35
|
async function fixTinyQueue() {
|
|
30
|
-
const fileName = path.join(
|
|
36
|
+
const fileName = path.join(
|
|
37
|
+
process.cwd(),
|
|
38
|
+
'node_modules',
|
|
39
|
+
'tinyqueue',
|
|
40
|
+
'package.json',
|
|
41
|
+
);
|
|
31
42
|
if (fs.existsSync(fileName)) {
|
|
32
43
|
const content = await fs.promises.readFile(fileName);
|
|
33
44
|
const jsonContent = JSON.parse(content);
|
package/index.d.ts
CHANGED
|
@@ -5328,7 +5328,7 @@ export class ObliqueMap extends BaseOLMap {
|
|
|
5328
5328
|
collectionChanged: VcsEvent<ObliqueCollection>;
|
|
5329
5329
|
switchEnabled: any;
|
|
5330
5330
|
switchThreshold: any;
|
|
5331
|
-
mapChangeEvent:
|
|
5331
|
+
mapChangeEvent: string;
|
|
5332
5332
|
readonly collection: ObliqueCollection;
|
|
5333
5333
|
readonly imageChanged: VcsEvent<ObliqueImage>;
|
|
5334
5334
|
readonly currentImage: ObliqueImage | null;
|
|
@@ -8757,48 +8757,57 @@ export class VcsObject {
|
|
|
8757
8757
|
|
|
8758
8758
|
|
|
8759
8759
|
export interface ReplacedEvent<T extends any> {
|
|
8760
|
-
|
|
8761
|
-
|
|
8760
|
+
new: T;
|
|
8761
|
+
old: T;
|
|
8762
8762
|
}
|
|
8763
8763
|
|
|
8764
8764
|
export interface OverrideCollectionInterface<T extends any> {
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
}
|
|
8773
|
-
|
|
8774
|
-
export class OverrideCollection<T extends any>
|
|
8775
|
-
|
|
8776
|
-
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8765
|
+
replaced: VcsEvent<ReplacedEvent<T>>;
|
|
8766
|
+
shadowMap: Map<string, object[]>;
|
|
8767
|
+
override: (item: T) => T;
|
|
8768
|
+
parseItems: (items: object[], moduleId: string) => Promise<void>;
|
|
8769
|
+
getSerializedByKey: (key: string) => object;
|
|
8770
|
+
removeModule: (moduleId: string) => Promise<void>;
|
|
8771
|
+
serializeModule: (moduleId: string) => object[];
|
|
8772
|
+
}
|
|
8773
|
+
|
|
8774
|
+
export class OverrideCollection<T extends any>
|
|
8775
|
+
extends Collection<T>
|
|
8776
|
+
implements OverrideCollectionInterface<T>
|
|
8777
|
+
{
|
|
8778
|
+
replaced: VcsEvent<ReplacedEvent<T>>;
|
|
8779
|
+
shadowMap: Map<string, object[]>;
|
|
8780
|
+
override: (item: T) => T;
|
|
8781
|
+
parseItems: (items: object[], moduleId: string) => Promise<void>;
|
|
8782
|
+
getSerializedByKey: (key: string) => object;
|
|
8783
|
+
removeModule: (moduleId: string) => Promise<void>;
|
|
8784
|
+
serializeModule: (moduleId: string) => object[];
|
|
8785
|
+
}
|
|
8786
|
+
|
|
8787
|
+
export class OverrideLayerCollection
|
|
8788
|
+
extends LayerCollection
|
|
8789
|
+
implements OverrideCollectionInterface<Layer>
|
|
8790
|
+
{
|
|
8791
|
+
replaced: VcsEvent<ReplacedEvent<Layer>>;
|
|
8792
|
+
shadowMap: Map<string, object[]>;
|
|
8793
|
+
override: (item: Layer) => Layer;
|
|
8794
|
+
parseItems: (items: object[], moduleId: string) => Promise<void>;
|
|
8795
|
+
getSerializedByKey: (key: string) => object;
|
|
8796
|
+
removeModule: (moduleId: string) => Promise<void>;
|
|
8797
|
+
serializeModule: (moduleId: string) => object[];
|
|
8798
|
+
}
|
|
8799
|
+
|
|
8800
|
+
export class OverrideMapCollection
|
|
8801
|
+
extends MapCollection
|
|
8802
|
+
implements OverrideCollectionInterface<VcsMap>
|
|
8803
|
+
{
|
|
8804
|
+
replaced: VcsEvent<ReplacedEvent<VcsMap>>;
|
|
8805
|
+
shadowMap: Map<string, object[]>;
|
|
8806
|
+
override: (item: VcsMap) => VcsMap;
|
|
8807
|
+
parseItems: (items: object[], moduleId: string) => Promise<void>;
|
|
8808
|
+
getSerializedByKey: (key: string) => object;
|
|
8809
|
+
removeModule: (moduleId: string) => Promise<void>;
|
|
8810
|
+
serializeModule: (moduleId: string) => object[];
|
|
8802
8811
|
}
|
|
8803
8812
|
|
|
8804
8813
|
|
|
@@ -8813,74 +8822,114 @@ export class OverrideMapCollection extends MapCollection implements OverrideColl
|
|
|
8813
8822
|
* Said geometry may be invalid.
|
|
8814
8823
|
* Geometries created may be in pixel coordinates. Appropriate symbols shall be set by the interaction.
|
|
8815
8824
|
*/
|
|
8816
|
-
export interface CreateInteraction<T extends import(
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
|
|
8820
|
-
|
|
8825
|
+
export interface CreateInteraction<T extends import('ol/geom').Geometry> {
|
|
8826
|
+
finish(): void;
|
|
8827
|
+
finished: VcsEvent<T | null>;
|
|
8828
|
+
created: VcsEvent<T>;
|
|
8829
|
+
destroy(): void;
|
|
8821
8830
|
}
|
|
8822
8831
|
|
|
8823
|
-
export type Vertex = import(
|
|
8832
|
+
export type Vertex = import('ol').Feature<import('ol/geom').Point>;
|
|
8824
8833
|
|
|
8825
8834
|
export interface SelectFeatureInteraction extends AbstractInteraction {
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
|
|
8831
|
-
|
|
8832
|
-
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
|
|
8837
|
-
|
|
8838
|
-
|
|
8839
|
-
|
|
8840
|
-
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
|
|
8844
|
-
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
|
|
8849
|
-
|
|
8850
|
-
|
|
8851
|
-
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
|
|
8857
|
-
|
|
8858
|
-
|
|
8859
|
-
|
|
8860
|
-
|
|
8861
|
-
|
|
8862
|
-
|
|
8863
|
-
|
|
8864
|
-
|
|
8865
|
-
|
|
8866
|
-
|
|
8867
|
-
|
|
8868
|
-
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
8873
|
-
|
|
8874
|
-
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
|
|
8885
|
-
|
|
8835
|
+
readonly selected: Array<import('ol').Feature>;
|
|
8836
|
+
setSelected(
|
|
8837
|
+
features:
|
|
8838
|
+
| Array<
|
|
8839
|
+
| import('ol').Feature
|
|
8840
|
+
| import('@vcmap-cesium/engine').Cesium3DTileFeature
|
|
8841
|
+
| import('@vcmap-cesium/engine').Cesium3DTilePointFeature
|
|
8842
|
+
| import('@vcmap-cesium/engine').Entity
|
|
8843
|
+
>
|
|
8844
|
+
| import('ol').Feature
|
|
8845
|
+
| import('@vcmap-cesium/engine').Cesium3DTileFeature
|
|
8846
|
+
| import('@vcmap-cesium/engine').Cesium3DTilePointFeature
|
|
8847
|
+
| import('@vcmap-cesium/engine').Entity,
|
|
8848
|
+
): void;
|
|
8849
|
+
hasFeatureId(id: string): boolean;
|
|
8850
|
+
}
|
|
8851
|
+
|
|
8852
|
+
declare module '@vcmap-cesium/engine' {
|
|
8853
|
+
interface Entity {
|
|
8854
|
+
getId(): number | string;
|
|
8855
|
+
getProperty(key: string): any;
|
|
8856
|
+
[vcsLayerName]: string | null;
|
|
8857
|
+
}
|
|
8858
|
+
|
|
8859
|
+
interface Cesium3DTileFeature {
|
|
8860
|
+
getId(): number | string;
|
|
8861
|
+
[vcsLayerName]: string | null;
|
|
8862
|
+
}
|
|
8863
|
+
|
|
8864
|
+
interface Cesium3DTilePointFeature {
|
|
8865
|
+
getId(): number | string;
|
|
8866
|
+
[vcsLayerName]: string | null;
|
|
8867
|
+
}
|
|
8868
|
+
|
|
8869
|
+
interface StyleExpression {
|
|
8870
|
+
evaluate(
|
|
8871
|
+
feature:
|
|
8872
|
+
| import('@vcmap-cesium/engine').Cesium3DTileFeature
|
|
8873
|
+
| import('ol/Feature').default<import('ol/geom/Geometry').default>,
|
|
8874
|
+
): any;
|
|
8875
|
+
evaluateColor(
|
|
8876
|
+
feature:
|
|
8877
|
+
| import('@vcmap-cesium/engine').Cesium3DTileFeature
|
|
8878
|
+
| import('ol/Feature').default<import('ol/geom/Geometry').default>,
|
|
8879
|
+
): import('@vcmap-cesium/engine').Color;
|
|
8880
|
+
}
|
|
8881
|
+
|
|
8882
|
+
interface Expression {
|
|
8883
|
+
evaluate(
|
|
8884
|
+
feature:
|
|
8885
|
+
| import('@vcmap-cesium/engine').Cesium3DTileFeature
|
|
8886
|
+
| import('ol/Feature').default<import('ol/geom/Geometry').default>,
|
|
8887
|
+
): any;
|
|
8888
|
+
evaluateColor(
|
|
8889
|
+
feature:
|
|
8890
|
+
| import('@vcmap-cesium/engine').Cesium3DTileFeature
|
|
8891
|
+
| import('ol/Feature').default<import('ol/geom/Geometry').default>,
|
|
8892
|
+
): import('@vcmap-cesium/engine').Color;
|
|
8893
|
+
}
|
|
8894
|
+
}
|
|
8895
|
+
|
|
8896
|
+
declare module 'ol/geom' {
|
|
8897
|
+
interface Geometry {
|
|
8898
|
+
getCoordinates(): any;
|
|
8899
|
+
setCoordinates(coordinates: any, layout?: any): void;
|
|
8900
|
+
getFlatCoordinates(): number[];
|
|
8901
|
+
getLayout(): import('ol/geom/Geometry').GeometryLayout;
|
|
8902
|
+
}
|
|
8903
|
+
|
|
8904
|
+
interface GeometryCollection {
|
|
8905
|
+
getCoordinates(): Array<
|
|
8906
|
+
| import('ol/coordinate').Coordinate
|
|
8907
|
+
| Array<import('ol/coordinate').Coordinate>
|
|
8908
|
+
| Array<Array<import('ol/coordinate').Coordinate>>
|
|
8909
|
+
| Array<Array<Array<import('ol/coordinate').Coordinate>>>
|
|
8910
|
+
>;
|
|
8911
|
+
setCoordinates(
|
|
8912
|
+
coordinates: Array<
|
|
8913
|
+
| import('ol/coordinate').Coordinate
|
|
8914
|
+
| Array<import('ol/coordinate').Coordinate>
|
|
8915
|
+
| Array<Array<import('ol/coordinate').Coordinate>>
|
|
8916
|
+
| Array<Array<Array<import('ol/coordinate').Coordinate>>>
|
|
8917
|
+
>,
|
|
8918
|
+
): void;
|
|
8919
|
+
getLayout(): import('ol/geom/Geometry').GeometryLayout;
|
|
8920
|
+
}
|
|
8921
|
+
|
|
8922
|
+
interface Circle {
|
|
8923
|
+
getCoordinates(): import('ol/coordinate').Coordinate[];
|
|
8924
|
+
setCoordinates(coordinates: import('ol/coordinate').Coordinate[]): void;
|
|
8925
|
+
rotate(angle: number, anchor: import('ol/coordinate').Coordinate): void;
|
|
8926
|
+
}
|
|
8927
|
+
}
|
|
8928
|
+
|
|
8929
|
+
declare module 'ol/index' {
|
|
8930
|
+
interface Feature<Geometry> {
|
|
8931
|
+
getProperty(key: string): any;
|
|
8932
|
+
getPropertyInherited(key: string): any;
|
|
8933
|
+
[vcsLayerName]: string | null;
|
|
8934
|
+
}
|
|
8886
8935
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vcmap/core",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.29",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"test": "node node_modules/mocha/bin/_mocha --exit --require tests/setupJsdom.js --require tests/setup.js --file tests/vcs.js --recursive \"tests/**/*spec.js\"",
|
|
10
|
-
"lint": "eslint .",
|
|
10
|
+
"lint:js": "eslint . --ext .vue,.js,.cjs,.mjs",
|
|
11
|
+
"lint:prettier": "prettier --check .",
|
|
12
|
+
"lint": "npm run lint:js && npm run lint:prettier",
|
|
13
|
+
"format": "prettier --write --list-different . && npm run lint:js -- --fix",
|
|
11
14
|
"pretype-check": "npm run build-typedefs",
|
|
12
15
|
"type-check": "node build/typeCheck.js",
|
|
13
16
|
"postinstall": "node build/postinstall.js",
|
|
@@ -36,12 +39,12 @@
|
|
|
36
39
|
"author": "Virtual City Systems",
|
|
37
40
|
"license": "MIT",
|
|
38
41
|
"devDependencies": {
|
|
39
|
-
"@vcsuite/eslint-config": "^
|
|
42
|
+
"@vcsuite/eslint-config": "^3.0.3",
|
|
40
43
|
"@vcsuite/tsd-jsdoc": "^1.0.2",
|
|
41
44
|
"c8": "^7.7.1",
|
|
42
45
|
"canvas": "^2.8.0",
|
|
43
46
|
"chai": "^4.3.4",
|
|
44
|
-
"eslint": "^8.
|
|
47
|
+
"eslint": "^8.38.0",
|
|
45
48
|
"jsdoc": "^3.6.7",
|
|
46
49
|
"jsdoc-plugin-typescript": "^2.0.6",
|
|
47
50
|
"jsdom": "^16.5.2",
|
|
@@ -50,6 +53,7 @@
|
|
|
50
53
|
"mocha-junit-reporter": "^2.0.2",
|
|
51
54
|
"nock": "^13.2.4",
|
|
52
55
|
"node-fetch": "^3.2.0",
|
|
56
|
+
"prettier": "^2.8.7",
|
|
53
57
|
"resize-observer-polyfill": "1.5.1",
|
|
54
58
|
"sinon": "^9.2.4",
|
|
55
59
|
"sinon-chai": "^3.6.0",
|
|
@@ -72,6 +76,7 @@
|
|
|
72
76
|
"*.d.ts",
|
|
73
77
|
"docs"
|
|
74
78
|
],
|
|
79
|
+
"prettier": "@vcsuite/eslint-config/prettier.js",
|
|
75
80
|
"dependencies": {
|
|
76
81
|
"@types/rbush": "^3.0.0",
|
|
77
82
|
"@vcsuite/check": "^1.1.2",
|
package/src/category/category.js
CHANGED
|
@@ -2,14 +2,19 @@ import { check } from '@vcsuite/check';
|
|
|
2
2
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
3
|
import { Feature } from 'ol';
|
|
4
4
|
import { moduleIdSymbol, destroyCollection } from '../vcsModuleHelpers.js';
|
|
5
|
-
import makeOverrideCollection, {
|
|
5
|
+
import makeOverrideCollection, {
|
|
6
|
+
isOverrideCollection,
|
|
7
|
+
} from '../util/overrideCollection.js';
|
|
6
8
|
import VcsObject from '../vcsObject.js';
|
|
7
9
|
import VectorLayer from '../layer/vectorLayer.js';
|
|
8
10
|
import IndexedCollection from '../util/indexedCollection.js';
|
|
9
11
|
import { parseGeoJSON, writeGeoJSONFeature } from '../layer/geojsonHelpers.js';
|
|
10
12
|
import Collection from '../util/collection.js';
|
|
11
13
|
import { getStyleOrDefaultStyle } from '../style/styleFactory.js';
|
|
12
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
categoryClassRegistry,
|
|
16
|
+
getObjectFromClassRegistry,
|
|
17
|
+
} from '../classRegistry.js';
|
|
13
18
|
import OverrideClassRegistry from '../overrideClassRegistry.js';
|
|
14
19
|
import VcsEvent from '../vcsEvent.js';
|
|
15
20
|
|
|
@@ -38,8 +43,13 @@ function assignLayerOptions(layer, options) {
|
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
if (options.highlightStyle) {
|
|
41
|
-
const highlightStyle = getStyleOrDefaultStyle(
|
|
42
|
-
|
|
46
|
+
const highlightStyle = getStyleOrDefaultStyle(
|
|
47
|
+
options.highlightStyle,
|
|
48
|
+
layer.highlightStyle,
|
|
49
|
+
);
|
|
50
|
+
layer.setHighlightStyle(
|
|
51
|
+
/** @type {import("@vcmap/core").VectorStyleItem} */ (highlightStyle),
|
|
52
|
+
);
|
|
43
53
|
}
|
|
44
54
|
|
|
45
55
|
if (options.vectorProperties) {
|
|
@@ -60,7 +70,8 @@ function assignLayerOptions(layer, options) {
|
|
|
60
70
|
* @returns {void}
|
|
61
71
|
*/
|
|
62
72
|
function checkMergeOptionOverride(key, value, defaultOption, option) {
|
|
63
|
-
const isOverride =
|
|
73
|
+
const isOverride =
|
|
74
|
+
option == null ? value !== defaultOption : option !== value;
|
|
64
75
|
if (isOverride) {
|
|
65
76
|
throw new Error(`Cannot merge options, values of ${key} do not match`);
|
|
66
77
|
}
|
|
@@ -76,7 +87,9 @@ function checkMergeOptionOverride(key, value, defaultOption, option) {
|
|
|
76
87
|
* @template {Object|VcsObject} T
|
|
77
88
|
*/
|
|
78
89
|
class Category extends VcsObject {
|
|
79
|
-
static get className() {
|
|
90
|
+
static get className() {
|
|
91
|
+
return 'Category';
|
|
92
|
+
}
|
|
80
93
|
|
|
81
94
|
/**
|
|
82
95
|
* @returns {CategoryOptions}
|
|
@@ -110,7 +123,8 @@ class Category extends VcsObject {
|
|
|
110
123
|
* @type {string}
|
|
111
124
|
* @private
|
|
112
125
|
*/
|
|
113
|
-
this._featureProperty =
|
|
126
|
+
this._featureProperty =
|
|
127
|
+
options.featureProperty || defaultOptions.featureProperty;
|
|
114
128
|
/**
|
|
115
129
|
* @type {string|symbol}
|
|
116
130
|
* @private
|
|
@@ -163,7 +177,9 @@ class Category extends VcsObject {
|
|
|
163
177
|
* @type {string|symbol}
|
|
164
178
|
* @readonly
|
|
165
179
|
*/
|
|
166
|
-
get classRegistryName() {
|
|
180
|
+
get classRegistryName() {
|
|
181
|
+
return this._classRegistryName;
|
|
182
|
+
}
|
|
167
183
|
|
|
168
184
|
/**
|
|
169
185
|
* The collection of this category.
|
|
@@ -179,7 +195,9 @@ class Category extends VcsObject {
|
|
|
179
195
|
* @type {VcsEvent<void>}
|
|
180
196
|
* @readonly
|
|
181
197
|
*/
|
|
182
|
-
get collectionChanged() {
|
|
198
|
+
get collectionChanged() {
|
|
199
|
+
return this._collectionChanged;
|
|
200
|
+
}
|
|
183
201
|
|
|
184
202
|
/**
|
|
185
203
|
* Returns the layer of this collection. Caution, do not use the layer API to add or remove items.
|
|
@@ -206,14 +224,17 @@ class Category extends VcsObject {
|
|
|
206
224
|
feature = geoJsonFeature;
|
|
207
225
|
} else if (typeof geoJsonFeature === 'object') {
|
|
208
226
|
const { features } = parseGeoJSON(geoJsonFeature);
|
|
209
|
-
if (features[0]) {
|
|
227
|
+
if (features[0]) {
|
|
228
|
+
// XXX do we warn on feature collection?
|
|
210
229
|
feature = features[0];
|
|
211
230
|
}
|
|
212
231
|
}
|
|
213
232
|
|
|
214
233
|
if (feature) {
|
|
215
234
|
feature.setId(id);
|
|
216
|
-
setTimeout(() => {
|
|
235
|
+
setTimeout(() => {
|
|
236
|
+
this._layer.addFeatures([feature]);
|
|
237
|
+
}, 0); // We need to set a timeout, since removing and adding the feature in the same sync call leads to undefined behavior in OL TODO recheck in ol 6.11
|
|
217
238
|
}
|
|
218
239
|
}
|
|
219
240
|
}
|
|
@@ -272,7 +293,12 @@ class Category extends VcsObject {
|
|
|
272
293
|
defaultOptions.featureProperty,
|
|
273
294
|
options.featureProperty,
|
|
274
295
|
);
|
|
275
|
-
checkMergeOptionOverride(
|
|
296
|
+
checkMergeOptionOverride(
|
|
297
|
+
'keyProperty',
|
|
298
|
+
this._keyProperty,
|
|
299
|
+
defaultOptions.keyProperty,
|
|
300
|
+
options.keyProperty,
|
|
301
|
+
);
|
|
276
302
|
this.title = options.title || this.title;
|
|
277
303
|
if (options.layerOptions && this._layer) {
|
|
278
304
|
assignLayerOptions(this._layer, options.layerOptions);
|
|
@@ -290,10 +316,14 @@ class Category extends VcsObject {
|
|
|
290
316
|
check(collection, Collection);
|
|
291
317
|
|
|
292
318
|
if (this._keyProperty !== collection.uniqueKey) {
|
|
293
|
-
throw new Error(
|
|
319
|
+
throw new Error(
|
|
320
|
+
'The collections key property does not match the categories key property',
|
|
321
|
+
);
|
|
294
322
|
}
|
|
295
323
|
|
|
296
|
-
this._collectionListeners.forEach((cb) => {
|
|
324
|
+
this._collectionListeners.forEach((cb) => {
|
|
325
|
+
cb();
|
|
326
|
+
});
|
|
297
327
|
if (this._collection) {
|
|
298
328
|
destroyCollection(this._collection);
|
|
299
329
|
}
|
|
@@ -301,16 +331,18 @@ class Category extends VcsObject {
|
|
|
301
331
|
this._layer.removeAllFeatures(); // XXX should we call `itemRemoved` instead?
|
|
302
332
|
}
|
|
303
333
|
|
|
304
|
-
this._collection = collection[isOverrideCollection]
|
|
305
|
-
/** @type {OverrideCollection} */ (collection)
|
|
306
|
-
makeOverrideCollection(
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
[...this.collection].forEach((item) => {
|
|
334
|
+
this._collection = collection[isOverrideCollection]
|
|
335
|
+
? /** @type {OverrideCollection} */ (collection)
|
|
336
|
+
: makeOverrideCollection(
|
|
337
|
+
collection,
|
|
338
|
+
this._getDynamicModuleId.bind(this),
|
|
339
|
+
this._serializeItem.bind(this),
|
|
340
|
+
this._deserializeItem.bind(this),
|
|
341
|
+
);
|
|
342
|
+
|
|
343
|
+
[...this.collection].forEach((item) => {
|
|
344
|
+
this._itemAdded(item);
|
|
345
|
+
});
|
|
314
346
|
/**
|
|
315
347
|
* @type {Array<function():void>}
|
|
316
348
|
* @private
|
|
@@ -323,8 +355,10 @@ class Category extends VcsObject {
|
|
|
323
355
|
|
|
324
356
|
// @ts-ignore
|
|
325
357
|
if (this._collection.moved) {
|
|
326
|
-
|
|
327
|
-
|
|
358
|
+
this._collectionListeners.push(
|
|
359
|
+
// @ts-ignore
|
|
360
|
+
this._collection.moved.addEventListener(this._itemMoved.bind(this)),
|
|
361
|
+
);
|
|
328
362
|
}
|
|
329
363
|
this.collectionChanged.raiseEvent();
|
|
330
364
|
}
|
|
@@ -337,9 +371,11 @@ class Category extends VcsObject {
|
|
|
337
371
|
throw new Error('Cannot switch apps');
|
|
338
372
|
}
|
|
339
373
|
this._app = app;
|
|
340
|
-
this._moduleRemovedListener = this._app.moduleRemoved.addEventListener(
|
|
341
|
-
|
|
342
|
-
|
|
374
|
+
this._moduleRemovedListener = this._app.moduleRemoved.addEventListener(
|
|
375
|
+
(module) => {
|
|
376
|
+
this._collection.removeModule(module._id);
|
|
377
|
+
},
|
|
378
|
+
);
|
|
343
379
|
if (this._layer) {
|
|
344
380
|
this._app.layers.add(this._layer);
|
|
345
381
|
}
|
|
@@ -354,7 +390,9 @@ class Category extends VcsObject {
|
|
|
354
390
|
if (!this._app) {
|
|
355
391
|
throw new Error('Cannot deserialize item before setting the vcApp');
|
|
356
392
|
}
|
|
357
|
-
const classRegistry = this._classRegistryName
|
|
393
|
+
const classRegistry = this._classRegistryName
|
|
394
|
+
? this._app[this._classRegistryName]
|
|
395
|
+
: null;
|
|
358
396
|
if (classRegistry && classRegistry instanceof OverrideClassRegistry) {
|
|
359
397
|
return getObjectFromClassRegistry(classRegistry, config);
|
|
360
398
|
}
|
|
@@ -429,7 +467,9 @@ class Category extends VcsObject {
|
|
|
429
467
|
this._layer.destroy();
|
|
430
468
|
}
|
|
431
469
|
|
|
432
|
-
this._collectionListeners.forEach((cb) => {
|
|
470
|
+
this._collectionListeners.forEach((cb) => {
|
|
471
|
+
cb();
|
|
472
|
+
});
|
|
433
473
|
this._collectionListeners.splice(0);
|
|
434
474
|
this._moduleRemovedListener();
|
|
435
475
|
this._moduleRemovedListener = () => {};
|
|
@@ -441,4 +481,3 @@ class Category extends VcsObject {
|
|
|
441
481
|
|
|
442
482
|
export default Category;
|
|
443
483
|
categoryClassRegistry.registerClass(Category.className, Category);
|
|
444
|
-
|