Skip to content

Loading…

Remove parameters that aren't supported by ArcGIS to improve REST performance #80

Open
wants to merge 1 commit into from

1 participant

Commits on Nov 30, 2011
  1. Remove parameters that aren't supported by ArcGIS to improve REST per…

    Christian Johansson committed
    …formance
This page is out of date. Refresh to see the latest.
Showing with 61 additions and 0 deletions.
  1. +61 −0 lib/OpenLayers/Layer/ArcGIS93Rest.js
View
61 lib/OpenLayers/Layer/ArcGIS93Rest.js
@@ -221,5 +221,66 @@ OpenLayers.Layer.ArcGIS93Rest = OpenLayers.Class(OpenLayers.Layer.Grid, {
newArguments);
},
+ /**
+ * Method: getFullRequestString
+ * Combine url with layer's params and these newParams.
+ *
+ * does checking on the serverPath variable, allowing for cases when it
+ * is supplied with trailing ? or &, as well as cases where not.
+ *
+ * return in formatted string like this:
+ * "server?key1=value1&key2=value2&key3=value3"
+ *
+ * WARNING: The altUrl parameter is deprecated and will be removed in 3.0.
+ *
+ * Parameters:
+ * newParams - {Object}
+ * altUrl - {String} Use this as the url instead of the layer's url
+ *
+ * Returns:
+ * {String}
+ */
+ getFullRequestString:function(newParams, altUrl) {
+ // if not altUrl passed in, use layer's url
+ var url = altUrl || this.url;
+
+ // create a new params hashtable with all the layer params and the
+ // new params together. then convert to string
+ var allParams = OpenLayers.Util.extend({}, this.params);
+ allParams = OpenLayers.Util.extend(allParams, newParams);
+ var paramsString = OpenLayers.Util.getParameterString(allParams);
+
+ // if url is not a string, it should be an array of strings,
+ // in which case we will deterministically select one of them in
+ // order to evenly distribute requests to different urls.
+ //
+ if (OpenLayers.Util.isArray(url)) {
+ url = this.selectUrl(paramsString, url);
+ }
+
+ // ignore parameters that are already in the url search string
+ var urlParams =
+ OpenLayers.Util.upperCaseObject(OpenLayers.Util.getParameters(url));
+ for(var key in allParams) {
+ if(key.toUpperCase() in urlParams) {
+ delete allParams[key];
+ }
+ }
+
+ // Remove parameters that aren't supported by ArcGIS to improve REST performance
+ var allowedParams = {f:0, bbox:0, size:0, dpi:0, imageSR:0, bboxSR:0, format:0, layerDefs:0, layers:0, transparent:0, time:0, layerTimeOptions:0 };
+ for(var key in allParams) {
+ if(key.toLowerCase() in allowedParams) {
+ // Nothing
+ } else {
+ delete allParams[key];
+ }
+ }
+
+ paramsString = OpenLayers.Util.getParameterString(allParams);
+
+ return OpenLayers.Util.urlAppend(url, paramsString);
+ },
+
CLASS_NAME: "OpenLayers.Layer.ArcGIS93Rest"
});
Something went wrong with that request. Please try again.