@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 4.9 kB
JavaScript
/*
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"../../Graphic.js";import e from"../../core/Error.js";import t from"../../geometry/Point.js";import r from"../../geometry/Polygon.js";import n from"../../geometry/Polyline.js";import i from"../GraphicsLayer.js";import{systemOidFieldName as s}from"./constants.js";import a from"./SessionMemoryStorage.js";import{Direction2D as l}from"../../libs/linkchartlayout/LinkChartLayout.js";import{layoutMap as m}from"../../linkChart/enums.js";import{executeQueryStreaming as c}from"../../rest/knowledgeGraphService.js";import y from"../../rest/knowledgeGraph/GraphQueryStreaming.js";import p from"../../symbols/CIMSymbol.js";import f from"../../symbols/SimpleFillSymbol.js";import h from"../../symbols/TextSymbol.js";function d(o,e){const t=new Map;if(e.dataModel?.relationshipTypes)for(const r of e.dataModel.relationshipTypes)r.name&&t.set(r.name,[]);for(const r of o)t.has(r.typeName)&&t.get(r.typeName)?.push(r.id);return t}async function g(o,e,t){const r=[],n=d(o,e),i={},s=[];for(const[c,y]of n){if(y.length<1)continue;const o=`${c}_ids`;i[o]=y,s.push(`MATCH (n)-[r:${c}]->(m) WHERE id(r) in $${o} RETURN id(n), labels(n)[0], id(m), labels(m)[0]`)}if(0===s.length)return[];const a=s.join(" UNION "),l=new y({openCypherQuery:a,bindParameters:i}),m=(await c(e,l,t?.requestOptions)).resultRowsStream.getReader();for(;;){const{done:o,value:e}=await m.read();if(o)break;for(const t of e)r.push({id:t[0],typeName:t[1]}),r.push({id:t[2],typeName:t[3]})}return r}async function u(o,e,t){const r=new Map,n=d(o,e),i={},s=[];for(const[c,y]of n){if(y.length<1)continue;const o=`${c}_ids`;i[o]=y,s.push(`MATCH (n)-[r:${c}]->(m) WHERE id(r) in $${o} RETURN id(r), id(n), id(m)`)}if(0===s.length)return r;const a=s.join(" UNION "),l=new y({openCypherQuery:a,bindParameters:i}),m=(await c(e,l,t?.requestOptions)).resultRowsStream.getReader();for(;;){const{done:o,value:e}=await m.read();if(o)break;for(const t of e)r.set(t[0],[t[1],t[2]])}return r}const b="ESRI__ChronologicalLayoutOverlay",w=()=>b,x=e=>{const s=[],a={type:"CIMGeometricEffectCut",beginCut:3,endCut:3};for(const t of e.chronologicalAuxiliaryGraphics?.lines??[]){const e={type:"CIMSolidStroke",enable:!0,width:t.width,color:[t.color.r,t.color.g,t.color.b,Math.round(t.color.a/100*255)],effects:t.dashPattern.length>0?[{type:"CIMGeometricEffectDashes",dashTemplate:t.dashPattern,lineDashEnding:"NoConstraint"},a]:void 0},r={type:"CIMVectorMarker",enable:!0,size:10,frame:{xmin:-5,ymin:-5,xmax:0,ymax:5},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{rings:[[[-12,-3.47],[-12,3.6],[-2.06,-.03],[-12,-3.47]]]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[t.color.r,t.color.g,t.color.b,Math.round(t.color.a/100*255)]}]}}],markerPlacement:{type:"CIMMarkerPlacementOnLine",angleToLine:!0,relativeTo:"LineEnd",offsetAlongLine:0}},i=new p({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:t.arrowheadSizeAtEnd?[e,r]:[e]}}});for(const a of t.elements){const e=new n({paths:[[[a.origin.x,a.origin.y],[a.destination.x,a.destination.y]]]});s.push(new o({geometry:e,symbol:i}))}}for(const t of e.chronologicalAuxiliaryGraphics?.polygons??[]){const e=new f({color:[t.color.r,t.color.g,t.color.b,t.color.a/100],style:"solid",outline:null});for(const n of t.elements){const t=new r({rings:[n.points.map((o=>[o.x,o.y]))]});s.push(new o({geometry:t,symbol:e}))}}for(const r of e.chronologicalAuxiliaryGraphics?.texts??[]){let e="middle",n="center";switch(r.direction?.value){case l.left:n="right";break;case l.right:n="left";break;case l.bottom:e="bottom"}for(const i of r.elements){const a=new h({color:[r.color.r,r.color.g,r.color.b,r.color.a/100],text:i.str,font:{size:r.height,weight:"bold"},verticalAlignment:e,horizontalAlignment:n}),l=new t({x:i.anchor.x,y:i.anchor.y});s.push(new o({geometry:l,symbol:a}))}}return new i({graphics:s,listMode:"hide",title:b,id:b})},M=(o,e)=>{const t=new Map;for(const n of[...e.entityTypes??[],...e.relationshipTypes??[]])for(const o of n.properties??[])o.geometryType&&"esriGeometryNull"!==o.geometryType&&t.set(n.name,o.name??"");const r=a.getInstance();for(const n of o)r.writeToStore([n],s,t.get(n.typeName??"")??"")},C=o=>m.get(o)??"radial-root-centric";function S(o){if(!o.spatialReference.isWGS84)throw new e("knowledge-graph:layer-support-utils","The utilsExtentToInBoundsRings function only supports WGS84 spatial references.");return o.clone().normalize().map((o=>[[o.xmin,o.ymin],[o.xmin,o.ymax],[o.xmax,o.ymax],[o.xmax,o.ymin],[o.xmin,o.ymin]]))}export{C as convertLayoutTypeToWebSupportedFormat,x as getChronologicalOverlay,w as getDefaultChronologicalOverlayLayerId,g as getRelationshipEndNodeIds,u as getRelationshipEndNodeMap,M as loadRecordsIntoLocalCache,S as utilsExtentToInBoundsRings};