⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aimsextract.js

📁 采用arcims结合asp开发的一个webgis系统,针对地下水,实现了曲线时时绘制的功能.
💻 JS
字号:
// aimsExtract.js
/*
*  JavaScript template file for ArcIMS HTML Viewer Extract Sample
*		dependent on aimsXML.js, ArcIMSparam.js, aimsCommon.js, aimsMap.js, aimsIdentify.js, aimsSelect.js, and aimsLayers.js
*		To be interactive, dependent also on aimsDHTML.js, aimsClick.js, and aimsNavigation.js
*
*		It is assumed that the Image MapService will have the appropriate paramaters set up in the axl file for extraction. . .
*		Add the following lines in the MapService axl file in one of the layers' definitions:
*      		<EXTENSION type="extract" >
*        		<EXTRACTPARAMS clip="true" >
*        		</EXTRACTPARAMS>
*     		</EXTENSION>
*
*		Only one <EXTENSION type="extract"> tag set is required for the Extract functionality to be enabled
*
*		The output directory and URL are defined in the mapservice configuration.
*
*		Only the layers visible within the current extent will be extracted.
*		The active layer can be further filtered by selection or query. 
*
*		Image layers cannot be extracted. Only feature-type layers can be extracted.
*
*/

aimsExtractPresent=true;

var totLayers = 0;
var xLayers = new Array();

// this variable added for Extract MapService
var imsExtractURL = imsURL + "&CustomService=Extract";



// extract layers to download
	// overrides function in aimsCustom.js
function extractIt() {
	hideLayer("measureBox");
	//alert("Extract function here");
	totLayers = 0;
	xLayers.length = 0;
	for (var i=0;i<LayerVisible.length;i++) {
		if ((mapScaleFactor>=LayerMinScale[i]) && (mapScaleFactor<=LayerMaxScale[i])) {
			if (LayerIsFeature[i]) {
				if (LayerVisible[i]) {
					xLayers[totLayers] = i;
					totLayers++;
				}
			}
		}
	}
	//if (totLayers>0) {
		var Win1 = parent.TextFrame;
		var theFrame = "parent.MapFrame";
		if ((useExternalWindow) || (!useTextFrame)) {
			Win1 = window.open("","ExtractWindow","width=575,height=120,scrollbars=yes,resizable=yes");
			theFrame = "opener";
			if (parent.MapFrame!=null) theFrame = "opener.parent.MapFrame";
		} else {
			Win1 = parent.TextFrame;
			Win1.document.open();
		}
		Win1.document.open();
		Win1.document.writeln('<html><meta http-equiv="Content-Type" content="text/html; charset=' + charSet + '"><head><title>' + extractList[0] + '</title></head>');
		Win1.document.writeln('<body bgcolor="' + textFrameBackColor + '" text="' + textFrameTextColor + '" link="' + textFrameLinkColor + '" vlink="' + textFrameLinkColor + '" LEFTMARGIN=10 TOPMARGIN=5 onload="window.focus()">');
		Win1.document.writeln('<FONT FACE="Arial" SIZE="-1"><b>' + extractList[1] + '</b><br>');
		Win1.document.writeln('<DIV ALIGN="center"><table width="90%" border="0" cellspacing="2" cellpadding="2" nowrap bgcolor="' + tableBackColor + '">');
		
		if (xLayers.length>0) {
			Win1.document.writeln('<form>');
			Win1.document.writeln('<tr><td><FONT FACE="Arial" SIZE="-1">');
			var exCount = 0;
			for (var i=0;i<xLayers.length;i++) {
				var exNum = parseInt(xLayers[i]);
				if (LayerVisible[exNum]==1) {
					Win1.document.writeln(LayerName[exNum] + '<br>');
					exCount++;
				}
			}
			if (exCount>0) {
				Win1.document.writeln('</font></td><td>');
				Win1.document.writeln('<input type="button" value="' + extractList[2] + '" onclick="' + theFrame + '.extractTheLayers()">');
			} else {
				Win1.document.writeln(extractList[3]);

			}
			Win1.document.writeln('</td></tr>');
			Win1.document.writeln('</form>');
		} else {
			Win1.document.writeln('<tr><td><FONT FACE="Arial" SIZE="-1">');
			Win1.document.writeln(extractList[4]);
			Win1.document.writeln('</font></td></tr>');
		}
		Win1.document.writeln('</table>');
		Win1.document.writeln('</DIV>');
		Win1.document.writeln(extractList[5] + eLeft + ',' + eBottom + ',' + eRight + ',' + eTop + '<br>');
		Win1.document.writeln('</font></body></html>');
		Win1.document.close();
		
		//alert(totLayers + " layers:\n" + xLayers.toString());
	//} else {
	//	alert("No extractable layers are visible.");
	//}
}



