Custom Gis Application with Arcgis Javascript API with modern layouting
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

22 lines
9.7 KiB

// All material copyright Esri, All Rights Reserved, unless otherwise specified.
// See https://js.arcgis.com/4.30/esri/copyright.txt for details.
//>>built
define("exports ../../request ../../core/Error ../../core/MapUtils ../graphics/featureConversionUtils ../graphics/OptimizedGeometry ../../rest/knowledgeGraphService ../../rest/knowledgeGraph/GraphQueryStreaming ../../rest/knowledgeGraph/ProtoFeatureCollection ../../rest/knowledgeGraph/wasmInterface/knowledgeWasmAccess ../../rest/knowledgeGraph/wasmInterface/WasmDataModelWrapperInterfaces ../../rest/knowledgeGraph/wasmInterface/WasmSerializedLayerData ../../rest/knowledgeGraph/wasmInterface/wasmToFeatureFactories".split(" "),
function(n,B,r,C,M,N,D,E,q,u,F,v,O){async function G(b){var a=await u.getWasmInterface();const d=new a.MapOfObjectIdentifierSets;for(const [c,f]of b.namedTypeDefinitions){if(!f.members||f.useAllData)continue;b=f.members.keys();const e=new a.GlobalIdArray,l=new a.ObjectIdentifierSet;for(const g of b)e.add_globalid(g);l.set_globalid_array(e);e.delete();d.put_identifier_set(c,l);l.delete()}a=new a.MapOfObjectIdentifierSetsEncoder;try{a.set_map_of_identifier_sets(d);a.encode();const c=a.get_encoding_result();
if(0!==c.error.error_code)throw new r("knowledge-graph:layer-support-utils",c.error.error_message);const f=structuredClone(c.get_byte_buffer());a.delete();return f}finally{d.delete()}}function H(b,a,d,c,f,e){b.version="";const l=new a.QueryResult,g=new a.FeatureResult,k="entities"===c?q.ProtoOutboundEntityFeatureCollectionAttributionIndexes:q.ProtoOutboundRelationshipFeatureCollectionAttributionIndexes;g.unique_id_field={name:k[k.ELEMENTUID],isSystemMaintained:!1};g.globalid_field_name=k[k.ELEMENTUID];
g.geohash_field_name="";g.geometry_properties={shapeAreaFieldName:"",shapeLengthFieldName:"",units:""};g.spatial_reference={wkid:4326,latestWkid:4326,vcsWkid:0,latestVcsWkid:0,wkt:""};g.exceeded_transfer_limit=!1;g.has_z=!1;g.has_m=!1;g.transform={quantizeOriginPosition:{value:v.WasmQuantizeOriginPositionTypeCode.upperLeft},scale:{xScale:1E-9,yScale:1E-9,mScale:1E-4,zScale:1E-4},translate:{xTranslate:-400,yTranslate:-400,mTranslate:-1E5,zTranslate:-1E5}};for(var m of Object.keys(k).filter(h=>isNaN(Number(h)))){const h=
new a.Field;h.name=m;h.alias=m;h.sql_type={value:v.SqlTypeCode.sqlTypeBigInt};if("entities"===c)switch(m){case k[k.ELEMENTUID]:case k[k.TYPENAME]:h.field_type={value:F.EsriFieldTypes.esriFieldTypeString}}else switch(m){case k[k.ELEMENTUID]:case k[k.TYPENAME]:case q.ProtoOutboundRelationshipFeatureCollectionAttributionIndexes[q.ProtoOutboundRelationshipFeatureCollectionAttributionIndexes.FROMUID]:case q.ProtoOutboundRelationshipFeatureCollectionAttributionIndexes[q.ProtoOutboundRelationshipFeatureCollectionAttributionIndexes.TOUID]:h.field_type=
{value:F.EsriFieldTypes.esriFieldTypeString}}h.domain="";g.add_field(h);h.delete()}m=new Map;for(const h of f.dataModel.entityTypes)m.set(h.name,"entities");for(const h of f.dataModel.relationshipTypes)m.set(h.name,"relationships");for(const [h,w]of d.namedTypeDefinitions)if(c===m.get(h))for(const p of w.members.values()){d=new a.Feature;for(const I of Object.keys(k).filter(P=>isNaN(Number(P))))if("entities"===c)switch(I){case k[k.ELEMENTUID]:d.add_attribute(p.id,a.esriFieldType.esriFieldTypeString);
break;case k[k.TYPENAME]:d.add_attribute(h,a.esriFieldType.esriFieldTypeString)}else switch(I){case k[k.ELEMENTUID]:d.add_attribute(p.id,a.esriFieldType.esriFieldTypeString);break;case q.ProtoOutboundRelationshipFeatureCollectionAttributionIndexes[q.ProtoOutboundRelationshipFeatureCollectionAttributionIndexes.FROMUID]:d.add_attribute(e.has(p.id)?e.get(p.id)[0]:"",a.esriFieldType.esriFieldTypeString);break;case q.ProtoOutboundRelationshipFeatureCollectionAttributionIndexes[q.ProtoOutboundRelationshipFeatureCollectionAttributionIndexes.TOUID]:d.add_attribute(e.has(p.id)?
e.get(p.id)[1]:"",a.esriFieldType.esriFieldTypeString);break;case k[k.TYPENAME]:d.add_attribute(h,a.esriFieldType.esriFieldTypeString)}let t;p.linkChartLocation&&"x"in p.linkChartLocation?t=M.convertFromGeometry(p.linkChartLocation):p.linkChartLocation&&(t=p.linkChartLocation);if(p.linkChartLocation&&t){f=new a.FeatureCollectionGeometry;switch(c){case "entities":f.geometry_type=a.esriGeometryType.esriGeometryPoint;break;case "relationships":f.geometry_type=a.esriGeometryType.esriGeometryPolyline}f.coords=
new Float64Array(t.coords);f.lengths=new Uint32Array(t.lengths);d.set_compressed_geometry(f);f.delete()}g.add_feature(d);d.delete()}switch(c){case "entities":g.geometry_type=a.esriGeometryType.esriGeometryPoint;break;case "relationships":g.geometry_type=a.esriGeometryType.esriGeometryPolyline}l.set_feature_result(g);b.set_query_result(l);g.delete();l.delete();return b}async function x(b){b=await (await B(b,{responseType:"array-buffer"})).data;return J(b)}async function J(b){const a=new ((await u.getWasmInterface()).FeatureCollectionDecoder);
b=a.decode(new Uint8Array(b));if(0!==b.error_code)throw new r("knowledge-graph:layer-support-utils",b.error_message);b=a.get_feature_collection();b=O.wasmToProtoFeatureCollection(b);a.delete();return b}async function y(b){b=await (await B(b,{responseType:"array-buffer"})).data;return K(new Uint8Array(b))}async function K(b){const a=new ((await u.getWasmInterface()).MapOfObjectIdentifierSetsDecoder);var d=a.decode(new Uint8Array(b));b=new Map;if(0!==d.error_code)throw new r("knowledge-graph:layer-support-utils",
d.error_message);d=a.get_map_of_identifier_sets();const c=d.keys,f=c.size();for(let k=0;k<f;k++){const m=c.get(k);var e=d.query_identifier_set(m);const h=[];if(e.id_array_type.value===v.IdArrayType.GLOBALID_ARRAY){e=e.get_globalid_array();var l=e.count();for(var g=0;g<l;g++)h.push(e.get_globalid_at(g))}else if(e.id_array_type.value===v.IdArrayType.IDENTIFIER_ARRAY)for(e=e.get_identifier_array(),l=e.count(),g=0;g<l;g++)h.push(e.get_identifier_at(g).toString());else throw new r("knowledge-graph:layer-support-utils",
"Tried to encode an unexpected ID Array type.");b.set(m,h)}a.delete();return b}function z(b,a){if(!b?.queryResult?.featureResult)return a;const d=b.queryResult.featureResult.fieldNameToAttributeIndexMap;for(const c of b.queryResult.featureResult.features){b=C.getOrCreateMapValue(a.namedTypeDefinitions,c.attributes[d[q.ProtoInboundFeatureCollectionAttributionNames.TYPENAME]],()=>({useAllData:!1,members:new Map}));const f=c.attributes[d[q.ProtoInboundFeatureCollectionAttributionNames.ELEMENTUID]];0<
c.compressedGeometry?.coords?.length?b.members.set(f,{id:f,linkChartLocation:new N(c.compressedGeometry.lengths,c.compressedGeometry.coords)}):b.members.set(f,{id:f})}return a}function A(b,a){for(const [d,c]of b){b=C.getOrCreateMapValue(a.namedTypeDefinitions,d,()=>({useAllData:!1,members:new Map}));for(const f of c)b.members.has(f)||b.members.set(f,{id:f})}return a}const L=(b,a)=>{a.set_feature_collection(b);a.encode();b=a.get_encoding_result();if(0!==b.error.error_code)throw new r("knowledge-graph:layer-support-utils",
b.error.error_message);return b.get_byte_buffer()};n.addFeatureCollectionToInclusionDefinition=z;n.addIdMapToInclusionDefinition=A;n.deserializeFeatureCollection=J;n.deserializeIdCollectionMap=K;n.extentToInBoundsRings=function(b){if(!b.spatialReference.isWGS84)throw new r("knowledge-graph:layer-support-utils","The extentToInBoundsRings function only supports WGS84 spatial references.");return b.clone().normalize().map(a=>[[a.xmin,a.ymin],[a.xmin,a.ymax],[a.xmax,a.ymax],[a.xmax,a.ymin],[a.xmin,a.ymin]])};
n.fetchAndConvertSerializedKgIdMap=async function(b,a){a??=!1;const d={generateAllSublayers:a,namedTypeDefinitions:new Map};await y(b).then(c=>{A(c,d)});return d};n.fetchAndConvertSerializedLinkChart=async function(b){const a=[],d={generateAllSublayers:!1,namedTypeDefinitions:new Map};b.entitiesUrl&&a.push(x(b.entitiesUrl).then(c=>{z(c,d)}));b.relationshipsUrl&&a.push(x(b.relationshipsUrl).then(c=>{z(c,d)}));b.idCollectionsUrl&&a.push(y(b.idCollectionsUrl).then(c=>{A(c,d)}));await Promise.all(a);
return d};n.fetchAndDeserializeFeatureCollection=x;n.fetchAndDeserializeIdCollectionMap=y;n.getRelationshipEndNodeIds=async function(b,a){const d=[],c=new Map,f=[];if(a.dataModel?.relationshipTypes)for(const e of a.dataModel.relationshipTypes)e.name&&c.set(e.name,[]);for(const e of b)c.has(e.typeName)&&c.get(e.typeName)?.push(e.id);for(const [e,l]of c)1>l.length||(b=new E({openCypherQuery:`MATCH (n)-[r:${e}]->(m) WHERE id(r) in $ids RETURN id(n), labels(n)[0], id(m), labels(m)[0]`,bindParameters:{ids:l}}),
f.push(D.executeQueryStreaming(a,b).then(async g=>{for(g=g.resultRowsStream.getReader();;){const {done:k,value:m}=await g.read();if(k)break;for(const h of m)d.push({id:h[0],typeName:h[1]}),d.push({id:h[2],typeName:h[3]})}})));await Promise.all(f);return d};n.getRelationshipEndNodeMap=async function(b,a){const d=new Map,c=new Map,f=[];if(a.dataModel?.relationshipTypes)for(const e of a.dataModel.relationshipTypes)e.name&&c.set(e.name,[]);for(const e of b)c.has(e.typeName)&&c.get(e.typeName)?.push(e.id);
for(const [e,l]of c)1>l.length||(b=new E({openCypherQuery:`MATCH (n)-[r:${e}]->(m) WHERE id(r) in $ids RETURN id(r), id(n), id(m)`,bindParameters:{ids:l}}),f.push(D.executeQueryStreaming(a,b).then(async g=>{for(g=g.resultRowsStream.getReader();;){const {done:k,value:m}=await g.read();if(k)break;for(const h of m)d.set(h[0],[h[1],h[2]])}})));await Promise.all(f);return d};n.serializeInclusionDefinitionToAllPbf=async function(b,a,d){const c=await u.getWasmInterface(),f=new c.FeatureCollection,e=new c.FeatureCollection;
try{H(f,c,b,"entities",a,d);H(e,c,b,"relationships",a,d);const l=new c.FeatureCollectionEncoder,g=new c.FeatureCollectionEncoder,k=L(f,l),m=structuredClone(k),h=L(e,g),w=structuredClone(h),p={entitiesFC:m,relationshipsFC:w,idCollections:await G(b)};l.delete();g.delete();return p}finally{f.delete(),e.delete()}};n.serializeInclusionDefinitionToIdCollectionsMapPbf=G;Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});