aimsExtractPresent=true;var totLayers=0;var xLayers=new Array();var imsExtractURL=imsURL+"&CustomService=Extract";var rasterTop;var rasterBottom;var rasterLeft;var rasterRight;function USGSextractVector(){hideLayer("measureBox");totLayers=0;xLayers.length=0;for(var i=0;i<LayerVisible.length;i++){if(LayerIsFeature[i]){if((LayerName[i]!="Road Labels")&&(LayerName[i]!="Counties-2M")&&(LayerName[i]!="States-2M")&&(LayerName[i]!="HUC-4")&&(LayerName[i]!="HUC-6")&&(LayerName[i]!="HUCS")&&(LayerName[i]!="Lakes-2M")&&(LayerName[i]!="EDNA Metadata")&&(LayerName[i]!="Urban-2M")&&(LayerName[i]!="Roads-2M")&&(LayerName[i]!="Route_Numbers")&&(LayerName[i]!="Roads-100K")&&(LayerName[i]!="EDNA Contours")&&(LayerName[i]!="CONFLATEDFLOW")&&(LayerName[i]!="Streams-2M")&&(LayerName[i]!="Streams-100K")&&(LayerName[i]!="Cities")&&(LayerName[i]!="EDNA ECO Regions")&&(LayerName[i]!="Waterbodies")&&(LayerName[i]!="NHD Drainage Network")&&(LayerID[i]!="Flow_Lines2")){xLayers[totLayers]=i;totLayers++;}}};var WindowContent='';var theFrame="parent.MapFrame";if((useExternalWindow)||(!useTextFrame)){theFrame="opener";if(parent.MapFrame!=null){theFrame="opener.parent.MapFrame";}};WindowContent+=('<html><meta http-equiv="Content-Type" content="text/html; charset='+charSet+'">');WindowContent+=('<head><title>'+extractList[0]+'</title></head>');WindowContent+=('<body bgcolor="'+textFrameBackColor+'" text="'+textFrameTextColor+'" link="'+textFrameLinkColor+'" vlink="'+textFrameLinkColor+'" LEFTMARGIN=10 TOPMARGIN=5 onload="window.focus()">');WindowContent+=('<TABLE cols="3" width="100%" border="0" cellspacing="1" bgcolor="'+tableBackColor+'">');WindowContent+=('  <TR>');WindowContent+=('    <TD ALIGN="center"><B>'+extractList[1]+'</B></TD>');WindowContent+=('    <td ALIGN="center">');WindowContent+=('      <form>');WindowContent+=('        <input type="button" value="'+extractList[2]+'" onclick="'+theFrame+'.extractTheLayers()">');WindowContent+=('      </form>');WindowContent+=('    </td>');WindowContent+=('    <TD ALIGN="center"><B>'+extractList[5]+'</B></TD>');WindowContent+=('  </TR>');WindowContent+=('  <TR>');WindowContent+=('    <TD VALIGN="top" COLSPAN="2">');if(xLayers.length>0){WindowContent+=('      <form name="extractListForm">');var exCount=0;for(var j=0;j<xLayers.length;j++){var exNum=parseInt(xLayers[j]);WindowContent+=('        <INPUT CHECKED TYPE="checkbox" ID="'+LayerName[exNum]+' will be extracted" NAME="Extractable Layer" VALUE="'+exNum+'"><LABEL FOR="'+LayerName[exNum]+' will be extracted">'+LayerName[exNum]+'</LABEL><br>');exCount++;};WindowContent+=('      </form>');}else{WindowContent+=(extractList[4]);};WindowContent+=('    </td>');WindowContent+=('    <td VALIGN="top" Align="center">');WindowContent+=('      <DIV ALIGN="left">');WindowContent+=('        <B>Top:&nbsp;&nbsp;</B>'+xTop+'<BR>');WindowContent+=('        <B>Left:&nbsp;&nbsp;</B>'+xLeft+'<BR>');WindowContent+=('        <B>Right:&nbsp;&nbsp;</B>'+xRight+'<BR>');WindowContent+=('        <B>Bottom:&nbsp;&nbsp;</B>'+xBottom+'<BR>');WindowContent+=('      </DIV>');WindowContent+=('    </td>');WindowContent+=('  </tr>');WindowContent+=('</table>');Create_Pop_Up_Window(extractList[0],'',WindowContent,'ExtractWindow','width=500,height=400,scrollbars=yes,resizable=yes');};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 nodefault="true">\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';}}eString+='</LAYERLIST>\n';eString+='</PROPERTIES>\n</GET_EXTRACT>\n</REQUEST>\n';eString+='</ARCXML>\n';return eString;};function extractTheLayers(){showRetrieveData();var theString=writeExtractXML();if(theString=="NoneSelected"){hideRetrieveData();alert("Error - You must specify layers to be extracted.");}else{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){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)){var smoothEdge=shapeBufferDistance*0.01;selString+='<BUFFER distance="'+forceComma(shapeBufferDistance)+'" ';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+='</RING>\n</POLYGON>\n';}else if(clickType==2){selString+='</PATH>\n</POLYLINE>\n';}else{selString+='</MULTIPOINT>\n';}}selString+='</SPATIALFILTER>\n';if(useLimitExtent){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();var WindowContent='';var pos=theReply.indexOf("OUTPUT");var theURL="";if(pos!=-1){theURL=getInsideString(theReply,'url="',dQuote,pos,0,false);WindowContent+=('<ul><li><a href="'+theURL+'">Extract Download</A></li></ul>');}else{WindowContent+=('<ul>Error processing response: '+theReply+'</ul>');}Create_Pop_Up_Window('Extraction Download','',WindowContent,'ExtractWindow','width=500,height=300,scrollbars=yes,resizable=yes');}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);okToSend=true;if(debugOn>2){alert(msgList[13]+theReply);};var theError=getXMLErrorMessage(theReply);if(XMLMode==4001){showExtractURL(theReply);};if(XMLMode==4002){}}

