source: sipes/libraries/openlayers/examples/wps-client.js @ 92f109b

stableversion-3.0
Last change on this file since 92f109b was 307d09d, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agregaron las librerias

  • Propiedad mode establecida a 100644
File size: 2.2 KB
Línea 
1OpenLayers.ProxyHost = 'proxy.cgi?url=';
2
3var map, client, intersect, buffer;
4
5function init() {
6   
7    map = new OpenLayers.Map('map', {
8        allOverlays: true,
9        center: [114, 16],
10        zoom: 4,
11        layers: [new OpenLayers.Layer.Vector()]
12    });
13
14    var features = [new OpenLayers.Feature.Vector(OpenLayers.Geometry.fromWKT(
15        'LINESTRING(117 22,112 18,118 13, 115 8)'
16    ))];
17    var geometry = OpenLayers.Geometry.fromWKT(
18        'POLYGON((110 20,120 20,120 10,110 10,110 20),(112 17,118 18,118 16,112 15,112 17))'
19    );
20
21    map.baseLayer.addFeatures(features);
22    map.baseLayer.addFeatures([new OpenLayers.Feature.Vector(geometry)]);
23   
24    client = new OpenLayers.WPSClient({
25        servers: {
26            opengeo: 'http://demo.opengeo.org/geoserver/wps'
27        }
28    });
29   
30    // Create a process and configure it
31    intersect = client.getProcess('opengeo', 'JTS:intersection');   
32    intersect.configure({
33        // spatial input can be a feature or a geometry or an array of
34        // features or geometries
35        inputs: {
36            a: features,
37            b: geometry
38        }
39    });
40   
41    // Create another process which chains the previous one and execute it
42    buffer = client.getProcess('opengeo', 'JTS:buffer');
43    buffer.execute({
44        inputs: {
45            geom: intersect.output(),
46            distance: 1
47        },
48        success: function(outputs) {
49            // outputs.result is a feature or an array of features for spatial
50            // processes.
51            map.baseLayer.addFeatures(outputs.result);
52        }
53    });
54
55    // Instead of creating a process and executing it, we could call execute on
56    // the client directly if we are only dealing with a single process:
57    /*
58    client.execute({
59        server: "opengeo",
60        process: "JTS:intersection",
61        // spatial input can be a feature or a geometry or an array of
62        // features or geometries
63        inputs: {
64            a: features,
65            b: geometry
66        },
67        success: function(outputs) {
68            // outputs.result is a feature or an array of features for spatial
69            // processes.
70            map.baseLayer.addFeatures(outputs.result);
71        }
72    });
73    */
74
75}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.