Arcgis api for JavaScript疊加分析geometryEngine.contains
阿新 • • 發佈:2019-02-03
疊加分析geometryEngine.contains:
//建立FeatureLayer要素圖層 var targetLayer = mapManager.createFeatureLayer($("#targetLayer").combobox("getValue")); var targetFeatures = null; //儲存餅狀圖展示資料 var overlayArray = []; //儲存各個型別名稱和數量 var dataName = []; //儲存各個型別下的資料 var arrayAll = new Array(); //查詢要素圖層得到所有要素集 targetLayer.queryFeatures().then(function(results){ targetFeatures = results.features; global.currentQueryUrl = $("#joinLayer").combobox("getValue"); //建立FeatureLayer要素圖層 var joinLayer = mapManager.createFeatureLayer(global.currentQueryUrl); //查詢要素圖層得到所有要素集 joinLayer.queryFeatures().then(function(results){ featureArray = results.features; for(var i=0; i<targetFeatures.length; i++){ var count = 0; var array = new Array(); for(var j=0; j<featureArray.length; j++){ //迴圈判斷2個圖形是否重疊,如果重疊則記錄在數值裡 if(geometryEngine.contains(targetFeatures[i].geometry,featureArray[j].geometry)){ count++; featureArray[j].attributes.id = featureArray[j].attributes.ID; array.push(featureArray[j].attributes); } } arrayAll.push(array); overlayArray.push({"name":targetFeatures[i].attributes.NAME+":"+count,"value":count}); dataName.push({"name":targetFeatures[i].attributes.NAME,"count":count}); } $("#contentBox").html("<hr><div id=\"overlayPie\" style=\"width:360px;height:300px;\" align=\"center\"></div><div id=\"overlayResultDg\" data-options=\"width:360,striped:true\"></div>"); overlayAnalysis.pieResult(overlayArray); overlayAnalysis.overlayDg(dataName,arrayAll); }); });