Extracting Data

This activity assumes you have created an AXL file, chosen (in your head) which layer you want to extract, created a service and website with an html viewer. Go into the ArcIMSParams.js file and set this variable

var useExtract=true;

You cannot set this tool to true in Designer.

1. Changes to the AXL file - The extract extension is a private extension, not public.  This means it cannot be called directly but must be called from inside an image service.  Extract only works with image services.  In your AXL file, directly under the <DATASET> opening element of the layer you want to extract is where you call the extension.

<DATASET name="gdt_st_sp83" type="line" workspace="shp_ws-1" />
<EXTENSION type="Extract">
<EXTRACTPARAMS clip="true">
</EXTRACTPARAMS>
</EXTENSION>

The <EXTRACTPARAMS> element is a required child of the <EXTENSION> element when type = "EXTRACT."  None of the attributes are mandatory.  The only one set in this example is clip = "true" (default is  "false")  By setting it to true, when you click the extract button it clips the features rather than just extracting the intersected features.  For this activity we will take the defaults for the rest of the children of the extract <EXTENSION> but there are others.  Feel free to add them if you wish.

Refresh the service.

Zoom into a scale where your selected layer is visible, make sure it is active, and click the Extract tool (should be at the bottom of the toolbar).  You will get a "Function not Enabled" message.  Here is the function (in aimsCustom.js) that is being run right now:

// extract layers to download
function extractIt() {
hideLayer("measureBox");
alert(msgList[51]);
}

All it is doing is hiding something called "measureBox" and putting up a message (from the aimsResource.js file)

msgList[51] = "Function not enabled.";

Obviously, there are functions missing from the aimsCustom.js file that Designer extracts from the html.jar file when it makes the website.  Right now the sole functionality is to display the error message - not very helpful.  Specifically, there needs to be a function to do the extraction, one to send the request and one to handle the response.  I think I developed the code from the support site [http://support.esri.com/index.cfm?fa=knowledgebase.techarticles.articleShow&d=28930]
So you can either go to that site for help on the Java code or copy the  n:\int_gis_map\labs\extract_lab\aimsCustom.js file which has the coding already done for you.

// extract layers to download
function extractIt() {
hideLayer("measureBox");
// alert(msgList[51]);
if (checkIfActiveLayerAvailable()) {
sendExtractRequest() ;
}
}
function sendExtractRequest(){
var extractAXL="";
//extractAXL += '<?xml version="1.0" encoding="UTF-8"?>\n';
extractAXL += '<ARCXML version="1.1">\n';
extractAXL += '<REQUEST>\n';
extractAXL += ' <GET_EXTRACT>\n';
extractAXL += ' <PROPERTIES>\n';
extractAXL += ' <ENVELOPE minx="' + forceComma(eLeft) + '" miny="' + forceComma(eBottom) + '" maxx="' + forceComma(eRight) + '" maxy="' + forceComma(eTop) + '" />\n';
extractAXL += ' <LAYERLIST>\n';
extractAXL += ' <LAYERDEF id="' + ActiveLayer + '" visible="true" />\n';
extractAXL += ' </LAYERLIST>\n';
extractAXL += ' </PROPERTIES>\n';
extractAXL += ' </GET_EXTRACT>\n';
extractAXL += '</REQUEST>\n';
extractAXL += '</ARCXML>\n';
sendToServer(imsExtractURL, extractAXL ,extractXMLMode);
}
function parseExtractResponse(theResponse){
var extractURL = getURL(theResponse);
//alert(extractURL);
if(extractURL!="") var Win1 = open(extractURL);
}

Just by copying this text into your aimsCustom.js file you would think that would do it... but it didn't.  So...go to n:\int_gis_map\labs\extract_lab, copy the aimsCustom.js file that is there to your website javascript folder (overwriting the one that is there), refresh your website.  If you ever think you will want to implement the extract function, keep a copy of this aimsCustom.js file.  These files tend to be different because it is here that custom scripting is added.

Now, when you click on the extract button it should create a zip file, place it in the output folder and ask whether you want to unzip it from there or save it to a folder.

Send me your URI when you are done.  Nothing fancy, I just want you to implement an EXTRACT server.