UNPKG

qwc2

Version:
7 lines 2.65 kB
function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0}}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n}/** * Copyright 2024 Sourcepole AG * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */import ColorLayer from"@giro3d/giro3d/core/layer/ColorLayer";import VectorSource from"@giro3d/giro3d/sources/VectorSource.js";import ol from"openlayers";import FeatureStyles from"../../../utils/FeatureStyles";import{createFeatures,featureStyleFunction,updateFeatures}from"../../map/layers/VectorLayer";export default{create3d:function create3d(options,projection){return new ColorLayer({name:options.name,source:new VectorSource({data:createFeatures(options,projection),format:new ol.format.GeoJSON,style:options.styleFunction||function(feature){var styleName=options.styleName||"default";var styleOptions=options.styleOptions||{};return FeatureStyles[styleName](feature,styleOptions)}})})},update3d:function update3d(layer,newOptions,oldOptions,projection){if(newOptions.styleName!==oldOptions.styleName||newOptions.styleOptions!==oldOptions.styleOptions){layer.source.setStyle(featureStyleFunction(newOptions))}else if(newOptions.styleFunction!==oldOptions.styleFunction){layer.source.setStyle(newOptions.styleFunction)}if(newOptions.features!==oldOptions.features){updateFeatures(layer.source,newOptions,oldOptions,projection)}else if((oldOptions.rev||0)!==(newOptions.rev||0)){layer.source.update()}},getFields:function getFields(options){return new Promise(function(resolve){var fields=new Set;options.features.forEach(function(feature){Object.keys(feature.properties).forEach(function(key){return fields.add(key)})});resolve(_toConsumableArray(fields.values()))})}};