aimsBuffer.js
资源名称:arcims.rar [点击查看]
上传用户:gzuoyue
上传日期:2022-07-08
资源大小:177k
文件大小:16k
源码类别:
GIS编程
开发平台:
ASP/ASPX
- // aimsBuffer.js
- /*
- * JavaScript template file for ArcIMS HTML Viewer
- * dependent on aimsXML.js, ArcIMSparam.js, aimsCommon.js, aimsMap.js, aimsIdentify.js,
- * aimsSelect.js, aimsQuery.js, and aimsLayers.js
- * To be interactive, dependent also on aimsDHTML.js, aimsClick.js, and aimsNavigation.js
- */
- aimsBufferPresent=true;
- var drawTargetLayer = true;
- var bufferTargetLayer = "";
- var bufferTargetLayerIndex = 0;
- var bufferDistance = 5;
- var bufferSmoothEdges = 1/100;
- var getBufferedData = false;
- /*
- ***************************************************************************************
- Buffer functions
- ***************************************************************************************
- */
- function writeBufferForm() {
- var url = appDir + "buffer.htm";
- if (useTextFrame) {
- parent.TextFrame.document.location = url;
- } else {
- Win1 = open(url,"BufferWindow","width=575,height=150,scrollbars=yes,resizable=yes");
- }
- }
- // buffer around selected features
- function bufferIt() {
- hideLayer("measureBox");
- showBuffer=true;
- sendMapXML();
- }
- // add buffer stuff to Map XML request
- function addBufferToMap() {
- var buffString = "";
- if (selectionMode==1) {
- if (drawTargetLayer) {
- buffString += '<LAYER type="featureclass" name="' + titleList[24] + '" visible="true">n';
- buffString += '<DATASET fromlayer="' + LayerID[ActiveLayerIndex] + '" />n';
- buffString += '<SPATIALQUERY where="' + setQueryString + '" >n';
- buffString += '<BUFFER distance="' + forceComma(bufferDistance) + '" ';
- buffString += ' bufferunits="' + ScaleBarUnits.toLowerCase() + '"';
- buffString += '>n';
- if (useLimitExtent) {
- // keep this within the limitExtent
- buffString += '<SPATIALQUERY>n';
- buffString += '<SPATIALFILTER relation="area_intersection">n';
- buffString += '<ENVELOPE maxx="' + forceComma(limitRight) + '" maxy="' + forceComma(limitTop) + '" minx="' + forceComma(limitLeft) + '" miny="' + forceComma(limitBottom) + '" />n';
- buffString += '</SPATIALFILTER>n';
- buffString += '</SPATIALQUERY>n';
- }
- buffString += '<TARGETLAYER id="' + LayerID[bufferTargetLayerIndex] + '" />n';
- buffString += '</BUFFER>n';
- buffString += '</SPATIALQUERY>n';
- buffString += '<SIMPLERENDERER>n';
- var tlType = LayerType[bufferTargetLayerIndex];
- if (tlType=="point") {
- buffString += '<SIMPLEMARKERSYMBOL color="' + highlightColor + '" type="Circle" width="10" />n';
- } else if (tlType=="line") {
- buffString += '<SIMPLELINESYMBOL color="' + highlightColor + '" width="2" />n';
- } else {
- buffString += '<SIMPLEPOLYGONSYMBOL fillcolor="' + highlightColor + '" filltype="solid" transparency="' + forceComma(5/10) + '" boundarycolor="255,255,255" />n';
- }
- buffString += '</SIMPLERENDERER>n';
- buffString += '</LAYER>n';
- }
- buffString += '<LAYER type="featureclass" name="' + titleList[25] + '" visible="true">n';
- buffString += '<DATASET fromlayer="' + LayerID[ActiveLayerIndex] + '" />n';
- buffString += '<SPATIALQUERY where="' + setQueryString + '" >n';
- buffString += '<BUFFER distance="' + forceComma(bufferDistance) + '" bufferunits="' + ScaleBarUnits.toLowerCase() + '" />n';
- buffString += '</SPATIALQUERY>n';
- buffString += '<SIMPLERENDERER>n';
- buffString += '<SIMPLEPOLYGONSYMBOL fillcolor="100,100,100" filltype="solid" transparency="' + forceComma(35/100) + '" boundarycolor="255,255,255" />n';
- buffString += '</SIMPLERENDERER>n';
- buffString += '</LAYER>n';
- } else if ((selectionMode==2) ||(selectionMode==3)){
- if (drawTargetLayer) {
- buffString += '<LAYER type="featureclass" name="' + titleList[26] + '" visible="true">n';
- buffString += '<DATASET fromlayer="' + LayerID[ActiveLayerIndex] + '" />n';
- buffString += '<SPATIALQUERY>n';
- buffString += '<BUFFER distance="' + forceComma(bufferDistance) + '" bufferunits="' + ScaleBarUnits.toLowerCase() + '">n';
- buffString += '<TARGETLAYER id="' + LayerID[bufferTargetLayerIndex] + '" />n';
- if (useLimitExtent) {
- // keep this within the limitExtent
- buffString += '<SPATIALQUERY>n';
- buffString += '<SPATIALFILTER relation="area_intersection">n';
- buffString += '<ENVELOPE maxx="' + forceComma(limitRight) + '" maxy="' + forceComma(limitTop) + '" minx="' + forceComma(limitLeft) + '" miny="' + forceComma(limitBottom) + '" />n';
- buffString += '</SPATIALFILTER>n';
- buffString += '</SPATIALQUERY>n';
- }
- buffString += '</BUFFER>n';
- // select rectangle or shape
- buffString += '<SPATIALFILTER relation="area_intersection">n';
- if (selectionMode==2) {
- buffString += '<ENVELOPE ' + selectEnvelope + ' />n';
- } else {
- if (clickType==2) {
- buffString += '<POLYLINE>n<PATH>n';
- } else if (clickType==3) {
- buffString += '<POLYGON>n<RING>n';
- } else {
- buffString += '<MULTIPOINT>n';
- }
- for (var i=0;i<clickCount;i++) {
- buffString += '<POINT x="' + clickPointX[i] + '" y="' + clickPointY[i] + '" />n';
- }
- if (clickType==3) {
- buffString += '</RING>n</POLYGON>n';
- } else if (clickType==2) {
- buffString += '</PATH>n</POLYLINE>n';
- } else {
- buffString += '</MULTIPOINT>n';
- }
- }
- buffString += '</SPATIALFILTER>n';
- buffString += '</SPATIALQUERY>n';
- buffString += '<SIMPLERENDERER>n';
- var tlType = LayerType[bufferTargetLayerIndex];
- if (tlType=="point") {
- buffString += '<SIMPLEMARKERSYMBOL color="' + highlightColor + '" type="Circle" width="10" />n';
- } else if (tlType=="line") {
- buffString += '<SIMPLELINESYMBOL color="' + highlightColor + '" width="2" />n';
- } else {
- buffString += '<SIMPLEPOLYGONSYMBOL fillcolor="' + highlightColor + '" filltype="solid" transparency="' + forceComma(35/100) + '" boundarycolor="255,255,255" />n';
- }
- buffString += '</SIMPLERENDERER>n';
- buffString += '</LAYER>n';
- }
- buffString += '<LAYER type="featureclass" name="' + titleList[27] + '" visible="true">n';
- buffString += '<DATASET fromlayer="' + LayerID[ActiveLayerIndex] + '" />n';
- buffString += '<SPATIALQUERY>n';
- buffString += '<BUFFER distance="' + forceComma(bufferDistance) + '" bufferunits="' + ScaleBarUnits.toLowerCase() + '" />n';
- buffString += '<SPATIALFILTER relation="area_intersection">n';
- if (selectionMode==2) {
- buffString += '<ENVELOPE ' + selectEnvelope + ' />n';
- } else {
- if (clickType==2) {
- buffString += '<POLYLINE>n<PATH>n';
- } else if (clickType==3) {
- buffString += '<POLYGON>n<RING>n';
- } else {
- buffString += '<MULTIPOINT>n';
- }
- for (var i=0;i<clickCount;i++) {
- buffString += '<POINT x="' + clickPointX[i] + '" y="' + clickPointY[i] + '" />n';
- }
- if (clickType==3) {
- buffString += '</RING>n</POLYGON>n';
- } else if (clickType==2) {
- buffString += '</PATH>n</POLYLINE>n';
- } else {
- buffString += '</MULTIPOINT>n';
- }
- }
- buffString += '</SPATIALFILTER>n';
- if (useLimitExtent) {
- // keep this within the limitExtent
- buffString += '<SPATIALFILTER relation="area_intersection">n';
- buffString += '<ENVELOPE maxx="' + forceComma(limitRight) + '" maxy="' + forceComma(limitTop) + '" minx="' + forceComma(limitLeft) + '" miny="' + forceComma(limitBottom) + '" />n';
- buffString += '</SPATIALFILTER>n';
- }
- buffString += '</SPATIALQUERY>n';
- buffString += '<SIMPLERENDERER>n';
- buffString += '<SIMPLEPOLYGONSYMBOL fillcolor="100,100,100" filltype="solid" transparency="' + forceComma(5/10) + '" boundarycolor="255,255,255" />n';
- buffString += '</SIMPLERENDERER>n';
- buffString += '</LAYER>n';
- }
- return buffString;
- }
- function writeGetBufferedData() {
- var buffString = "";
- queryStartRecord=1;
- showRetrieveData();
- switch(selectionMode) {
- case 1:
- buffString = writeQueryBufferXML();
- break;
- case 2:
- buffString = writeEnvelopeBufferXML();
- break;
- case 3:
- buffString = writeShapeBufferXML(clickType-1);
- break;
- }
- //alert(buffString);
- return buffString;
- }
- function writeQueryBufferXML() {
- if (swapSelectFields) {
- selectFields=selFieldList[bufferTargetLayerIndex];
- }
- var targetLayerType = LayerType[bufferTargetLayerIndex];
- var theString = '<ARCXML version="1.1">n<REQUEST>n<GET_FEATURES outputmode="xml" geometry="false" envelope="false" checkesc ="true" ';
- theString += ' featurelimit="' + maxFeaturesReturned + '" beginrecord="' + queryStartRecord + '"';
- theString += '>n';
- //CustomLayer===================================================
- if (mCustomLayer.getActiveLayer()>-1){
- theString += mCustomLayer.getActiveLayerString();
- }else{
- theString += '<LAYER id="' + ActiveLayer + '" ftype="' + ActiveLayerType + '" />n';
- }
- //CustomLayer===================================================
- theString += '<SPATIALQUERY where="' + setQueryString + '">n';
- theString += '<BUFFER distance="' + forceComma(bufferDistance) + '" bufferunits="' + ScaleBarUnits.toLowerCase() + '" >n';
- theString += '<TARGETLAYER id="' + LayerID[bufferTargetLayerIndex] + '"/>n';
- theString += '<SPATIALQUERY subfields="' + selectFields + '" />n';
- theString += '</BUFFER>n';
- if (useLimitExtent) {
- // keep this within the limitExtent
- theString += '<SPATIALFILTER relation="area_intersection">n';
- theString += '<ENVELOPE maxx="' + forceComma(limitRight) + '" maxy="' + forceComma(limitTop) + '" minx="' + forceComma(limitLeft) + '" miny="' + forceComma(limitBottom) + '" />n';
- theString += '</SPATIALFILTER>n';
- }
- theString += '</SPATIALQUERY>n';
- theString += '</GET_FEATURES>';
- theString += '</REQUEST>';
- theString += '</ARCXML>';
- //alert("writeQueryXML()nQuery XML Request:n" + theString);
- return theString;
- }
- // write out xml request for selection by shape
- function writeShapeBufferXML(theType) {
- if (swapSelectFields) {
- selectFields=selFieldList[bufferTargetLayerIndex];
- }
- var theString = '<ARCXML version="1.1">n<REQUEST>n<GET_FEATURES outputmode="xml" envelope="false" geometry="false" checkesc ="true" ';
- theString += ' featurelimit="' + maxFeaturesReturned + '" beginrecord="' + queryStartRecord + '"';
- theString += '>n';
- //CustomLayer===================================================
- if (mCustomLayer.getActiveLayer()>-1){
- theString += mCustomLayer.getActiveLayerString();
- }else{
- theString += '<LAYER id="' + ActiveLayer + '" ftype="' + ActiveLayerType + '" />';
- }
- //CustomLayer===================================================
- theString += '<SPATIALQUERY>';
- if (useLimitExtent) {
- // keep this within the limitExtent
- theString += '<SPATIALFILTER relation="area_intersection">n';
- theString += '<ENVELOPE maxx="' + forceComma(limitRight) + '" maxy="' + forceComma(limitTop) + '" minx="' + forceComma(limitLeft) + '" miny="' + forceComma(limitBottom) + '" />n';
- theString += '</SPATIALFILTER>n';
- }
- theString += '<SPATIALFILTER relation="area_intersection" >';
- if (theType==1) {
- theString += '<POLYLINE>n<PATH>n';
- } else {
- theString += '<POLYGON>n<RING>n';
- }
- for (var i=0;i<clickCount;i++) {
- theString += '<POINT x="' + clickPointX[i] + '" y="' + clickPointY[i] + '" />n';
- }
- if (theType==2) {
- theString += '</RING>n</POLYGON>n';
- } else {
- theString += '</PATH>n</POLYLINE>n';
- }
- theString += '</SPATIALFILTER>';
- if (useLimitExtent) {
- // keep this within the limitExtent
- theString += '<SPATIALFILTER relation="area_intersection">n';
- theString += '<ENVELOPE maxx="' + forceComma(limitRight) + '" maxy="' + forceComma(limitTop) + '" minx="' + forceComma(limitLeft) + '" miny="' + forceComma(limitBottom) + '" />n';
- theString += '</SPATIALFILTER>n';
- }
- theString += '<BUFFER distance="' + forceComma(bufferDistance) + '" bufferunits="' + ScaleBarUnits.toLowerCase() + '" >n';
- theString += '<TARGETLAYER id="' + LayerID[bufferTargetLayerIndex] + '"/>n';
- theString += '<SPATIALQUERY subfields="' + selectFields + '" />n';
- theString += '</BUFFER>n';
- theString += '</SPATIALQUERY>';
- theString += '</GET_FEATURES>';
- theString += '</REQUEST>';
- theString += '</ARCXML>';
- //alert(theString);
- return theString;
- }
- // generic envelope select xml write routine
- function writeEnvelopeBufferXML() {
- if (swapSelectFields) {
- selectFields=selFieldList[bufferTargetLayerIndex];
- }
- var theString = '<ARCXML version="1.1">n<REQUEST>n<GET_FEATURES outputmode="xml" envelope="false" geometry="false" checkesc ="true"';
- theString += ' featurelimit="' + maxFeaturesReturned + '" beginrecord="' + queryStartRecord + '"';
- theString += '>n';
- //CustomLayer===================================================
- if (mCustomLayer.getActiveLayer()>-1){
- theString += mCustomLayer.getActiveLayerString();
- }else{
- theString += '<LAYER id="' + ActiveLayer + '" ftype="' + ActiveLayerType + '" />';
- }
- //CustomLayer===================================================
- theString += '<SPATIALQUERY>';
- theString += '<SPATIALFILTER relation="area_intersection" >n';
- theString += '<ENVELOPE ' + selectEnvelope + ' />';
- theString += '</SPATIALFILTER>n';
- if (useLimitExtent) {
- // keep this within the limitExtent
- theString += '<SPATIALFILTER relation="area_intersection">n';
- theString += '<ENVELOPE maxx="' + forceComma(limitRight) + '" maxy="' + forceComma(limitTop) + '" minx="' + forceComma(limitLeft) + '" miny="' + forceComma(limitBottom) + '" />n';
- theString += '</SPATIALFILTER>n';
- }
- theString += '<BUFFER distance="' + forceComma(bufferDistance) + '" bufferunits="' + ScaleBarUnits.toLowerCase() + '" >n';
- theString += '<TARGETLAYER id="' + LayerID[bufferTargetLayerIndex] + '"/>n';
- theString += '<SPATIALQUERY subfields="' + selectFields + '" />n';
- theString += '</BUFFER>n';
- theString += '</SPATIALQUERY>';
- theString += '</GET_FEATURES>';
- theString += '</REQUEST>';
- theString += '</ARCXML>';
- return theString;
- }
- // parse XML response for selected features
- function getBufferAttributeData(theReply) {
- var docObject = parent.MapFrame;
- var docName = "parent.MapFrame";
- if (!useTextFrame) docName = "opener.parent.MapFrame";
- var str = '<html><meta http-equiv="Content-Type" content="text/html; charset=' + charSet + '"><head><title>' + titleList[10] + '</title></head>';
- str += '<body bgcolor="' + textFrameBackColor + '" text="Black" link="Blue" vlink="Gray" LEFTMARGIN=0 onload="window.focus()" onunload="' + docName + '.focusOnData=false">';
- setLayerFields(bufferTargetLayerIndex);
- str += writeOutDataPage(theReply,bufferTargetLayerIndex,docObject,docName,Win1);
- str += '</body></html>';
- var Win1;
- if (useTextFrame) {
- Win1 = parent.TextFrame;
- Win1.document.open();
- } else {
- Win1 = open("","DataWindow","width=575,height=250,scrollbars=yes,resizable=yes");
- extWin = Win1;
- focusOnData = true;
- }
- Win1.document.writeln(str);
- Win1.document.close();
- hideRetrieveData();
- }
- // request more records to display
- function getMoreBufferData(startRecord) {
- var theString = "";
- queryStartRecord = startRecord;
- if (selectionMode==1) {
- //query
- theString = writeQueryBufferXML();
- } else if (selectionMode==2) {
- theString = writeGetBufferFeatures();
- } else {
- var theType = clickType-1;
- theString = writeShapeBufferXML(theType);
- }
- showRetrieveData();
- sendToServer(imsQueryURL,theString,11);
- }
- function writeGetBufferFeatures() {
- if (swapSelectFields) {
- selectFields=selFieldList[bufferTargetLayerIndex];
- }
- var theString = writeEnvelopeBufferXML();
- //alert(theString);
- selectLayer=bufferTargetLayer;
- selectType=bufferTargetLayerIndex;
- selectCount=0;
- hightlightedOne="";
- selectPoints.length=1;
- selectLeft.length=1;
- selectRight.length=1;
- selectTop.length=1;
- selectBottom.length=1;
- return theString;
- }