空间分析放在for循环里,运行时iserver就自己关闭了,
function calc(){
for (var i = 1; i < 500; i++) {
var topographyServiceByDatasets = new SuperMap.REST.OverlayAnalystService(url3);
var dsTopographyAnalystParameters = new SuperMap.REST.DatasetOverlayAnalystParameters({
sourceDataset: "安康市地形地貌分布图@192.168.30.10_map_ankang",
operateDataset: "安康市2500米网格@192.168.30.10_map_ankang2",
//operateDatasetFilter: {attributeFilter: "smid = 276"},
operateDatasetFilter: {attributeFilter: "smid ="+i+""},
sourceDatasetFields:["topography","probability"],
operateDatasetFields:["smid","SmArea"],
tolerance: 0,
operation: SuperMap.REST.OverlayOperationType.INTERSECT
});
topographyServiceByDatasets.events.on({"processCompleted": function(args){
var feature, features = [];
var p1=0;
for(var i=0;i<args.result.recordset.features.length;i++){
feature = args.result.recordset.features[i];
var areaTotal=feature.attributes.SmArea_2;
var probability=feature.attributes.probability;
var area=feature.attributes.SmArea;
var p=(area/areaTotal)*probability;
p1+=p;
}
console.log(p1);
}, "processFailed": overlayAnalystFailed});
topographyServiceByDatasets.processAsync(dsTopographyAnalystParameters);
}
}