📄 aimsquery.js
字号:
// aimsQuery.js
/*
* JavaScript template file for ArcIMS HTML Viewer
* 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
*/
aimsQueryPresent=true;
var showSampleValues=false;
var storedQueryCount = 0;
var storedQueryName = new Array();
var storedQueryString = new Array();
var storedQueryVariable = new Array();
var storedQueryVarCount = new Array();
var storedQueryFieldList = new Array();
var storedQueryIndex = 0;
/*
***************************************************************************************
Querying functions
***************************************************************************************
*/
// query form
function queryForm() {
if (checkIfActiveLayerAvailable()) {
fieldIndex=0;
showSampleValues=false;
setLayerFields(ActiveLayerIndex);
if (showSampleValues) {
var theText = writeFieldSample(LayerFields[fieldIndex]);
sendToServer(imsQueryURL,theText,40);
} else {
writeQueryForm();
}
}
}
// find Form
function findForm() {
if (checkIfActiveLayerAvailable()) {
setLayerFields(ActiveLayerIndex);
if (useTextFrame) {
parent.TextFrame.document.location= appDir + "findForm.htm";
} else {
var Win1 = open(appDir + "findForm.htm","QueryWindow","width=575,height=150,scrollbars=yes,resizable=yes");
}
}
}
// process query
function sendQueryString(newString) {
//if (LayerIDField[ActiveLayerIndex]!="#ID#") {
newString = fixSingleQuotes(newString);
newString = swapQuotes(newString);
//}
//alert(newString);
newString = makeXMLsafe(newString);
setQueryString=newString;
selectionMode=1;
selectData.length=0;
LayerFields.length=0;
LayerFieldType.length=0;
LayerFieldCount=0;
highlightedOne="";
showBuffer=false;
showRetrieveData();
var theString = writeQueryXML(newString);
sendToServer(imsQueryURL,theString,queryXMLMode);
}
// write out XML request to query attributes
function writeQueryXML(queryString) {
if (swapSelectFields) {
selectFields=selFieldList[ActiveLayerIndex];
}
var theString = '<ARCXML version="1.1">\n<REQUEST>\n<GET_FEATURES outputmode="xml" geometry="false" envelope="true" checkesc ="true"';
theString += ' featurelimit="' + maxFeaturesReturned + '" beginrecord="' + queryStartRecord + '">\n';
theString += '<LAYER id="' + ActiveLayer + '" />';
if (useLimitExtent) {
// keep this within the limitExtent
theString += '<SPATIALQUERY subfields="' + selectFields + '" where="' + queryString + '">';
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';
} else {
//theString += '<QUERY subfields="' + selectFields + '" where="' + queryString + '" />';
theString += '<SPATIALQUERY subfields="' + selectFields + '" where="' + queryString + '" />';
}
theString += '</GET_FEATURES>';
theString += '</REQUEST>';
theString += '</ARCXML>';
//alert("writeQueryXML()\nQuery XML Request:\n" + theString);
selectLayer=ActiveLayer;
selectType=ActiveLayerType;
selectCount=0;
hightlightedOne="";
selectPoints.length=1;
selectLeft.length=1;
selectRight.length=1;
selectTop.length=1;
selectBottom.length=1;
return theString;
}
// write out XML request to get field value samples
function writeFieldSample(theField) {
var theFields = theField;
var theString = '<ARCXML version="1.1">\n<REQUEST>\n<GET_FEATURES outputmode="xml" geometry="false" envelope="false" checkesc ="true"';
theString += ' featurelimit="' + numberDataSamples + '">\n';
theString += '<LAYER id="' + ActiveLayer + '" />';
//theString += '<QUERY subfields="' + theFields + '" where="' + LayerIDField[ActiveLayerIndex] + ' GT 0" />';
theString += '<QUERY subfields="' + theFields + '" />';
theString += '</GET_FEATURES>';
theString += '</REQUEST>';
theString += '</ARCXML>';
//alert(theString);
selectLayer=ActiveLayer;
selectType=ActiveLayerType;
selectCount=0;
hightlightedOne="";
selectPoints.length=1;
selectLeft.length=1;
selectRight.length=1;
selectTop.length=1;
selectBottom.length=1;
//alert(theString);
return theString;
}
// send find request
function getFind(theValue) {
//alert(theValue);
selectCount=0;
showBuffer=false;
highlightedOne="";
selectPoints.length=0;
selectLeft.length=0;
selectRight.length=0;
selectTop.length=0;
selectBottom.length=0;
drawSelectBoundary=false;
showGeocode=false;
clickCount=0;
totalMeasure=0;
currentMeasure=0;
selectionMode=1;
var theNewQueryString = "";
var theTempString = "";
var fieldListString = LayerIDField[ActiveLayerIndex] + " " + LayerShapeField[ActiveLayerIndex];
var elemCount = 0;
for (var i=0;i<LayerFields.length;i++) {
var ftval = parseInt(LayerFieldType[i]);
if ((ftval>=12) && (ftval<=15)) {
//if ((LayerFieldType[i].indexOf("12",0)!=-1) || (LayerFieldType[i].indexOf("13",0)!=-1) || (LayerFieldType[i].indexOf("13",0)!=-1) || (LayerFieldType[i].indexOf("15",0)!=-1)){
if (queryCaseInsensitive) {
theTempString = "UPPER(" + LayerFields[i] + ") LIKE '%" + theValue.toUpperCase() + "%'";
} else {
theTempString = LayerFields[i] + " LIKE '%" + theValue + "%'";
}
if (elemCount>0) theTempString = " OR " + theTempString;
//if (theNewQueryString.length + theTempString.length < 1024) {
theNewQueryString = theNewQueryString + theTempString;
fieldListString = fieldListString + " " + LayerFields[i];
elemCount += 1;
//}
}
}
if (theNewQueryString!="") {
showRetrieveData();
showBuffer=false;
theNewQueryString=makeXMLsafe(theNewQueryString);
//alert(theNewQueryString);
setQueryString = theNewQueryString;
var theString = writeFindRequest(theNewQueryString,fieldListString);
//alert(theString);
sendToServer(imsQueryURL,theString,findXMLMode);
} else {
alert(msgList[80]);
}
}
// write out find form
function writeFindRequest(findQuery,fieldList) {
var theString = '<ARCXML version="1.1">\n<REQUEST>\n<GET_FEATURES outputmode="xml" geometry="false" envelope="true" checkesc ="true"';
theString += ' featurelimit="' + maxFeaturesReturned + '" beginrecord="' + queryStartRecord + '">\n';
theString += '<LAYER id="' + ActiveLayer + '" />\n';
if (useLimitExtent) {
// keep this within the limitExtent
theString += '<SPATIALQUERY subfields="' + fieldList + '" where="' + findQuery + '" />';
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';
} else {
theString += '<QUERY subfields="' + fieldList + '" where="' + findQuery + '" />';
}
theString += '</GET_FEATURES>\n';
theString += '</REQUEST>\n';
theString += '</ARCXML>';
//alert(theString);
selectLayer=ActiveLayer;
selectType=ActiveLayerType;
selectCount=0;
hightlightedOne="";
selectPoints.length=1;
selectLeft.length=1;
selectRight.length=1;
selectTop.length=1;
selectBottom.length=1;
return theString;
}
// parse layer field value samples
function parseFieldSamples(theReply) {
if (onlyUniqueSamples) {
parseFieldSamplesUnique(theReply);
} else {
//alert("Reply Length: " + theReply.length);
//alert(theReply);
var fList="";
var lpos1 = 1;
var lpos2 = 1;
var epos = 1;
var spos = 1;
var morePoints=true;
var moreFeatures=true;
var pos = 0;
var startpos = 0;
var endpos = 0;
var featureCount = justGetFeatureCount(theReply);
var tempString="";
if (featureCount > 0) {
selectData.length=featureCount;
for (var i=0;i<featureCount;i++) {
pos = theReply.indexOf("<FIELDS ",endpos);
startpos = pos + 8;
endpos =theReply.indexOf(' />',startpos);
inData = theReply.substring(startpos,endpos);
//inData = fixSingleQuotes(inData);
//selectData[i] = clearLeadingSpace(inData);
//selectData[i] = escape(inData);
selectData[i] = inData;
}
} else {
selectData.length=0;
}
}
}
//replace the original function parseFieldSamples with this function parseFieldSamples
// parse layer field value samples
function parseFieldSamplesUnique(theReply) {
//alert("Reply Length: " + theReply.length);
//alert(theReply);
var fList="";
var lpos1 = 1;
var lpos2 = 1;
var epos = 1;
var spos = 1;
var morePoints=true;
var moreFeatures=true;
var pos = 0;
var startpos = 0;
var endpos = 0;
var featureCount = justGetFeatureCount(theReply);
//alert(theReply);
var tempString="";
//variables added to original function
var k = 1;
var sdLeng = 0;
var charSort = false;
if (featureCount > 0) {
//Add the first sample value
for (var i=0;i<1;i++) {
if (selectData.length>0) {
selectData.length=0;
}
pos = theReply.indexOf("<FIELDS ",endpos);
startpos = pos + 8;
endpos =theReply.indexOf(' />',startpos);
inData = theReply.substring(startpos,endpos);
selectData[i] = inData;
}
//Add additional sample values
for (var i=1;i<featureCount;i++) {
pos = theReply.indexOf("<FIELDS ",endpos);
startpos = pos + 8;
endpos =theReply.indexOf(' />',startpos);
inData = theReply.substring(startpos,endpos);
sdLeng = selectData.length;
for (var j=0;j<sdLeng;j++){
if (selectData[j] == inData){
addValue = false;
break;
} else {
addValue = true;
}
}
if (addValue){
selectData[k] = inData;
k = k + 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -