标签:
//获取并初始化等值线面图层 function getIsoAnalyzeResultLayer() { var layerId = "isoAnalyzeResult"; var graphicsLayerIsoAnalyze = map.getLayer(layerId); if (typeof (graphicsLayerIsoAnalyze) == "undefined" || graphicsLayerIsoAnalyze == null) { graphicsLayerIsoAnalyze = new esri.layers.GraphicsLayer({ id: layerId }); map.addLayer(graphicsLayerIsoAnalyze); } else { graphicsLayerIsoAnalyze.clear(); } return graphicsLayerIsoAnalyze; } //设置等值线渲染符号 function setIsolineAnalyzeResultLayerRender(graphicsLayerIsoAnalyze, breakArray, colorArray) { var defaultSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 0, 0]), 3); var renderer = new esri.renderer.UniqueValueRenderer(defaultSymbol, "Contour"); // Contour // CONTOUR // for (var i = 0; i < colorArray.length; i++) { var colorHex = colorArray[i]; var colorRGB = HexToRGB(colorHex); var value = parseFloat(breakArray[i]); var simpleLineSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([colorRGB.r, colorRGB.g, colorRGB.b]), 3); renderer.addValue(value, simpleLineSymbol); } graphicsLayerIsoAnalyze.setRenderer(renderer); } //设置等值面渲染符号 function setIsosurfaceAnalyzeResultLayerRender(graphicsLayerIsoAnalyze, breakArray, colorArray) { var defaultSymbol = new esri.symbol.SimpleFillSymbol().setStyle(esri.symbol.SimpleFillSymbol.STYLE_NULL); defaultSymbol.outline.setStyle(esri.symbol.SimpleLineSymbol.STYLE_NULL); var renderer = new esri.renderer.UniqueValueRenderer(defaultSymbol, "GRIDCODE"); // for (var i = 0; i < colorArray.length; i++) { var simpleFillSymbol = new esri.symbol.SimpleFillSymbol(); simpleFillSymbol.setStyle(esri.symbol.SimpleFillSymbol.STYLE_SOLID); simpleFillSymbol.outline.setStyle(esri.symbol.SimpleLineSymbol.STYLE_NULL); var colorHex = colorArray[i]; var colorRGB = HexToRGB(colorHex); simpleFillSymbol.setColor(new dojo.Color([colorRGB.r, colorRGB.g, colorRGB.b, 0.5])); renderer.addValue(i, simpleFillSymbol); } graphicsLayerIsoAnalyze.setRenderer(renderer); } // function setThiessenPolygonAnalyzeResultLayerRender(graphicsLayerIsoAnalyze) { var defaultSymbol = new esri.symbol.SimpleFillSymbol().setStyle(esri.symbol.SimpleFillSymbol.STYLE_NULL); var outline = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 2); defaultSymbol.setOutline(outline); var renderer = new esri.renderer.SimpleRenderer(defaultSymbol); graphicsLayerIsoAnalyze.setRenderer(renderer); } //清除等值线面结果 function cleanIsoAnalyze(layerNameArray) { var graphicsLayerIsoAnalyze = getIsoAnalyzeResultLayer(); graphicsLayerIsoAnalyze.clear(); if(layerNameArray && layerNameArray.length > 0) { for(var i=0; i<layerNameArray.length; i++) { var layerName = layerNameArray[i]; var gplayer = map.getLayer(layerName); if(gplayer!=null) { map.removeLayer(gplayer); } } } } //计算等值线 function isolineAnalyze(parameter) { var breakString = parameter.breakString; var breakArray = breakString.split(","); var colorArray = parameter.colorArray; var id = parameter.layerid; //调用GP服务 var gpUrl = config.map.gpServer.isolineAnalyze; var bd = Ext.getBody(); bd.mask("<font style=‘font-weight:bold;‘>正在计算!!!</font>", ‘x-mask-loading‘); var params={ starttime:parameter.startTime, endtime:parameter.endTime, gpUrl:gpUrl, breakString:breakString, id:id }; var url = Watf.REQUEST_CONTEXTPATH+"/syq/rainforgisisoSurfaceAnalyze.do"; $.ajax({ url: url, type: ‘POST‘, timeout: 3000, async:false, data: Ext.urlEncode(params), dataType:‘json‘, cache:false, error: function(XMLHttpRequest, textStatus, errorThrown){ alert(‘错误:‘,[‘<div >‘,‘<div >‘,url,‘</div>‘,‘<div >‘,errorThrown,‘</div>‘,‘</div>‘].join(‘‘)); }, success: function(data){ var gp = new esri.tasks.Geoprocessor(gpUrl); var id = data.jobId; taskid = window.setInterval(function(){ checkstatus(id, gp); }, 500); } }); function checkstatus(jobId,gp){ gp.checkJobStatus(jobId, function(jobInfo){ if(jobInfo.jobStatus ==‘esriJobSucceeded‘){ window.clearInterval(taskid); gp.getResultData(jobId, "isoResult", renderIsolineAnalyzeResult, errorCallback); Ext.MessageBox.alert(‘提示‘, ‘计算完成!‘); bd.unmask(); }else if(jobInfo.jobStatus ==‘esriJobFailed‘ || jobInfo.jobStatus ==‘esriJobTimedOut‘){ window.clearInterval(taskid); Ext.MessageBox.alert(‘提示‘, ‘生成失败!‘); bd.unmask(); } }); } //加载GP服务计算结果的回调函数 function renderIsolineAnalyzeResult(result) { var featureSet = result.value; var graphicsLayerIsoAnalyze = getIsoAnalyzeResultLayer(); setIsolineAnalyzeResultLayerRender(graphicsLayerIsoAnalyze, breakArray, colorArray); var features = featureSet.features; for (var i = 0; i < features.length; i++) { var graphic = features[i]; graphicsLayerIsoAnalyze.add(graphic); } hideLoading(); } } //计算等值面 function isosurfaceAnalyze(parameter) { var breakString = parameter.breakString; var breakArray = breakString.split(","); var colorArray = parameter.colorArray; // var gradeMap = new Array(); for(var i=0; i<breakArray.length; i++) { var grade = new Object(); grade.color = colorArray[i]; grade.value = parseFloat(breakArray[i]); gradeMap.push(grade); } // var id = parameter.layerid; //调用GP服务 var gpUrl = config.map.gpServer.isosurfaceAnalyze; var bd = Ext.getBody(); bd.mask("<font style=‘font-weight:bold;‘>正在计算!!!</font>", ‘x-mask-loading‘); var params={ starttime:parameter.startTime, endtime:parameter.endTime, gpUrl:gpUrl, breakString:breakString, id:id }; var url = Watf.REQUEST_CONTEXTPATH+"/syq/rainforgisisoSurfaceAnalyze.do"; $.ajax({ url: url, type: ‘POST‘, timeout: 3000, async:false, data: Ext.urlEncode(params), dataType:‘json‘, cache:false, error: function(XMLHttpRequest, textStatus, errorThrown){ alert(‘错误:‘,[‘<div >‘,‘<div >‘,url,‘</div>‘,‘<div >‘,errorThrown,‘</div>‘,‘</div>‘].join(‘‘)); }, success: function(data){ var gp = new esri.tasks.Geoprocessor(gpUrl); var id = data.jobId; taskid=window.setInterval(function(){ checkstatus(id,gp); },500); } }); function checkstatus(jobId,gp){ gp.checkJobStatus(jobId,function(jobInfo){ if(jobInfo.jobStatus ==‘esriJobSucceeded‘){ window.clearInterval(taskid); gp.getResultData(jobId, "isoResult", renderIsosurfaceAnalyzeResult,errorCallback); //加载GP服务计算结果 hideLoading(); Ext.MessageBox.alert(‘提示‘, ‘计算完成!‘); }else if(jobInfo.jobStatus ==‘esriJobFailed‘ || jobInfo.jobStatus ==‘esriJobTimedOut‘){ window.clearInterval(taskid); Ext.MessageBox.alert(‘提示‘, ‘生成失败!‘); hideLoading(); } }); } //加载GP服务计算结果的回调函数 function renderIsosurfaceAnalyzeResult(result) { var featureSet = result.value; var graphicsLayerIsoAnalyze = getIsoAnalyzeResultLayer(); setIsosurfaceAnalyzeResultLayerRender(graphicsLayerIsoAnalyze, breakArray, colorArray); var features = featureSet.features; for (var i = 0; i < features.length; i++) { var graphic = features[i]; graphicsLayerIsoAnalyze.add(graphic); } hideLoading(); } } //计算泰森多边形thiessenPolygon function thiessenPolygonAnalyze() { var urlArray = config.operatorLayers.station; var fieldsArray = ["STCD"]; var sql = "1=1"; var gisLayerAccess = new GisLayerAccess(urlArray, fieldsArray, sql, null, function (resultData) { var featureSet = resultData[0]; // Value for (var i = 1; i < resultData.length; i++) { var features = resultData[i].features; for (var j = 0; j < features.length; j++) { var graphic = features[j]; featureSet.features.push(graphic); } } //调用GP服务 var url = config.map.gpServer.thiessenPolygon; var gp = new esri.tasks.Geoprocessor(url); gp.setOutputSpatialReference(map.spatialReference); gp.setProcessSpatialReference(map.spatialReference); var params = new Object(); params.station = featureSet; //params.extentValue = config.map.initialextent[0] + " " + config.map.initialextent[1] + " " + config.map.initialextent[2] + " " + config.map.initialextent[3]; // showLoading(); Ext.MessageBox.alert(‘提示‘, ‘开始计算!‘); gp.submitJob(params, completeCallback, statusCallback, errorCallback); //GP服务计算完成回调函数 function completeCallback(jobInfo) { if (jobInfo.jobStatus !== "esriJobFailed") { Ext.MessageBox.alert(‘提示‘, ‘计算完成,加载结果!‘); //加载GP服务计算结果 gp.getResultData(jobInfo.jobId, "analyzeResult", renderThiessenPolygonAnalyzeResult, errorCallback); showLoading(); } } //加载GP服务计算结果的回调函数 function renderThiessenPolygonAnalyzeResult(result) { var featureSet = result.value; var graphicsLayerIsoAnalyze = getIsoAnalyzeResultLayer(); setThiessenPolygonAnalyzeResultLayerRender(graphicsLayerIsoAnalyze); var features = featureSet.features; for (var i = 0; i < features.length; i++) { var graphic = features[i]; graphicsLayerIsoAnalyze.add(graphic); } } }); } function labelAnalyze(parameter, layerName){ var breakString = ""; //调用GP服务 var gpUrl = config.map.gpServer.labelStationAnalyze; var bd = Ext.getBody(); bd.mask("<font style=‘font-weight:bold;‘>正在计算!!!</font>", ‘x-mask-loading‘); var params={ starttime:parameter.startTime, endtime:parameter.endTime, gpUrl:gpUrl }; var url = Watf.REQUEST_CONTEXTPATH+"/syq/rainforgisisoSurfaceAnalyze.do"; $.ajax({ url: url, type: ‘POST‘, timeout: 3000, async:false, data: Ext.urlEncode(params), dataType:‘json‘, cache:false, error: function(XMLHttpRequest, textStatus, errorThrown){ alert(‘错误:‘,[‘<div >‘,‘<div >‘,url,‘</div>‘,‘<div >‘,errorThrown,‘</div>‘,‘</div>‘].join(‘‘)); }, success: function(data){ var gp = new esri.tasks.Geoprocessor(gpUrl); var id = data.jobId; taskid=window.setInterval(function(){ checkstatus(id,gp); },500); } }); function checkstatus(jobId,gp){ gp.checkJobStatus(jobId,function(jobInfo){ if(jobInfo.jobStatus ==‘esriJobSucceeded‘){ window.clearInterval(taskid); //加载GP服务计算结果 var imageParams = new esri.layers.ImageParameters(); imageParams.format = "png"; imageParams.transparent = true; imageParams.imageSpatialReference = map.spatialReference; gp.getResultImageLayer(jobInfo.jobId, "stationResult", imageParams, displayResult, errorCallback); Ext.MessageBox.alert(‘提示‘, ‘计算完成!‘); // bd.unmask(); }else if(jobInfo.jobStatus ==‘esriJobFailed‘ || jobInfo.jobStatus ==‘esriJobTimedOut‘){ window.clearInterval(taskid); Ext.MessageBox.alert(‘提示‘, ‘生成失败!‘); bd.unmask(); } }); } function displayResult(layer) { var gplayer = map.getLayer(layerName); if(gplayer!=null) { map.removeLayer(gplayer); } gplayer=layer; gplayer.id = layerName; gplayer = map.addLayer(gplayer); hideLoading(); } } /** * 雨量测站标注 * @param {} prodInfoId * @param {} layerName */ function tsLabelAnalyze(prodInfoId, layerName){ var breakString = ""; //调用GP服务 var gpUrl = config.map.gpServer.labelStationAnalyze; var params={ gpUrl:gpUrl, id:prodInfoId }; var url = Watf.REQUEST_CONTEXTPATH+"/syq/rainforgisisoTaggingAnalyze.do"; $.ajax({ url: url, type: ‘POST‘, timeout: 3000, async:false, data: Ext.urlEncode(params), dataType:‘json‘, cache:false, error: function(XMLHttpRequest, textStatus, errorThrown){ alert(‘错误:‘,[‘<div >‘,‘<div >‘,url,‘</div>‘,‘<div >‘,errorThrown,‘</div>‘,‘</div>‘].join(‘‘)); }, success: function(data){ var gp = new esri.tasks.Geoprocessor(gpUrl); if(null!=data){ var id = data.jobId; taskid=window.setInterval(function(){ checkstatus(id,gp); },500); }else{ Ext.Msg.alert(‘提示‘,‘没有该产品信息!‘); } } }); function checkstatus(jobId,gp){ gp.checkJobStatus(jobId,function(jobInfo){ if(jobInfo.jobStatus ==‘esriJobSucceeded‘){ window.clearInterval(taskid); //加载GP服务计算结果 var imageParams = new esri.layers.ImageParameters(); imageParams.format = "png"; imageParams.transparent = true; imageParams.imageSpatialReference = map.spatialReference; gp.getResultImageLayer(jobInfo.jobId, "stationResult", imageParams, displayResult, errorCallback); // bd.unmask(); }else if(jobInfo.jobStatus ==‘esriJobFailed‘ || jobInfo.jobStatus ==‘esriJobTimedOut‘){ window.clearInterval(taskid); Ext.MessageBox.alert(‘提示‘, ‘生成失败!‘); bd.unmask(); } }); } function displayResult(layer) { var gplayer = map.getLayer(layerName); if(gplayer!=null) { map.removeLayer(gplayer); } gplayer=layer; gplayer.id = layerName; gplayer = map.addLayer(gplayer); hideLoading(); } } function thiessenPolygonAnalyzeServerRender(layerName) { var urlArray = config.operatorLayers.station; var fieldsArray = ["STCD"]; var sql = "1=1"; var bd = Ext.getBody(); bd.mask("<font style=‘font-weight:bold;‘>正在计算!!!</font>", ‘x-mask-loading‘); var gisLayerAccess = new GisLayerAccess(urlArray, fieldsArray, sql, null, function (resultData) { var featureSet = resultData[0]; // Value for (var i = 1; i < resultData.length; i++) { var features = resultData[i].features; for (var j = 0; j < features.length; j++) { var graphic = features[j]; featureSet.features.push(graphic); } } //调用GP服务 var url = config.map.gpServer.thiessenPolygon; //"http://10.1.98.60/ArcGIS/rest/services/thiessenPolygon/GPServer/thiessenPolygon"; var gp = new esri.tasks.Geoprocessor(url); gp.setOutputSpatialReference(map.spatialReference); gp.setProcessSpatialReference(map.spatialReference); var params = new Object(); params.station = featureSet; params.boundry = ""; params.extentValue = "";// config.map.initialextent[0] + " " + config.map.initialextent[1] + " " + config.map.initialextent[2] + " " + config.map.initialextent[3]; // gp.submitJob(params, completeCallback, statusCallback, errorCallback); //GP服务计算完成回调函数 function completeCallback(jobInfo) { if(jobInfo.jobStatus ==‘esriJobSucceeded‘){ Ext.MessageBox.alert(‘提示‘, ‘计算完成,加载结果!‘); //加载GP服务计算结果 var imageParams = new esri.layers.ImageParameters(); imageParams.format = "png"; imageParams.transparent = true; imageParams.imageSpatialReference = map.spatialReference; gp.getResultImageLayer(jobInfo.jobId, "analyzeResult", imageParams, displayResult, errorCallback); // bd.unmask(); } else if (jobInfo.jobStatus == "esriJobFailed") { Ext.MessageBox.alert(‘提示‘, ‘生成失败!‘); bd.unmask(); } } function displayResult(layer) { var gplayer = map.getLayer(layerName); if(gplayer!=null) { map.removeLayer(gplayer); } gplayer=layer; gplayer.id = layerName; gplayer = map.addLayer(gplayer); hideLoading(); } }); } // function dynamicLoadServerRenderData(mapServiceLayerId, url, sql, layerIndex, opacity, field, gradeMap) { removeMapService(mapServiceLayerId); //调用GP服务 var gp = new esri.tasks.Geoprocessor(url); gp.setOutputSpatialReference(map.spatialReference); gp.setProcessSpatialReference(map.spatialReference); var params = new Object(); params.Expression = sql; // showLoading(); //Ext.MessageBox.alert(‘提示‘, ‘开始计算!‘); gp.submitJob(params, completeCallback, statusCallback, errorCallback); //GP服务计算完成回调函数 function completeCallback(jobInfo) { if (jobInfo.jobStatus !== "esriJobFailed") { //Ext.MessageBox.alert(‘提示‘, ‘计算完成,加载结果!‘); //加载GP服务计算结果 var index = url.lastIndexOf("/"); url = url.substring(0, index); index = url.lastIndexOf("/"); url = url.substring(0, index); url += "/MapServer"; /* url = url + "/jobs/" + jobInfo.jobId; */ addMapService(mapServiceLayerId, url, layerIndex, null, opacity, field, gradeMap); hideLoading(); } } } //GP服务计算出错回调函数 function errorCallback(error) { Ext.MessageBox.alert(‘出错‘, error.toString()); hideLoading(); } //GP服务计算状态检查回调函数 function statusCallback(jobInfo) { var status = jobInfo.jobStatus; if (status === "esriJobFailed") { Ext.MessageBox.alert(‘出错‘, status.toString()); hideLoading(); } else if (status === "esriJobSucceeded") { hideLoading(); } }
标签:
原文地址:http://www.cnblogs.com/gispathfinder/p/5789721.html