[OpenLayers-Commits] r4254 - sandbox/jachym/openlayers/lib/OpenLayers/Control
commits at openlayers.org
commits at openlayers.org
Thu Sep 13 04:43:10 EDT 2007
Author: jachym
Date: 2007-09-13 04:43:08 -0400 (Thu, 13 Sep 2007)
New Revision: 4254
Modified:
sandbox/jachym/openlayers/lib/OpenLayers/Control/WPS.js
Log:
wps control updated, still under development
Modified: sandbox/jachym/openlayers/lib/OpenLayers/Control/WPS.js
===================================================================
--- sandbox/jachym/openlayers/lib/OpenLayers/Control/WPS.js 2007-09-13 02:29:52 UTC (rev 4253)
+++ sandbox/jachym/openlayers/lib/OpenLayers/Control/WPS.js 2007-09-13 08:43:08 UTC (rev 4254)
@@ -25,9 +25,16 @@
* {DOMElement}
*/
wpsDiv: null,
+ wpsform: null,
+ inputform: null,
serverInputId: "wpsServerInput",
+ inputSize: "200px",
+ version: "0.4.0",
+ service: "wps",
+ selectProcess: null,
+
/**
* Property: dataLayers
* {Array(<OpenLayers.Layer>)}
@@ -384,13 +391,14 @@
this.serverInput = document.createElement("input");
this.serverInput.type = "text";
- this.serverInput.size=25;
+ this.serverInput.style.width=this.inputSize;
this.serverInput.value = "http://localhost/cgi-bin/wps.py";
this.serverInput.id = this.serverInputId;
this.serverButton = document.createElement("input");
this.serverButton.type = "button";
+ this.serverButton.WPS = this;
this.serverButton.value = "GetCapabilities";
this.serverButton.onclick = this.getCapabilities;
@@ -398,6 +406,7 @@
this.wpsDiv.appendChild(this.serverInput);
this.wpsDiv.appendChild(document.createElement("br"));
this.wpsDiv.appendChild(this.serverButton);
+ this.wpsDiv.appendChild(document.createElement("br"));
this.div.appendChild(this.wpsDiv);
@@ -490,33 +499,148 @@
getCapabilities: function() {
var server = this.previousSibling.previousSibling;
- var div
+ this.WPS.server = server.value;
- var setProcesses = function(response) {
- var wpsdiv = document.getElementById("wpsDiv");
- var procdiv = document.createElement("div");
- wpsdiv.appendChild(procdiv);
- alert (response.responseText);
- var processes = response.responseXML.getElementsByTagName("Process");
- for (var i =0; i < processes.length; i++) {
- alert(processes[i]);
- alert(proc.getElementsByTagName("Title"));
- proctext = document.createElement("div");
- proctext.appendChild(document.createTextNode(proc.getElementsByTagName("Title")[0].nodeValue));
- procdiv.appendChild(proctext);
- }
-
- };
-
this.address = server.value;
if (this.address != "" || this.address != "http://") {
- var url = this.address + "?service=WPS&version=0.4.0&request=GetCapabilities";
- OpenLayers.loadURL(url, '', this, setProcesses);
+ var url = this.address + "?service="+this.WPS.service+"&version="+this.WPS.version+"&request=GetCapabilities";
+ OpenLayers.loadURL(url, '', this, this.WPS.setProcesses);
}
},
+ setProcesses: function(response) {
+ if (this.WPS.wpsform) {
+ this.WPS.wpsform.parentNode.removeChild(this.WPS.wpsform);
+ this.WPS.wpsform = null;
+ }
+
+ var wpsdiv = document.getElementById("wpsDiv");
+ this.WPS.selectProcess = document.createElement("select");
+ var processes = response.responseXML.getElementsByTagName("Process");
+ var option = document.createElement("option");
+ var procLbl = document.createElement("div");
+
+ this.WPS.wpsform = document.createElement("div");
+
+ this.WPS.wpsform.id = "wpsForm";
+
+ procLbl.innerHTML = "<u>"+ response.responseXML.getElementsByTagName("Title")[0].firstChild.nodeValue+
+ ": Available processes</u>";
+ procLbl.style.marginTop = "3px";
+ procLbl.style.marginLeft = "3px";
+ procLbl.style.marginBottom = "3px";
+
+ wpsdiv.appendChild(this.WPS.wpsform);
+ this.WPS.wpsform.appendChild(procLbl);
+ this.WPS.wpsform.appendChild(this.WPS.selectProcess);
+ option.style.fontStyle = "italic";
+ this.WPS.selectProcess.appendChild(option);
+ this.WPS.selectProcess.style.width = this.WPS.inputSize;
+ this.WPS.selectProcess.WPS = this.WPS;
+ this.WPS.selectProcess.onchange = this.WPS.describeProcess;
+
+ for (var i =0; i < processes.length; i++) {
+ option = document.createElement("option");
+ option.value = processes[i].getElementsByTagName("Identifier")[0].firstChild.nodeValue;
+ option.appendChild(document.createTextNode(processes[i].getElementsByTagName("Title")[0].firstChild.nodeValue));
+ option.style.fontStyle = "normal";
+ this.WPS.selectProcess.appendChild(option);
+ }
+
+ },
+
+ describeProcess: function() {
+ this.WPS.process = this.WPS.selectProcess.value;
+
+ if (this.WPS.server != "" || this.WPS.server != "http://") {
+ var url = this.WPS.server + "?service="+this.WPS.service+
+ "&version="+this.WPS.version+"&request=DescribeProcess"+
+ "&Identifier="+this.WPS.process;
+
+ OpenLayers.loadURL(url, '', this, this.WPS.setInputForm);
+ }
+ },
+
+ setInputForm: function(response) {
+ if (this.WPS.inputform) {
+ this.WPS.inputform.parentNode.removeChild(this.WPS.inputform);
+ this.WPS.inputform = null;
+ }
+ var procLbl = document.createElement("div");
+ var inputs = response.responseXML.getElementsByTagName("Input");
+ this.WPS.inputform = document.createElement("div");
+
+ procLbl.innerHTML = "<u>Inputs:</u>";
+ procLbl.style.marginTop = "3px";
+ procLbl.style.marginLeft = "3px";
+ procLbl.style.marginBottom = "3px";
+ this.WPS.wpsform.appendChild(this.WPS.inputform);
+ this.WPS.inputform.appendChild(procLbl);
+
+ for (var i = 0; i<inputs.length; i++) {
+ input = null;
+
+ if (inputs[i].getElementsByTagName("LiteralData").length) {
+ input = document.createElement("input");
+ input.type = "text";
+ }
+ else if (inputs[i].getElementsByTagName("ComplexData").length) {
+ input = document.createElement("select");
+ complexData = inputs[i].getElementsByTagName("ComplexData")[0];
+
+ if (complexData.getAttribute("defaultFormat") == "text/xml") {
+ for (var j = 0; j < this.WPS.map.layers.length; j++) {
+ if (this.WPS.map.layers[j].CLASS_NAME == "OpenLayers.Layer.Vector") {
+ option = document.createElement("option");
+ option.value = "";
+ option.appendChild(document.createTextNode(
+ this.WPS.map.layers[j].name));
+ input.appendChild(option);
+ }
+ }
+ }
+ else {
+ for (var j = 0; j < this.WPS.map.layers.length; j++) {
+ if (this.WPS.map.layers[j].CLASS_NAME == "OpenLayers.Layer.WMS") {
+ option =document.createElement("option");
+ option.value = inputs[i].getFullRequestString();
+ option.appendChild(document.createTextNode(
+ this.WPS.map.layers[j].name));
+ input.appendChild(option);
+ }
+ }
+ }
+ }
+ else {
+ input = document.createElement("input");
+ input.type = text;
+ }
+
+ input.style.size = this.WPS.inputSize;
+ input.id = "wps_input_"+ inputs[i].getElementsByTagName("Identifier")[0].firstChild.nodeValue;
+
+ lbl = document.createElement("label");
+ lbl.setAttribute("for", input.id);
+ lbl.appendChild(
+ document.createTextNode(inputs[i].getElementsByTagName("Title")[0].firstChild.nodeValue+ ": "));
+ lbl.style.width = (parseInt(this.WPS.inputSize)/2)+"px";
+
+ this.WPS.inputform.appendChild(lbl);
+ this.WPS.inputform.appendChild(input);
+ this.WPS.inputform.appendChild(document.createElement("br"));
+ }
+
+ var execButt = document.createElement("input");
+ execButt.type="button";
+ execButt.value="Execute";
+
+ this.WPS.inputform.appendChild(document.createElement("br"));
+ this.WPS.inputform.appendChild(execButt);
+
+ },
+
CLASS_NAME: "OpenLayers.Control.WPS"
});
More information about the Commits
mailing list