function writeExtractXML() {
	var eString = '<ARCXML version="1.1">\n';
	eString += '<REQUEST>\n<GET_EXTRACT>\n<PROPERTIES>\n';
	eString += '<ENVELOPE minx="' + forceComma(eLeft) + '" miny="' + forceComma(eBottom) +'" maxx="' + forceComma(eRight) + '" maxy="' + forceComma(eTop) + '" />\n';
	eString += '<IMAGESIZE height="' + iHeight + '" width="' + iWidth + '" />\n';
	eString += '<LAYERLIST>\n';
	/*
	for (var ex=0;ex<xLayers.length;ex++) {
		var exNum = parseInt(xLayers[ex]);
		eString += '<LAYERDEF id="' + LayerID[exNum] + '" ';
		if (LayerVisible[exNum]==1) {
			eString += 'visible="true"';
		} else {
			eString += 'visible="false"';
		}
		if (exNum==ActiveLayerIndex) {
			var addString = addSelectToExtractRequest();
			if (addString!="") {
				eString += '>\n' + addString + '</LAYERDEF>\n';
			} else {
				eString += '/>\n';
			}
		} else {
			eString += '/>\n';
		} 
	}
	
	*/
	for (var j=0;j<LayerID.length;j++) {
		eString += '<LAYERDEF id="' + LayerID[j] + '" ';
		var k=-1;
		for (var m=0;m<xLayers.length;m++) {
			if (parseInt(xLayers[m])==j) k=j;
		}
		if (k>-1) {
			eString += 'visible="true"';
			if (k==ActiveLayerIndex) {
				var addString = addSelectToExtractRequest();
				if (addString!="") {
					eString += '>\n' + addString + '</LAYERDEF>\n';
				} else {
					eString += '/>\n';
				}
			} else {
				eString += '/>\n';
			} 
		} else {
			eString += 'visible="false"/>\n';
		}
	}
	eString += '</LAYERLIST>\n';
	eString += '</PROPERTIES>\n</GET_EXTRACT>\n</REQUEST>\n';
	eString += '</ARCXML>\n';
	return eString;
}

function extractTheLayers() {
	//alert("Extract stuff here.");
	showRetrieveData();
	var theString = writeExtractXML();
	//alert(theString);
	sendExtractRequest(theString, 4001)
	
}

