@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 1.34 kB
JavaScript
import{readSymbol as o}from"../../symbols.js";import e from"../../core/Error.js";import{isSome as n,isNone as t}from"../../core/maybe.js";import{isSceneServiceLayer as r}from"../../layers/support/layerUtils.js";import s from"../Symbol3D.js";import{to3D as l}from"./symbolConversion.js";import i from"../WebStyleSymbol.js";function m(o,e,t,r){const s=p(o,{},{context:r,isLabelSymbol:!1});n(s)&&(e[t]=s)}function a(o,e,t,r){const s=p(o,{},{context:r,isLabelSymbol:!0});n(s)&&(e[t]=s)}function b(o){return o instanceof s||o instanceof i}function p(o,s,i){if(t(o))return null;const{context:m,isLabelSymbol:a}=i,p=m?.origin,y=m?.messages;if("web-scene"===p&&!b(o)){const t=l(o,{retainCIM:!0,hasLabelingContext:a});return n(t.symbol)?t.symbol.write(s,m):(y?.push(new e("symbol:unsupported",`Symbols of type '${o.declaredClass}' are not supported in scenes. Use 3D symbology instead when working with WebScene and SceneView`,{symbol:o,context:m,error:t.error})),null)}return("web-map"===p||"portal-item"===p&&!r(m?.layer))&&b(o)?(y?.push(new e("symbol:unsupported",`Symbols of type '${o.declaredClass}' are not supported in web maps and portal items. Use 2D symbology and CIMSymbol instead when working with MapView`,{symbol:o,context:m})),null):o.write(s,m)}function y(e,n){return o(e,null,n)}export{y as fromJSON,m as write,a as writeLabelSymbol};