<div dir="ltr"><br clear="all"><div><div><br></div><div>//OpenLayers.ProxyHost = "proxy.cgi?url=";<br>OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";<br><br>var wps = "<a href="http://localhost:8080/geoserver/wps">http://localhost:8080/geoserver/wps</a>",<br>
capabilities, // the capabilities, read by Format.WPSCapabilities::read<br> process; // the process description from Format.WPSDescribeProcess::read<br><br>// get some capabilities<br>getCapabilities();<br><br>// create the UI<br>
var layer = new OpenLayers.Layer.Vector("Scratchpad");<br>var toolbar = new OpenLayers.Control.EditingToolbar(layer);<br>toolbar.addControls([new OpenLayers.Control.ModifyFeature(layer, {<br> title: "Select feature"<br>
})]);<br>var map = new OpenLayers.Map('map', {<br> controls: [<br> toolbar,<br> new OpenLayers.Control.ZoomPanel(),<br> new OpenLayers.Control.PanPanel()<br> ],<br> layers: [<br> new OpenLayers.Layer.WMS(<br>
"OSM", "<a href="http://maps.opengeo.org/geowebcache/service/wms">http://maps.opengeo.org/geowebcache/service/wms</a>",<br> {layers: "openstreetmap", format: "image/png"}<br>
), layer<br> ]<br>});<br>map.zoomToMaxExtent();<br><br>// add behavior to html elements<br>document.getElementById("processes").onchange = describeProcess;<br><br>// using OpenLayers.Format.WPSCapabilities to read the capabilities<br>
function getCapabilities() {<br> OpenLayers.Request.GET({<br> url: wps,<br> params: {<br> "SERVICE": "WPS",<br> "REQUEST": "GetCapabilities"<br>
},<br> success: function(response){<br> capabilities = new OpenLayers.Format.WPSCapabilities().read(<br> response.responseText<br> );<br> var dropdown = document.getElementById("processes");<br>
var offerings = capabilities.processOfferings, option;<br> // populate the dropdown<br> for (var p in offerings) {<br> option = document.createElement("option");<br>
option.innerHTML = offerings[p].identifier;<br> option.value = p;<br> dropdown.appendChild(option);<br> }<br> }<br> });<br>}<br><br>// using OpenLayers.Format.WPSDescribeProcess to get information about a<br>
// process<br>function describeProcess() {<br> var selection = this.options[this.selectedIndex].value;<br> OpenLayers.Request.GET({<br> url: wps,<br> params: {<br> "SERVICE": "WPS",<br>
"REQUEST": "DescribeProcess",<br> "VERSION": capabilities.version,<br> "IDENTIFIER": selection<br> },<br> success: function(response) {<br>
process = new OpenLayers.Format.WPSDescribeProcess().read(<br> response.responseText<br> ).processDescriptions[selection];<br> buildForm();<br> }<br> });<br>}<br>
<br>// dynamically create a form from the process description<br>function buildForm() {<br> document.getElementById("abstract").innerHTML = process["abstract"];<br> document.getElementById("input").innerHTML = "<h3>Input:</h3>";<br>
document.getElementById("output").innerHTML = "";<br><br> var inputs = process.dataInputs, supported = true,<br> sld = "text/xml; subtype=sld/1.0.0",<br> input;<br> //var change=inputs.innerHTML.toFixed(2);<br>
for (var i=0,ii=inputs.length; i<ii; ++i) {<br> alert("Hello! I am an alert box!!");<br> input = inputs[i];<br> if (input.complexData) {<br> //alert("Hello! I am an alert box in complexdata !!");<br>
var formats = input.complexData.supported.formats;<br> if (formats["application/wkt"]) {<br> //alert("Hello! I am an alert box in app/wkt!!");<br> addWKTInput(input);<br>
} else if (formats["text/xml; subtype=wfs-collection/1.0"]) {<br> //alert("Hello! I am an alert box in text/xml!!");<br> addWFSCollectionInput(input);<br> } else if (formats["image/tiff"]) {<br>
<br> // addRasterInput(input);<br> //alert(truncator(5.1231231, 1));<br> //alert("Hello! I am an alert box in image/tiff!!");<br> addRasterInput(truncator(input,2));<br>
} else if (formats[sld]) {<br> //alert("Hello! I am an alert box in formatssld!!");<br> addXMLInput(input, sld);<br> } else {<br> supported = false;<br>
}<br> } else if (input.boundingBoxData) {<br> alert("Hello! I am an alert box in bounding box!!");<br> // var change=input.innerHTML.toFixed(2);<br> addBoundingBoxInput(input);<br>
} else if (input.literalData) {<br> //alert("Hello! I am an alert box in literal box!!");<br> addLiteralInput(input);<br> } else {<br> supported = false;<br> }<br>
if (input.minOccurs > 0) {<br> //alert("Hello! I am an alert box in minoccurs box!!");<br> document.getElementById("input").appendChild(document.createTextNode("* "));<br>
}<br> }<br> <br> if (supported) {<br> var executeButton = document.createElement("button");<br> executeButton.innerHTML = "Execute";<br> document.getElementById("input").appendChild(executeButton);<br>
executeButton.onclick = execute;<br> } else {<br> document.getElementById("input").innerHTML = '<span class="notsupported">' +<br> "Sorry, the WPS builder does not support the selected process." +<br>
"</span>";<br> }<br>}<br><br>// helper function to dynamically create a textarea for geometry (WKT) data<br>// input<br>function addWKTInput(input, previousSibling) {<br>alert("Hello! I am an alert box in dynamically create a textarea for geometry data input!!");<br>
var name = input.identifier;<br> var container = document.getElementById("input");<br> var label = document.createElement("label");<br> label["for"] = name;<br> label.title = input["abstract"];<br>
label.innerHTML = name + " (select feature, then click field):";<br> previousSibling && previousSibling.nextSibling ?<br> container.insertBefore(label, previousSibling.nextSibling) :<br> container.appendChild(label);<br>
var field = document.createElement("textarea");<br> field.onclick = function () {<br> alert("Hello! I am an alert box in onclick!!");<br> if (layer.selectedFeatures.length) {<br> alert("Hello! I am an alert box in selected features function for geometry data input writing!!");<br>
this.innerHTML = new OpenLayers.Format.WKT().write(<br> <br> //layer.selectedFeatures[0]<br> //layer.selectedFeatures[0]<br> //name.length();<br> //alert(trun.toFixed(2));<br>
//layer.selectedFeatures[0]<br> layer.selectedFeatures[0]<br> <br> );<br> }<br> createCopy(input, this, addWKTInput);<br> };<br> field.onblur = function() {<br>
input.data = field.value ? {<br> complexData: {<br> mimeType: "application/wkt",<br> value: this.value<br> }<br> } : undefined;<br> };<br> field.title = input["abstract"];<br>
<a href="http://field.id">field.id</a> = name;<br> previousSibling && previousSibling.nextSibling ?<br> container.insertBefore(field, previousSibling.nextSibling.nextSibling) :<br> container.appendChild(field);<br>
}<br><br>// helper function for xml input<br>function addXMLInput(input, type) {<br> var name = input.identifier;<br> var field = document.createElement("input");<br> field.title = input["abstract"];<br>
field.value = name + " (" + type + ")";<br> field.onblur = function() {<br> input.data = field.value ? {<br> complexData: {<br> mimeType: type,<br> value: this.value<br>
}<br> } : undefined;<br> };<br> document.getElementById("input").appendChild(field);<br>}<br><br>// helper function to dynamically create a WFS collection reference input<br>function addWFSCollectionInput(input) {<br>
var name = input.identifier;<br> var field = document.createElement("input");<br> field.title = input["abstract"];<br> field.value = name + " (layer on demo server)";<br> addValueHandlers(field, function() {<br>
input.reference = field.value ? {<br> mimeType: "text/xml; subtype=wfs-collection/1.0",<br> href: "<a href="http://geoserver/wfs">http://geoserver/wfs</a>",<br> method: "POST",<br>
body: {<br> wfs: {<br> version: "1.0.0",<br> outputFormat: "GML2",<br> featureType: field.value<br> }<br>
}<br> } : undefined;<br> });<br> document.getElementById("input").appendChild(field);<br>}<br><br>// helper function to dynamically create a raster (GeoTIFF) url input<br>function addRasterInput(input) {<br>
var name = input.identifier;<br> var field = document.createElement("input");<br> field.title = input["abstract"];<br> var url = window.location.href.split("?")[0];<br> field.value = url.substr(0, url.lastIndexOf("/")+1) + "data/tazdem.tiff";<br>
document.getElementById("input").appendChild(field);<br> (field.onblur = function() {<br> input.reference = {<br> mimeType: "image/tiff",<br> href: field.value,<br> method: "GET"<br>
};<br> })();<br>}<br><br>// helper function to dynamically create a bounding box input<br>function addBoundingBoxInput(input) {<br> var name = input.identifier;<br> var field = document.createElement("input");<br>
field.title = input["abstract"];<br> field.value = "left,bottom,right,top (EPSG:4326)";<br> document.getElementById("input").appendChild(field);<br> addValueHandlers(field, function() {<br>
input.boundingBoxData = {<br> projection: "EPSG:4326",<br> bounds: OpenLayers.Bounds.fromString(field.value)<br> };<br> });<br>}<br><br>// helper function to create a literal input textfield or dropdown<br>
function addLiteralInput(input, previousSibling) {<br> var name = input.identifier;<br> var container = document.getElementById("input");<br> var anyValue = input.literalData.anyValue;<br> // anyValue means textfield, otherwise we create a dropdown<br>
var field = document.createElement(anyValue ? "input" : "select");<br> <a href="http://field.id">field.id</a> = name;<br> field.title = input["abstract"];<br> previousSibling && previousSibling.nextSibling ?<br>
container.insertBefore(field, previousSibling.nextSibling) :<br> container.appendChild(field);<br> if (anyValue) {<br> var dataType = input.literalData.dataType;<br> field.value = name + (dataType ? " (" + dataType + ")" : "");<br>
addValueHandlers(field, function() {<br> input.data = field.value ? {<br> literalData: {<br> value: field.value<br> }<br> } : undefined;<br> createCopy(input, field, addLiteralInput);<br>
});<br> } else {<br> var option;<br> option = document.createElement("option");<br> option.innerHTML = name;<br> field.appendChild(option);<br> for (var v in input.literalData.allowedValues) {<br>
option = document.createElement("option");<br> option.value = v;<br> option.innerHTML = v;<br> field.appendChild(option);<br> }<br> field.onchange = function() {<br>
createCopy(input, field, addLiteralInput);<br> input.data = this.selectedIndex ? {<br> literalData: {<br> value: this.options[this.selectedIndex].value<br> }<br>
} : undefined;<br> };<br> }<br>}<br><br>// if maxOccurs is > 1, this will add a copy of the field<br>function createCopy(input, field, fn) {<br> if (input.maxOccurs && input.maxOccurs > 1 && !field.userSelected) {<br>
// add another copy of the field - we don't check maxOccurs<br> field.userSelected = true;<br> var newInput = OpenLayers.Util.extend({}, input);<br> // we recognize copies by the occurrence property<br>
newInput.occurrence = (input.occurrence || 0) + 1;<br> process.dataInputs.push(newInput);<br> fn(newInput, field);<br> }<br>}<br><br>// helper function for adding events to form fields<br>function addValueHandlers(field, onblur) {<br>
field.onclick = function() {<br> if (!this.initialValue) {<br> this.initialValue = this.value;<br> this.value = "";<br> }<br> };<br> field.onblur = function() {<br> if (!this.value) {<br>
this.value = this.initialValue;<br> delete this.initialValue;<br> }<br> onblur.apply(this, arguments);<br> };<br>}<br><br>// execute the process<br>function execute() {<br> var output = process.processOutputs[0];<br>
var input;<br> // remove occurrences that the user has not filled out<br> for (var i=process.dataInputs.length-1; i>=0; --i) {<br> input = process.dataInputs[i];<br> if ((input.minOccurs === 0 || input.occurrence) && !input.data && !input.reference) {<br>
OpenLayers.Util.removeItem(process.dataInputs, input);<br> }<br> }<br> process.responseForm = {<br> rawDataOutput: {<br> identifier: output.identifier<br> }<br> };<br> if (output.complexOutput && output.complexOutput.supported.formats["application/wkt"]) {<br>
process.responseForm.rawDataOutput.mimeType = "application/wkt";<br> }<br> OpenLayers.Request.POST({<br> url: wps,<br> data: new OpenLayers.Format.WPSExecute().write(process),<br> success: showOutput<br>
});<br>}<br><br>// add the process's output to the page<br>function showOutput(response) {<br> var result = document.getElementById("output");<br> result.innerHTML = "<h3>Output:</h3>";<br>
var features;<br> var contentType = response.getResponseHeader("Content-Type");<br> if (contentType == "application/wkt") {<br> features = new OpenLayers.Format.WKT().read(response.responseText);<br>
} else if (contentType == "text/xml; subtype=wfs-collection/1.0") {<br> features = new OpenLayers.Format.WFST.v1_0_0().read(response.responseText);<br> }<br> if (features && (features instanceof OpenLayers.Feature.Vector || features.length)) {<br>
layer.addFeatures(features);<br> result.innerHTML += "The result should also be visible on the map.";<br> }<br> result.innerHTML += "<textarea>" + response.responseText + "</textarea>";<br>
}<br></div><div><br></div><div>In this code <br></div><div><br></div><div><br></div><div><br></div><div>layer.selectedFeatures[0] i need to dispaly the values in that string <br><span class="">example like this POLYGON((77.34375 54.345677989,74.123434444 29.3452334,136.456 24.6789000)) here i need to first divide them into individual values then turncate them </span><br>
</div> <div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br>
</div><div> -----K.Manjula-------</div></div>
</div>