function addSelectToExtractRequest() {
	var selString = "";
	var sFactor = (eRight-eLeft) / iWidth
	if ((sFactor>=LayerMinScale[ActiveLayerIndex]) && (sFactor<=LayerMaxScale[ActiveLayerIndex]) && (LayerVisible[ActiveLayerIndex]==1)) {
		if (selectCount>0) {
			if (selectionMode==1) {
				selString +='<SPATIALQUERY  where="' + setQueryString + '"';
				if (useLimitExtent) {
					// keep this within the limitExtent
					
					selString +='>\n<SPATIALFILTER relation="area_intersection">\n';
					selString +='<ENVELOPE maxx="' + forceComma(limitRight) + '" maxy="' + forceComma(limitTop) + '" minx="' + forceComma(limitLeft) + '" miny="' + forceComma(limitBottom) + '" />\n';
					selString +='</SPATIALFILTER>\n';
					selString +='</SPATIALQUERY>\n';
				} else {
				selString +='/>\n';
				}
			
			} else {
				selString +='<SPATIALQUERY>\n';
				selString +='<SPATIALFILTER relation="area_intersection" >\n';
				if (selectionMode==2) {
					selString +='<ENVELOPE ' + selectEnvelope + ' />\n';
				} else {
					if ((shapeSelectBuffer) && (shapeBufferDistance>0)) {
					//if (shapeBufferDistance>0) {
						// do a buffer around the shape before selecting
						var smoothEdge = shapeBufferDistance  * 0.01;
						selString += '<BUFFER distance="' + forceComma(shapeBufferDistance) + '" ';
						//selString += 'smoothedges="' + smoothEdge + '"';
						selString += ' bufferunits="' + ScaleBarUnits + '"';
						selString += ' />\n';
					}
					if (clickType==2) {
						selString +='<POLYLINE>\n<PATH>\n';
					} else if (clickType==3) {
						selString +='<POLYGON>\n<RING>\n';
					} else {
						selString +='<MULTIPOINT>\n';
					}
					if (clickType==1) {
						selString +='<POINT x="' + forceComma(clickPointX[clickCount-1]) + '" y="' + forceComma(clickPointY[clickCount-1]) + '" />\n';
					} else {
						for (var i=0;i<clickCount;i++) {
							selString +='<POINT x="' + forceComma(clickPointX[i]) + '" y="' + forceComma(clickPointY[i]) + '" />\n'; 
						}
					}
					if (clickType==3) {
						//selString +='<POINT x="' + clickPointX[0] + '" y="' + clickPointY[0] + '" />\n';
						selString +='</RING>\n</POLYGON>\n';
					} else if (clickType==2) {
						selString +='</PATH>\n</POLYLINE>\n';
					} else {
						selString +='</MULTIPOINT>\n';
					}
				}
				selString +='</SPATIALFILTER>\n';
				///*
				if (useLimitExtent) {
					// keep this within the limitExtent
					selString +='<SPATIALFILTER relation="area_intersection">\n';
					selString +='<ENVELOPE maxx="' + forceComma(limitRight) + '" maxy="' + forceComma(limitTop) + '" minx="' + forceComma(limitLeft) + '" miny="' + forceComma(limitBottom) + '" />\n';
					selString +='</SPATIALFILTER>\n';
				} 
				//*/
				selString +='</SPATIALQUERY>\n';
			}
		}
	}
	return selString;
}

function showExtractURL(theReply) {
	hideRetrieveData();
	//alert(theReply);
	var Win1 = parent.TextFrame;
	var theFrame = "parent.MapFrame";
	if ((useExternalWindow) || (!useTextFrame)) {
		Win1 = window.open("","ExtractWindow","width=575,height=120,scrollbars=yes,resizable=yes");
		theFrame = "opener";
		if (parent.MapFrame!=null) theFrame = "opener.parent.MapFrame";
	} else {
		Win1 = parent.TextFrame;
		Win1.document.open();
	}
	Win1.document.open();
	Win1.document.writeln('<html><meta http-equiv="Content-Type" content="text/html; charset=' + charSet + '"><head><title>' + extractList[0] + '</title></head>');
	Win1.document.writeln('<body bgcolor="' + textFrameBackColor + '" text="' + textFrameTextColor + '" link="' + textFrameLinkColor + '" vlink="' + textFrameLinkColor + '" LEFTMARGIN=10 TOPMARGIN=5 onload="window.focus()">');
	Win1.document.writeln('<form><FONT FACE="Arial" SIZE="-1"><b>');
	var pos = theReply.indexOf("OUTPUT");
	var theURL = "";
	if (pos != -1) {
		Win1.document.writeln(extractList[6] + '&nbsp;&nbsp;&nbsp;&nbsp;');
		theURL = getInsideString(theReply,'url="',dQuote,pos,0,false);
		Win1.document.writeln('<a href="' + theURL + '">' + extractList[7] + '</A>');
	} else {
		Win1.document.writeln(extractList[8]);
	}
	Win1.document.writeln('</b></font></form></body></html>');
	Win1.document.close();
	
	
}

// send custom XML request. . . set up custom response handler
function sendExtractRequest(XMLRequest, theType) {
	var theFunction = "parent.MapFrame.processExtractXML";
	var theForm = parent.PostFrame.document.forms[0];
	theForm.JavaScriptFunction.value = theFunction;
	sendToServer(imsExtractURL,XMLRequest,theType)
}

function processExtractXML(theReplyIn) {
	theReplyIn = replacePlus(theReplyIn);
	var theReply = unescape(theReplyIn);
	//alert(theReply);
	okToSend = true;
	if (debugOn>2) alert(msgList[13] + theReply);
	var theError = getXMLErrorMessage(theReply);
	if (XMLMode == 4001) {
		//alert("XMLMode=4001\n" + theReply);
		showExtractURL(theReply);
	
	}
	if (XMLMode == 4002) {
		alert("XMLMode=4002");
	
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -