@vcmap/core 5.0.0-rc.3 → 5.0.0-rc.31
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/LICENSE.md +1 -1
- package/README.md +12 -5
- package/build/postinstall.js +14 -3
- package/index.d.ts +3480 -2008
- package/index.js +169 -131
- package/package.json +25 -27
- package/src/category/category.js +483 -0
- package/src/category/categoryCollection.js +153 -0
- package/src/cesium/cesium3DTileFeature.js +2 -2
- package/src/cesium/cesium3DTilePointFeature.js +1 -1
- package/src/cesium/cesiumVcsCameraPrimitive.js +16 -8
- package/src/cesium/entity.js +29 -0
- package/src/cesium/wallpaperMaterial.js +5 -3
- package/src/classRegistry.js +169 -0
- package/src/{vcs/vcm/util/featureProvider → featureProvider}/abstractFeatureProvider.js +49 -46
- package/src/{vcs/vcm/util/featureProvider → featureProvider}/tileProviderFeatureProvider.js +13 -5
- package/src/{vcs/vcm/util/featureProvider → featureProvider}/wmsFeatureProvider.js +56 -26
- package/src/{vcs/vcm/interaction → interaction}/abstractInteraction.js +33 -21
- package/src/{vcs/vcm/interaction → interaction}/coordinateAtPixel.js +40 -21
- package/src/{vcs/vcm/interaction → interaction}/eventHandler.js +131 -26
- package/src/{vcs/vcm/interaction → interaction}/featureAtPixelInteraction.js +108 -53
- package/src/interaction/featureProviderInteraction.js +58 -0
- package/src/{vcs/vcm/interaction → interaction}/interactionChain.js +40 -41
- package/src/{vcs/vcm/interaction → interaction}/interactionType.js +24 -31
- package/src/{vcs/vcm/layer/cesium/cesiumTilesetCesium.js → layer/cesium/cesiumTilesetCesiumImpl.js} +83 -70
- package/src/{vcs/vcm/layer → layer}/cesium/clusterContext.js +33 -8
- package/src/{vcs/vcm/layer/cesium/dataSourceCesium.js → layer/cesium/dataSourceCesiumImpl.js} +24 -13
- package/src/layer/cesium/openStreetMapCesiumImpl.js +32 -0
- package/src/{vcs/vcm/layer/cesium/rasterLayerCesium.js → layer/cesium/rasterLayerCesiumImpl.js} +12 -9
- package/src/{vcs/vcm/layer/cesium/singleImageCesium.js → layer/cesium/singleImageCesiumImpl.js} +19 -9
- package/src/{vcs/vcm/layer/cesium/terrainCesium.js → layer/cesium/terrainCesiumImpl.js} +8 -9
- package/src/{vcs/vcm/layer/cesium/tmsCesium.js → layer/cesium/tmsCesiumImpl.js} +21 -10
- package/src/{vcs/vcm/layer/cesium/vectorCesium.js → layer/cesium/vectorCesiumImpl.js} +93 -35
- package/src/layer/cesium/vectorContext.js +363 -0
- package/src/{vcs/vcm/layer/cesium/vectorRasterTileCesium.js → layer/cesium/vectorRasterTileCesiumImpl.js} +21 -13
- package/src/{vcs/vcm/layer → layer}/cesium/vectorTileImageryProvider.js +58 -21
- package/src/{vcs/vcm/layer/cesium/wmsCesium.js → layer/cesium/wmsCesiumImpl.js} +20 -9
- package/src/{vcs/vcm/layer/cesium/wmtsCesium.js → layer/cesium/wmtsCesiumImpl.js} +24 -13
- package/src/{vcs/vcm/layer → layer}/cesium/x3dmHelper.js +6 -3
- package/src/{vcs/vcm/layer/cesiumTileset.js → layer/cesiumTilesetLayer.js} +71 -112
- package/src/{vcs/vcm/layer/czml.js → layer/czmlLayer.js} +23 -20
- package/src/{vcs/vcm/layer/dataSource.js → layer/dataSourceLayer.js} +55 -90
- package/src/{vcs/vcm/layer → layer}/featureLayer.js +89 -74
- package/src/{vcs/vcm/layer/featureStore.js → layer/featureStoreLayer.js} +197 -150
- package/src/{vcs/vcm/layer/featureStoreChanges.js → layer/featureStoreLayerChanges.js} +150 -92
- package/src/{vcs/vcm/layer/featureStoreState.js → layer/featureStoreLayerState.js} +1 -2
- package/src/{vcs/vcm/layer → layer}/featureVisibility.js +114 -82
- package/src/{vcs/vcm/layer → layer}/geojsonHelpers.js +84 -69
- package/src/{vcs/vcm/layer/geojson.js → layer/geojsonLayer.js} +30 -27
- package/src/{vcs/vcm/layer → layer}/globalHider.js +25 -39
- package/src/{vcs/vcm/layer → layer}/layer.js +171 -96
- package/src/{vcs/vcm/layer → layer}/layerImplementation.js +13 -6
- package/src/{vcs/vcm/layer → layer}/layerState.js +0 -1
- package/src/{vcs/vcm/layer → layer}/layerSymbols.js +2 -1
- package/src/{vcs/vcm/layer/oblique/layerOblique.js → layer/oblique/layerObliqueImpl.js} +7 -5
- package/src/{vcs/vcm/layer → layer}/oblique/obliqueHelpers.js +76 -31
- package/src/{vcs/vcm/layer/oblique/vectorOblique.js → layer/oblique/vectorObliqueImpl.js} +198 -80
- package/src/{vcs/vcm/layer/openStreetMap.js → layer/openStreetMapLayer.js} +59 -40
- package/src/layer/openlayers/layerOpenlayersImpl.js +165 -0
- package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +28 -0
- package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +44 -0
- package/src/{vcs/vcm/layer/openlayers/singleImageOpenlayers.js → layer/openlayers/singleImageOpenlayersImpl.js} +8 -7
- package/src/{vcs/vcm/layer/openlayers/tileDebugOpenlayers.js → layer/openlayers/tileDebugOpenlayersImpl.js} +7 -6
- package/src/{vcs/vcm/layer/openlayers/tmsOpenlayers.js → layer/openlayers/tmsOpenlayersImpl.js} +12 -10
- package/src/{vcs/vcm/layer/openlayers/vectorOpenlayers.js → layer/openlayers/vectorOpenlayersImpl.js} +21 -12
- package/src/{vcs/vcm/layer/openlayers/vectorTileOpenlayers.js → layer/openlayers/vectorTileOpenlayersImpl.js} +18 -12
- package/src/{vcs/vcm/layer/openlayers/wmsOpenlayers.js → layer/openlayers/wmsOpenlayersImpl.js} +9 -8
- package/src/{vcs/vcm/layer/openlayers/wmtsOpenlayers.js → layer/openlayers/wmtsOpenlayersImpl.js} +19 -12
- package/src/{vcs/vcm/layer/pointCloud.js → layer/pointCloudLayer.js} +42 -39
- package/src/{vcs/vcm/layer → layer}/rasterLayer.js +86 -37
- package/src/{vcs/vcm/layer/singleImage.js → layer/singleImageLayer.js} +25 -22
- package/src/layer/terrainHelpers.js +95 -0
- package/src/{vcs/vcm/layer/terrain.js → layer/terrainLayer.js} +28 -21
- package/src/{vcs/vcm/layer → layer}/tileLoadedHelper.js +13 -8
- package/src/{vcs/vcm/layer → layer}/tileProvider/mvtTileProvider.js +51 -8
- package/src/layer/tileProvider/staticGeojsonTileProvider.js +87 -0
- package/src/{vcs/vcm/layer → layer}/tileProvider/tileProvider.js +200 -89
- package/src/{vcs/vcm/layer → layer}/tileProvider/urlTemplateTileProvider.js +54 -13
- package/src/{vcs/vcm/layer/tms.js → layer/tmsLayer.js} +22 -22
- package/src/layer/vectorHelpers.js +129 -0
- package/src/{vcs/vcm/layer/vector.js → layer/vectorLayer.js} +124 -94
- package/src/{vcs/vcm/layer → layer}/vectorProperties.js +419 -107
- package/src/{vcs/vcm/layer → layer}/vectorSymbols.js +11 -1
- package/src/{vcs/vcm/layer/vectorTile.js → layer/vectorTileLayer.js} +181 -116
- package/src/{vcs/vcm/layer/wfs.js → layer/wfsLayer.js} +33 -23
- package/src/{vcs/vcm/layer → layer}/wmsHelpers.js +14 -7
- package/src/{vcs/vcm/layer/wms.js → layer/wmsLayer.js} +53 -32
- package/src/{vcs/vcm/layer/wmts.js → layer/wmtsLayer.js} +56 -42
- package/src/{vcs/vcm/maps → map}/baseOLMap.js +83 -35
- package/src/{vcs/vcm/maps → map}/cameraLimiter.js +64 -37
- package/src/{vcs/vcm/maps/cesium.js → map/cesiumMap.js} +431 -277
- package/src/{vcs/vcm/maps → map}/mapState.js +0 -1
- package/src/{vcs/vcm/maps/oblique.js → map/obliqueMap.js} +132 -97
- package/src/{vcs/vcm/maps/openlayers.js → map/openlayersMap.js} +69 -45
- package/src/{vcs/vcm/maps/map.js → map/vcsMap.js} +118 -46
- package/src/oblique/defaultObliqueCollection.js +62 -0
- package/src/{vcs/vcm/oblique → oblique}/helpers.js +221 -78
- package/src/{vcs/vcm/oblique/ObliqueCollection.js → oblique/obliqueCollection.js} +151 -55
- package/src/{vcs/vcm/oblique/ObliqueDataSet.js → oblique/obliqueDataSet.js} +77 -46
- package/src/{vcs/vcm/oblique/ObliqueImage.js → oblique/obliqueImage.js} +58 -26
- package/src/{vcs/vcm/oblique/ObliqueImageMeta.js → oblique/obliqueImageMeta.js} +9 -9
- package/src/{vcs/vcm/oblique/ObliqueProvider.js → oblique/obliqueProvider.js} +85 -35
- package/src/{vcs/vcm/oblique/ObliqueView.js → oblique/obliqueView.js} +45 -5
- package/src/{vcs/vcm/oblique/ObliqueViewDirection.js → oblique/obliqueViewDirection.js} +3 -5
- package/src/{vcs/vcm/oblique → oblique}/parseImageJson.js +62 -28
- package/src/ol/feature.js +34 -1
- package/src/ol/geom/circle.js +14 -5
- package/src/ol/geom/geometryCollection.js +14 -8
- package/src/ol/render/canvas/canvasTileRenderer.js +11 -10
- package/src/overrideClassRegistry.js +214 -0
- package/src/style/arcStyle.js +453 -0
- package/src/style/arrowStyle.js +304 -0
- package/src/{vcs/vcm/util/style → style}/declarativeStyleItem.js +147 -82
- package/src/{vcs/vcm/util/style → style}/shapesCategory.js +8 -8
- package/src/style/styleFactory.js +32 -0
- package/src/{vcs/vcm/util/style → style}/styleHelpers.js +24 -26
- package/src/style/styleItem.js +174 -0
- package/src/{vcs/vcm/util/style → style}/vectorStyleItem.js +230 -156
- package/src/{vcs/vcm/util/style → style}/writeStyle.js +7 -12
- package/src/{vcs/vcm/util → util}/clipping/clippingObject.js +79 -49
- package/src/{vcs/vcm/util → util}/clipping/clippingObjectManager.js +56 -23
- package/src/{vcs/vcm/util → util}/clipping/clippingPlaneHelper.js +149 -88
- package/src/{vcs/vcm/util → util}/collection.js +28 -10
- package/src/util/editor/createFeatureSession.js +195 -0
- package/src/util/editor/editFeaturesSession.js +325 -0
- package/src/util/editor/editGeometrySession.js +452 -0
- package/src/util/editor/editorHelpers.js +300 -0
- package/src/util/editor/editorSessionHelpers.js +132 -0
- package/src/util/editor/editorSymbols.js +21 -0
- package/src/util/editor/interactions/createBBoxInteraction.js +154 -0
- package/src/util/editor/interactions/createCircleInteraction.js +119 -0
- package/src/util/editor/interactions/createLineStringInteraction.js +119 -0
- package/src/util/editor/interactions/createPointInteraction.js +73 -0
- package/src/util/editor/interactions/createPolygonInteraction.js +136 -0
- package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +88 -0
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +119 -0
- package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +50 -0
- package/src/util/editor/interactions/insertVertexInteraction.js +103 -0
- package/src/util/editor/interactions/mapInteractionController.js +119 -0
- package/src/util/editor/interactions/removeVertexInteraction.js +42 -0
- package/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +152 -0
- package/src/util/editor/interactions/selectMultiFeatureInteraction.js +165 -0
- package/src/util/editor/interactions/selectSingleFeatureInteraction.js +120 -0
- package/src/util/editor/interactions/translateVertexInteraction.js +60 -0
- package/src/util/editor/selectFeaturesSession.js +303 -0
- package/src/util/editor/transformation/create2DHandlers.js +339 -0
- package/src/util/editor/transformation/create3DHandlers.js +678 -0
- package/src/util/editor/transformation/extrudeInteraction.js +106 -0
- package/src/util/editor/transformation/rotateInteraction.js +201 -0
- package/src/util/editor/transformation/scaleInteraction.js +201 -0
- package/src/util/editor/transformation/transformationHandler.js +178 -0
- package/src/util/editor/transformation/transformationTypes.js +88 -0
- package/src/util/editor/transformation/translateInteraction.js +263 -0
- package/src/util/editor/validateGeoemetry.js +24 -0
- package/src/{vcs/vcm/util → util}/exclusiveManager.js +6 -3
- package/src/{vcs/vcm/util → util}/extent.js +26 -20
- package/src/util/featureconverter/arcToCesium.js +121 -0
- package/src/{vcs/vcm/util → util}/featureconverter/circleToCesium.js +70 -37
- package/src/{vcs/vcm/util → util}/featureconverter/convert.js +94 -16
- package/src/util/featureconverter/extent3D.js +284 -0
- package/src/{vcs/vcm/util → util}/featureconverter/featureconverterHelper.js +253 -94
- package/src/util/featureconverter/lineStringToCesium.js +343 -0
- package/src/util/featureconverter/pointHelpers.js +413 -0
- package/src/{vcs/vcm/util → util}/featureconverter/pointToCesium.js +157 -107
- package/src/{vcs/vcm/util → util}/featureconverter/polygonToCesium.js +57 -24
- package/src/util/fetch.js +34 -0
- package/src/{vcs/vcm/util → util}/geometryHelpers.js +25 -17
- package/src/{vcs/vcm/util → util}/indexedCollection.js +27 -8
- package/src/{vcs/vcm/util → util}/isMobile.js +8 -2
- package/src/{vcs/vcm/util → util}/layerCollection.js +109 -19
- package/src/util/locale.js +12 -0
- package/src/{vcs/vcm/util → util}/mapCollection.js +170 -63
- package/src/util/math.js +193 -0
- package/src/util/overrideCollection.js +261 -0
- package/src/{vcs/vcm/util → util}/projection.js +23 -31
- package/src/{vcs/vcm/util → util}/urlHelpers.js +5 -3
- package/src/{vcs/vcm/util → util}/viewpoint.js +83 -57
- package/src/vcsApp.js +657 -0
- package/src/{vcs/vcm/event/vcsEvent.js → vcsEvent.js} +2 -3
- package/src/vcsModule.js +130 -0
- package/src/vcsModuleHelpers.js +136 -0
- package/src/{vcs/vcm/object.js → vcsObject.js} +3 -10
- package/tests/data/dynamicPointCzml.json +53 -0
- package/tests/data/oblique/imageData/imagev34.json +136 -0
- package/tests/data/oblique/imageData/imagev35.json +307 -0
- package/tests/data/oblique/imageData/imagev35PerImageSize.json +333 -0
- package/tests/data/oblique/tiledImageData/12/2199/1342.json +11056 -0
- package/tests/data/oblique/tiledImageData/12/2199/1343.json +11236 -0
- package/tests/data/oblique/tiledImageData/12/2199/1344.json +11077 -0
- package/tests/data/oblique/tiledImageData/12/2200/1342.json +11036 -0
- package/tests/data/oblique/tiledImageData/12/2200/1343.json +11277 -0
- package/tests/data/oblique/tiledImageData/12/2200/1344.json +11131 -0
- package/tests/data/oblique/tiledImageData/12/2201/1342.json +10870 -0
- package/tests/data/oblique/tiledImageData/12/2201/1343.json +11492 -0
- package/tests/data/oblique/tiledImageData/12/2201/1344.json +10909 -0
- package/tests/data/oblique/tiledImageData/image.json +70 -0
- package/tests/data/terrain/13/8800/6485.terrain +0 -0
- package/tests/data/terrain/13/8800/6486.terrain +0 -0
- package/tests/data/terrain/13/8801/6485.terrain +0 -0
- package/tests/data/terrain/13/8801/6486.terrain +0 -0
- package/tests/data/terrain/layer.json +127 -0
- package/tests/data/testGeoJSON.json +149 -0
- package/tests/data/tile.pbf +0 -0
- package/tests/unit/helpers/cesiumHelpers.js +326 -0
- package/tests/unit/helpers/getFileNameFromUrl.js +12 -0
- package/tests/unit/helpers/helpers.js +32 -0
- package/tests/unit/helpers/imageHelpers.js +24 -0
- package/tests/unit/helpers/importJSON.js +15 -0
- package/tests/unit/helpers/obliqueData.js +102 -0
- package/tests/unit/helpers/obliqueHelpers.js +115 -0
- package/tests/unit/helpers/openlayersHelpers.js +25 -0
- package/tests/unit/helpers/terrain/terrainData.js +45 -0
- package/src/vcs/vcm/classRegistry.js +0 -106
- package/src/vcs/vcm/globalCollections.js +0 -11
- package/src/vcs/vcm/interaction/featureProviderInteraction.js +0 -54
- package/src/vcs/vcm/layer/buildings.js +0 -17
- package/src/vcs/vcm/layer/cesium/openStreetMapCesium.js +0 -29
- package/src/vcs/vcm/layer/cesium/pointCloudCesium.js +0 -58
- package/src/vcs/vcm/layer/cesium/vectorContext.js +0 -167
- package/src/vcs/vcm/layer/openlayers/layerOpenlayers.js +0 -79
- package/src/vcs/vcm/layer/openlayers/openStreetMapOpenlayers.js +0 -27
- package/src/vcs/vcm/layer/openlayers/rasterLayerOpenlayers.js +0 -121
- package/src/vcs/vcm/layer/terrainHelpers.js +0 -119
- package/src/vcs/vcm/layer/tileProvider/staticGeojsonTileProvider.js +0 -67
- package/src/vcs/vcm/layer/tileProvider/tileProviderFactory.js +0 -28
- package/src/vcs/vcm/layer/vectorHelpers.js +0 -206
- package/src/vcs/vcm/util/dateTime.js +0 -60
- package/src/vcs/vcm/util/featureProvider/featureProviderHelpers.js +0 -51
- package/src/vcs/vcm/util/featureconverter/extent3d.js +0 -154
- package/src/vcs/vcm/util/featureconverter/lineStringToCesium.js +0 -171
- package/src/vcs/vcm/util/locale.js +0 -53
- package/src/vcs/vcm/util/math.js +0 -71
- package/src/vcs/vcm/util/splitScreen.js +0 -233
- package/src/vcs/vcm/util/style/styleFactory.js +0 -48
- package/src/vcs/vcm/util/style/styleItem.js +0 -243
- /package/src/{vcs/vcm/util/featureProvider → featureProvider}/featureProviderSymbols.js +0 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { Cartesian3 } from '@vcmap-cesium/engine';
|
|
2
|
+
import {
|
|
3
|
+
Circle,
|
|
4
|
+
Fill,
|
|
5
|
+
Icon,
|
|
6
|
+
Stroke,
|
|
7
|
+
Style,
|
|
8
|
+
Image as OlImage,
|
|
9
|
+
} from 'ol/style.js';
|
|
10
|
+
import { parseEnumValue, parseNumber } from '@vcsuite/parsers';
|
|
11
|
+
import { getCartesianBearing } from '../util/math.js';
|
|
12
|
+
import { PrimitiveOptionsType } from '../layer/vectorProperties.js';
|
|
13
|
+
import { getStringColor, parseColor } from './styleHelpers.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {Object} ArrowStyleOptions
|
|
17
|
+
* @property {import("ol/color").Color|import("ol/colorlike").ColorLike} [color='#000000'] - color used to color in the line & the icon
|
|
18
|
+
* @property {number} [width=1] - passed to ol.Style.Stroke
|
|
19
|
+
* @property {number} [zIndex] - passed to ol.Style
|
|
20
|
+
* @property {import("ol/style/Icon").Options|import("ol/style").Image} [arrowIcon] - icon options to use. if none are provided, if is attempted to derive the arrow icon from the primitive options. if providing your own icon, the color will not be options.color by default
|
|
21
|
+
* @property {VectorPropertiesPrimitiveOptions} [primitiveOptions] - the default primitive options are a cylinder with a bottom radius of 1/3 its length and 0 top radius
|
|
22
|
+
* @property {ArrowEnd} [end=ArrowEnd.END] - end to place the arrow head at
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @enum {string}
|
|
27
|
+
*/
|
|
28
|
+
export const ArrowEnd = {
|
|
29
|
+
NONE: 'none',
|
|
30
|
+
BOTH: 'both',
|
|
31
|
+
START: 'start',
|
|
32
|
+
END: 'end',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @param {VectorPropertiesPrimitiveOptions} primitiveOptions
|
|
37
|
+
* @param {number} [twoDFactor=1.5]
|
|
38
|
+
* @returns {string}
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
export function getDefaultArrowIconSrc(primitiveOptions, twoDFactor = 1.5) {
|
|
42
|
+
let height = 13;
|
|
43
|
+
let width = 13;
|
|
44
|
+
let points = [
|
|
45
|
+
[0, 13],
|
|
46
|
+
[13, 13],
|
|
47
|
+
[6, 0],
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
if (primitiveOptions.type === PrimitiveOptionsType.SPHERE) {
|
|
51
|
+
const radius = Math.floor(
|
|
52
|
+
(primitiveOptions.geometryOptions?.radius ?? 1) * twoDFactor,
|
|
53
|
+
);
|
|
54
|
+
return `<svg height="${radius * 2}" width="${
|
|
55
|
+
radius * 2
|
|
56
|
+
}" xmlns="http://www.w3.org/2000/svg">
|
|
57
|
+
<circle cx="${radius}" cy="${radius}" r="${radius}" style="fill:white;" />
|
|
58
|
+
</svg>`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (
|
|
62
|
+
primitiveOptions.type === PrimitiveOptionsType.BOX &&
|
|
63
|
+
primitiveOptions.geometryOptions.minimum &&
|
|
64
|
+
primitiveOptions.geometryOptions.maximum
|
|
65
|
+
) {
|
|
66
|
+
const min = Array.isArray(primitiveOptions.geometryOptions.minimum)
|
|
67
|
+
? primitiveOptions.geometryOptions.minimum
|
|
68
|
+
: Cartesian3.pack(primitiveOptions.geometryOptions.minimum, []);
|
|
69
|
+
|
|
70
|
+
const max = Array.isArray(primitiveOptions.geometryOptions.maximum)
|
|
71
|
+
? primitiveOptions.geometryOptions.maximum
|
|
72
|
+
: Cartesian3.pack(primitiveOptions.geometryOptions.maximum, []);
|
|
73
|
+
|
|
74
|
+
width = Math.floor((max[0] - min[0]) * twoDFactor);
|
|
75
|
+
height = Math.floor((max[1] - min[1]) * twoDFactor);
|
|
76
|
+
|
|
77
|
+
points = [
|
|
78
|
+
[0, 0],
|
|
79
|
+
[width, 0],
|
|
80
|
+
[width, height],
|
|
81
|
+
[0, height],
|
|
82
|
+
];
|
|
83
|
+
} else if (
|
|
84
|
+
primitiveOptions.type === PrimitiveOptionsType.CYLINDER &&
|
|
85
|
+
primitiveOptions.geometryOptions.length
|
|
86
|
+
) {
|
|
87
|
+
const topRadius = Math.floor(
|
|
88
|
+
primitiveOptions.geometryOptions.topRadius * twoDFactor,
|
|
89
|
+
);
|
|
90
|
+
const bottomRadius = Math.floor(
|
|
91
|
+
primitiveOptions.geometryOptions.bottomRadius * twoDFactor,
|
|
92
|
+
);
|
|
93
|
+
const maxRadius = Math.max(topRadius, bottomRadius);
|
|
94
|
+
|
|
95
|
+
height = Math.floor(primitiveOptions.geometryOptions.length * twoDFactor);
|
|
96
|
+
width = maxRadius * 2;
|
|
97
|
+
|
|
98
|
+
points = [
|
|
99
|
+
[width / 2 - bottomRadius, height],
|
|
100
|
+
[width / 2 + bottomRadius, height],
|
|
101
|
+
[width / 2 + topRadius, 0],
|
|
102
|
+
[width / 2 - topRadius, 0],
|
|
103
|
+
];
|
|
104
|
+
if (bottomRadius === 0) {
|
|
105
|
+
points.splice(1, 1);
|
|
106
|
+
} else if (topRadius === 0) {
|
|
107
|
+
points.splice(2, 1);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return `<svg height="${height}" width="${width}" xmlns="http://www.w3.org/2000/svg"><polygon points="${points
|
|
111
|
+
.map((p) => p.join(','))
|
|
112
|
+
.join(' ')}" style="fill:white;" /></svg>`;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @returns {VectorPropertiesPrimitiveOptions}
|
|
117
|
+
*/
|
|
118
|
+
function getDefaultArrowPrimitive() {
|
|
119
|
+
return {
|
|
120
|
+
type: PrimitiveOptionsType.CYLINDER,
|
|
121
|
+
geometryOptions: {
|
|
122
|
+
length: 9,
|
|
123
|
+
bottomRadius: 3,
|
|
124
|
+
topRadius: 0,
|
|
125
|
+
},
|
|
126
|
+
offset: [0, 0, -4.3],
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* A style which renders arrow heads at the ends of a line string. This style cannot be applied to non-LineString geometries.
|
|
132
|
+
* When setting this on a layer with heterogeneous geometry types, use a style function.
|
|
133
|
+
* @class
|
|
134
|
+
* @extends {Style}
|
|
135
|
+
*/
|
|
136
|
+
class ArrowStyle extends Style {
|
|
137
|
+
/**
|
|
138
|
+
* @param {ArrowStyleOptions} [options={}]
|
|
139
|
+
*/
|
|
140
|
+
constructor(options = {}) {
|
|
141
|
+
const color = options.color ?? '#000000';
|
|
142
|
+
const styleOptions = {
|
|
143
|
+
stroke: new Stroke({
|
|
144
|
+
color,
|
|
145
|
+
width: parseNumber(options.width, 1),
|
|
146
|
+
}),
|
|
147
|
+
zIndex: options.zIndex,
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const primitiveOptions =
|
|
151
|
+
options.primitiveOptions ?? getDefaultArrowPrimitive();
|
|
152
|
+
const iconOptions = options.arrowIcon ?? {
|
|
153
|
+
src: `data:image/svg+xml,${encodeURIComponent(
|
|
154
|
+
getDefaultArrowIconSrc(primitiveOptions),
|
|
155
|
+
)}`,
|
|
156
|
+
color: parseColor(color),
|
|
157
|
+
};
|
|
158
|
+
styleOptions.image =
|
|
159
|
+
iconOptions instanceof OlImage ? iconOptions : new Icon(iconOptions);
|
|
160
|
+
super(styleOptions);
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @type {VectorPropertiesPrimitiveOptions}
|
|
164
|
+
*/
|
|
165
|
+
this.primitiveOptions = primitiveOptions;
|
|
166
|
+
/**
|
|
167
|
+
* @type {ArrowEnd}
|
|
168
|
+
*/
|
|
169
|
+
this.end = parseEnumValue(options.end, ArrowEnd, ArrowEnd.END);
|
|
170
|
+
this.setRenderer(this._render.bind(this));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Same as getStroke().getWidth() / getStroke().setWidth()
|
|
175
|
+
* @type {number}
|
|
176
|
+
*/
|
|
177
|
+
get width() {
|
|
178
|
+
return this.getStroke().getWidth();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @param {number} width
|
|
183
|
+
*/
|
|
184
|
+
set width(width) {
|
|
185
|
+
this.getStroke().setWidth(width);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* The color of the stroke and icon styles. Setting the color will not re-apply the icons color.
|
|
190
|
+
* @type {import("ol/color").Color|import("ol/colorlike").ColorLike}
|
|
191
|
+
*/
|
|
192
|
+
get color() {
|
|
193
|
+
return this.getStroke().getColor();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @param {import("ol/color").Color|import("ol/colorlike").ColorLike} color
|
|
198
|
+
*/
|
|
199
|
+
set color(color) {
|
|
200
|
+
this.getStroke().setColor(color);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
205
|
+
* @param {import("ol/coordinate").Coordinate} imagePosition
|
|
206
|
+
* @param {number} rotation
|
|
207
|
+
* @param {number} pixelRatio
|
|
208
|
+
* @private
|
|
209
|
+
*/
|
|
210
|
+
_drawArrow(ctx, imagePosition, rotation, pixelRatio) {
|
|
211
|
+
ctx.save();
|
|
212
|
+
let scale = this.getImage().getScale();
|
|
213
|
+
scale = Array.isArray(scale) ? scale : [scale, scale];
|
|
214
|
+
ctx.setTransform(
|
|
215
|
+
scale[0],
|
|
216
|
+
0,
|
|
217
|
+
0,
|
|
218
|
+
scale[1],
|
|
219
|
+
imagePosition[0],
|
|
220
|
+
imagePosition[1],
|
|
221
|
+
);
|
|
222
|
+
ctx.rotate(Math.PI - rotation);
|
|
223
|
+
const image = this.getImage().getImage(pixelRatio);
|
|
224
|
+
ctx.translate(0, Math.floor(image.height / 2));
|
|
225
|
+
ctx.drawImage(image, -image.width / 2, -image.height / 2);
|
|
226
|
+
ctx.restore();
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @param {Array<import("ol/coordinate").Coordinate>} geom
|
|
231
|
+
* @param {import("ol/render").State} e
|
|
232
|
+
* @private
|
|
233
|
+
*/
|
|
234
|
+
_render(geom, e) {
|
|
235
|
+
if (e.geometry.getType() === 'LineString' && geom.length > 1) {
|
|
236
|
+
const ctx = e.context;
|
|
237
|
+
if (this.end !== ArrowEnd.NONE) {
|
|
238
|
+
if (this.end === ArrowEnd.START || this.end === ArrowEnd.BOTH) {
|
|
239
|
+
this._drawArrow(
|
|
240
|
+
ctx,
|
|
241
|
+
geom[0],
|
|
242
|
+
getCartesianBearing(geom[1], geom[0]),
|
|
243
|
+
e.pixelRatio,
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (this.end === ArrowEnd.END || this.end === ArrowEnd.BOTH) {
|
|
248
|
+
this._drawArrow(
|
|
249
|
+
ctx,
|
|
250
|
+
geom.at(-1),
|
|
251
|
+
getCartesianBearing(geom.at(-2), geom.at(-1)),
|
|
252
|
+
e.pixelRatio,
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
ctx.save();
|
|
257
|
+
ctx.lineJoin = 'round';
|
|
258
|
+
ctx.lineWidth = this.width;
|
|
259
|
+
ctx.strokeStyle = getStringColor(this.color);
|
|
260
|
+
ctx.beginPath();
|
|
261
|
+
ctx.moveTo(geom[0][0], geom[0][1]);
|
|
262
|
+
for (let i = 0; i < geom.length; i++) {
|
|
263
|
+
ctx.lineTo(geom[i][0], geom[i][1]);
|
|
264
|
+
}
|
|
265
|
+
ctx.stroke();
|
|
266
|
+
ctx.restore();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Returns the style used to render primitives (a style with a circle image and the color of this style).
|
|
272
|
+
* @returns {import("ol/style").Style}
|
|
273
|
+
*/
|
|
274
|
+
getOlcsStyle() {
|
|
275
|
+
return new Style({
|
|
276
|
+
image: new Circle({
|
|
277
|
+
radius: 2,
|
|
278
|
+
fill: new Fill({ color: this.color }),
|
|
279
|
+
}),
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @returns {ArrowStyleOptions}
|
|
285
|
+
* @protected
|
|
286
|
+
*/
|
|
287
|
+
_getCloneOptions() {
|
|
288
|
+
return {
|
|
289
|
+
color: this.color,
|
|
290
|
+
width: this.width,
|
|
291
|
+
arrowIcon: this.getImage().clone(),
|
|
292
|
+
zIndex: this.getZIndex(),
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* @returns {ArrowStyle}
|
|
298
|
+
*/
|
|
299
|
+
clone() {
|
|
300
|
+
return new ArrowStyle(this._getCloneOptions());
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export default ArrowStyle;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Color,
|
|
3
|
+
ConditionsExpression,
|
|
4
|
+
Expression,
|
|
5
|
+
Cesium3DTileStyle,
|
|
6
|
+
} from '@vcmap-cesium/engine';
|
|
7
|
+
import { is } from '@vcsuite/check';
|
|
8
|
+
|
|
2
9
|
import Style from 'ol/style/Style.js';
|
|
3
10
|
import Stroke from 'ol/style/Stroke.js';
|
|
4
11
|
import Icon from 'ol/style/Icon.js';
|
|
@@ -6,14 +13,14 @@ import Circle from 'ol/style/Circle.js';
|
|
|
6
13
|
import OLText from 'ol/style/Text.js';
|
|
7
14
|
import Fill from 'ol/style/Fill.js';
|
|
8
15
|
|
|
9
|
-
import StyleItem
|
|
16
|
+
import StyleItem from './styleItem.js';
|
|
10
17
|
import {
|
|
11
18
|
cesiumColorToColor,
|
|
12
|
-
emptyStyle,
|
|
13
19
|
getDefaultCondition,
|
|
14
20
|
whiteColor,
|
|
15
21
|
} from './styleHelpers.js';
|
|
16
|
-
import { originalFeatureSymbol } from '
|
|
22
|
+
import { originalFeatureSymbol } from '../layer/vectorSymbols.js';
|
|
23
|
+
import { styleClassRegistry } from '../classRegistry.js';
|
|
17
24
|
|
|
18
25
|
/**
|
|
19
26
|
* @typedef {Object} DeclarativeStyleItemConditions
|
|
@@ -62,7 +69,7 @@ import { originalFeatureSymbol } from '../../layer/vectorSymbols.js';
|
|
|
62
69
|
* @api
|
|
63
70
|
*/
|
|
64
71
|
|
|
65
|
-
/** @type {import("@vcmap/
|
|
72
|
+
/** @type {import("@vcmap-cesium/engine").Color} */
|
|
66
73
|
const scratchColor = new Color();
|
|
67
74
|
|
|
68
75
|
const defaultText = new OLText({
|
|
@@ -73,16 +80,13 @@ const defaultText = new OLText({
|
|
|
73
80
|
});
|
|
74
81
|
|
|
75
82
|
/**
|
|
76
|
-
* @param {import("@vcmap/
|
|
83
|
+
* @param {import("@vcmap-cesium/engine").Cesium3DTileStyle} style
|
|
77
84
|
* @param {string} key
|
|
78
85
|
* @param {DeclarativeStyleOptions} options
|
|
79
86
|
*/
|
|
80
87
|
function addCustomProperty(style, key, options) {
|
|
81
88
|
if (options[key].conditions) {
|
|
82
|
-
style[key] = new ConditionsExpression(
|
|
83
|
-
options[key],
|
|
84
|
-
options.defines,
|
|
85
|
-
);
|
|
89
|
+
style[key] = new ConditionsExpression(options[key], options.defines);
|
|
86
90
|
} else {
|
|
87
91
|
style[key] = new Expression(options[key], options.defines);
|
|
88
92
|
}
|
|
@@ -91,12 +95,13 @@ function addCustomProperty(style, key, options) {
|
|
|
91
95
|
/**
|
|
92
96
|
* Style Object {@see https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/Styling}
|
|
93
97
|
* @class
|
|
94
|
-
* @export
|
|
95
98
|
* @extends {StyleItem}
|
|
96
99
|
* @api stable
|
|
97
100
|
*/
|
|
98
101
|
class DeclarativeStyleItem extends StyleItem {
|
|
99
|
-
static get className() {
|
|
102
|
+
static get className() {
|
|
103
|
+
return 'DeclarativeStyleItem';
|
|
104
|
+
}
|
|
100
105
|
|
|
101
106
|
/**
|
|
102
107
|
* @param {DeclarativeStyleItemOptions} options
|
|
@@ -105,9 +110,10 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
105
110
|
super(options);
|
|
106
111
|
|
|
107
112
|
const declarativeStyle = options.declarativeStyle || {};
|
|
108
|
-
declarativeStyle.show =
|
|
113
|
+
declarativeStyle.show =
|
|
114
|
+
declarativeStyle.show != null ? declarativeStyle.show : true;
|
|
109
115
|
|
|
110
|
-
/** @type {import("@vcmap/
|
|
116
|
+
/** @type {import("@vcmap-cesium/engine").Cesium3DTileStyle} */
|
|
111
117
|
this.cesiumStyle = new Cesium3DTileStyle(declarativeStyle);
|
|
112
118
|
|
|
113
119
|
this._style = this._styleFunction.bind(this);
|
|
@@ -118,7 +124,7 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
118
124
|
if (declarativeStyle.strokeWidth) {
|
|
119
125
|
addCustomProperty(this.cesiumStyle, 'strokeWidth', declarativeStyle);
|
|
120
126
|
}
|
|
121
|
-
/** @type {DeclarativeStyleOptions} */
|
|
127
|
+
/** @type {DeclarativeStyleOptions} */ // XXX is this even still needed?
|
|
122
128
|
this._styleOptions = declarativeStyle;
|
|
123
129
|
|
|
124
130
|
/** @type {Map<string,import("ol/style/Circle").default>} */
|
|
@@ -126,22 +132,32 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
126
132
|
}
|
|
127
133
|
|
|
128
134
|
/**
|
|
129
|
-
* @
|
|
135
|
+
* @type {DeclarativeStyleOptions}
|
|
136
|
+
* @readonly
|
|
137
|
+
*/
|
|
138
|
+
get styleOptions() {
|
|
139
|
+
return JSON.parse(JSON.stringify(this._styleOptions));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
130
143
|
* @returns {DeclarativeStyleItemOptions}
|
|
131
144
|
* @api
|
|
132
145
|
*/
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
146
|
+
toJSON() {
|
|
147
|
+
const config = /** @type {DeclarativeStyleItemOptions} */ (super.toJSON());
|
|
148
|
+
|
|
149
|
+
config.declarativeStyle = Object.fromEntries(
|
|
150
|
+
Object.entries(this.cesiumStyle.style)
|
|
151
|
+
.filter(([, value]) => value != null)
|
|
152
|
+
.map(([key, value]) => {
|
|
153
|
+
if (is(value, Boolean)) {
|
|
154
|
+
return [key, value.toString()];
|
|
155
|
+
}
|
|
156
|
+
return [key, value];
|
|
157
|
+
}),
|
|
158
|
+
);
|
|
143
159
|
|
|
144
|
-
return
|
|
160
|
+
return config;
|
|
145
161
|
}
|
|
146
162
|
|
|
147
163
|
/**
|
|
@@ -153,7 +169,9 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
153
169
|
if (result) {
|
|
154
170
|
return result.assign(this);
|
|
155
171
|
}
|
|
156
|
-
|
|
172
|
+
const config = this.toJSON();
|
|
173
|
+
delete config.name;
|
|
174
|
+
return new DeclarativeStyleItem(config);
|
|
157
175
|
}
|
|
158
176
|
|
|
159
177
|
/**
|
|
@@ -162,8 +180,10 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
162
180
|
* @api
|
|
163
181
|
*/
|
|
164
182
|
assign(styleItem) {
|
|
165
|
-
|
|
166
|
-
this._styleOptions =
|
|
183
|
+
super.assign(styleItem);
|
|
184
|
+
this._styleOptions = styleItem.cesiumStyle.style;
|
|
185
|
+
|
|
186
|
+
this.cesiumStyle = new Cesium3DTileStyle(this._styleOptions);
|
|
167
187
|
return this;
|
|
168
188
|
}
|
|
169
189
|
|
|
@@ -175,7 +195,7 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
175
195
|
_styleFunction(feature) {
|
|
176
196
|
const actualFeature = feature[originalFeatureSymbol] || feature;
|
|
177
197
|
if (!this.cesiumStyle.show.evaluate(actualFeature)) {
|
|
178
|
-
return
|
|
198
|
+
return undefined;
|
|
179
199
|
}
|
|
180
200
|
|
|
181
201
|
const geometryType = actualFeature.getGeometry().getType();
|
|
@@ -203,7 +223,7 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
203
223
|
}
|
|
204
224
|
|
|
205
225
|
this.getLogger().warning(`could not style geometry type: ${geometryType}`);
|
|
206
|
-
return
|
|
226
|
+
return undefined;
|
|
207
227
|
}
|
|
208
228
|
|
|
209
229
|
/**
|
|
@@ -213,12 +233,18 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
213
233
|
*/
|
|
214
234
|
_stylePolygon(feature) {
|
|
215
235
|
const style = new Style({});
|
|
216
|
-
const color = this.cesiumStyle.color
|
|
217
|
-
// @ts-ignore
|
|
218
|
-
|
|
219
|
-
Color.WHITE;
|
|
236
|
+
const color = this.cesiumStyle.color
|
|
237
|
+
? // @ts-ignore
|
|
238
|
+
this.cesiumStyle.color.evaluate(feature, scratchColor)
|
|
239
|
+
: Color.WHITE;
|
|
220
240
|
if (color) {
|
|
221
|
-
style.setFill(
|
|
241
|
+
style.setFill(
|
|
242
|
+
new Fill({
|
|
243
|
+
color: cesiumColorToColor(
|
|
244
|
+
/** @type {import("@vcmap-cesium/engine").Color} */ (color),
|
|
245
|
+
),
|
|
246
|
+
}),
|
|
247
|
+
);
|
|
222
248
|
}
|
|
223
249
|
|
|
224
250
|
this._evaluateStroke(feature, style);
|
|
@@ -232,23 +258,34 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
232
258
|
*/
|
|
233
259
|
_styleLineString(feature) {
|
|
234
260
|
const style = new Style({});
|
|
235
|
-
const isExtruded =
|
|
261
|
+
const isExtruded =
|
|
262
|
+
feature.get('olcs_extrudedHeight') ||
|
|
236
263
|
(feature.get('olcs_storeyHeight') && feature.get('olcs_storeyNumber'));
|
|
237
|
-
const color = this.cesiumStyle.color
|
|
238
|
-
// @ts-ignore
|
|
239
|
-
|
|
240
|
-
Color.WHITE;
|
|
264
|
+
const color = this.cesiumStyle.color
|
|
265
|
+
? // @ts-ignore
|
|
266
|
+
this.cesiumStyle.color.evaluate(feature, scratchColor)
|
|
267
|
+
: Color.WHITE;
|
|
241
268
|
if (color) {
|
|
242
269
|
if (isExtruded) {
|
|
243
|
-
style.setFill(
|
|
270
|
+
style.setFill(
|
|
271
|
+
new Fill({
|
|
272
|
+
color: cesiumColorToColor(
|
|
273
|
+
/** @type {import("@vcmap-cesium/engine").Color} */ (color),
|
|
274
|
+
),
|
|
275
|
+
}),
|
|
276
|
+
);
|
|
244
277
|
} else {
|
|
245
|
-
const strokeWidth = this.cesiumStyle.strokeWidth
|
|
246
|
-
this.cesiumStyle.strokeWidth.evaluate(feature)
|
|
247
|
-
1;
|
|
248
|
-
style.setStroke(
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
278
|
+
const strokeWidth = this.cesiumStyle.strokeWidth
|
|
279
|
+
? this.cesiumStyle.strokeWidth.evaluate(feature)
|
|
280
|
+
: 1;
|
|
281
|
+
style.setStroke(
|
|
282
|
+
new Stroke({
|
|
283
|
+
width: Number.isFinite(strokeWidth) ? strokeWidth : 1,
|
|
284
|
+
color: cesiumColorToColor(
|
|
285
|
+
/** @type {import("@vcmap-cesium/engine").Color} */ (color),
|
|
286
|
+
),
|
|
287
|
+
}),
|
|
288
|
+
);
|
|
252
289
|
}
|
|
253
290
|
}
|
|
254
291
|
|
|
@@ -281,24 +318,36 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
281
318
|
}
|
|
282
319
|
}
|
|
283
320
|
if (this.cesiumStyle.labelColor) {
|
|
284
|
-
|
|
285
|
-
|
|
321
|
+
const textColor = this.cesiumStyle.labelColor.evaluateColor(
|
|
322
|
+
// @ts-ignore
|
|
323
|
+
feature,
|
|
324
|
+
scratchColor,
|
|
325
|
+
);
|
|
286
326
|
if (textColor) {
|
|
287
327
|
textStyle.getFill().setColor(cesiumColorToColor(textColor));
|
|
288
328
|
}
|
|
289
329
|
}
|
|
290
330
|
if (this.cesiumStyle.labelOutlineColor) {
|
|
291
|
-
|
|
292
|
-
|
|
331
|
+
const outlineColor = this.cesiumStyle.labelOutlineColor.evaluate(
|
|
332
|
+
// @ts-ignore
|
|
333
|
+
feature,
|
|
334
|
+
scratchColor,
|
|
335
|
+
);
|
|
293
336
|
if (outlineColor) {
|
|
294
|
-
const outlineWidth = this.cesiumStyle.labelOutlineWidth
|
|
295
|
-
// @ts-ignore
|
|
296
|
-
|
|
297
|
-
1;
|
|
298
|
-
textStyle.setStroke(
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
337
|
+
const outlineWidth = this.cesiumStyle.labelOutlineWidth
|
|
338
|
+
? // @ts-ignore
|
|
339
|
+
this.cesiumStyle.labelOutlineWidth.evaluate(feature)
|
|
340
|
+
: 1;
|
|
341
|
+
textStyle.setStroke(
|
|
342
|
+
new Stroke({
|
|
343
|
+
color: cesiumColorToColor(
|
|
344
|
+
/** @type {import("@vcmap-cesium/engine").Color} */ (
|
|
345
|
+
outlineColor
|
|
346
|
+
),
|
|
347
|
+
),
|
|
348
|
+
width: outlineWidth,
|
|
349
|
+
}),
|
|
350
|
+
);
|
|
302
351
|
}
|
|
303
352
|
}
|
|
304
353
|
style.setText(textStyle);
|
|
@@ -312,10 +361,10 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
312
361
|
style.setImage(new Icon({ src }));
|
|
313
362
|
}
|
|
314
363
|
} else {
|
|
315
|
-
const color = this.cesiumStyle.color
|
|
316
|
-
// @ts-ignore
|
|
317
|
-
|
|
318
|
-
Color.WHITE;
|
|
364
|
+
const color = this.cesiumStyle.color
|
|
365
|
+
? // @ts-ignore
|
|
366
|
+
this.cesiumStyle.color.evaluate(feature, scratchColor)
|
|
367
|
+
: Color.WHITE;
|
|
319
368
|
|
|
320
369
|
let radius = 4;
|
|
321
370
|
if (this.cesiumStyle.pointSize) {
|
|
@@ -323,16 +372,19 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
323
372
|
const size = this.cesiumStyle.pointSize.evaluate(feature);
|
|
324
373
|
radius = size / 2;
|
|
325
374
|
}
|
|
326
|
-
const width = this.cesiumStyle.pointOutlineWidth
|
|
327
|
-
// @ts-ignore
|
|
328
|
-
|
|
329
|
-
0;
|
|
375
|
+
const width = this.cesiumStyle.pointOutlineWidth
|
|
376
|
+
? // @ts-ignore
|
|
377
|
+
this.cesiumStyle.pointOutlineWidth.evaluate(feature)
|
|
378
|
+
: 0;
|
|
330
379
|
|
|
331
380
|
let pointOutlineColor = Color.BLACK;
|
|
332
381
|
if (width) {
|
|
333
382
|
if (this.cesiumStyle.pointOutlineColor) {
|
|
334
|
-
|
|
335
|
-
|
|
383
|
+
pointOutlineColor = this.cesiumStyle.pointOutlineColor.evaluateColor(
|
|
384
|
+
// @ts-ignore
|
|
385
|
+
feature,
|
|
386
|
+
scratchColor,
|
|
387
|
+
);
|
|
336
388
|
}
|
|
337
389
|
radius += width / 2;
|
|
338
390
|
}
|
|
@@ -341,7 +393,11 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
341
393
|
if (!this._circleCache.has(circleCacheKey)) {
|
|
342
394
|
const circleOptions = {
|
|
343
395
|
radius,
|
|
344
|
-
fill: new Fill({
|
|
396
|
+
fill: new Fill({
|
|
397
|
+
color: cesiumColorToColor(
|
|
398
|
+
/** @type {import("@vcmap-cesium/engine").Color} */ (color),
|
|
399
|
+
),
|
|
400
|
+
}),
|
|
345
401
|
};
|
|
346
402
|
if (width) {
|
|
347
403
|
circleOptions.stroke = new Stroke({
|
|
@@ -372,16 +428,21 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
372
428
|
*/
|
|
373
429
|
_evaluateStroke(feature, style) {
|
|
374
430
|
if (this.cesiumStyle.strokeColor) {
|
|
375
|
-
|
|
376
|
-
|
|
431
|
+
const strokeColor = this.cesiumStyle.strokeColor.evaluateColor(
|
|
432
|
+
// @ts-ignore
|
|
433
|
+
feature,
|
|
434
|
+
scratchColor,
|
|
435
|
+
);
|
|
377
436
|
if (strokeColor) {
|
|
378
|
-
const strokeWidth = this.cesiumStyle.strokeWidth
|
|
379
|
-
this.cesiumStyle.strokeWidth.evaluate(feature)
|
|
380
|
-
1;
|
|
381
|
-
style.setStroke(
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
437
|
+
const strokeWidth = this.cesiumStyle.strokeWidth
|
|
438
|
+
? this.cesiumStyle.strokeWidth.evaluate(feature)
|
|
439
|
+
: 1;
|
|
440
|
+
style.setStroke(
|
|
441
|
+
new Stroke({
|
|
442
|
+
width: Number.isFinite(strokeWidth) ? strokeWidth : 1,
|
|
443
|
+
color: cesiumColorToColor(strokeColor),
|
|
444
|
+
}),
|
|
445
|
+
);
|
|
385
446
|
}
|
|
386
447
|
}
|
|
387
448
|
}
|
|
@@ -558,6 +619,10 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
558
619
|
}
|
|
559
620
|
|
|
560
621
|
export default DeclarativeStyleItem;
|
|
622
|
+
styleClassRegistry.registerClass(
|
|
623
|
+
DeclarativeStyleItem.className,
|
|
624
|
+
DeclarativeStyleItem,
|
|
625
|
+
);
|
|
561
626
|
|
|
562
627
|
/**
|
|
563
628
|
* @type {DeclarativeStyleItem}
|