UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 2.29 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import o from"../../core/Error.js";import e from"../LabelSymbol3D.js";import r from"../LineSymbol3D.js";import l from"../MeshSymbol3D.js";import m from"../PictureMarkerSymbol.js";import i from"../PointSymbol3D.js";import n from"../PolygonSymbol3D.js";import s from"../SimpleFillSymbol.js";import t from"../SimpleLineSymbol.js";import y from"../SimpleMarkerSymbol.js";import b from"../TextSymbol.js";import a from"../WebStyleSymbol.js";import{defaultRendererPolygonSymbol3D as p,defaultRendererPolylineSymbol3D as f}from"./defaults3D.js";import{isSymbol3D as c}from"./typeUtils.js";const S="#useCIMFallbackSymbology()",g={retainId:!1,ignoreDrivers:!1,hasLabelingContext:!0};function u(u,d=g){if(!u)return{symbol:null};const{retainId:D=g.retainId,ignoreDrivers:M=g.ignoreDrivers,hasLabelingContext:j=g.hasLabelingContext,retainCIM:C=g.retainCIM,cimFallbackEnabled:I=g.cimFallbackEnabled}=d;let k=null;if(c(u)||u instanceof a)k=u.clone();else if("cim"===u.type){const e=u.data?.symbol?.type;switch(e){case"CIMPointSymbol":k=C?u.clone():i.fromCIMSymbol(u);break;case"CIMLineSymbol":I&&(k=f.clone(),d?.logWarning?.(S,"Unsupported CIM line symbology converted to fallback 3D line symbology"));break;case"CIMPolygonSymbol":I&&(k=p.clone(),d?.logWarning?.(S,"Unsupported CIM polygon symbology converted to fallback 3D polygon symbology"))}if(!k)return{error:new o("symbol-conversion:unsupported-cim-symbol",`CIM symbol of type '${e||"unknown"}' is unsupported in 3D`,{symbol:u})}}else if(u instanceof t)k=r.fromSimpleLineSymbol(u);else if(u instanceof y)k=i.fromSimpleMarkerSymbol(u);else if(u instanceof m)k=i.fromPictureMarkerSymbol(u);else if(u instanceof s)k=d.geometryType&&"mesh"===d.geometryType?l.fromSimpleFillSymbol(u):n.fromSimpleFillSymbol(u);else{if(!(u instanceof b))return{error:new o("symbol-conversion:unsupported-2d-symbol",`2D symbol of type '${u.type||u.declaredClass}' is unsupported in 3D`,{symbol:u})};k=j?e.fromTextSymbol(u):i.fromTextSymbol(u)}return D&&k&&"cim"!==k.type&&(k.id=u.id),!M||"cim"===k.type||k instanceof a||k.symbolLayers.forEach((o=>o.ignoreDrivers=!0)),{symbol:k}}export{g as defaultTo3DOptions,u as to3D};