├── .bowerrc ├── .gitignore ├── .idea ├── .gitignore ├── misc.xml ├── modules.xml ├── vcs.xml └── wps-js.iml ├── Gruntfile.js ├── LICENSE ├── README.md ├── bower.json ├── package-lock.json ├── package.json └── src ├── types └── index.d.ts └── web ├── example.html ├── favicon.ico ├── js └── wps-js-lib │ ├── Constants.js │ ├── Utility.js │ ├── WpsService.js │ ├── lib │ └── Class.js │ ├── request │ ├── BaseRequest.js │ ├── DescribeProcessGetRequest.js │ ├── DescribeProcessPostRequest.js │ ├── ExecuteRequest.js │ ├── ExecuteRequest_v1.js │ ├── ExecuteRequest_v2.js │ ├── GetCapabilitiesGetRequest.js │ ├── GetCapabilitiesPostRequest.js │ ├── GetRequest.js │ ├── GetResultGetRequest.js │ ├── GetStatusGetRequest.js │ ├── InputGenerator.js │ ├── OutputGenerator.js │ └── PostRequest.js │ └── response │ ├── BaseResponse.js │ ├── CapabilitiesResponse.js │ ├── CapabilitiesResponse_v1_xml.js │ ├── CapabilitiesResponse_v2_xml.js │ ├── CapabilitiesResponse_xml.js │ ├── DescribeProcessResponse.js │ ├── DescribeProcessResponse_v1_xml.js │ ├── DescribeProcessResponse_v2_xml.js │ ├── DescribeProcessResponse_xml.js │ ├── ExceptionReportResponse.js │ ├── ExecuteResponse.js │ ├── ExecuteResponse_v1_xml.js │ ├── ExecuteResponse_v2_xml.js │ └── ResponseFactory.js ├── lib └── wps-js-all.js └── test.html /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "src/web/bower_components" 3 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | .settings 3 | .classpath 4 | 5 | /node_modules/ 6 | /src/web/bower_components/ 7 | /dist/ 8 | /build/ 9 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/wps-js.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function (grunt) { 2 | grunt.initConfig({ 3 | pkg: grunt.file.readJSON('package.json'), 4 | name: 'wps-js', 5 | context_name: '<%= name %>##<%= pkg.version %>-<%= grunt.template.today("yyyymmddHHMM")%>', 6 | lib_scripts: [ 7 | 'src/web/bower_components/jquery/dist/jquery.min.js' 8 | ], 9 | wps_js: [ 10 | 'src/web/js/wps-js-lib/lib/Class.js', 11 | 'src/web/js/wps-js-lib/Constants.js', 12 | 'src/web/js/wps-js-lib/Utility.js', 13 | 'src/web/js/wps-js-lib/response/BaseResponse.js', 14 | 'src/web/js/wps-js-lib/response/CapabilitiesResponse.js', 15 | 'src/web/js/wps-js-lib/response/CapabilitiesResponse_xml.js', 16 | 'src/web/js/wps-js-lib/response/CapabilitiesResponse_v1_xml.js', 17 | 'src/web/js/wps-js-lib/response/CapabilitiesResponse_v2_xml.js', 18 | 'src/web/js/wps-js-lib/response/DescribeProcessResponse.js', 19 | 'src/web/js/wps-js-lib/response/DescribeProcessResponse_xml.js', 20 | 'src/web/js/wps-js-lib/response/DescribeProcessResponse_v1_xml.js', 21 | 'src/web/js/wps-js-lib/response/DescribeProcessResponse_v2_xml.js', 22 | 'src/web/js/wps-js-lib/response/ExecuteResponse.js', 23 | 'src/web/js/wps-js-lib/response/ExecuteResponse_v1_xml.js', 24 | 'src/web/js/wps-js-lib/response/ExecuteResponse_v2_xml.js', 25 | 'src/web/js/wps-js-lib/response/ResponseFactory.js', 26 | 'src/web/js/wps-js-lib/response/ExceptionReportResponse.js', 27 | 'src/web/js/wps-js-lib/request/BaseRequest.js', 28 | 'src/web/js/wps-js-lib/request/GetRequest.js', 29 | 'src/web/js/wps-js-lib/request/PostRequest.js', 30 | 'src/web/js/wps-js-lib/request/InputGenerator.js', 31 | 'src/web/js/wps-js-lib/request/OutputGenerator.js', 32 | 'src/web/js/wps-js-lib/request/ExecuteRequest.js', 33 | 'src/web/js/wps-js-lib/request/ExecuteRequest_v1.js', 34 | 'src/web/js/wps-js-lib/request/ExecuteRequest_v2.js', 35 | 'src/web/js/wps-js-lib/request/DescribeProcessGetRequest.js', 36 | 'src/web/js/wps-js-lib/request/GetCapabilitiesGetRequest.js', 37 | 'src/web/js/wps-js-lib/request/DescribeProcessPostRequest.js', 38 | 'src/web/js/wps-js-lib/request/GetCapabilitiesPostRequest.js', 39 | 'src/web/js/wps-js-lib/request/GetStatusGetRequest.js', 40 | 'src/web/js/wps-js-lib/request/GetResultGetRequest.js', 41 | 'src/web/js/wps-js-lib/WpsService.js' 42 | 43 | ], 44 | copy_files: [ 45 | //the path prefix 'src/web/' will be set in the copy-command itself! Thus is omitted here. 46 | 'config/*', 47 | 'demo/**/*', 48 | 'html/*', 49 | 'images/*', 50 | 'jstestdriver/*', 51 | 'xml/*', 52 | 'favicon.ico' 53 | ], 54 | clean: ["dist/"], 55 | tags: { 56 | options: { 57 | scriptTemplate: '', 58 | linkTemplate: '' 59 | }, 60 | build_lib_scripts: { 61 | options: { 62 | openTag: '', 63 | closeTag: '' 64 | }, 65 | src: ['<%= lib_scripts %>'], 66 | dest: 'src/web/example.html' 67 | }, 68 | build_client_scripts: { 69 | options: { 70 | openTag: '', 71 | closeTag: '' 72 | }, 73 | src: ['<%= wps_js %>'], 74 | dest: 'src/web/example.html' 75 | } 76 | }, 77 | concat: { 78 | libs: { 79 | src: ['<%= lib_scripts %>'], 80 | dest: 'dist/js/deps.<%= name %>.js' 81 | }, 82 | wps: { 83 | src: '<%= wps_js %>', 84 | dest: 'dist/js/wps-js-all.js' 85 | } 86 | }, 87 | uglify: { 88 | options: { 89 | banner: '/*! <%= name %> <%= grunt.template.today("yyyy-mm-dd HH:MM") %> */\n' 90 | }, 91 | libs: { 92 | files: { 93 | 'dist/js/deps.<%= name %>.min.js': ['<%= concat.libs.dest %>'] 94 | } 95 | }, 96 | appJs: { 97 | files: { 98 | 'dist/wps-js-all.min.js': ['<%= concat.wps.dest %>'] 99 | } 100 | } 101 | }, 102 | copy: { 103 | locals: { 104 | files: [ 105 | {expand: true, flatten: false, cwd: 'src/web/', src: '<%= copy_files %>', dest: 'dist/'}, 106 | ] 107 | } 108 | }, 109 | //lint the source files 110 | jshint: { 111 | files: ['gruntfile.js', 'src/web/js/**/*.js', 'test/**/*.js'], 112 | options: { 113 | globals: { 114 | jQuery: true, 115 | console: true, 116 | module: true 117 | } 118 | } 119 | }, 120 | processhtml: { 121 | options: { 122 | data: { 123 | message: '<%= name %> - version <%= pkg.version %> - build at <%= grunt.template.today("yyyy-mm-dd HH:MM") %>' 124 | } 125 | }, 126 | index: { 127 | files: { 128 | 'dist/example.html': ['src/web/example.html'] 129 | } 130 | } 131 | }, 132 | watch: { 133 | less: { 134 | files: [ 'bower.json' ], 135 | tasks: [ 'exec:bower_install' ] 136 | }, 137 | hint: { 138 | files: ['<%= jshint.files %>'], 139 | tasks: ['jshint'] 140 | } 141 | }, 142 | exec: { 143 | bower_install: { 144 | cmd: "bower install" 145 | } 146 | }, 147 | war: { 148 | target: { 149 | options: { 150 | war_dist_folder: 'build/', 151 | war_name: '<%= context_name %>', 152 | webxml_welcome: 'example.html', 153 | webxml_display_name: '<%= name %> - version <%= pkg.version %> - build at <%= grunt.template.today("yyyy-mm-dd HH:MM") %>', 154 | webxml_mime_mapping: [ 155 | { 156 | extension: 'xml', 157 | mime_type: 'application/xml' 158 | }] 159 | }, 160 | files: [ 161 | { 162 | expand: true, 163 | cwd: 'dist/', 164 | src: ['**'], 165 | dest: '' 166 | } 167 | ] 168 | } 169 | } 170 | }); 171 | 172 | grunt.loadNpmTasks('grunt-contrib-uglify'); 173 | grunt.loadNpmTasks('grunt-contrib-jshint'); 174 | grunt.loadNpmTasks('grunt-contrib-watch'); 175 | grunt.loadNpmTasks('grunt-contrib-concat'); 176 | grunt.loadNpmTasks('grunt-contrib-copy'); 177 | grunt.loadNpmTasks('grunt-contrib-clean'); 178 | grunt.loadNpmTasks('grunt-script-link-tags'); 179 | grunt.loadNpmTasks('grunt-processhtml'); 180 | grunt.loadNpmTasks('grunt-exec'); 181 | grunt.loadNpmTasks('grunt-war'); 182 | 183 | grunt.registerTask('test', ['jshint']); 184 | grunt.registerTask('env-build', ['tags']); 185 | grunt.registerTask('default', ['clean', 'concat', 'uglify', 'copy', 'processhtml']); 186 | grunt.registerTask('buildDebugScript', ['clean', 'concat']); 187 | 188 | grunt.registerTask('buildWar', ['default', 'war']); 189 | // grunt.registerTask('buildWar', ['test', 'default', 'war']); 190 | }; 191 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright (C) 2013 by 52 North Initiative for Geospatial Open 191 | Source Software GmbH 192 | 193 | Licensed under the Apache License, Version 2.0 (the "License"); 194 | you may not use this file except in compliance with the License. 195 | You may obtain a copy of the License at 196 | 197 | http://www.apache.org/licenses/LICENSE-2.0 198 | 199 | Unless required by applicable law or agreed to in writing, software 200 | distributed under the License is distributed on an "AS IS" BASIS, 201 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 202 | See the License for the specific language governing permissions and 203 | limitations under the License. 204 | 205 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ARCHIVED 2 | 3 | This project is no longer maintained and will not receive any further updates. If you plan to continue using it, please be aware that future security issues will not be addressed. 4 | 5 | wps-js 6 | ====== 7 | 8 | Standalone Javascript OGC Web Processing Service (WPS) API with the following functions: 9 | 10 | - Encoding and parsing of WPS requests for WPS 1.0 and 2.0 (GetCapabilities, DescribeProcess, Execute, getStatus, getResult) 11 | - Encoding and parsing of WPS responses (Capabilities, ProcessDescription, Execute ResponseDocument (WPS 1.0), Execute ResultDocument (WPS 2.0), StatusInfo Document) 12 | 13 | Requirements to develop or build the client 14 | ------------------------------------------- 15 | 16 | - git 17 | - [nodejs](https://nodejs.org) 18 | - [npm](https://www.npmjs.com/) 19 | - [grunt](http://gruntjs.com/) 20 | 21 | Get ready to start 22 | ------------------ 23 | - npm install wps-js-52-north 24 | Run the above command to fetch the module directly from npm. 25 | 26 | Or Clone directly 27 | ------------------ 28 | - `git clone` this repository 29 | - run `npm install` to get all dependencies 30 | 31 | ### Get a static files folder which can be added to a web-server 32 | 33 | - with `grunt` all files are collected and build in a `dist` folder. The content of this folder can be deployed on a webserver like Tomcat. 34 | 35 | Installation and basic usage 36 | ---------------------------- 37 | 38 | wps-js is a plain Javascipt API. To try out examples follow these steps: 39 | 40 | - Check out the code: `git clone https://github.com/52North/wps-js.git` 41 | - Change to the directory and perform `npm install` and `grunt` to build the API (which will create a new `dist` folder) 42 | - Add the file `dist/wps-js-all.min.js` as dependency in your own application. 43 | - Note that wps-js requires JQuery! So you should include this as well in your application before wps-js. 44 | - To see how to use the API, please refer to the subsequent Documentation. 45 | 46 | Updating wps-js on NPM 47 | ---------------------------- 48 | Currently, the library wps-js could be found on NPM: https://www.npmjs.com/package/wps-js-52-north 49 | 50 | To update update this library on npm, perform the following steps: 51 | 52 | - Check out the code: `git clone https://github.com/52North/wps-js.git` 53 | - Change to the directory and perform `npm install` and `grunt` to build the API (which will create a new `dist` folder) 54 | - Add the file `dist/wps-js-all.min.js` and `dist/wps-js-all.js` in the [lib](src/web/lib) folder. (Please add both files as current users use both the files.) 55 | - Finally, run `npm login` and `npm publish` 56 | 57 | Note: This action requires maintainer permission on npm for this library. 58 | 59 | 60 | Documentation 61 | ------------- 62 | 63 | To use the wps-js API, the most important class is `WpsService`. It acts as the central interface to query Web Processing Services of version 1.0 and 2.0. 64 | 65 | ### WpsService interface 66 | 67 | This section explains how to initialize the `WpsService` object and use it's methods to query any WPS. 68 | 69 | #### How to Initialize WpsService 70 | 71 | Initialize the object with the following settings: 72 | 73 | ``` 74 | // initialize wpsService 75 | var wpsService = new WpsService({ 76 | url: "http://geoprocessing.demo.52north.org:8080/wps/WebProcessingService", 77 | version: "2.0.0" 78 | }); 79 | ``` 80 | 81 | At least, you have to provide a valid URL to a WPS instance within the parameter `url`. For parameter `version` valid options are `1.0.0` and `2.0.0`. When omitted, `1.0.0` is used per default. 82 | 83 | Should you want to change the `url` or `version` manually, you can call the methods 84 | 85 | ``` 86 | // allowed values : "1.0.0" or "2.0.0" 87 | wpsService.setVersion(newVersion); 88 | 89 | // url must be a valid URL to a WPS instance 90 | wpsService.setUrl(url); 91 | ``` 92 | 93 | Once initialized, you may use new variable to execute typical WPS requests. The following subsections describe each operation. 94 | 95 | #### Info on Response 96 | 97 | For each subsequent request, a callback function has to be defined, which is called with the corresponding response of the WPS. This structure of the response object depends on the following two cases: 98 | 99 | - success: the request was successful and a valid response was generated. Then the callback function is called with a parameter 'response', which contains two properties, 'responseDocument' (the raw XML response from the WPS) and a request-specific JavaScript Object representation of the WPS response. E.g. a valid Capabilities request responds with: 100 | 101 | ``` 102 | // call callback function 103 | callbackFunction(response); 104 | 105 | ------------------------------ 106 | 107 | // where response has structure: 108 | response.responseDocument // raw response of WPS (XML encoded response). 109 | response.capabilities // all properties of the WPS Capabilities response encoded as JavaScript properties. 110 | 111 | ``` 112 | 113 | Clearly, for each different request type, the second property will differ (see method details below). 114 | 115 | - error: an error occurred. Then no valid response object could be constructed and the response will include two error properties (which are simply forwarded from the failing WPS request): 116 | 117 | ``` 118 | // call callback function 119 | callbackFunction(errorObject); 120 | 121 | ------------------------------ 122 | 123 | // where errorObject has structure: 124 | errorObject.textStatus 125 | errorObject.errorThrown 126 | 127 | ``` 128 | 129 | #### GetCapabilities Request 130 | 131 | ``` 132 | /** 133 | * getCapabilities via HTTP GET 134 | * 135 | * @callbackFunction is called with a parameter 'wpsResponse' after the WPS was contacted. The parameter 'wpsResponse' either comprises a JavaScript Object representation of the WPS response or, if an error occured, error properties 'textStatus' and/or 'errorThrown'! 136 | */ 137 | wpsService.getCapabilities_GET(callbackFunction); 138 | ``` 139 | 140 | ``` 141 | /** 142 | * getCapabilities via HTTP POST 143 | * 144 | * @callbackFunction is called with a parameter 'wpsResponse' after the WPS was contacted. The parameter 'wpsResponse' either comprises a JavaScript Object representation of the WPS response or, if an error occured, error properties 'textStatus' and/or 'errorThrown'! 145 | */ 146 | wpsService.getCapabilities_POST(callbackFunction); 147 | ``` 148 | 149 | #### GetCapabilities Response 150 | 151 | ``` 152 | // call callback function 153 | callbackFunction(response); 154 | 155 | ------------------------------ 156 | 157 | // where response has structure: 158 | response.responseDocument // raw response of WPS (XML encoded response). 159 | response.capabilities // all properties of the WPS Capabilities response encoded as JavaScript properties according to WPS 2.0 standard. 160 | 161 | ``` 162 | 163 | #### DescribeProcess Request 164 | 165 | ``` 166 | /** 167 | * process description via HTTP GET 168 | * 169 | * @callbackFunction is called with a parameter 'wpsResponse' after the WPS was contacted. The parameter 'wpsResponse' either comprises a JavaScript Object representation of the WPS response or, if an error occured, error properties 'textStatus' and/or 'errorThrown'! . 170 | * Takes the response object as argument 171 | * @processIdentifier the identifier of the process 172 | */ 173 | wpsService.describeProcess_GET(callbackFunction, processIdentifier); 174 | ``` 175 | 176 | ``` 177 | /** 178 | * process description via HTTP POST 179 | * 180 | * @callbackFunction is called with a parameter 'wpsResponse' after the WPS was contacted. The parameter 'wpsResponse' either comprises a JavaScript Object representation of the WPS response or, if an error occured, error properties 'textStatus' and/or 'errorThrown'! . 181 | * Takes the response object as argument 182 | * @processIdentifier the identifier of the process 183 | */ 184 | wpsService.describeProcess_POST(callbackFunction, processIdentifier); 185 | ``` 186 | 187 | #### DescribeProcess Response 188 | 189 | ``` 190 | // call callback function 191 | callbackFunction(response); 192 | 193 | ------------------------------ 194 | 195 | // where response has structure: 196 | response.responseDocument // raw response of WPS (XML encoded response). 197 | response.processOffering // all properties of the WPS DescribeProcess response encoded as JavaScript properties according to WPS 2.0 standard. 198 | ``` 199 | 200 | #### Execute Request 201 | 202 | ``` 203 | /** 204 | * WPS execute request via HTTP POST 205 | * 206 | * @callbackFunction is called with a parameter 'wpsResponse' after the WPS was contacted. The parameter 'wpsResponse' either comprises a JavaScript Object representation of the WPS response or, if an error occured, error properties 'textStatus' and/or 'errorThrown'! . 207 | * Takes the response object as argument 208 | * @processIdentifier the identifier of the process 209 | * @responseFormat either "raw" or "document", default is "document" 210 | * @executionMode either "sync" or "async"; 211 | * @lineage only relevant for WPS 1.0; boolean, if "true" then returned 212 | * response will include original input and output definition; false per default 213 | * @inputs an array of needed Input objects, use JS-object InputGenerator to 214 | * create inputs 215 | * @outputs an array of requested Output objects, use JS-object 216 | * OutputGenerator to create inputs 217 | */ 218 | wpsService.execute(callbackFunction, processIdentifier, responseFormat, executionMode, lineage, inputs, outputs); 219 | ``` 220 | 221 | As you notice, to create the arrays of `inputs` and `outputs`, you have to use the JavaScript class `InputGenerator` and `OutputGenerator`. A description of those can be found further below. 222 | 223 | #### Execute Response 224 | 225 | Whereas in the previous requests/responses there were no differences between different WPS versions, an execute response is very different for WPS 1.0 and 2.0 services. 226 | 227 | In general, the a response has the following basic structure: 228 | 229 | ``` 230 | // call callback function 231 | callbackFunction(response); 232 | 233 | ------------------------------ 234 | 235 | // basic structure of execute response: 236 | response.type // is set to one of { responseDocument | resultDocument | statusInfoDocument | rawOutput } 237 | response.serviceVersion // is set to one of { 1.0.0 | 2.0.0 } 238 | response.responseDocument // property that stores the contents of response (structure depends on type!) 239 | ``` 240 | 241 | - type 'rawOutput' stands for raw output 242 | - type 'responseDocument' stands for a WPS 1.0.0 response document 243 | - type 'resultDocument' stands for a WPS 2.0.0 result document (in response to a synchronous execution) 244 | - type 'resultDocument' stands for a WPS 2.0.0 status info document (in response to an asynchronous execution) 245 | 246 | In accordance to the 'type' property, the structure of the property 'responseDocument' varies, as shown in the subsequent request descriptions. 247 | 248 | #### WPS 1.0.0 Execute Response 249 | 250 | ``` 251 | // call callback function 252 | callbackFunction(response); 253 | 254 | ------------------------------ 255 | 256 | // where response has structure: 257 | response.type = "responseDocument" 258 | response.serviceVersion = "1.0.0" 259 | response.responseDocument.service = "WPS" 260 | response.responseDocument.version = "1.0.0" 261 | response.responseDocument.lang = "EN" // language 262 | response.responseDocument.statusLocation = "url" // URL to statuslocation in case of asynchronous execution or 'undefined' 263 | response.responseDocument.process.identifier = "processId" 264 | response.responseDocument.process.title = "processTitle" 265 | response.responseDocument.status.creationTime = "creationTime" 266 | response.responseDocument.status.info = "infoMessage" 267 | response.responseDocument.outputs // array of outputs 268 | ``` 269 | 270 | #### Retrieve Stored ExecuteResponse (WPS 1.0.0) 271 | 272 | For WPS 1.0.0 execute operation you may define to execute it asynchronously and store a status document on the server, which is updated by the WPS. With the following method you can retrieve the updated document. 273 | 274 | ``` 275 | /** 276 | * Only relevant for WPS 1.0 277 | * 278 | * @callbackFunction a callback function that will be triggered with the 279 | * parsed executeResponse as argument 280 | * @storedExecuteResponseLocation the url, where the execute response document 281 | * is located / can be retrieved from 282 | */ 283 | wpsService.parseStoredExecuteResponse_WPS_1_0(callbackFunction, storedExecuteResponseLocation); 284 | ``` 285 | 286 | #### Retrieve Stored ExecuteResponse (WPS 1.0.0) - Response 287 | 288 | identical to WPS 1.0.0 Execute Response 289 | 290 | ``` 291 | // call callback function 292 | callbackFunction(response); 293 | 294 | ------------------------------ 295 | 296 | // where response has structure: 297 | response.type = "responseDocument" 298 | response.serviceVersion = "1.0.0" 299 | response.responseDocument.service = "WPS" 300 | response.responseDocument.version = "1.0.0" 301 | response.responseDocument.lang = "EN" // language 302 | response.responseDocument.statusLocation = "url" // URL to statuslocation in case of asynchronous execution or 'undefined' 303 | response.responseDocument.process.identifier = "processId" 304 | response.responseDocument.process.title = "processTitle" 305 | response.responseDocument.status.creationTime = "creationTime" 306 | response.responseDocument.status.info = "infoMessage" 307 | response.responseDocument.outputs // array of outputs 308 | ``` 309 | 310 | #### GetStatus (WPS 2.0.0) 311 | 312 | The `GetStatus` operation is only defined for WPS 2.0.0 and retrieves a `StatusInfo Document` from the WPS service, which is generated as a result of an asynchronous `Execute` request. 313 | 314 | ``` 315 | /** 316 | * WPS 2.0 getStatus operation to retrieve the status of an executed job 317 | * 318 | * Not usable with WPS 1.0 319 | * 320 | * @callbackFunction a callback function that will be triggered with the 321 | * parsed StatusInfo document as argument 322 | * @jobId the ID of the asynchronously executed job 323 | */ 324 | wpsService.getStatus_WPS_2_0(callbackFunction, jobId); 325 | ``` 326 | 327 | #### GetStatus Response 328 | 329 | ``` 330 | // call callback function 331 | callbackFunction(response); 332 | 333 | ------------------------------ 334 | 335 | // where response has structure: 336 | response.type = "statusInfoDocument" 337 | response.serviceVersion = "2.0.0" 338 | response.responseDocument.jobId = "jobId" // job id of executed process 339 | response.responseDocument.status = "status" // job status 340 | response.responseDocument.expirationDate = "jobId" // expiration date of job 341 | response.responseDocument.estimatedCompletion = "estimatedCompletion" // estimated completion 342 | response.responseDocument.nextPoll = "nextPoll" // next poll 343 | response.responseDocument.percentCompleted = "42" // job completion in percent 344 | ``` 345 | 346 | #### GetResult (WPS 2.0.0) 347 | 348 | The `GetResult` operation is only defined for WPS 2.0.0 and retrieves a `ResultDocument` from the WPS service (when a `Job` was executed asynchronously and has finished, then the result may be retrieved this way). 349 | 350 | ``` 351 | /** 352 | * WPS 2.0 getResult operation to retrieve the status of an executed job 353 | * 354 | * Not usable with WPS 1.0 355 | * 356 | * @callbackFunction a callback function that will be triggered with the 357 | * parsed StatusInfo document as argument 358 | * @jobId the ID of the asynchronously executed job 359 | */ 360 | wpsService.getResult_WPS_2_0(callbackFunction, jobId); 361 | ``` 362 | 363 | ####GetResult Response 364 | 365 | ``` 366 | // call callback function 367 | callbackFunction(response); 368 | 369 | ------------------------------ 370 | 371 | // where response has structure: 372 | response.jobId = "jobId" // job id of finished job 373 | response.expirationDate = "expirationDate" // expiration date of job 374 | response.responseDocument.outputs // array of outputs 375 | ``` 376 | 377 | ### InputGenerator Interface 378 | 379 | The `InputGenerator` is used to create `Input` objects for an `Execute` request. 380 | 381 | To initialize it do the following: 382 | 383 | ``` 384 | // new instance of InputGenerator 385 | var inputGenerator = new InputGenerator(); 386 | ``` 387 | 388 | After that you can use the following methods to create valid Input objects. 389 | 390 | #### Literal Data Input 391 | 392 | ``` 393 | /** 394 | * the following parameters are mandatory: identifier and value 395 | * 396 | * the rest might be set to 'undefined'! 397 | * 398 | * @identifier input identifier 399 | * @dataType data type of the input; may be 'undefined' 400 | * @uom unit of measure; may be 'undefined' 401 | * @value the literal value of the input 402 | */ 403 | var literalInput = inputGenerator.createLiteralDataInput_wps_1_0_and_2_0(identifier, dataType, uom, value); 404 | ``` 405 | 406 | #### Complex Data Input 407 | 408 | ``` 409 | /** 410 | * the following parameters are mandatory: identifier and complexPayload 411 | * 412 | * the rest might be set to 'undefined'! 413 | * 414 | * @identifier input identifier 415 | * @mimeType MIME type of the input; may be 'undefined' 416 | * @schema reference to a schema; may be 'undefined' 417 | * @encoding encoding; may be 'undefined' 418 | * @asReference boolean, either "true" or "false", indicating 419 | * whether parameter body contains a URL as reference 420 | * to an external body or the actual POST body 421 | * @complexPayload the complex payload as String 422 | */ 423 | var complexInput = inputGenerator.createComplexDataInput_wps_1_0_and_2_0(identifier, 424 | mimeType, schema, encoding, asReference, complexPayload); 425 | ``` 426 | 427 | #### Bounding Box Data Input 428 | 429 | ``` 430 | /** 431 | * the following parameters are mandatory: identifier, crs, 432 | * lowerCorner and upperCorner 433 | * 434 | * the rest might be set to 'undefined'! 435 | * 436 | * @identifier input identifier 437 | * @crs coordinate reference system URI 438 | * @dimension number of dimensions in this CRS 439 | * @lowerCorner orderedSequence of double values 440 | * @upperCorner orderedSequence of double values 441 | */ 442 | var bboxInput = inputGenerator.createBboxDataInput_wps_1_0_and_2_0(identifier, crs, 443 | dimension, lowerCorner, upperCorner); 444 | ``` 445 | 446 | ### OutputGenerator Interface 447 | 448 | The `OutputGenerator` is used to create `Output` objects for an `Execute` request. 449 | 450 | To initialize it do the following: 451 | 452 | ``` 453 | // new instance of OutputGenerator 454 | var outputGenerator = new OutputGenerator(); 455 | ``` 456 | 457 | After that you can use the following methods to create valid `Output` objects. In contrast to the `InputGenerator`, the methods are specialized for different WPS version, since they require different parameters. 458 | 459 | #### Literal Data Output WPS 1.0.0 460 | 461 | ``` 462 | /** 463 | * the following parameters are mandatory: identifier 464 | * 465 | * @identifier output identifier 466 | * @asReference boolean, "true" or "false" 467 | */ 468 | var literalOutput = outputGenerator.createLiteralOutput_WPS_1_0(identifier, asReference); 469 | ``` 470 | 471 | #### Complex Data Output WPS 1.0.0 472 | 473 | ``` 474 | /** 475 | * the following parameters are mandatory: identifier 476 | * 477 | * the rest might be set to 'undefined'! 478 | * 479 | * @identifier output identifier 480 | * @mimeType MIME type of the input; may be 'undefined' 481 | * @schema reference to a schema; may be 'undefined' 482 | * @encoding encoding; may be 'undefined' 483 | * @uom unit of measure; may be 'undefined' 484 | * @asReference boolean, "true" or "false" 485 | * @title new title 486 | * @abstractValue new description as text of the 'Abstract' element 487 | * of the response document 488 | */ 489 | var complexOutput = outputGenerator.createComplexOutput_WPS_1_0(identifier, asReferenceidentifier, mimeType, schema, 490 | encoding, uom, asReference, title, abstractValue); 491 | ``` 492 | 493 | #### Literal Data Output WPS 2.0.0 494 | 495 | ``` 496 | /** 497 | * the following parameters are mandatory: identifier and transmission 498 | * 499 | * @identifier output identifier 500 | * @transmission either "value" or "reference" 501 | */ 502 | var literalOutput = outputGenerator.createLiteralOutput_WPS_2_0(identifier, transmission); 503 | ``` 504 | 505 | #### Complex Data Output WPS 2.0.0 506 | 507 | ``` 508 | /** 509 | * the following parameters are mandatory: identifier and transmission 510 | * 511 | * the rest might be set to 'undefined'! 512 | * 513 | * @identifier output identifier 514 | * @mimeType MIME type of the input; may be 'undefined' 515 | * @schema reference to a schema; may be 'undefined' 516 | * @encoding encoding; may be 'undefined' 517 | * @transmission either "value" or "reference" 518 | */ 519 | var complexOutput = outputGenerator.createComplexOutput_WPS_2_0(identifier, mimeType, schema, 520 | encoding, transmission); 521 | ``` 522 | 523 | License 524 | ------- 525 | 526 | wps-js is published under Apache Software License, Version 2.0 527 | 528 | The used libraries are: 529 | 530 | - jQuery - MIT License - https://jquery.org/license/ 531 | 532 | Contact / Support 533 | ----------------- 534 | 535 | To get help in running wps-js, please use the Geoprocessing community mailing list and forum: http://geoprocessing.forum.52north.org/ 536 | 537 | Please leave an issue on GitHub if you have any bug reports or feature requests: https://github.com/52North/wps-js/issues 538 | 539 | Contact: Benjamin Proß (b.pross@52north.org) 540 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wps-js", 3 | "homepage": "https://github.com/52North/wps-js", 4 | "authors": [ 5 | "Benjamin Proß ", 6 | "Matthes Rieke ", 7 | "Daniel Nüst ", 8 | "Christian Autermann ", 9 | "Christian Danowski " 10 | ], 11 | "description": "Web Processing Service JavaScript library", 12 | "keywords": [ 13 | "WPS", 14 | "Web Processing Service", 15 | "JavaScript library", 16 | "JavaScript client" 17 | ], 18 | "license": "Apache2", 19 | "private": false, 20 | "ignore": [ 21 | "**/.*", 22 | "node_modules", 23 | "bower_components", 24 | "src/web/bower_components", 25 | "test", 26 | "tests" 27 | ], 28 | "dependencies": { 29 | "jquery": "3.0.0" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wps-js-52-north", 3 | "version": "2.0.6", 4 | "private": false, 5 | "description": "Web Processing Service JavaScrict library", 6 | "main": "TBD", 7 | "repository": { 8 | "type": "git", 9 | "url": "git+https://github.com/52North/wps-js.git" 10 | }, 11 | "keywords": [ 12 | "WPS", 13 | "Web Processing Service", 14 | "JavaScript library", 15 | "JavaScript client" 16 | ], 17 | "license": "Apache-2.0", 18 | "bugs": { 19 | "url": "https://github.com/52North/wps-js/issues" 20 | }, 21 | "homepage": "https://github.com/52North/wps-js#readme", 22 | "devDependencies": { 23 | "bower": "^1.7.9", 24 | "grunt": "^1.0.1", 25 | "grunt-cli": "^1.2.0", 26 | "grunt-contrib-clean": "^1.0.0", 27 | "grunt-contrib-concat": "^1.0.1", 28 | "grunt-contrib-copy": "^1.0.0", 29 | "grunt-contrib-cssmin": "^1.0.1", 30 | "grunt-contrib-jshint": "^1.0.0", 31 | "grunt-contrib-nodeunit": "^1.0.0", 32 | "grunt-contrib-qunit": "^1.2.0", 33 | "grunt-contrib-uglify": "^1.0.1", 34 | "grunt-contrib-watch": "^1.0.0", 35 | "grunt-exec": "^0.4.7", 36 | "grunt-processhtml": "^0.3.13", 37 | "grunt-script-link-tags": "^1.0.2", 38 | "grunt-war": "^0.5.1" 39 | }, 40 | "scripts": { 41 | "test": "echo \"Error: no test specified\" && exit 1", 42 | "postinstall": "bower install", 43 | "prestart": "npm install" 44 | }, 45 | "dependencies": { 46 | "@types/npm": "^2.0.31" 47 | }, 48 | "author": "52north", 49 | "types": "types/index.d.ts" 50 | } 51 | -------------------------------------------------------------------------------- /src/types/index.d.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable-next-line:no-namespace 2 | declare namespace WpsServiceModule { 3 | 4 | export interface Service { 5 | 6 | new(settings: { version: string; url: string }): WpsServiceModule.Service; 7 | 8 | settings: any; 9 | 10 | init(settings: any): WpsServiceModule.Service; 11 | 12 | /** 13 | * allowed values : "1.0.0" or "2.0.0" 14 | * 15 | * requires Constant.js 16 | */ 17 | setVersion(version: string): void; 18 | 19 | /** 20 | * set base URL of target WPS 21 | */ 22 | setUrl(url: string): void; 23 | 24 | /** 25 | * getCapabilities via HTTP GET 26 | * 27 | * @callbackFunction is triggered on success-event of JQuery.ajax method 28 | */ 29 | getCapabilities_GET(callback: (response: 30 | any) => void): void; 31 | 32 | /** 33 | * getCapabilities via HTTP POST 34 | * 35 | * @callbackFunction is triggered on success-event of JQuery.ajax method. 36 | * Takes the response object as argument 37 | */ 38 | getCapabilities_POST(callback: (response: 39 | any) => void): void; 40 | 41 | /** 42 | * process description via HTTP GET 43 | * 44 | * @callbackFunction is triggered on success-event of JQuery.ajax method. 45 | * Takes the response object as argument 46 | * @processIdentifier the identifier of the process 47 | */ 48 | describeProcess_GET(callback: (response: 49 | any) => void, 50 | processIdentifier: string); 51 | 52 | /** 53 | * process description via HTTP POST 54 | * 55 | * @callbackFunction is triggered on success-event of JQuery.ajax method. 56 | * Takes the response object as argument 57 | * @processIdentifier the identifier of the process 58 | */ 59 | describeProcess_POST(callback: (response: 60 | any) => void, 61 | processIdentifier: string); 62 | 63 | /** 64 | * WPS execute request via HTTP POST 65 | * 66 | * @callbackFunction is triggered on success-event of JQuery.ajax method. 67 | * Takes the response object as argument 68 | * @processIdentifier the identifier of the process 69 | * @responseFormat either "raw" or "document", default is "document" 70 | * @executionMode either "sync" or "async"; 71 | * @lineage only relevant for WPS 1.0; boolean, if "true" then returned 72 | * response will include original input and output definition 73 | * @inputs an array of needed Input objects, use JS-object InputGenerator to 74 | * create inputs 75 | * @outputs an array of requested Output objects, use JS-object 76 | * OutputGenerator to create inputs 77 | */ 78 | execute(callbackFunction: (response: any) => void , processIdentifier: string, 79 | responseFormat: string, executionMode: string, 80 | lineage: boolean, inputs: Array, outputs: Array); 81 | 82 | /** 83 | * Only important for WPS 1.0 84 | * 85 | * @callbackFunction a callback function that will be triggered with the 86 | * parsed executeResponse as argument 87 | * @storedExecuteResponseLocation the url, where the execute response 88 | * document is located / can be retrieved 89 | * from 90 | */ 91 | parseStoredExecuteResponse_WPS_1_0(callback: (executeResponse) => any, storedExecuteResponseLocation); 92 | 93 | /** 94 | * WPS 2.0 getStatus operation to retrieve the status of an executed job 95 | * 96 | * Not usable with WPS 1.0 97 | * 98 | * @callbackFunction a callback function that will be triggered with the 99 | * parsed StatusInfo document as argument 100 | * @jobId the ID of the asynchronously executed job 101 | */ 102 | getStatus_WPS_2_0(callback: (response) => any, jobId: string); 103 | 104 | /** 105 | * WPS 2.0 getStatus operation to retrieve the status of an executed job 106 | * 107 | * Not usable with WPS 1.0 108 | * 109 | * @callbackFunction a callback function that will be triggered with the 110 | * parsed StatusInfo document as argument 111 | * @jobId the ID of the asynchronously executed job 112 | */ 113 | getResult_WPS_2_0(callback: (response) => any, jobId: string); 114 | 115 | } 116 | } 117 | declare var WpsService: WpsServiceModule.Service; 118 | -------------------------------------------------------------------------------- /src/web/example.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | wps-js example 52 | 53 | 54 | 55 |
56 |
57 |

wps-js example

58 |

wps-js is an open source client library for connecting Javascript client to OGC Web Processing services. This page demonstrates how you can use it. More documentation is available in the 52°North Wiki and on GitHub.

59 |
60 | 61 |
62 |

63 | Capabilities 64 |

65 |
66 | 71 | 75 |
76 |

77 |
78 | 79 |
80 |
81 |
82 |

83 | DescribeProcess 84 |

85 |
86 | 87 |
88 |

89 |
90 | 91 |
92 |
93 |
94 |

Execute Process - TODO NO CLIENT INTERFACE YET

95 |
96 | 97 | 98 |
99 |
100 |

101 |
102 |
103 |
104 |
105 |
106 |
107 | 208 | 209 | 214 | 215 | 216 | 217 | -------------------------------------------------------------------------------- /src/web/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/52North/wps-js/275cd96fb8f687ec7ca44b6e462e5b6ef3f5ac66/src/web/favicon.ico -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/Constants.js: -------------------------------------------------------------------------------- 1 | var WPS_VERSION_1_0_0 = "1.0.0" 2 | var WPS_VERSION_2_0_0 = "2.0.0" 3 | 4 | var GET_CAPABILITIES_TYPE = "GetCapabilities"; 5 | var DESCRIBE_PROCESS_TYPE = "DescribeProcess"; 6 | var EXECUTE_TYPE = "Execute"; 7 | var GET_STATUS_TYPE = "GetStatus"; 8 | var GET_RESULT_TYPE = "GetResult"; 9 | 10 | var OWS_11_NAMESPACE = "http://www.opengis.net/ows/1.1"; 11 | var WPS_100_NAMESPACE = "http://www.opengis.net/wps/1.0.0"; 12 | 13 | var METHOD_POST = "POST"; 14 | var METHOD_GET = "GET"; 15 | var PARAM_WPS_REQUEST_URL = "wpsRequestUrl"; 16 | var PARAM_WPS_REQUEST_TYPE = "wpsRequestType"; 17 | 18 | var USE_PROXY = false; 19 | var PROXY_URL = ""; 20 | var PROXY_TYPE = ""; 21 | 22 | var USER_TEMPLATE_CAPABILITIES_MARKUP = null; 23 | var USER_TEMPLATE_PROCESS_DESCRIPTION_MARKUP = null; 24 | var USER_TEMPLATE_EXECUTE_RESPONSE_MARKUP = null; 25 | 26 | var DATA_TYPE_LITERAL = "LITERAL"; 27 | var DATA_TYPE_COMPLEX = "COMPLEX"; 28 | var DATA_TYPE_BBOX = "BBOX"; 29 | 30 | function wpsResetSetup() { 31 | USE_PROXY = false; 32 | PROXY_URL = ""; 33 | PROXY_TYPE = ""; 34 | 35 | USER_TEMPLATE_CAPABILITIES_MARKUP = null; 36 | USER_TEMPLATE_PROCESS_DESCRIPTION_MARKUP = null; 37 | USER_TEMPLATE_EXECUTE_RESPONSE_MARKUP = null; 38 | } 39 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/Utility.js: -------------------------------------------------------------------------------- 1 | 2 | function equalsString(a, b) { 3 | if (!a) { 4 | return false; 5 | } 6 | 7 | if (!b) { 8 | return false; 9 | } 10 | 11 | return jQuery.trim(a).localeCompare(jQuery.trim(b)) == 0; 12 | } 13 | 14 | function stringStartsWith(target, sub) { 15 | return target.indexOf(sub) == 0; 16 | } 17 | 18 | function fillXMLTemplate(template, properties) { 19 | var result = template; 20 | 21 | for (var key in properties) { 22 | if (properties.hasOwnProperty(key)) { 23 | result = result.replace("${"+key+"}", properties[key]); 24 | } 25 | } 26 | 27 | return result; 28 | } 29 | 30 | function isImageMimetype(mimetype) { 31 | 32 | return ($.inArray(mimetype, imageMimetypes) > -1); 33 | } 34 | 35 | function stringify(format){ 36 | 37 | return '{"mimeType" : "' + (format.mimeType ? format.mimeType : "") + '", "schema" : "' + (format.schema ? format.schema : "") + '", "encoding" : "' + (format.encoding ? format.encoding : "") + '"}'; 38 | 39 | } 40 | 41 | function escapeCharactersForSelect(id){ 42 | 43 | var result = id.replace(/\./g,"\\."); 44 | 45 | return result; 46 | } -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/WpsService.js: -------------------------------------------------------------------------------- 1 | // refers to Constant.js 2 | var defaultWpsVersion = WPS_VERSION_1_0_0; 3 | 4 | /** 5 | * requires Constants.js! 6 | */ 7 | var WpsService = Class.extend({ 8 | 9 | /** 10 | * 11 | */ 12 | init : function(settings) { 13 | this.settings = settings; 14 | 15 | if (!this.settings.version || (this.settings.version !== '1.0.0' && this.settings.version !== '2.0.0')) 16 | this.settings.version = defaultWpsVersion; 17 | }, 18 | 19 | /** 20 | * allowed values : "1.0.0" or "2.0.0" 21 | * 22 | * requires Constant.js 23 | */ 24 | setVersion : function(version) { 25 | if (version === WPS_VERSION_1_0_0 || version === WPS_VERSION_2_0_0) 26 | this.settings.version = version; 27 | }, 28 | 29 | /** 30 | * set base URL of target WPS 31 | */ 32 | setUrl : function(url) { 33 | this.settings.url = url; 34 | }, 35 | 36 | /** 37 | * getCapabilities via HTTP GET 38 | * 39 | * @callbackFunction is triggered on success-event of JQuery.ajax method 40 | */ 41 | getCapabilities_GET : function(callbackFunction) { 42 | var capabilitiesRequest; 43 | 44 | /** 45 | * getCapabilities via HTTP GET 46 | * 47 | * @callbackFunction is triggered on success-event of JQuery.ajax 48 | * method. Takes the response object as argument 49 | */ 50 | capabilitiesRequest = new GetCapabilitiesGetRequest({ 51 | url : this.settings.url, 52 | version : this.settings.version 53 | }); 54 | 55 | capabilitiesRequest.execute(callbackFunction); 56 | }, 57 | 58 | /** 59 | * getCapabilities via HTTP POST 60 | * 61 | * @callbackFunction is triggered on success-event of JQuery.ajax method. 62 | * Takes the response object as argument 63 | */ 64 | getCapabilities_POST : function(callbackFunction) { 65 | var capabilitiesRequest; 66 | 67 | /* 68 | * TODO has to be instantiated depending on the version 69 | */ 70 | capabilitiesRequest = new GetCapabilitiesPostRequest({ 71 | url : this.settings.url, 72 | version : this.settings.version 73 | }); 74 | 75 | capabilitiesRequest.execute(callbackFunction); 76 | }, 77 | 78 | /** 79 | * process description via HTTP GET 80 | * 81 | * @callbackFunction is triggered on success-event of JQuery.ajax method. 82 | * Takes the response object as argument 83 | * @processIdentifier the identifier of the process 84 | */ 85 | describeProcess_GET : function(callbackFunction, processIdentifier) { 86 | var processDescriptionRequest; 87 | 88 | processDescriptionRequest = new DescribeProcessGetRequest({ 89 | url : this.settings.url, 90 | version : this.settings.version, 91 | processIdentifier : processIdentifier 92 | }); 93 | 94 | processDescriptionRequest.execute(callbackFunction); 95 | }, 96 | 97 | /** 98 | * process description via HTTP POST 99 | * 100 | * @callbackFunction is triggered on success-event of JQuery.ajax method. 101 | * Takes the response object as argument 102 | * @processIdentifier the identifier of the process 103 | */ 104 | describeProcess_POST : function(callbackFunction, processIdentifier) { 105 | var processDescriptionRequest; 106 | 107 | processDescriptionRequest = new DescribeProcessPostRequest({ 108 | url : this.settings.url, 109 | version : this.settings.version, 110 | processIdentifier : processIdentifier 111 | }); 112 | 113 | processDescriptionRequest.execute(callbackFunction); 114 | }, 115 | 116 | /** 117 | * WPS execute request via HTTP POST 118 | * 119 | * @callbackFunction is triggered on success-event of JQuery.ajax method. 120 | * Takes the response object as argument 121 | * @processIdentifier the identifier of the process 122 | * @responseFormat either "raw" or "document", default is "document" 123 | * @executionMode either "sync" or "async"; 124 | * @lineage only relevant for WPS 1.0; boolean, if "true" then returned 125 | * response will include original input and output definition 126 | * @inputs an array of needed Input objects, use JS-object InputGenerator to 127 | * create inputs 128 | * @outputs an array of requested Output objects, use JS-object 129 | * OutputGenerator to create inputs 130 | */ 131 | execute : function(callbackFunction, processIdentifier, responseFormat, 132 | executionMode, lineage, inputs, outputs) { 133 | var executeRequest; 134 | 135 | if (this.settings.version === WPS_VERSION_1_0_0) { 136 | executeRequest = new ExecuteRequest_v1({ 137 | url : this.settings.url, 138 | version : this.settings.version, 139 | processIdentifier : processIdentifier, 140 | responseFormat : responseFormat, 141 | executionMode : executionMode, 142 | lineage : lineage, 143 | inputs : inputs, 144 | outputs : outputs 145 | }); 146 | } 147 | 148 | else { 149 | executeRequest = new ExecuteRequest_v2({ 150 | url : this.settings.url, 151 | version : this.settings.version, 152 | processIdentifier : processIdentifier, 153 | responseFormat : responseFormat, 154 | executionMode : executionMode, 155 | inputs : inputs, 156 | outputs : outputs 157 | }); 158 | } 159 | 160 | executeRequest.execute(callbackFunction); 161 | }, 162 | 163 | /** 164 | * Only important for WPS 1.0 165 | * 166 | * @callbackFunction a callback function that will be triggered with the 167 | * parsed executeResponse as argument 168 | * @storedExecuteResponseLocation the url, where the execute response 169 | * document is located / can be retrieved 170 | * from 171 | */ 172 | parseStoredExecuteResponse_WPS_1_0 : function(callbackFunction, 173 | storedExecuteResponseLocation) { 174 | /* 175 | * TODO the url stores a ready-to-be-parsed executeResponse. This should 176 | * be parsed as ExecuteResponse_v1_xml object 177 | * 178 | * GET request against that URL 179 | */ 180 | $.ajax({ 181 | url : storedExecuteResponseLocation, 182 | success : function(executeResponseXML) { 183 | /* 184 | * create the executeResponse as JavaScript object 185 | */ 186 | var executeResponse = new ExecuteResponse_v1_xml( 187 | executeResponseXML); 188 | 189 | /* 190 | * call callback function and pass executeResponse-object as 191 | * argument 192 | */ 193 | callbackFunction(executeResponse); 194 | } 195 | }); 196 | }, 197 | 198 | /** 199 | * WPS 2.0 getStatus operation to retrieve the status of an executed job 200 | * 201 | * Not usable with WPS 1.0 202 | * 203 | * @callbackFunction a callback function that will be triggered with the 204 | * parsed StatusInfo document as argument 205 | * @jobId the ID of the asynchronously executed job 206 | */ 207 | getStatus_WPS_2_0 : function(callbackFunction, jobId) { 208 | if (this.settings.version === WPS_VERSION_2_0_0) { 209 | var getStatusRequest; 210 | 211 | getStatusRequest = new GetStatusGetRequest({ 212 | url : this.settings.url, 213 | version : this.settings.version, 214 | jobId : jobId 215 | }); 216 | 217 | getStatusRequest.execute(callbackFunction); 218 | } 219 | else{ 220 | /* 221 | * not supported for WPS 1.0 222 | */ 223 | throw "Get Status operation is only supported for WPS 2.0!"; 224 | } 225 | }, 226 | 227 | /** 228 | * WPS 2.0 getStatus operation to retrieve the status of an executed job 229 | * 230 | * Not usable with WPS 1.0 231 | * 232 | * @callbackFunction a callback function that will be triggered with the 233 | * parsed StatusInfo document as argument 234 | * @jobId the ID of the asynchronously executed job 235 | */ 236 | getResult_WPS_2_0 : function(callbackFunction, jobId) { 237 | if (this.settings.version === WPS_VERSION_2_0_0) { 238 | var getResultRequest; 239 | 240 | getResultRequest = new GetResultGetRequest({ 241 | url : this.settings.url, 242 | version : this.settings.version, 243 | jobId : jobId 244 | }); 245 | 246 | getResultRequest.execute(callbackFunction); 247 | } 248 | else{ 249 | /* 250 | * not supported for WPS 1.0 251 | */ 252 | throw "Get Result operation is only supported for WPS 2.0!"; 253 | } 254 | }, 255 | 256 | /** 257 | * WPS execute request via HTTP POST 258 | * 259 | * @processIdentifier the identifier of the process 260 | * @responseFormat either "raw" or "document", default is "document" 261 | * @executionMode either "sync" or "async"; 262 | * @lineage only relevant for WPS 1.0; boolean, if "true" then returned 263 | * response will include original input and output definition 264 | * @inputs an array of needed Input objects, use JS-object InputGenerator to 265 | * create inputs 266 | * @outputs an array of requested Output objects, use JS-object 267 | * OutputGenerator to create inputs 268 | */ 269 | getXmlRequestExecuteProcess : function (processIdentifier , responseFormat , executionMode, 270 | lineage , inputs , outputs ) { 271 | var executeRequest; 272 | 273 | if (this.settings.version === WPS_VERSION_1_0_0) { 274 | executeRequest = new ExecuteRequest_v1({ 275 | url: this.settings.url, 276 | version: this.settings.version, 277 | processIdentifier: processIdentifier, 278 | responseFormat: responseFormat, 279 | executionMode: executionMode, 280 | lineage: lineage, 281 | inputs: inputs, 282 | outputs: outputs 283 | }); 284 | } else { 285 | executeRequest = new ExecuteRequest_v2({ 286 | url: this.settings.url, 287 | version: this.settings.version, 288 | processIdentifier: processIdentifier, 289 | responseFormat: responseFormat, 290 | executionMode: executionMode, 291 | inputs: inputs, 292 | outputs: outputs 293 | }); 294 | } 295 | 296 | return executeRequest.createPostPayload(); 297 | } 298 | 299 | }); 300 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/lib/Class.js: -------------------------------------------------------------------------------- 1 | /* Simple JavaScript Inheritance 2 | * By John Resig http://ejohn.org/ 3 | * MIT Licensed. 4 | */ 5 | // Inspired by base2 and Prototype 6 | (function() { 7 | var initializing = false, fnTest = /xyz/.test(function() { 8 | xyz; 9 | }) ? /\b_super\b/ : /.*/; 10 | 11 | // The base Class implementation (does nothing) 12 | this.Class = function() { 13 | }; 14 | 15 | // Create a new Class that inherits from this class 16 | Class.extend = function(prop) { 17 | var _super = this.prototype; 18 | 19 | // Instantiate a base class (but only create the instance, 20 | // don't run the init constructor) 21 | initializing = true; 22 | var prototype = new this(); 23 | initializing = false; 24 | 25 | // Copy the properties over onto the new prototype 26 | for ( var name in prop) { 27 | // Check if we're overwriting an existing function 28 | prototype[name] = typeof prop[name] == "function" 29 | && typeof _super[name] == "function" 30 | && fnTest.test(prop[name]) ? (function(name, fn) { 31 | return function() { 32 | var tmp = this._super; 33 | 34 | // Add a new ._super() method that is the same method 35 | // but on the super-class 36 | this._super = _super[name]; 37 | 38 | // The method only need to be bound temporarily, so we 39 | // remove it when we're done executing 40 | var ret = fn.apply(this, arguments); 41 | this._super = tmp; 42 | 43 | return ret; 44 | }; 45 | })(name, prop[name]) : prop[name]; 46 | } 47 | 48 | // The dummy class constructor 49 | function Class() { 50 | // All construction is actually done in the init method 51 | if (!initializing && this.init) 52 | this.init.apply(this, arguments); 53 | } 54 | 55 | // Populate our constructed prototype object 56 | Class.prototype = prototype; 57 | 58 | // Enforce the constructor to be what we expect 59 | Class.prototype.constructor = Class; 60 | 61 | // And make this class extendable 62 | Class.extend = arguments.callee; 63 | 64 | return Class; 65 | }; 66 | })(); 67 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/request/BaseRequest.js: -------------------------------------------------------------------------------- 1 | var BaseRequest = Class.extend({ 2 | init : function(settings) { 3 | this.settings = settings; 4 | 5 | this.addRequestTypeToSettings(); 6 | }, 7 | 8 | addRequestTypeToSettings: function(){ 9 | //override this method to add a request type to the settings object 10 | }, 11 | 12 | getSettings : function() { 13 | return this.settings; 14 | }, 15 | 16 | execute : function(callback) { 17 | /* 18 | * define a callback which gets called after finishing the request 19 | */ 20 | this.callback = callback; 21 | 22 | this.preRequestExecution(); 23 | 24 | this.executeHTTPRequest(this.prepareHTTPRequest()); 25 | 26 | this.postRequestExecution(); 27 | }, 28 | 29 | preRequestExecution : function() { 30 | }, 31 | 32 | postRequestExecution : function() { 33 | 34 | }, 35 | 36 | processResponse : function(xml) { 37 | 38 | }, 39 | 40 | prepareHTTPRequest : function() { 41 | return null; 42 | }, 43 | 44 | executeHTTPRequest : function(requestSettings) { 45 | /* 46 | * we need 'self' as 'this' is different in the anonymous callbacks 47 | */ 48 | var self = this; 49 | 50 | var combinedRequestSettings = jQuery.extend({ 51 | success : function(responseData) { 52 | /* 53 | * create an appropriate response document (which depends on the 54 | * request type) 55 | */ 56 | var respFactory = new ResponseFactory(); 57 | var response = respFactory.resolveResponseHandler(responseData, 58 | self); 59 | 60 | /* 61 | * if a callback function has been defined, then call it with 62 | * the response object 63 | */ 64 | if (self.callback) { 65 | self.callback(response); 66 | } 67 | 68 | return response; 69 | }, 70 | error : function(jqXHR, textStatus, errorThrown) { 71 | /* 72 | * error handling, return textStatus and errorThrown as new 73 | * object 74 | */ 75 | 76 | var errorResponse = { 77 | textStatus : textStatus, 78 | errorThrown : jqXHR.responseText 79 | } 80 | 81 | /* 82 | * if a callback function has been defined, then call it with 83 | * the response object 84 | */ 85 | if (self.callback) { 86 | self.callback(errorResponse); 87 | } 88 | 89 | } 90 | }, requestSettings); 91 | 92 | var targetUrl; 93 | if (USE_PROXY) { 94 | if (PROXY_TYPE == "parameter") { 95 | targetUrl = PROXY_URL + encodeURIComponent(this.settings.url); 96 | } else { 97 | // TODO split URL into host-base + query and create new 98 | targetUrl = this.settings.url; 99 | } 100 | } else { 101 | targetUrl = this.settings.url; 102 | } 103 | jQuery.ajax(targetUrl, combinedRequestSettings); 104 | } 105 | }); 106 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/request/DescribeProcessGetRequest.js: -------------------------------------------------------------------------------- 1 | 2 | var DescribeProcessGetRequest = GetRequest.extend({ 3 | 4 | addRequestTypeToSettings : function() { 5 | 6 | // set new requestType parameter to a fixed value from Constants.js 7 | this.settings.requestType = DESCRIBE_PROCESS_TYPE; 8 | }, 9 | 10 | createTargetUrlQuery : function() { 11 | var result = "request=DescribeProcess&identifier="+this.settings.processIdentifier; 12 | 13 | return result; 14 | } 15 | 16 | }); 17 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/request/DescribeProcessPostRequest.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | var DescribeProcessPostRequest = PostRequest.extend({ 5 | 6 | addRequestTypeToSettings : function() { 7 | 8 | // set new requestType parameter to a fixed value from Constants.js 9 | this.settings.requestType = DESCRIBE_PROCESS_TYPE; 10 | }, 11 | 12 | createPostPayload : function() { 13 | 14 | var DESCRIBE_PROCESS_POST = ""; 15 | var processIdentifier = this.settings.processIdentifier; 16 | var serviceVersion = this.settings.version; 17 | 18 | if(serviceVersion == WPS_VERSION_1_0_0) 19 | DESCRIBE_PROCESS_POST = '\ 24 | ' + processIdentifier + '\ 25 | '; 26 | 27 | else 28 | DESCRIBE_PROCESS_POST = '\ 34 | ' + processIdentifier + '\ 35 | '; 36 | 37 | return DESCRIBE_PROCESS_POST; 38 | } 39 | 40 | }); 41 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/request/ExecuteRequest.js: -------------------------------------------------------------------------------- 1 | /* 2 | * the following variables define XML templates that will be instantiated 3 | * during request building! 4 | * 5 | * in child classes they should be overridden to reflect the correct 6 | * WPS version POST request 7 | */ 8 | 9 | var EXECUTE_REQUEST_XML_START = ' \ 16 | ${processIdentifier}\ 17 | \ 18 | ${dataInputs}\ 19 | \ 20 | ${responseForm}\ 21 | '; 22 | 23 | var EXECUTE_REQUEST_XML_COMPLEX_DATA_ALL_INPUT = '\ 24 | ${identifier}\ 25 | \ 26 | \ 27 | ${complexPayload}\ 28 | \ 29 | \ 30 | '; 31 | 32 | var EXECUTE_REQUEST_XML_COMPLEX_DATA_MIME_TYPE_INPUT = '\ 33 | ${identifier}\ 34 | \ 35 | \ 36 | ${complexPayload}\ 37 | \ 38 | \ 39 | '; 40 | 41 | var EXECUTE_REQUEST_XML_COMPLEX_DATA_SCHEMA_INPUT = '\ 42 | ${identifier}\ 43 | \ 44 | \ 45 | ${complexPayload}\ 46 | \ 47 | \ 48 | '; 49 | 50 | var EXECUTE_REQUEST_XML_COMPLEX_DATA_ENCODING_INPUT = '\ 51 | ${identifier}\ 52 | \ 53 | \ 54 | ${complexPayload}\ 55 | \ 56 | \ 57 | '; 58 | 59 | var EXECUTE_REQUEST_XML_COMPLEX_DATA_BY_REFERENCE_ALL_INPUT = '\ 60 | ${identifier}\ 61 | \ 63 | '; 64 | 65 | var EXECUTE_REQUEST_XML_COMPLEX_DATA_BY_REFERENCE_SCHEMA_INPUT = '\ 66 | ${identifier}\ 67 | \ 69 | '; 70 | 71 | var EXECUTE_REQUEST_XML_COMPLEX_DATA_BY_REFERENCE_ENCODING_INPUT = '\ 72 | ${identifier}\ 73 | \ 75 | '; 76 | 77 | var EXECUTE_REQUEST_XML_COMPLEX_DATA_BY_REFERENCE_INPUT = '\ 78 | ${identifier}\ 79 | \ 81 | '; 82 | 83 | var EXECUTE_REQUEST_XML_LITERAL_DATA_INPUT_TYPE = '\ 84 | ${identifier}\ 85 | \ 86 | ${value}\ 87 | \ 88 | '; 89 | 90 | var EXECUTE_REQUEST_XML_LITERAL_DATA_INPUT_ALL = '\ 91 | ${identifier}\ 92 | \ 93 | ${value}\ 94 | \ 95 | '; 96 | 97 | var EXECUTE_REQUEST_XML_LITERAL_DATA_NO_TYPE_INPUT = '\ 98 | ${identifier}\ 99 | \ 100 | ${value}\ 101 | \ 102 | '; 103 | 104 | var EXECUTE_REQUEST_XML_BOUNDING_BOX_INPUT = '\ 105 | ${identifier}\ 106 | \ 107 | \ 108 | ${lowerCorner}\ 109 | ${upperCorner}\ 110 | \ 111 | \ 112 | '; 113 | 114 | var EXECUTE_REQUEST_XML_RESPONSE_FORM_RAW_ALL = '\ 115 | \ 117 | ${identifier}\ 118 | \ 119 | '; 120 | 121 | var EXECUTE_REQUEST_XML_RESPONSE_FORM_RAW_TYPE_ENCODING_UOM = '\ 122 | \ 124 | ${identifier}\ 125 | \ 126 | '; 127 | 128 | var EXECUTE_REQUEST_XML_RESPONSE_FORM_RAW_TYPE_UOM = '\ 129 | \ 131 | ${identifier}\ 132 | \ 133 | '; 134 | 135 | var EXECUTE_REQUEST_XML_RESPONSE_FORM_RAW_TYPE = '\ 136 | \ 137 | ${identifier}\ 138 | \ 139 | '; 140 | 141 | var EXECUTE_REQUEST_XML_RESPONSE_FORM_DOCUMENT = '\ 142 | \ 144 | ${outputs}\ 145 | \ 146 | '; 147 | 148 | var EXECUTE_REQUEST_XML_COMPLEX_ALL_OUTPUT = '\ 150 | ${identifier}\ 151 | '; 152 | 153 | var EXECUTE_REQUEST_XML_COMPLEX_OUTPUT = '\ 155 | ${identifier}\ 156 | '; 157 | 158 | var EXECUTE_REQUEST_XML_COMPLEX_MIME_TYPE_OUTPUT = '\ 160 | ${identifier}\ 161 | '; 162 | 163 | var EXECUTE_REQUEST_XML_COMPLEX_SCHEMA_OUTPUT = '\ 165 | ${identifier}\ 166 | '; 167 | 168 | var EXECUTE_REQUEST_XML_COMPLEX_ENCODING_OUTPUT = '\ 170 | ${identifier}\ 171 | '; 172 | 173 | var EXECUTE_REQUEST_XML_LITERAL_OUTPUT = '\ 174 | ${identifier}\ 175 | '; 176 | 177 | var ExecuteRequest = PostRequest.extend({ 178 | 179 | addRequestTypeToSettings : function() { 180 | 181 | // set new requestType parameter to a fixed value from Constants.js 182 | this.settings.requestType = EXECUTE_TYPE; 183 | }, 184 | 185 | createPostPayload : function() { 186 | 187 | /* 188 | * used to reset all templates to reflect differences in different WPS version. 189 | */ 190 | this.overrideTemplates(); 191 | 192 | /* 193 | * used to analyze the given request parameters and, if needed, 194 | * add additional parameters to properly instantiate the templates. 195 | */ 196 | this.addVersionDependentProperties(); 197 | 198 | /** 199 | * instantiate templates 200 | */ 201 | return this.fillTemplates(); 202 | }, 203 | 204 | /** 205 | * will adjust the templates stored in aforementioned variables to reflect 206 | * the WPS version dependent execute request POST body 207 | */ 208 | overrideTemplates : function(){ 209 | /* 210 | * override in child methods 211 | */ 212 | }, 213 | 214 | 215 | /** 216 | * used to analyze the given request parameters and, if needed, 217 | * add additional parameters to properly instantiate the 218 | * templates. 219 | */ 220 | addVersionDependentProperties : function(){ 221 | /* 222 | * override in child methods 223 | */ 224 | 225 | /* 226 | * inspect missing values and instantiate with defaults 227 | */ 228 | if (!this.settings.executionMode) 229 | this.settings.executionMode = "async"; 230 | 231 | if (!this.settings.responseFormat) 232 | this.settings.responseFormat = "document"; 233 | }, 234 | 235 | /** 236 | * add certain parameters, if necessary, to the given object 237 | */ 238 | addVersionDependentPropertiesToFinalExecuteProperties : function(finalExecuteProperties){ 239 | /* 240 | * override in child classes 241 | */ 242 | return finalExecuteProperties; 243 | }, 244 | 245 | /** 246 | * instantiate all templates and concat them to create the POST body 247 | */ 248 | fillTemplates : function(){ 249 | var inputs = this.settings.inputs; 250 | var outputs = this.settings.outputs; 251 | 252 | var dataInputsMarkup = ""; 253 | if (inputs) { 254 | dataInputsMarkup = this.createDataInputsMarkup(inputs); 255 | } 256 | 257 | var responseFormMarkup = ""; 258 | if (outputs) { 259 | responseFormMarkup = this.createResponseFormMarkup(outputs, this.settings.outputStyle); 260 | } 261 | 262 | var finalExecuteProperties = { 263 | processIdentifier: this.settings.processIdentifier, 264 | dataInputs: dataInputsMarkup, 265 | responseForm: responseFormMarkup 266 | }; 267 | 268 | finalExecuteProperties = this.addVersionDependentPropertiesToFinalExecuteProperties(finalExecuteProperties); 269 | 270 | var result = this.fillTemplate(EXECUTE_REQUEST_XML_START, finalExecuteProperties); 271 | 272 | return result; 273 | }, 274 | 275 | createDataInputsMarkup : function(inputs) { 276 | var result = ""; 277 | for (var i = 0; i < inputs.length; i++) { 278 | var markup = ""; 279 | if (equalsString("literal", inputs[i].type)) { 280 | markup = this.createLiteralDataInput(inputs[i]); 281 | } 282 | else if (equalsString("complex", inputs[i].type)) { 283 | markup = this.createComplexDataInput(inputs[i]); 284 | } 285 | else if (equalsString("bbox", inputs[i].type)) { 286 | markup = this.createBoundingBoxDataInput(inputs[i]); 287 | } 288 | result += markup; 289 | } 290 | 291 | return result; 292 | }, 293 | 294 | /* 295 | * example 'input' objects: 296 | * 297 | * { 298 | * identifier: "theInputId", 299 | * value: "10.0", 300 | * dataType: "xs:double" 301 | * } 302 | * 303 | * { 304 | * identifier: "theInputId", 305 | * value: "myStringValue" 306 | * } 307 | * 308 | */ 309 | createLiteralDataInput : function(input) { 310 | var markup; 311 | if (input.dataType) { 312 | if(input.uom) 313 | markup = this.fillTemplate(EXECUTE_REQUEST_XML_LITERAL_DATA_INPUT_ALL, input); 314 | else 315 | markup = this.fillTemplate(EXECUTE_REQUEST_XML_LITERAL_DATA_INPUT_TYPE, input); 316 | } 317 | else { 318 | markup = this.fillTemplate(EXECUTE_REQUEST_XML_LITERAL_DATA_NO_TYPE_INPUT, input); 319 | } 320 | 321 | return markup; 322 | }, 323 | 324 | /* 325 | * example 'input' objects: 326 | * 327 | * { 328 | * identifier: "theProcessId", 329 | * schema: "http://schema.xsd.url", 330 | * complexPayload: "" 331 | * } 332 | * 333 | * { 334 | * identifier: "theProcessId", 335 | * schema: "http://schema.xsd.url", 336 | * href: "http://the.online.resource", 337 | * method: "GET" 338 | * } 339 | * 340 | */ 341 | createComplexDataInput : function(input) { 342 | var markup; 343 | if (input.asReference) { 344 | if (input.schema && input.encoding) { 345 | markup = this.fillTemplate(EXECUTE_REQUEST_XML_COMPLEX_DATA_BY_REFERENCE_ALL_INPUT, input); 346 | } 347 | 348 | else if (input.schema && !input.encoding) { 349 | markup = this.fillTemplate(EXECUTE_REQUEST_XML_COMPLEX_DATA_BY_REFERENCE_SCHEMA_INPUT, input); 350 | } 351 | 352 | else if (!input.schema && input.encoding) { 353 | markup = this.fillTemplate(EXECUTE_REQUEST_XML_COMPLEX_DATA_BY_REFERENCE_ENCODING_INPUT, input); 354 | } 355 | 356 | else { 357 | markup = this.fillTemplate(EXECUTE_REQUEST_XML_COMPLEX_DATA_BY_REFERENCE_INPUT, input); 358 | } 359 | } 360 | else { 361 | if (input.schema && input.encoding) { 362 | markup = this.fillTemplate(EXECUTE_REQUEST_XML_COMPLEX_DATA_ALL_INPUT, input); 363 | } 364 | 365 | else if (input.schema && !input.encoding) { 366 | markup = this.fillTemplate(EXECUTE_REQUEST_XML_COMPLEX_DATA_SCHEMA_INPUT, input); 367 | } 368 | 369 | else if (!input.schema && input.encoding) { 370 | markup = this.fillTemplate(EXECUTE_REQUEST_XML_COMPLEX_DATA_ENCODING_INPUT, input); 371 | } 372 | 373 | else { 374 | markup = this.fillTemplate(EXECUTE_REQUEST_XML_COMPLEX_DATA_MIME_TYPE_INPUT, input); 375 | } 376 | } 377 | 378 | return markup; 379 | }, 380 | 381 | /* 382 | * example 'input' objects: 383 | * 384 | * { 385 | * identifier: "theInputId", 386 | * crs: "EPSG:4236", 387 | * dimension: 2, 388 | * lowerCorner: "-10.0 40.5", 389 | * upperCorner: "20.4 65.3", 390 | * } 391 | * 392 | * { 393 | * identifier: "theInputId", 394 | * value: "myStringValue" 395 | * } 396 | * 397 | */ 398 | createBoundingBoxDataInput : function(input) { 399 | /* 400 | * set some default values 401 | */ 402 | if (!input.crs) { 403 | input.crs = "EPSG:4326"; 404 | } 405 | 406 | if (!input.dimension) { 407 | input.dimension = 2; 408 | } 409 | 410 | var markup = this.fillTemplate(EXECUTE_REQUEST_XML_BOUNDING_BOX_INPUT, input); 411 | 412 | return markup; 413 | }, 414 | 415 | /* 416 | * example 'outputStyle' objects: 417 | * 418 | * { 419 | * storeExecuteResponse: true, 420 | * lineage: false, 421 | * status: true 422 | * } 423 | * 424 | * example 'outputs' objects: 425 | * 426 | * [ 427 | * { 428 | * identifier: "myComplexOutput1", 429 | * type: "complex", 430 | * asReference:false, 431 | * mimeType: "text/xml", 432 | * schema:"http://schemas.opengis.net/gml/3.1.1/base/gml.xsd", 433 | * encoding: "UTF-8" 434 | * }, 435 | * { 436 | * identifier: "myLiteralOutput1", 437 | * type: "literal" 438 | * } 439 | * ] 440 | * 441 | */ 442 | createResponseFormMarkup : function(outputs, outputStyle) { 443 | var outputString = ""; 444 | var result; 445 | 446 | if(this.settings.responseFormat == "raw" && outputs.length == 1){ 447 | /* 448 | * raw output requested, only one output allowed. So take the first one. 449 | */ 450 | var rawOutput = outputs[0]; 451 | 452 | if (rawOutput.encoding && rawOutput.schema && rawOutput.mimeType && rawOutput.uom){ 453 | result = this.fillTemplate(EXECUTE_REQUEST_XML_RESPONSE_FORM_RAW_ALL, rawOutput); 454 | } 455 | else if (rawOutput.encoding && rawOutput.mimeType && rawOutput.uom){ 456 | result = this.fillTemplate(EXECUTE_REQUEST_XML_RESPONSE_FORM_RAW_TYPE_ENCODING_UOM, rawOutput); 457 | } 458 | else if (rawOutput.mimeType && rawOutput.uom){ 459 | result = this.fillTemplate(EXECUTE_REQUEST_XML_RESPONSE_FORM_RAW_TYPE_UOM, rawOutput); 460 | } 461 | else { 462 | result = this.fillTemplate(EXECUTE_REQUEST_XML_RESPONSE_FORM_RAW_TYPE, rawOutput); 463 | } 464 | 465 | } 466 | else{ 467 | /* 468 | * response document with additional attributes and multiple outputs! 469 | */ 470 | for (var i = 0; i < outputs.length; i++) { 471 | if (equalsString("literal", outputs[i].type)) { 472 | outputString += this.fillTemplate(EXECUTE_REQUEST_XML_LITERAL_OUTPUT, outputs[i]); 473 | } 474 | else { 475 | if (outputs[i].encoding && outputs[i].schema && outputs[i].mimeType) { 476 | outputString += this.fillTemplate(EXECUTE_REQUEST_XML_COMPLEX_ALL_OUTPUT, outputs[i]); 477 | } 478 | 479 | else if (outputs[i].encoding && !outputs[i].schema && outputs[i].mimeType) { 480 | outputString += this.fillTemplate(EXECUTE_REQUEST_XML_COMPLEX_ENCODING_OUTPUT, outputs[i]); 481 | } 482 | 483 | else if (!outputs[i].encoding && outputs[i].schema && outputs[i].mimeType) { 484 | outputString += this.fillTemplate(EXECUTE_REQUEST_XML_COMPLEX_SCHEMA_OUTPUT, outputs[i]); 485 | } 486 | 487 | else if (outputs[i].mimeType){ 488 | outputString += this.fillTemplate(EXECUTE_REQUEST_XML_COMPLEX_MIME_TYPE_OUTPUT, outputs[i]); 489 | } 490 | else{ 491 | outputString += this.fillTemplate(EXECUTE_REQUEST_XML_COMPLEX_OUTPUT, outputs[i]); 492 | } 493 | } 494 | } 495 | 496 | outputStyle.outputs = outputString; 497 | 498 | result = this.fillTemplate(EXECUTE_REQUEST_XML_RESPONSE_FORM_DOCUMENT, outputStyle); 499 | } 500 | 501 | return result; 502 | } 503 | 504 | }); 505 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/request/ExecuteRequest_v1.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | var ExecuteRequest_v1 = ExecuteRequest 5 | .extend({ 6 | 7 | /** 8 | * will adjust the templates stored in ExecuteRequest.js file to 9 | * reflect the WPS 1.0 request POST body 10 | */ 11 | overrideTemplates : function() { 12 | EXECUTE_REQUEST_XML_START = ' \ 19 | ${processIdentifier}\ 20 | \ 21 | ${dataInputs}\ 22 | \ 23 | ${responseForm}\ 24 | '; 25 | 26 | EXECUTE_REQUEST_XML_COMPLEX_DATA_ALL_INPUT = '\ 27 | ${identifier}\ 28 | \ 29 | \ 30 | ${complexPayload}\ 31 | \ 32 | \ 33 | '; 34 | 35 | EXECUTE_REQUEST_XML_COMPLEX_DATA_MIME_TYPE_INPUT = '\ 36 | ${identifier}\ 37 | \ 38 | \ 39 | ${complexPayload}\ 40 | \ 41 | \ 42 | '; 43 | 44 | EXECUTE_REQUEST_XML_COMPLEX_DATA_SCHEMA_INPUT = '\ 45 | ${identifier}\ 46 | \ 47 | \ 48 | ${complexPayload}\ 49 | \ 50 | \ 51 | '; 52 | 53 | EXECUTE_REQUEST_XML_COMPLEX_DATA_ENCODING_INPUT = '\ 54 | ${identifier}\ 55 | \ 56 | \ 57 | ${complexPayload}\ 58 | \ 59 | \ 60 | '; 61 | 62 | EXECUTE_REQUEST_XML_COMPLEX_DATA_BY_REFERENCE_ALL_INPUT = '\ 63 | ${identifier}\ 64 | \ 66 | '; 67 | 68 | EXECUTE_REQUEST_XML_COMPLEX_DATA_BY_REFERENCE_SCHEMA_INPUT = '\ 69 | ${identifier}\ 70 | \ 72 | '; 73 | 74 | EXECUTE_REQUEST_XML_COMPLEX_DATA_BY_REFERENCE_ENCODING_INPUT = '\ 75 | ${identifier}\ 76 | \ 78 | '; 79 | 80 | EXECUTE_REQUEST_XML_COMPLEX_DATA_BY_REFERENCE_INPUT = '\ 81 | ${identifier}\ 82 | \ 84 | '; 85 | 86 | EXECUTE_REQUEST_XML_LITERAL_DATA_INPUT_TYPE = '\ 87 | ${identifier}\ 88 | \ 89 | ${value}\ 90 | \ 91 | '; 92 | 93 | EXECUTE_REQUEST_XML_LITERAL_DATA_INPUT_ALL = '\ 94 | ${identifier}\ 95 | \ 96 | ${value}\ 97 | \ 98 | '; 99 | 100 | EXECUTE_REQUEST_XML_LITERAL_DATA_NO_TYPE_INPUT = '\ 101 | ${identifier}\ 102 | \ 103 | ${value}\ 104 | \ 105 | '; 106 | 107 | EXECUTE_REQUEST_XML_BOUNDING_BOX_INPUT = '\ 108 | ${identifier}\ 109 | \ 110 | \ 111 | ${lowerCorner}\ 112 | ${upperCorner}\ 113 | \ 114 | \ 115 | '; 116 | 117 | EXECUTE_REQUEST_XML_RESPONSE_FORM_RAW_ALL = '\ 118 | \ 120 | ${identifier}\ 121 | \ 122 | '; 123 | 124 | EXECUTE_REQUEST_XML_RESPONSE_FORM_RAW_TYPE_ENCODING_UOM = '\ 125 | \ 127 | ${identifier}\ 128 | \ 129 | '; 130 | 131 | EXECUTE_REQUEST_XML_RESPONSE_FORM_RAW_TYPE_UOM = '\ 132 | \ 134 | ${identifier}\ 135 | \ 136 | '; 137 | 138 | EXECUTE_REQUEST_XML_RESPONSE_FORM_RAW_TYPE = '\ 139 | \ 140 | ${identifier}\ 141 | \ 142 | '; 143 | 144 | EXECUTE_REQUEST_XML_RESPONSE_FORM_DOCUMENT = '\ 145 | \ 147 | ${outputs}\ 148 | \ 149 | '; 150 | 151 | EXECUTE_REQUEST_XML_COMPLEX_ALL_OUTPUT = '\ 153 | ${identifier}\ 154 | '; 155 | 156 | EXECUTE_REQUEST_XML_COMPLEX_OUTPUT = '\ 158 | ${identifier}\ 159 | '; 160 | 161 | EXECUTE_REQUEST_XML_COMPLEX_MIME_TYPE_OUTPUT = '\ 163 | ${identifier}\ 164 | '; 165 | 166 | EXECUTE_REQUEST_XML_COMPLEX_SCHEMA_OUTPUT = '\ 168 | ${identifier}\ 169 | '; 170 | 171 | EXECUTE_REQUEST_XML_COMPLEX_ENCODING_OUTPUT = '\ 173 | ${identifier}\ 174 | '; 175 | 176 | EXECUTE_REQUEST_XML_LITERAL_OUTPUT = '\ 177 | ${identifier}\ 178 | '; 179 | }, 180 | 181 | /** 182 | * used to analyze the given request parameters and, if needed, add 183 | * additional parameters to properly instantiate the templates. 184 | */ 185 | addVersionDependentProperties : function() { 186 | 187 | if (!this.settings.executionMode) 188 | this.settings.executionMode = "async"; 189 | 190 | if (!this.settings.responseFormat) 191 | this.settings.responseFormat = "document"; 192 | 193 | /* 194 | * add an explicit outputStyle object 195 | */ 196 | 197 | this.settings.outputStyle = new Object(); 198 | if (this.settings.executionMode == "async") { 199 | /* 200 | * if execution mode is set to async, then we imply that 201 | * response must be stored on the server and that there 202 | * shall be status updates to enable status queries 203 | */ 204 | this.settings.storeExecuteResponse = true; 205 | this.settings.status = true; 206 | } else 207 | this.settings.storeExecuteResponse = false; 208 | 209 | this.settings.outputStyle.lineage = false; 210 | if (this.settings.lineage == true) 211 | this.settings.outputStyle.lineage = true; 212 | 213 | this.settings.outputStyle.storeExecuteResponse = false; 214 | if (this.settings.storeExecuteResponse == true) 215 | this.settings.outputStyle.storeExecuteResponse = true; 216 | 217 | this.settings.outputStyle.status = false; 218 | if (this.settings.status == true) 219 | this.settings.outputStyle.status = true; 220 | 221 | }, 222 | 223 | /** 224 | * add certain parameters, if necessary, to the given object 225 | */ 226 | addVersionDependentPropertiesToFinalExecuteProperties : function( 227 | finalExecuteProperties) { 228 | /* 229 | * for WPS 1.0 we do not have to add anything! 230 | */ 231 | return finalExecuteProperties; 232 | } 233 | 234 | }); -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/request/ExecuteRequest_v2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | var ExecuteRequest_v2 = ExecuteRequest 5 | .extend({ 6 | 7 | /** 8 | * will adjust the templates stored in ExecuteRequest.js file to 9 | * reflect the WPS 2.0 request POST body 10 | */ 11 | overrideTemplates : function() { 12 | 13 | /* 14 | * TODO ${responseForm} might be changed in WPS 2.0! check that! 15 | */ 16 | EXECUTE_REQUEST_XML_START = ' \ 24 | ${processIdentifier}\ 25 | ${dataInputs}\ 26 | ${responseForm}\ 27 | '; 28 | 29 | EXECUTE_REQUEST_XML_COMPLEX_DATA_ALL_INPUT = '\ 30 | \ 31 | ${complexPayload}\ 32 | \ 33 | '; 34 | 35 | EXECUTE_REQUEST_XML_COMPLEX_DATA_MIME_TYPE_INPUT = '\ 36 | \ 37 | ${complexPayload}\ 38 | \ 39 | '; 40 | 41 | EXECUTE_REQUEST_XML_COMPLEX_DATA_SCHEMA_INPUT = '\ 42 | \ 43 | ${complexPayload}\ 44 | \ 45 | '; 46 | 47 | EXECUTE_REQUEST_XML_COMPLEX_DATA_ENCODING_INPUT = '\ 48 | \ 49 | ${complexPayload}\ 50 | \ 51 | '; 52 | 53 | EXECUTE_REQUEST_XML_COMPLEX_DATA_BY_REFERENCE_ALL_INPUT = '\ 54 | \ 56 | '; 57 | 58 | EXECUTE_REQUEST_XML_COMPLEX_DATA_BY_REFERENCE_SCHEMA_INPUT = '\ 59 | \ 61 | '; 62 | 63 | EXECUTE_REQUEST_XML_COMPLEX_DATA_BY_REFERENCE_ENCODING_INPUT = '\ 64 | \ 66 | '; 67 | 68 | EXECUTE_REQUEST_XML_COMPLEX_DATA_BY_REFERENCE_INPUT = '\ 69 | \ 70 | '; 71 | /* 72 | * These are the CORRECT values, currently the 52N WPS is 73 | * implemented wrongly wrt literalValue 74 | * 75 | */ 76 | EXECUTE_REQUEST_XML_LITERAL_DATA_INPUT_TYPE = '\ 77 | \ 78 | ${value}\ 79 | \ 80 | '; 81 | 82 | EXECUTE_REQUEST_XML_LITERAL_DATA_INPUT_ALL = '\ 83 | \ 84 | ${value}\ 85 | \ 86 | '; 87 | 88 | EXECUTE_REQUEST_XML_LITERAL_DATA_NO_TYPE_INPUT = '\ 89 | \ 90 | ${value}\ 91 | \ 92 | '; 93 | 94 | /* 95 | * The follwing 3 are NOT CORRECT, but work currently with the 96 | * 52°North WPS 2.0, which contains a false implmenetation wrt 97 | * literalValues 98 | */ 99 | /* 100 | EXECUTE_REQUEST_XML_LITERAL_DATA_INPUT_TYPE = '\ 101 | \ 102 | ${value}\ 103 | \ 104 | '; 105 | 106 | EXECUTE_REQUEST_XML_LITERAL_DATA_INPUT_ALL = '\ 107 | \ 108 | ${value}\ 109 | \ 110 | '; 111 | 112 | EXECUTE_REQUEST_XML_LITERAL_DATA_NO_TYPE_INPUT = '\ 113 | \ 114 | ${value}\ 115 | \ 116 | '; 117 | */ 118 | EXECUTE_REQUEST_XML_BOUNDING_BOX_INPUT = '\ 119 | \ 120 | \ 121 | ${lowerCorner}\ 122 | ${upperCorner}\ 123 | \ 124 | \ 125 | '; 126 | 127 | /* 128 | * for WPS 2.0 there is no wrapping element around the outputs! 129 | */ 130 | EXECUTE_REQUEST_XML_RESPONSE_FORM_DOCUMENT = '${outputs}'; 131 | 132 | EXECUTE_REQUEST_XML_COMPLEX_ALL_OUTPUT = '\ 134 | '; 135 | 136 | EXECUTE_REQUEST_XML_COMPLEX_OUTPUT = '\ 138 | '; 139 | 140 | EXECUTE_REQUEST_XML_COMPLEX_MIME_TYPE_OUTPUT = '\ 142 | '; 143 | 144 | EXECUTE_REQUEST_XML_COMPLEX_SCHEMA_OUTPUT = '\ 146 | '; 147 | 148 | EXECUTE_REQUEST_XML_COMPLEX_ENCODING_OUTPUT = '\ 150 | '; 151 | 152 | EXECUTE_REQUEST_XML_LITERAL_OUTPUT = '\ 153 | '; 154 | 155 | /* 156 | * raw output 157 | * 158 | * in WPS 2.0 there is no special wrapping element for raw 159 | * outputs, hence we just use the already specified output 160 | * templates 161 | * 162 | * also in WPS 2.0 there is no specification of UOM anymore. so 163 | * simply ignore uom. 164 | */ 165 | EXECUTE_REQUEST_XML_RESPONSE_FORM_RAW_ALL = EXECUTE_REQUEST_XML_COMPLEX_ALL_OUTPUT; 166 | 167 | EXECUTE_REQUEST_XML_RESPONSE_FORM_RAW_TYPE_ENCODING_UOM = EXECUTE_REQUEST_XML_COMPLEX_ENCODING_OUTPUT; 168 | 169 | EXECUTE_REQUEST_XML_RESPONSE_FORM_RAW_TYPE_UOM = EXECUTE_REQUEST_XML_COMPLEX_MIME_TYPE_OUTPUT; 170 | 171 | EXECUTE_REQUEST_XML_RESPONSE_FORM_RAW_TYPE = EXECUTE_REQUEST_XML_COMPLEX_MIME_TYPE_OUTPUT; 172 | 173 | }, 174 | 175 | /** 176 | * used to analyze the given request parameters and, if needed, add 177 | * additional parameters to properly instantiate the templates. 178 | */ 179 | addVersionDependentProperties : function() { 180 | 181 | if (!this.settings.executionMode) 182 | this.settings.executionMode = "async"; 183 | 184 | if (!this.settings.responseFormat) 185 | this.settings.responseFormat = "document"; 186 | 187 | /* 188 | * needed object to properly instantiate the outputs 189 | * (responseForm template) 190 | */ 191 | this.settings.outputStyle = new Object(); 192 | 193 | }, 194 | 195 | /** 196 | * add certain parameters, if necessary, to the given object 197 | */ 198 | addVersionDependentPropertiesToFinalExecuteProperties : function( 199 | finalExecuteProperties) { 200 | /* 201 | * override in child classes 202 | */ 203 | 204 | finalExecuteProperties.responseFormat = this.settings.responseFormat; 205 | finalExecuteProperties.executionMode = this.settings.executionMode; 206 | 207 | return finalExecuteProperties; 208 | }, 209 | 210 | }); -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/request/GetCapabilitiesGetRequest.js: -------------------------------------------------------------------------------- 1 | var GetCapabilitiesGetRequest = GetRequest.extend({ 2 | 3 | addRequestTypeToSettings : function() { 4 | 5 | // set new requestType parameter to a fixed value from Constants.js 6 | this.settings.requestType = GET_CAPABILITIES_TYPE; 7 | }, 8 | 9 | createTargetUrlQuery : function() { 10 | return "request=GetCapabilities"; 11 | } 12 | 13 | }); 14 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/request/GetCapabilitiesPostRequest.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | var GetCapabilitiesPostRequest = PostRequest.extend({ 4 | 5 | addRequestTypeToSettings : function() { 6 | 7 | // set new requestType parameter to a fixed value from Constants.js 8 | this.settings.requestType = GET_CAPABILITIES_TYPE; 9 | }, 10 | 11 | createPostPayload : function() { 12 | var GET_CAPABILITIES_POST = ""; 13 | 14 | var serviceVersion = this.settings.version; 15 | 16 | if(serviceVersion == WPS_VERSION_1_0_0) 17 | GET_CAPABILITIES_POST = '\ 22 | \ 23 | ' + serviceVersion + '\ 24 | \ 25 | '; 26 | 27 | else{ 28 | GET_CAPABILITIES_POST = ' \ 34 | '; 35 | } 36 | 37 | return GET_CAPABILITIES_POST; 38 | } 39 | 40 | }); 41 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/request/GetRequest.js: -------------------------------------------------------------------------------- 1 | 2 | var GetRequest = BaseRequest.extend({ 3 | 4 | prepareHTTPRequest : function() { 5 | var targetUrl = this.settings.url; 6 | var targetUrlQuery = this.settings.urlQuery; 7 | 8 | //check for a query part 9 | if (!targetUrlQuery) { 10 | targetUrlQuery = this.createTargetUrlQuery(); 11 | } 12 | 13 | if (targetUrlQuery) { 14 | this.settings.url = this.buildTargetUrl(targetUrl, targetUrlQuery); 15 | } 16 | 17 | return { 18 | type : "GET" 19 | }; 20 | }, 21 | 22 | /* 23 | * overwrite this method to define specific behavior 24 | */ 25 | createTargetUrlQuery : function() { 26 | return null; 27 | }, 28 | 29 | buildTargetUrl : function(targetUrl, targetUrlQuery) { 30 | if (targetUrl.indexOf("?") == -1) { 31 | targetUrl += "?"; 32 | } 33 | 34 | if (targetUrl.indexOf("service=") == -1) { 35 | targetUrl += "service=WPS"; 36 | } 37 | 38 | if (targetUrl.indexOf("version=") == -1) { 39 | targetUrl += "&version=" + this.settings.version; 40 | } 41 | 42 | if (targetUrlQuery) { 43 | targetUrl += "&" + targetUrlQuery; 44 | } 45 | 46 | return encodeURI(targetUrl); 47 | } 48 | 49 | }); 50 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/request/GetResultGetRequest.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | var GetResultGetRequest = GetRequest.extend({ 5 | 6 | addRequestTypeToSettings : function() { 7 | 8 | // set new requestType parameter to a fixed value from Constants.js 9 | this.settings.requestType = GET_RESULT_TYPE; 10 | }, 11 | 12 | createTargetUrlQuery : function() { 13 | var result = "request=GetResult&jobId="+this.settings.jobId; 14 | 15 | return result; 16 | } 17 | 18 | }); -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/request/GetStatusGetRequest.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | var GetStatusGetRequest = GetRequest.extend({ 5 | 6 | addRequestTypeToSettings : function() { 7 | 8 | // set new requestType parameter to a fixed value from Constants.js 9 | this.settings.requestType = GET_STATUS_TYPE; 10 | }, 11 | 12 | createTargetUrlQuery : function() { 13 | var result = "request=GetStatus&jobId="+this.settings.jobId; 14 | 15 | return result; 16 | } 17 | 18 | }); -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/request/InputGenerator.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Helper class to construct input objects for execute requests against WPS 1.0 3 | * and 2.0 4 | */ 5 | var InputGenerator = Class 6 | .extend({ 7 | /** 8 | * 9 | */ 10 | init : function(settings) { 11 | this.settings = settings; 12 | }, 13 | 14 | /** 15 | * the following parameters are mandatory: identifier and value 16 | * 17 | * the rest might be set to 'undefined'! 18 | * 19 | * @identifier input identifier 20 | * @dataType data type of the input; may be 'undefined' 21 | * @uom unit of measure; may be 'undefined' 22 | * @value the literal value of the input 23 | */ 24 | createLiteralDataInput_wps_1_0_and_2_0 : function(identifier, dataType, 25 | uom, value) { 26 | var input = new Object({ 27 | type : "literal", 28 | identifier : identifier, 29 | dataType : dataType || undefined, 30 | uom : uom || undefined, 31 | value : value 32 | }); 33 | 34 | return input; 35 | }, 36 | 37 | /** 38 | * the following parameters are mandatory: identifier and 39 | * complexPayload 40 | * 41 | * the rest might be set to 'undefined'! 42 | * 43 | * @identifier input identifier 44 | * @mimeType MIME type of the input; may be 'undefined' 45 | * @schema reference to a schema; may be 'undefined' 46 | * @encoding encoding; may be 'undefined' 47 | * @complexPayload the complex payload (XML tags) as String 48 | * @asReference boolean, either "true" or "false", indicating 49 | * whether parameter body contains a URL as reference 50 | * to an external body or the actual POST body 51 | */ 52 | createComplexDataInput_wps_1_0_and_2_0 : function(identifier, 53 | mimeType, schema, encoding, asReference, complexPayload) { 54 | var input = new Object({ 55 | type : "complex", 56 | identifier : identifier, 57 | mimeType : mimeType || undefined, 58 | schema : schema || undefined, 59 | encoding : encoding || undefined, 60 | asReference : asReference || false, 61 | complexPayload : complexPayload 62 | }); 63 | 64 | return input; 65 | }, 66 | 67 | /** 68 | * the following parameters are mandatory: identifier, crs, 69 | * lowerCorner and upperCorner 70 | * 71 | * the rest might be set to 'undefined'! 72 | * 73 | * @identifier input identifier 74 | * @crs coordinate reference system URI 75 | * @dimension number of dimensions in this CRS 76 | * @lowerCorner orderedSequence of double values 77 | * @upperCorner orderedSequence of double values 78 | */ 79 | createBboxDataInput_wps_1_0_and_2_0 : function(identifier, crs, 80 | dimension, lowerCorner, upperCorner) { 81 | var input = new Object({ 82 | type : "bbox", 83 | identifier : identifier, 84 | crs : crs, 85 | dimension : dimension || undefined, 86 | lowerCorner : lowerCorner, 87 | upperCorner : upperCorner 88 | }); 89 | 90 | return input; 91 | }, 92 | 93 | }); -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/request/OutputGenerator.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Helper class to construct output objects for execute requests against WPS 1.0 3 | * and 2.0 4 | */ 5 | var OutputGenerator = Class.extend({ 6 | /** 7 | * 8 | */ 9 | init : function(settings) { 10 | this.settings = settings; 11 | }, 12 | 13 | /** 14 | * the following parameters are mandatory: identifier 15 | * 16 | * the rest might be set to 'undefined'! 17 | * 18 | * @identifier output identifier 19 | * @mimeType MIME type of the input; may be 'undefined' 20 | * @schema reference to a schema; may be 'undefined' 21 | * @encoding encoding; may be 'undefined' 22 | * @uom unit of measure; may be 'undefined' 23 | * @asReference boolean, "true" or "false" 24 | * @title new title 25 | * @abstractValue new description as text of the 'Abstract' element 26 | * of the response document 27 | */ 28 | createComplexOutput_WPS_1_0 : function(identifier, mimeType, schema, 29 | encoding, uom, asReference, title, abstractValue) { 30 | var output = new Object({ 31 | type : "complex", 32 | identifier : identifier, 33 | mimeType : mimeType || undefined, 34 | schema : schema || undefined, 35 | encoding : encoding || undefined, 36 | uom : uom || undefined, 37 | asReference : asReference || false, 38 | title : title || undefined, 39 | abstractValue : abstractValue || undefined 40 | }); 41 | 42 | return output; 43 | }, 44 | 45 | /** 46 | * the following parameters are mandatory: identifier 47 | * 48 | * @identifier output identifier 49 | * @asReference boolean, "true" or "false" 50 | */ 51 | createLiteralOutput_WPS_1_0 : function(identifier, asReference) { 52 | var output = new Object({ 53 | type : "literal", 54 | identifier : identifier, 55 | asReference : asReference || false 56 | }); 57 | 58 | return output; 59 | }, 60 | 61 | /** 62 | * the following parameters are mandatory: identifier and transmission 63 | * 64 | * the rest might be set to 'undefined'! 65 | * 66 | * @identifier output identifier 67 | * @mimeType MIME type of the input; may be 'undefined' 68 | * @schema reference to a schema; may be 'undefined' 69 | * @encoding encoding; may be 'undefined' 70 | * @transmission either "value" or "reference" 71 | */ 72 | createComplexOutput_WPS_2_0 : function(identifier, mimeType, schema, 73 | encoding, transmission) { 74 | var output = new Object({ 75 | type : "complex", 76 | identifier : identifier, 77 | mimeType : mimeType || undefined, 78 | schema : schema || undefined, 79 | encoding : encoding || undefined, 80 | transmission : transmission || "value" 81 | }); 82 | 83 | return output; 84 | }, 85 | 86 | /** 87 | * the following parameters are mandatory: identifier and transmission 88 | * 89 | * @identifier output identifier 90 | * @transmission either "value" or "reference" 91 | */ 92 | createLiteralOutput_WPS_2_0 : function(identifier, transmission) { 93 | var output = new Object({ 94 | type : "literal", 95 | identifier : identifier, 96 | transmission : transmission || "value" 97 | }); 98 | 99 | return output; 100 | } 101 | 102 | }); -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/request/PostRequest.js: -------------------------------------------------------------------------------- 1 | 2 | var PostRequest = BaseRequest.extend({ 3 | 4 | prepareHTTPRequest : function() { 5 | var payload = this.settings.data; 6 | if (!payload) { 7 | payload = this.createPostPayload(); 8 | } 9 | 10 | return { 11 | type : "POST", 12 | data : payload, 13 | contentType : "text/xml" 14 | }; 15 | }, 16 | 17 | /* 18 | * overwrite this method to create specific payload 19 | */ 20 | createPostPayload : function() { 21 | return null; 22 | }, 23 | 24 | fillTemplate : function(template, properties) { 25 | return fillXMLTemplate(template, properties); 26 | } 27 | 28 | }); 29 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/response/BaseResponse.js: -------------------------------------------------------------------------------- 1 | 2 | var BaseResponse = Class.extend({ 3 | 4 | init : function(responseDocument) { 5 | /* 6 | * represents the raw response document returned by the WPS 7 | */ 8 | this.responseDocument = responseDocument; 9 | }, 10 | 11 | getRawResponseDocument : function() { 12 | return this.responseDocument; 13 | } 14 | 15 | }); 16 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/response/CapabilitiesResponse.js: -------------------------------------------------------------------------------- 1 | var CapabilitiesResponse = BaseResponse 2 | .extend({ 3 | 4 | /* 5 | * { 6 | "capabilities":{ 7 | "serviceIdentification":{ 8 | "title":"52°North WPS 3.3.2-SNAPSHOT", 9 | "abstractValue":"Service based on the 52°North implementation of WPS 1.0.0", 10 | "keywords":[ 11 | "WPS", 12 | "geospatial", 13 | "geoprocessing" 14 | ], 15 | "serviceType":"WPS", 16 | "serviceTypeVersions":[ 17 | "ServiceTypeVersion":"1.0.0" 18 | ] 19 | "fees":"NONE", 20 | "accessConstraints":"NONE" 21 | }, 22 | "serviceProvider":{ 23 | "providerName":"52North", 24 | "providerSite":"http://www.52north.org/", 25 | "serviceContact":{ 26 | "individualName":"", 27 | "contactInfo":{ 28 | "address":{ 29 | "deliveryPoint":"", 30 | "city":"", 31 | "administrativeArea":"", 32 | "postalCode":"", 33 | "country":"", 34 | "electronicMailAddress":"" 35 | } 36 | } 37 | } 38 | }, 39 | "operations":[ 40 | { 41 | "DCP":{ 42 | "HTTP":{ 43 | "get":"http://geostatistics.demo.52north.org:80/wps/WebProcessingService?", 44 | "post":"http://geostatistics.demo.52north.org:80/wps/WebProcessingService" 45 | } 46 | }, 47 | "name":"GetCapabilities" 48 | }, 49 | { 50 | "DCP":{ 51 | "HTTP":{ 52 | "get":"http://geostatistics.demo.52north.org:80/wps/WebProcessingService?", 53 | "post":"http://geostatistics.demo.52north.org:80/wps/WebProcessingService" 54 | } 55 | }, 56 | "name":"DescribeProcess" 57 | } 58 | ], 59 | "processes":[ 60 | { 61 | "title":"org.n52.wps.server.algorithm.CSWLoDEnablerStarter", 62 | "identifier":"org.n52.wps.server.algorithm.CSWLoDEnablerStarter", 63 | "processVersion":"1.1.0", 64 | "jobControlOptions":"sync-execute async-execute", 65 | "outputTransmission":"value reference" 66 | }, 67 | { 68 | "title":"org.n52.wps.server.algorithm.JTSConvexHullAlgorithm", 69 | "identifier":"org.n52.wps.server.algorithm.JTSConvexHullAlgorithm", 70 | "processVersion":"1.1.0", 71 | "jobControlOptions":"sync-execute async-execute", 72 | "outputTransmission":"value reference" 73 | } 74 | ], 75 | "service":"WPS", 76 | "version":"2.0.0" 77 | } 78 | } 79 | */ 80 | 81 | init : function(wpsResponse) { 82 | this.responseDocument = wpsResponse; 83 | 84 | /* 85 | * create an empty new instance of capabilities object 86 | */ 87 | 88 | this.capabilities = new Object(); 89 | 90 | /* 91 | * service and version 92 | */ 93 | this.capabilities.service = "WPS"; 94 | this.capabilities.version = ""; 95 | 96 | /* 97 | * service identification 98 | */ 99 | this.capabilities.serviceIdentification = new Object(); 100 | this.capabilities.serviceIdentification.title = ""; 101 | this.capabilities.serviceIdentification.abstractValue = ""; 102 | this.capabilities.serviceIdentification.keywords = new Array; 103 | this.capabilities.serviceIdentification.serviceType = "WPS"; 104 | this.capabilities.serviceIdentification.serviceTypeVersions = new Array; 105 | this.capabilities.serviceIdentification.fees = ""; 106 | this.capabilities.serviceIdentification.accessConstraints = ""; 107 | 108 | /* 109 | * service provider 110 | */ 111 | this.capabilities.serviceProvider = new Object(); 112 | this.capabilities.serviceProvider.providerName = ""; 113 | this.capabilities.serviceProvider.providerSite = ""; 114 | this.capabilities.serviceProvider.serviceContact = new Object(); 115 | this.capabilities.serviceProvider.serviceContact.individualName = ""; 116 | this.capabilities.serviceProvider.serviceContact.contactInfo = new Object(); 117 | this.capabilities.serviceProvider.serviceContact.contactInfo.address = new Object(); 118 | this.capabilities.serviceProvider.serviceContact.contactInfo.address.deliveryPoint = ""; 119 | this.capabilities.serviceProvider.serviceContact.contactInfo.address.city = ""; 120 | this.capabilities.serviceProvider.serviceContact.contactInfo.address.administrativeArea = ""; 121 | this.capabilities.serviceProvider.serviceContact.contactInfo.address.postalCode = ""; 122 | this.capabilities.serviceProvider.serviceContact.contactInfo.address.country = ""; 123 | this.capabilities.serviceProvider.serviceContact.contactInfo.address.electronicMailAddress = ""; 124 | 125 | /* 126 | * operations with one dummy entry 127 | */ 128 | this.capabilities.operations = new Array(1); 129 | this.capabilities.operations[0] = this.createOperation("dummy", 130 | "dummyGet", "dummyPost"); 131 | 132 | /* 133 | * languages 134 | */ 135 | this.capabilities.languages = new Array(); 136 | 137 | /* 138 | * processes and dummy entry 139 | */ 140 | this.capabilities.processes = new Array(1); 141 | this.capabilities.processes[0] = this.createProcess("title", "id", 142 | "procVersion", "jobCOntrolOptions", 143 | "outputTransmission"); 144 | 145 | /* 146 | * now let child classes fill this empty instance with values 147 | */ 148 | this.instantiate(wpsResponse); 149 | 150 | }, 151 | 152 | instantiate : function(wpsResponse) { 153 | // override this method in child classes to properly set the 154 | // values 155 | }, 156 | 157 | createProcess : function(title, identifier, processVersion, jobControlOutputs, 158 | outputTransmission) { 159 | 160 | var process = new Object(); 161 | process.title = title; 162 | process.identifier = identifier; 163 | process.processVersion = processVersion; 164 | process.jobControlOptions = jobControlOutputs; 165 | process.outputTransmission = outputTransmission; 166 | 167 | return process; 168 | }, 169 | 170 | createOperation : function(name, getUrl, postUrl) { 171 | var operation = new Object(); 172 | operation.DCP = new Object(); 173 | operation.DCP.HTTP = new Object(); 174 | operation.DCP.HTTP.name = name; 175 | operation.DCP.HTTP.get = getUrl; 176 | operation.DCP.HTTP.post = postUrl; 177 | 178 | return operation; 179 | }, 180 | 181 | createArrayFromTextValues : function(nodes){ 182 | var array = new Array(); 183 | 184 | for (var int = 0; int < nodes.length; int++) { 185 | var textValue = $(nodes[int]).text(); 186 | 187 | array[int] = textValue; 188 | 189 | } 190 | return array; 191 | } 192 | 193 | }); 194 | 195 | 196 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/response/CapabilitiesResponse_v1_xml.js: -------------------------------------------------------------------------------- 1 | var CapabilitiesResponse_v1_xml = CapabilitiesResponse_xml.extend({ 2 | 3 | extractAllLanguages : function(xmlCapabilities){ 4 | return xmlCapabilities.find("wps\\:Languages, Languages").find("wps\\:Supported, Supported"); 5 | }, 6 | 7 | extractProcessOfferings : function(xmlCapabilities){ 8 | /* 9 | * override in child class 10 | */ 11 | return xmlCapabilities.find("wps\\:ProcessOfferings, ProcessOfferings"); 12 | }, 13 | 14 | extractAllProcesses : function(processOfferingsXml){ 15 | return processOfferingsXml.find("wps\\:Process, Process"); 16 | }, 17 | 18 | extractJobControlOptions : function(xmlProcess){ 19 | /* 20 | * override in child class 21 | */ 22 | return "For WPS 1.0 please execute a DescribeProcess request with this process identifier. This parameter will be included in the returned process description!"; 23 | }, 24 | 25 | extractOutputTransmission : function(xmlProcess){ 26 | return "For WPS 1.0 please execute a DescribeProcess request with this process identifier. This parameter will be included in the returned process description!"; 27 | } 28 | 29 | }); 30 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/response/CapabilitiesResponse_v2_xml.js: -------------------------------------------------------------------------------- 1 | var CapabilitiesResponse_v2_xml = CapabilitiesResponse_xml.extend({ 2 | 3 | extractAllLanguages : function(xmlCapabilities){ 4 | return xmlCapabilities.find("ows\\:Languages, Languages"); 5 | }, 6 | 7 | extractProcessOfferings : function(xmlCapabilities){ 8 | return xmlCapabilities.find("wps\\:Contents, Contents"); 9 | }, 10 | 11 | extractAllProcesses : function(processOfferingsXml){ 12 | return processOfferingsXml.find("wps\\:ProcessSummary, ProcessSummary"); 13 | }, 14 | 15 | extractJobControlOptions : function(xmlProcess){ 16 | return xmlProcess.attr("jobControlOptions"); 17 | }, 18 | 19 | extractOutputTransmission : function(xmlProcess){ 20 | return xmlProcess.attr("outputTransmission"); 21 | } 22 | 23 | }); 24 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/response/CapabilitiesResponse_xml.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * nearly all values are equal fpr WPS 1.0 and WPS 2.0. Thus most of them are hardcoded here! 4 | * Only some different values have to be set individually 5 | */ 6 | var CapabilitiesResponse_xml = CapabilitiesResponse.extend({ 7 | 8 | /** 9 | * @wpsResponse should be an XML v2.0.0 WPS Capabilities document 10 | */ 11 | instantiate : function(wpsResponse){ 12 | /* 13 | * set values 14 | */ 15 | 16 | var xmlCapabilities = $(wpsResponse).find("wps\\:Capabilities, Capabilities"); 17 | 18 | /* 19 | * version and service 20 | */ 21 | this.capabilities.version = xmlCapabilities.attr("version"); 22 | this.capabilities.service = xmlCapabilities.attr("service"); 23 | 24 | /* 25 | * service identification 26 | */ 27 | var xmlServiceIdentification = xmlCapabilities.find("ows\\:ServiceIdentification, ServiceIdentification"); 28 | this.capabilities.serviceIdentification.title = xmlServiceIdentification.find("ows\\:Title , Title").text(); 29 | this.capabilities.serviceIdentification.abstractValue = xmlServiceIdentification.find("ows\\:Abstract, Abstract").text(); 30 | this.capabilities.serviceIdentification.keywords = this.createArrayFromTextValues(xmlServiceIdentification.find("ows\\:Keyword, Keyword")); 31 | this.capabilities.serviceIdentification.serviceType = xmlServiceIdentification.find("ows\\:ServiceType, ServiceType").text(); 32 | this.capabilities.serviceIdentification.serviceTypeVersions = this.createArrayFromTextValues(xmlServiceIdentification.find("ows\\:ServiceTypeVersion, ServiceTypeVersion")); 33 | this.capabilities.serviceIdentification.fees = xmlServiceIdentification.find("ows\\:Fees, Fees").text(); 34 | this.capabilities.serviceIdentification.accessConstraints = xmlServiceIdentification.find("ows\\:AccessConstraints, AccessConstraints").text(); 35 | 36 | /* 37 | * service provider 38 | */ 39 | var xmlServiceProvider = $(xmlCapabilities).find("ows\\:ServiceProvider, ServiceProvider"); 40 | this.capabilities.serviceProvider.providerName = xmlServiceProvider.find("ows\\:ProviderName, ProviderName").text() || undefined; 41 | var providerSiteNode=xmlServiceProvider.find("ows\\:ProviderSite, ProviderSite") || undefined; 42 | this.capabilities.serviceProvider.providerSite = providerSiteNode.attr("href") || providerSiteNode.attr("xlin\\:href") || providerSiteNode.attr("xlink\\:href") || undefined; 43 | var serviceContact = xmlServiceProvider.find("ows\\:ServiceContact, ServiceContact") || undefined; 44 | this.capabilities.serviceProvider.serviceContact.individualName = serviceContact.find("ows\\:IndividualName, IndividualName").text() || undefined; 45 | var address = serviceContact.find("ows\\:Address, Address"); 46 | this.capabilities.serviceProvider.serviceContact.contactInfo.address.deliveryPoint = address.find("ows\\:DeliveryPoint, DeliveryPoint").text() || undefined; 47 | this.capabilities.serviceProvider.serviceContact.contactInfo.address.city = address.find("ows\\:City, City").text() || undefined; 48 | this.capabilities.serviceProvider.serviceContact.contactInfo.address.administrativeArea = address.find("ows\\:AdministrativeArea, AdministrativeArea").text() || undefined; 49 | this.capabilities.serviceProvider.serviceContact.contactInfo.address.postalCode = address.find("ows\\:PostalCode, PostalCode").text() || undefined; 50 | this.capabilities.serviceProvider.serviceContact.contactInfo.address.country = address.find("ows\\:Country, Country").text() || undefined; 51 | this.capabilities.serviceProvider.serviceContact.contactInfo.address.electronicMailAddress = address.find("ows\\:ElectronicMailAddress, ElectronicMailAddress").text() || undefined; 52 | 53 | /* 54 | * operations 55 | */ 56 | var operationsMetadata = xmlCapabilities.find("ows\\:OperationsMetadata, OperationsMetadata"); 57 | this.capabilities.operations = this.createOperationsArray(operationsMetadata.find("ows\\:Operation, Operation")); 58 | 59 | /* 60 | * languages 61 | */ 62 | var languages = this.extractAllLanguages(xmlCapabilities); 63 | this.capabilities.languages = this.createArrayFromTextValues(languages.find("ows\\:Language, Language")); 64 | 65 | /* 66 | * processes 67 | */ 68 | var processOfferings = this.extractProcessOfferings(xmlCapabilities); 69 | this.capabilities.processes = this.createProcessesArray(this.extractAllProcesses(processOfferings)); 70 | }, 71 | 72 | /** 73 | * extracts all languages. 74 | * 75 | * Differs for each WPS version 76 | */ 77 | extractAllLanguages : function(xmlCapabilities){ 78 | /* 79 | * override in child class 80 | */ 81 | }, 82 | 83 | /** 84 | * extracts process offering xml node. 85 | * 86 | * Differs for each WPS version 87 | */ 88 | extractProcessOfferings : function(xmlCapabilities){ 89 | /* 90 | * override in child class 91 | */ 92 | return xmlCapabilities.find("wps\\:Contents, Contents"); 93 | }, 94 | 95 | /** 96 | * extracts all process xml nodes. 97 | * 98 | * Differs for each WPS version 99 | */ 100 | extractAllProcesses : function(processOfferingsXml){ 101 | /* 102 | * override in child class 103 | */ 104 | }, 105 | 106 | createOperationsArray : function(nodes){ 107 | var array = new Array(nodes.length); 108 | 109 | for (var int = 0; int < nodes.length; int++) { 110 | var xmlOperation = $(nodes[int]); 111 | var name = xmlOperation.attr("name"); 112 | var getUrlNode=xmlOperation.find("ows\\:Get, Get"); 113 | var getUrl = getUrlNode.attr("href") || getUrlNode.attr("xlin\\:href") || getUrlNode.attr("xlink\\:href"); 114 | var PostUrlNode=xmlOperation.find("ows\\:Post, Post"); 115 | var postUrl = PostUrlNode.attr("href") || PostUrlNode.attr("xlin\\:href") || PostUrlNode.attr("xlink\\:href"); 116 | 117 | array[int] = this.createOperation(name, getUrl, postUrl); 118 | } 119 | return array; 120 | }, 121 | 122 | createProcessesArray : function(nodes){ 123 | var array = new Array(nodes.length); 124 | 125 | for (var int = 0; int < nodes.length; int++) { 126 | var xmlProcess = $(nodes[int]); 127 | 128 | var title = xmlProcess.find("ows\\:Title, Title").text(); 129 | var identifier = xmlProcess.find("ows\\:Identifier, Identifier").text(); 130 | var processVersion = xmlProcess.attr("processVersion") || xmlProcess.attr("wps\\:processVersion"); 131 | var jobControlOutputs = this.extractJobControlOptions(xmlProcess); 132 | var outputTransmission = this.extractOutputTransmission(xmlProcess); 133 | 134 | array[int] = this.createProcess(title, identifier, processVersion, jobControlOutputs, outputTransmission); 135 | 136 | } 137 | return array; 138 | }, 139 | 140 | /** 141 | * extracts jobControlOptions parameter. 142 | * 143 | * Differs for each WPS version 144 | */ 145 | extractJobControlOptions : function(xmlProcess){ 146 | /* 147 | * override in child class 148 | */ 149 | }, 150 | 151 | /** 152 | * extracts outputTransmission parameter. 153 | * 154 | * Differs for each WPS version 155 | */ 156 | extractOutputTransmission : function(xmlProcess){ 157 | /* 158 | * override in child class 159 | */ 160 | } 161 | 162 | }); 163 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/response/DescribeProcessResponse.js: -------------------------------------------------------------------------------- 1 | var DescribeProcessResponse = BaseResponse.extend({ 2 | 3 | init : function(wpsResponse) { 4 | this.responseDocument = wpsResponse; 5 | 6 | /* 7 | * empty process description 8 | */ 9 | this.processOffering = new Object(); 10 | 11 | /* 12 | * service and version 13 | */ 14 | this.processOffering.service = "WPS"; 15 | this.processOffering.version = ""; 16 | 17 | /* 18 | * process 19 | */ 20 | this.processOffering.process = new Object(); 21 | this.processOffering.process.title = ""; 22 | this.processOffering.process.abstractValue = ""; 23 | this.processOffering.process.identifier = ""; 24 | this.processOffering.process.inputs = new Array(); 25 | this.processOffering.process.outputs = new Array(); 26 | 27 | /* 28 | * attributes 29 | */ 30 | this.processOffering.processVersion = ""; 31 | this.processOffering.jobControlOptions = []; 32 | this.processOffering.outputTransmissionModes = []; 33 | 34 | this.instantiate(wpsResponse); 35 | }, 36 | 37 | instantiate: function(wpsResponse){ 38 | /* 39 | * override this method in child classes to instantiate the object 40 | */ 41 | }, 42 | 43 | createLiteralDataInput : function(title, abstractValue, identifier, 44 | minOccurs, maxOccurs, formatArray, literalDataDomainArray) { 45 | var literalDataInput = new Object(); 46 | 47 | this.instantiateCommonInputValues(title, abstractValue, identifier, 48 | minOccurs, maxOccurs, literalDataInput); 49 | 50 | //TODO what about metadata node? 51 | literalDataInput.literalData = new Object(); 52 | literalDataInput.literalData.formats = formatArray; 53 | literalDataInput.literalData.literalDataDomains = literalDataDomainArray; 54 | 55 | return literalDataInput; 56 | }, 57 | 58 | createComplexDataInput : function(title, abstractValue, identifier, 59 | minOccurs, maxOccurs, formatArray) { 60 | var complexDataInput = new Object(); 61 | 62 | this.instantiateCommonInputValues(title, abstractValue, identifier, 63 | minOccurs, maxOccurs, complexDataInput); 64 | 65 | //TODO what about metadata node? 66 | complexDataInput.complexData = new Object(); 67 | complexDataInput.complexData.formats = formatArray; 68 | 69 | return complexDataInput; 70 | 71 | }, 72 | 73 | createBboxInput : function(title, abstractValue, identifier, minOccurs, 74 | maxOccurs, formatArray, crsArray) { 75 | 76 | var bboxInput = new Object(); 77 | 78 | this.instantiateCommonInputValues(title, abstractValue, identifier, 79 | minOccurs, maxOccurs, bboxInput); 80 | 81 | //TODO what about metadata node? 82 | bboxInput.boundingBoxData = new Object(); 83 | bboxInput.boundingBoxData.formats = formatArray; 84 | 85 | bboxInput.boundingBoxData.supportedCRSs = crsArray; 86 | 87 | return bboxInput; 88 | 89 | }, 90 | 91 | createFormat : function(mimeType, encoding, schema) { 92 | var format = new Object(); 93 | format.mimeType = mimeType; 94 | format.encoding = encoding; 95 | format.schema = schema; 96 | 97 | return format; 98 | }, 99 | 100 | instantiateCommonInputValues : function(title, abstractValue, identifier, 101 | minOccurs, maxOccurs, inputObject) { 102 | 103 | inputObject.title = title; 104 | 105 | inputObject.abstractValue = abstractValue; 106 | 107 | inputObject.identifier = identifier; 108 | 109 | inputObject.minOccurs = minOccurs; 110 | 111 | inputObject.maxOccurs = maxOccurs; 112 | }, 113 | 114 | instantiateCommonOutputValues : function(title, abstractValue, identifier, 115 | outputObject){ 116 | outputObject.title = title; 117 | 118 | outputObject.abstractValue = abstractValue; 119 | 120 | outputObject.identifier = identifier; 121 | }, 122 | 123 | createLiteralDataOutput : function(title, abstractValue, identifier, 124 | formatArray, literalDataDomainArray) { 125 | var literalDataOutput = new Object(); 126 | 127 | this.instantiateCommonOutputValues(title, abstractValue, identifier, 128 | literalDataOutput); 129 | 130 | //TODO what about metadata node? 131 | literalDataOutput.literalData = new Object(); 132 | literalDataOutput.literalData.formats = formatArray; 133 | literalDataOutput.literalData.literalDataDomains = literalDataDomainArray; 134 | 135 | return literalDataOutput; 136 | }, 137 | 138 | createComplexDataOutput : function(title, abstractValue, identifier, 139 | formatArray) { 140 | var complexDataOutput = new Object(); 141 | 142 | this.instantiateCommonOutputValues(title, abstractValue, identifier, 143 | complexDataOutput); 144 | 145 | //TODO what about metadata node? 146 | complexDataOutput.complexData = new Object(); 147 | complexDataOutput.complexData.formats = formatArray; 148 | 149 | return complexDataOutput; 150 | 151 | }, 152 | 153 | createBboxOutput : function(title, abstractValue, identifier, 154 | formatArray, crsArray) { 155 | 156 | var bboxOutput = new Object(); 157 | 158 | this.instantiateCommonOutputValues(title, abstractValue, identifier, 159 | bboxOutput); 160 | 161 | //TODO what about metadata node? 162 | bboxOutput.boundingBoxData = new Object(); 163 | bboxOutput.boundingBoxData.formats = formatArray; 164 | 165 | bboxOutput.boundingBoxData.supportedCRSs = crsArray; 166 | 167 | return bboxOutput; 168 | 169 | }, 170 | 171 | }); 172 | 173 | 174 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/response/DescribeProcessResponse_v1_xml.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Override existing variables to match WPS 1.0 documents 3 | */ 4 | var DescribeProcessResponse_v1_xml = DescribeProcessResponse_xml.extend({ 5 | 6 | /* 7 | * possibly, some methods have to be overridden, to parse WPS 1.0 documents 8 | */ 9 | 10 | resetParameterVariables : function(){ 11 | PROCESS_OFFERING_VERSION = "1.0.0"; 12 | 13 | PROCESS_OFFERING_XML_TAG_NAME = "wps\\:ProcessDescription, ProcessDescription"; 14 | 15 | FORMAT_MIME_TYPE_ATTR_NAME = "ows\\:MimeType, MimeType"; 16 | FORMAT_ENCODING_ATTR_NAME = "ows\\:Encoding, Encoding"; 17 | FORMAT_SCHEMA_ATTR_NAME = "ows\\:Schema, Schema"; 18 | 19 | LITERAL_DATA_UNIT_OF_MEASURE_TAG_NAME = "ows\\:UOM, UOM"; 20 | 21 | //SUPPORTED_CRS_TAG_NAME = "SupportedCRS"; 22 | CRS_TAG_NAME = "ows\\:CRS, CRS"; 23 | 24 | LITERAL_DATA_OUTPUT_TAG_NAME = "wps\\:LiteralOutput, LiteralOutput"; 25 | COMPLEX_DATA_OUTPUT_TAG_NAME = "wps\\:ComplexOutput, ComplexOutput"; 26 | BBOX_DATA_OUTPUT_TAG_NAME = "wps\\:BoundingBoxOutput, BoundingBoxOutput"; 27 | }, 28 | 29 | createJobControlOptions : function(processOfferingXml){ 30 | 31 | /* 32 | * TODO for WPS 1.0 this attribut does not exist! 33 | * But we have the attributes "storeSupported" 34 | * if true, then async-execution and stored as reference! 35 | * 36 | * if false, then only sync-execution and return in document is possible. 37 | */ 38 | var storeSupported = processOfferingXml.attr("storeSupported") || false; 39 | if (storeSupported) 40 | return ["sync-execute", "async-execute"]; 41 | 42 | else 43 | return ["sync-execute"]; 44 | }, 45 | 46 | createOutputTransmissionModes : function(processOfferingXml){ 47 | 48 | /* 49 | * TODO for WPS 1.0 this attribut does not exist! 50 | * But we have the attributes "storeSupported" 51 | * if true, then async-execution and stored as reference! 52 | * 53 | * if false, then only sync-execution and return in document is possible. 54 | */ 55 | var storeSupported = processOfferingXml.attr("storeSupported") || false; 56 | if (storeSupported) 57 | return ["value", "reference"]; 58 | 59 | else 60 | return ["value"]; 61 | }, 62 | 63 | /** 64 | * in WPS 1.0 is encoded as Tag 65 | */ 66 | extractMimeType : function(formatXml){ 67 | return formatXml.find(FORMAT_MIME_TYPE_ATTR_NAME).text(); 68 | }, 69 | 70 | /** 71 | * in WPS 1.0 is encoded as Tag 72 | */ 73 | extractEncoding : function(formatXml){ 74 | return formatXml.find(FORMAT_ENCODING_ATTR_NAME).text() || undefined; 75 | }, 76 | 77 | /** 78 | * in WPS 1.0 is encoded as Tag 79 | */ 80 | extractSchema : function(formatXml){ 81 | return formatXml.find(FORMAT_SCHEMA_ATTR_NAME).text() || undefined; 82 | }, 83 | 84 | /** 85 | * extracts the unit of measure. 86 | * 87 | * in WPS 1.0 it is a bit tricky. WPS 1.0 defines a single LiteralData object which has a single UOMs object, 88 | * which is split up into a single Default and a single Supported node. Standard contains a single UOM, 89 | * whereas Supported defines a list of supported UOMs... 90 | * 91 | * However, this conceptually differs from WPS 2.0 where there is a completely new node named LiteralDataDomain, 92 | * which may occur multiple times! Each LiteralDataDomain object contains only ONE UOM node. 93 | * 94 | * This API returns documents closely modeled to the WPS 2.0 standard. Hence, we need one UOM per LiteralDatDomain. 95 | * Thus, we just use the Default UOM of WPS 1.0 and loose all others. 96 | */ 97 | extractUnitOfMeasure : function(literalDataXml){ 98 | return literalDataXml.find("ows\\:UOMs, UOMs").find("ows\\:Default, Default").find(LITERAL_DATA_UNIT_OF_MEASURE_TAG_NAME).text() || undefined; 99 | }, 100 | 101 | extractFormatNodes : function(xmlNode){ 102 | /* 103 | * in WPS 1.0 formats are split up in a Supported and a Default subtag. 104 | * To not have them listed twice, we just extract all Format Nodes from 105 | * the Supported subtag. 106 | */ 107 | return xmlNode.find("ows\\:Supported, Supported").find(FORMAT_TAG_NAME); 108 | }, 109 | 110 | createAllLiteralDataDomainObjects : function(literalDataXml){ 111 | /* 112 | * here, in WPS 1.0, we have no subTag called LiteralDataDomain 113 | * (which in WPS 2.0 may occur multiple times!). 114 | * 115 | * In WPS 1.0 the difference is, that there are multiple UOMs. 116 | * However, since this API encodes the description closely to 117 | * the WPS 2.0 standard, we only take the default UOM from WPS 1.0! 118 | * 119 | * Hence, we just create on single object which holds the information. 120 | * The remaining UOMs are lost! 121 | */ 122 | var literalDataDomainArray = new Array(1); 123 | 124 | literalDataDomainArray[0] = this.createLiteralDataDomainObject($(literalDataXml)); 125 | 126 | return literalDataDomainArray; 127 | } 128 | 129 | }); 130 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/response/DescribeProcessResponse_v2_xml.js: -------------------------------------------------------------------------------- 1 | var DescribeProcessResponse_v2_xml = DescribeProcessResponse_xml.extend({ 2 | 3 | /* 4 | * override any method whose implementation differs for various WPS version! 5 | */ 6 | 7 | resetParameterVariables : function(){ 8 | /* 9 | * Override existing variables 10 | */ 11 | PROCESS_OFFERING_VERSION = "2.0.0"; 12 | 13 | PROCESS_OFFERING_XML_TAG_NAME = "wps\\:ProcessOffering, ProcessOffering"; 14 | 15 | JOB_CONTROL_OPTIONS_ATTR_NAME = "jobControlOptions"; 16 | JOB_CONTROL_OPTIONS_ATTR_NAME_WITH_NS = "wps\\:jobControlOptions"; 17 | 18 | OUTPUT_TRANSMISSION_ATTR_NAME = "outputTransmission"; 19 | OUTPUT_TRANSMISSION_ATTR_NAME_WITH_NS = "wps\\:outputTransmission"; 20 | 21 | FORMAT_MIME_TYPE_ATTR_NAME = "mimeType"; 22 | FORMAT_ENCODING_ATTR_NAME = "encoding"; 23 | FORMAT_SCHEMA_ATTR_NAME = "schema"; 24 | 25 | LITERAL_DATA_DOMAIN_TAG_NAME = "wps\\:LiteralDataDomain, LiteralDataDomain"; 26 | LITERAL_DATA_UNIT_OF_MEASURE_TAG_NAME = "ows\\:UOM, UOM"; 27 | 28 | LITERAL_DATA_OUTPUT_TAG_NAME = "wps\\:LiteralData, ns\\:LiteralData, LiteralData"; 29 | COMPLEX_DATA_OUTPUT_TAG_NAME = "wps\\:ComplexData, ns\\:ComplexData, ComplexData"; 30 | BBOX_DATA_OUTPUT_TAG_NAME = "wps\\:BoundingBoxData, ns\\:BoundingBoxData, BoundingBoxData"; 31 | 32 | CRS_TAG_NAME = "ows\\:SupportedCRS, wps\\:SupportedCRS, SupportedCRS"; 33 | }, 34 | 35 | createJobControlOptions : function(processOfferingXml){ 36 | 37 | var jobControlOptionsString = processOfferingXml.attr(JOB_CONTROL_OPTIONS_ATTR_NAME) || processOfferingXml.attr(JOB_CONTROL_OPTIONS_ATTR_NAME_WITH_NS); 38 | 39 | /* 40 | * the string holds job control options separated by whitespace 41 | */ 42 | 43 | return jobControlOptionsString.split(" "); 44 | }, 45 | 46 | createOutputTransmissionModes : function(processOfferingXml){ 47 | 48 | var outputTransmissionString = processOfferingXml.attr(OUTPUT_TRANSMISSION_ATTR_NAME) || processOfferingXml.attr(OUTPUT_TRANSMISSION_ATTR_NAME_WITH_NS); 49 | 50 | /* 51 | * the string holds transmission modes separated by whitespace 52 | */ 53 | 54 | return outputTransmissionString.split(" "); 55 | }, 56 | 57 | /** 58 | * in WPS 2.0 is encoded as attribute 59 | */ 60 | extractMimeType : function(formatXml){ 61 | return formatXml.attr(FORMAT_MIME_TYPE_ATTR_NAME); 62 | }, 63 | 64 | /** 65 | * in WPS 2.0 is encoded as attribute 66 | */ 67 | extractEncoding : function(formatXml){ 68 | return formatXml.attr(FORMAT_ENCODING_ATTR_NAME) || undefined; 69 | }, 70 | 71 | /** 72 | * in WPS 2.0 is encoded as attribute 73 | */ 74 | extractSchema : function(formatXml){ 75 | return formatXml.attr(FORMAT_SCHEMA_ATTR_NAME) || undefined; 76 | }, 77 | 78 | /** 79 | * create all literal data domain object. 80 | * in WPS 2.0 a new Tag called "LiteralDataDomain" 81 | * is introduced which may occur multiple times! 82 | */ 83 | createAllLiteralDataDomainObjects : function(literalDataXml){ 84 | 85 | var literalDataDomain_xmlNodes = literalDataXml.find(LITERAL_DATA_DOMAIN_TAG_NAME); 86 | 87 | var literalDataDomainArray = new Array(literalDataDomain_xmlNodes.length); 88 | 89 | for(var index = 0; index < literalDataDomain_xmlNodes.length; index++){ 90 | literalDataDomainArray[index] = this.createLiteralDataDomainObject($(literalDataDomain_xmlNodes[index])); 91 | } 92 | 93 | return literalDataDomainArray; 94 | }, 95 | 96 | /** 97 | * extracts the unit of measure. 98 | */ 99 | extractUnitOfMeasure : function(literalDataXml){ 100 | return literalDataXml.find(LITERAL_DATA_UNIT_OF_MEASURE_TAG_NAME).text() || undefined; 101 | }, 102 | 103 | extractFormatNodes : function(xmlNode){ 104 | /* 105 | * simply use all occurrences 106 | */ 107 | return xmlNode.find(FORMAT_TAG_NAME); 108 | } 109 | 110 | }); 111 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/response/DescribeProcessResponse_xml.js: -------------------------------------------------------------------------------- 1 | /* 2 | * definition of parameter names and values that will be used for 3 | * generating the process description. Values will have standard values 4 | * for WPS 2.0. 5 | * 6 | * In subclasses, these values shall be overridden to alter the values!!!! 7 | */ 8 | 9 | var PROCESS_OFFERING_VERSION = "2.0.0"; 10 | 11 | var PROCESS_OFFERING_XML_TAG_NAME = "wps\\:ProcessOffering, ProcessOffering"; 12 | 13 | var PROCESS_VERSION_ATTR_NAME = "processVersion"; 14 | var PROCESS_VERSION_ATTR_NAME_WITH_NS = "wps\\:processVersion"; 15 | 16 | var JOB_CONTROL_OPTIONS_ATTR_NAME = "jobControlOptions"; 17 | var JOB_CONTROL_OPTIONS_ATTR_NAME_WITH_NS = "wps\\:jobControlOptions"; 18 | 19 | var OUTPUT_TRANSMISSION_ATTR_NAME = "outputTransmission"; 20 | var OUTPUT_TRANSMISSION_ATTR_NAME_WITH_NS = "wps\\:outputTransmission"; 21 | 22 | var PROCESS_TAG_NAME = "wps\\:Process, Process"; 23 | var TITLE_TAG_NAME = "ows\\:Title, Title"; 24 | var ABSTRACT_TAG_NAME = "ows\\:Abstract, Abstract"; 25 | var IDENTIFIER_TAG_NAME = "ows\\:Identifier, Identifier"; 26 | 27 | var PROCESS_INPUT_TAG_NAME = "wps\\:Input, Input"; 28 | var PROCESS_OUTPUT_TAG_NAME = "wps\\:Output, Output"; 29 | 30 | var LITERAL_DATA_TAG_NAME = "wps\\:LiteralData, ns\\:LiteralData, LiteralData"; 31 | var COMPLEX_DATA_TAG_NAME = "wps\\:ComplexData, ns\\:ComplexData, ComplexData"; 32 | var BBOX_DATA_TAG_NAME = "wps\\:BoundingBoxData, ns\\:BoundingBoxData, BoundingBoxData"; 33 | 34 | var LITERAL_DATA_OUTPUT_TAG_NAME = "wps\\:LiteralData, ns\\:LiteralData, LiteralData"; 35 | var COMPLEX_DATA_OUTPUT_TAG_NAME = "wps\\:ComplexData, ns\\:ComplexData, ComplexData"; 36 | var BBOX_DATA_OUTPUT_TAG_NAME = "wps\\:BoundingBoxData, ns\\:BoundingBoxData, BoundingBoxData"; 37 | 38 | var MIN_OCCURS_ATTR_NAME = "minOccurs"; 39 | var MIN_OCCURS_ATTR_NAME_WITH_NS = "wps\\:minOccurs"; 40 | 41 | var MAX_OCCURS_ATTR_NAME = "maxOccurs"; 42 | var MAX_OCCURS_ATTR_NAME_WITH_NS = "wps\\:maxOccurs"; 43 | 44 | var FORMAT_TAG_NAME = "ns\\:Format, wps\\:Format, Format"; 45 | var FORMAT_MIME_TYPE_ATTR_NAME = "mimeType"; 46 | var FORMAT_ENCODING_ATTR_NAME = "encoding"; 47 | var FORMAT_SCHEMA_ATTR_NAME = "schema"; 48 | 49 | var LITERAL_DATA_DOMAIN_TAG_NAME = "wps\\:LiteralDataDomain, LiteralDataDomain"; 50 | var LITERAL_DATA_ANY_VALUE_TAG_NAME = "ows\\:AnyValue, AnyValue"; 51 | var LITERAL_DATA_ALLOWED_VALUES_TAG_NAME = "ows\\:AllowedValues, AllowedValues"; 52 | 53 | var LITERAL_DATA_ALLOWED_VALUES_VALUE_TAG_NAME = "ows\\:Value, Value"; 54 | var LITERAL_DATA_ALLOWED_VALUES_RANGE_TAG_NAME = "ows\\:Range, Range"; 55 | var LITERAL_DATA_ALLOWED_VALUES_RANGE_MINIMUM_VALUE_TAG_NAME = "ows\\:MinimumValue, MinimumValue"; 56 | var LITERAL_DATA_ALLOWED_VALUES_RANGE_MAXIMUM_VALUE_TAG_NAME = "ows\\:MaximumValue, MaximumValue"; 57 | 58 | var LITERAL_DATA_DATA_TYPE_TAG_NAME = "ows\\:DataType, DataType"; 59 | var LITERAL_DATA_VALUES_REFERENCE_TAG_NAME = "ows\\:ValuesReference, ValuesReference"; 60 | var LITERAL_DATA_REFERENCE_ATTR_NAME = "reference"; 61 | var LITERAL_DATA_REFERENCE_ATTR_NAME_WITH_NS = "ows\\:reference"; 62 | var LITERAL_DATA_DEFAULT_VALUE_TAG_NAME = "ows\\:DefaultValue, DefaultValue"; 63 | var LITERAL_DATA_UNIT_OF_MEASURE_TAG_NAME = "ows\\:UOM, UOM"; 64 | 65 | //var SUPPORTED_CRS_TAG_NAME = "SupportedCRS"; 66 | var CRS_TAG_NAME = "ows\\:CRS, wps\\:CRS, CRS"; 67 | 68 | 69 | var DescribeProcessResponse_xml = DescribeProcessResponse.extend({ 70 | 71 | instantiate : function(wpsResponse) { 72 | 73 | /* 74 | * in child classes, this method may change certain values 75 | * of the above listed variables, that are used to extract 76 | * information out of the XML document 77 | */ 78 | this.resetParameterVariables(); 79 | 80 | /* 81 | * version 82 | */ 83 | this.processOffering.version = PROCESS_OFFERING_VERSION; 84 | 85 | var processOfferingXml = $(wpsResponse).find(PROCESS_OFFERING_XML_TAG_NAME); 86 | 87 | /* 88 | processOfferingXml */ 89 | this.processOffering.processVersion = processOfferingXml.attr(PROCESS_VERSION_ATTR_NAME) || processOfferingXml.attr(PROCESS_VERSION_ATTR_NAME_WITH_NS); 90 | this.processOffering.jobControlOptions = this.createJobControlOptions(processOfferingXml); 91 | this.processOffering.outputTransmissionModes = this.createOutputTransmissionModes(processOfferingXml); 92 | 93 | /* 94 | * process 95 | */ 96 | // var processXml = processOfferingXml.find(PROCESS_TAG_NAME); 97 | /* 98 | * .find(selector) will return more instances of title, abstract and identifier 99 | * than just the ones for the process. 100 | * 101 | * Instead it will also include objects for each Input and Output. 102 | * 103 | * Hence we simply take the first returned objects, as those will be the process level. 104 | */ 105 | this.processOffering.process.title = $(processOfferingXml.find(TITLE_TAG_NAME)[0]).text(); 106 | this.processOffering.process.abstractValue = $(processOfferingXml.find(ABSTRACT_TAG_NAME)[0]).text() || undefined; 107 | this.processOffering.process.identifier = $(processOfferingXml.find(IDENTIFIER_TAG_NAME)[0]).text(); 108 | /* 109 | * TODO how to deal with nested input and nested output??? 110 | * 111 | */ 112 | this.processOffering.process.inputs = this.createInputs(processOfferingXml.find(PROCESS_INPUT_TAG_NAME)); 113 | this.processOffering.process.outputs = this.createOutputs(processOfferingXml.find(PROCESS_OUTPUT_TAG_NAME)); 114 | 115 | }, 116 | 117 | /** 118 | * in child classes this method should be overridden in order to reset parameter values 119 | */ 120 | resetParameterVariables : function(){ 121 | /* 122 | * here do noting 123 | */ 124 | }, 125 | 126 | createJobControlOptions : function(processOfferingXml){ 127 | /* 128 | * must be overridden in child classes 129 | * 130 | * it differs fpr various WPS version! 131 | */ 132 | }, 133 | 134 | createOutputTransmissionModes : function(processOfferingXml){ 135 | /* 136 | * must be overridden in child classes 137 | * 138 | * it differs for various WPS version! 139 | */ 140 | }, 141 | 142 | createInputs : function(xmlNodes){ 143 | var array = new Array(xmlNodes.length); 144 | 145 | for (var index = 0; index < xmlNodes.length; index++) { 146 | var inputXml = $(xmlNodes[index]); 147 | 148 | if(inputXml.find(LITERAL_DATA_TAG_NAME).length > 0) 149 | array[index] = this.createLiteralDataInputFromXml(inputXml); 150 | 151 | else if (inputXml.find(COMPLEX_DATA_TAG_NAME).length > 0) 152 | array[index] = this.createComplexDataInputFromXml(inputXml); 153 | 154 | else if (inputXml.find(BBOX_DATA_TAG_NAME).length > 0) 155 | array[index] = this.createBboxDataInputFromXml(inputXml); 156 | 157 | /* 158 | * nested input! 159 | */ 160 | else if(inputXml.find(PROCESS_INPUT_TAG_NAME).length > 0) 161 | array[index] = this.createInputs(inputXml); 162 | 163 | } 164 | 165 | return array; 166 | }, 167 | 168 | createLiteralDataInputFromXml : function(xmlNode) { 169 | var minOccurs = xmlNode.attr(MIN_OCCURS_ATTR_NAME) || xmlNode.attr(MIN_OCCURS_ATTR_NAME_WITH_NS); 170 | var maxOccurs = xmlNode.attr(MAX_OCCURS_ATTR_NAME) || xmlNode.attr(MAX_OCCURS_ATTR_NAME_WITH_NS); 171 | 172 | var title = xmlNode.find(TITLE_TAG_NAME).text(); 173 | var abstractValue = xmlNode.find(ABSTRACT_TAG_NAME).text() || undefined; 174 | var identifier = xmlNode.find(IDENTIFIER_TAG_NAME).text(); 175 | 176 | /* 177 | * literal data input 178 | */ 179 | var formatNodes = this.extractFormatNodes(xmlNode); 180 | 181 | /* 182 | * in WPS 1.0 there is no format for a literal input! 183 | * 184 | * but in WPS 2.0 there is! 185 | * 186 | * Hence, we just add an "|| undefined" 187 | */ 188 | var formatArray = this.createFormatArray(formatNodes) || undefined; 189 | 190 | 191 | var literalDataDomainArray = this.createLiteralDataDomainArray(xmlNode.find(LITERAL_DATA_TAG_NAME)); 192 | 193 | // this.createLiteralDataDomainArray(xmlNode.find(LITERAL_DATA_DOMAIN_TAG_NAME)); 194 | 195 | return this.createLiteralDataInput(title, abstractValue, identifier, minOccurs, 196 | maxOccurs, formatArray, literalDataDomainArray); 197 | }, 198 | 199 | /** 200 | * extracts all Format nodes. Varies for different WPS version 201 | */ 202 | extractFormatNodes : function(xmlNode){ 203 | /* 204 | * override in child classes 205 | */ 206 | }, 207 | 208 | createLiteralDataDomainArray : function(literalDataDomainXml){ 209 | 210 | /* 211 | * for various WPS version, this call produces different results! 212 | */ 213 | return this.createAllLiteralDataDomainObjects(literalDataDomainXml); 214 | }, 215 | 216 | /** 217 | * create all literal data domain object. 218 | * for differnt WPS version, the number of allowed instances varies. In WPS 1.0 219 | * only one occurence is allowed, whereas in WPS 2.0 a new Tag called "LiteralDataDomain" 220 | * is introduced which may occur multiple times! 221 | * 222 | * Hence we override this method in child classes to provide the correct results! 223 | */ 224 | createAllLiteralDataDomainObjects : function(literalDataXml){ 225 | /* 226 | * override in child methods! 227 | */ 228 | }, 229 | 230 | /** 231 | * regardsles of the WPS version, this method should provide the expected results 232 | * to instantiate an instance of literalDataObject! 233 | */ 234 | createLiteralDataDomainObject : function(literalDataDomain_xml){ 235 | 236 | var literalDataDomainObject = new Object(); 237 | 238 | /* 239 | * on of the three tags for allowed value specification can occur: 240 | * 241 | * 1: AnyValue 242 | * 243 | * 2: AllowedValues 244 | * 245 | * 3: ValuesReference 246 | */ 247 | literalDataDomainObject.anyValue = false; 248 | 249 | if(literalDataDomain_xml.find(LITERAL_DATA_ANY_VALUE_TAG_NAME).length > 0) 250 | literalDataDomainObject.anyValue = true; 251 | 252 | else if(literalDataDomain_xml.find(LITERAL_DATA_ALLOWED_VALUES_TAG_NAME).length > 0) 253 | literalDataDomainObject.allowedValues = this.createAllowedValues(literalDataDomain_xml.find(LITERAL_DATA_ALLOWED_VALUES_TAG_NAME)); 254 | 255 | else 256 | literalDataDomainObject.valuesReference = literalDataDomain_xml.find(LITERAL_DATA_VALUES_REFERENCE_TAG_NAME).text(); 257 | 258 | var dataType_xml = literalDataDomain_xml.find(LITERAL_DATA_DATA_TYPE_TAG_NAME); 259 | 260 | var dataTypeObject = new Object(); 261 | dataTypeObject.type = dataType_xml.text() || undefined; 262 | dataTypeObject.reference = dataType_xml.attr(LITERAL_DATA_REFERENCE_ATTR_NAME) || dataType_xml.attr(LITERAL_DATA_REFERENCE_ATTR_NAME_WITH_NS); 263 | 264 | literalDataDomainObject.dataType = dataTypeObject; 265 | 266 | literalDataDomainObject.defaultValue = literalDataDomain_xml.find(LITERAL_DATA_DEFAULT_VALUE_TAG_NAME).text() || undefined; 267 | /* 268 | * uom = unit of measure 269 | * 270 | * TODO create new extraction method that is overridden in child classes 271 | */ 272 | literalDataDomainObject.unitOfMeasure = this.extractUnitOfMeasure(literalDataDomain_xml); 273 | 274 | return literalDataDomainObject; 275 | }, 276 | 277 | /** 278 | * extracts the unit of measure. 279 | * 280 | * Differs for different WPS versions 281 | */ 282 | extractUnitOfMeasure : function(literalDataXml){ 283 | /* 284 | * override in child classes! 285 | */ 286 | }, 287 | 288 | createAllowedValues : function(allowedValues_xml){ 289 | 290 | /* 291 | * if allowedValues_xml actually exists: 292 | * 293 | * allowedValues_xml might either be an array of "Value"-tags or 294 | * 295 | * have a child node called "Range". 296 | */ 297 | var object = new Object(); 298 | 299 | var values_xml = allowedValues_xml.find(LITERAL_DATA_ALLOWED_VALUES_VALUE_TAG_NAME); 300 | var numberOfValues = values_xml.length; 301 | 302 | /* 303 | * case Value array 304 | */ 305 | if (numberOfValues > 0){ 306 | /* 307 | * return an array with all values 308 | */ 309 | object.values = new Array(numberOfValues); 310 | 311 | for (var i=0; i < numberOfValues; i++){ 312 | object.values[i] = $(values_xml[i]).text(); 313 | } 314 | } 315 | 316 | /* 317 | * case Range child node 318 | */ 319 | else{ 320 | object.range = new Object(); 321 | 322 | var range_xml = allowedValues_xml.find(LITERAL_DATA_ALLOWED_VALUES_RANGE_TAG_NAME); 323 | 324 | object.range.minimumValue = range_xml.find(LITERAL_DATA_ALLOWED_VALUES_RANGE_MINIMUM_VALUE_TAG_NAME).text(); 325 | object.range.maximumValue = range_xml.find(LITERAL_DATA_ALLOWED_VALUES_RANGE_MAXIMUM_VALUE_TAG_NAME).text(); 326 | } 327 | 328 | return object; 329 | }, 330 | 331 | createComplexDataInputFromXml : function(xmlNode) { 332 | var minOccurs = xmlNode.attr(MIN_OCCURS_ATTR_NAME) || xmlNode.attr(MIN_OCCURS_ATTR_NAME_WITH_NS); 333 | var maxOccurs = xmlNode.attr(MAX_OCCURS_ATTR_NAME) || xmlNode.attr(MAX_OCCURS_ATTR_NAME_WITH_NS); 334 | 335 | var title = xmlNode.find(TITLE_TAG_NAME).text(); 336 | var abstractValue = xmlNode.find(ABSTRACT_TAG_NAME).text() || undefined; 337 | var identifier = xmlNode.find(IDENTIFIER_TAG_NAME).text(); 338 | 339 | /* 340 | * complex data input 341 | */ 342 | var formatNodes = this.extractFormatNodes(xmlNode); 343 | 344 | var formatArray = this.createFormatArray(formatNodes); 345 | 346 | return this.createComplexDataInput(title, abstractValue, identifier, minOccurs, maxOccurs, formatArray); 347 | }, 348 | 349 | createBboxDataInputFromXml : function(xmlNode) { 350 | 351 | var minOccurs = xmlNode.attr(MIN_OCCURS_ATTR_NAME) || xmlNode.attr(MIN_OCCURS_ATTR_NAME_WITH_NS); 352 | var maxOccurs = xmlNode.attr(MAX_OCCURS_ATTR_NAME) || xmlNode.attr(MAX_OCCURS_ATTR_NAME_WITH_NS); 353 | 354 | var title = xmlNode.find(TITLE_TAG_NAME).text(); 355 | var abstractValue = xmlNode.find(ABSTRACT_TAG_NAME).text() || undefined; 356 | var identifier = xmlNode.find(IDENTIFIER_TAG_NAME).text(); 357 | 358 | //TODO BBOX 359 | var formatNodes = this.extractFormatNodes(xmlNode); 360 | 361 | /* 362 | * in WPS 1.0 there is no format for a bbox input! 363 | * 364 | * but in WPS 2.0 there is! 365 | * 366 | * Hence, we just add an "|| undefined" 367 | */ 368 | var formatArray = this.createFormatArray(formatNodes) || undefined; 369 | 370 | var supportedCRSs = this.createCrsArray(xmlNode.find(CRS_TAG_NAME)); 371 | 372 | return this.createBboxInput(title, abstractValue, identifier, minOccurs, maxOccurs, formatArray, supportedCRSs); 373 | 374 | }, 375 | 376 | createCrsArray : function(supportedCRSs_xml){ 377 | var supportedCrsArray = new Array(supportedCRSs_xml.length); 378 | 379 | for (var index = 0; index < supportedCRSs_xml.length; index++) { 380 | supportedCrsArray[index] = $(supportedCRSs_xml[index]).text(); 381 | } 382 | return supportedCrsArray; 383 | }, 384 | 385 | createFormatArray : function(formatNodes) { 386 | if(formatNodes.length == 0) 387 | return undefined; 388 | 389 | var formatArray = new Array(); 390 | 391 | for (var index = 0; index < formatNodes.length; index++) { 392 | var formatXml = $(formatNodes[index]); 393 | 394 | var mimeType = this.extractMimeType(formatXml); 395 | var encoding = this.extractEncoding(formatXml); 396 | var schema = this.extractSchema(formatXml); 397 | 398 | formatArray[index] = this.createFormat(mimeType, encoding, schema); 399 | } 400 | return formatArray; 401 | }, 402 | 403 | /** 404 | * override in child method to extract the mime type from the format xml node. 405 | * 406 | * Differs for various WPS versions. 407 | */ 408 | extractMimeType : function(formatXml){ 409 | 410 | }, 411 | 412 | /** 413 | * override in child method to extract the encoding from the format xml node. 414 | * 415 | * Differs for various WPS versions. 416 | */ 417 | extractEncoding : function(formatXml){ 418 | 419 | }, 420 | 421 | /** 422 | * override in child method to extract the schema from the format xml node. 423 | * 424 | * Differs for various WPS versions. 425 | */ 426 | extractSchema : function(formatXml){ 427 | 428 | }, 429 | 430 | createOutputs : function (outputNodes){ 431 | 432 | var array = new Array(outputNodes.length); 433 | 434 | for (var index = 0; index < outputNodes.length; index++) { 435 | var OutputXml = $(outputNodes[index]); 436 | 437 | if(OutputXml.find(LITERAL_DATA_OUTPUT_TAG_NAME).length > 0) 438 | array[index] = this.createLiteralDataOutputFromXml(OutputXml); 439 | 440 | else if (OutputXml.find(COMPLEX_DATA_OUTPUT_TAG_NAME).length > 0) 441 | array[index] = this.createComplexDataOutputFromXml(OutputXml); 442 | 443 | else if (OutputXml.find(BBOX_DATA_OUTPUT_TAG_NAME).length > 0) 444 | array[index] = this.createBboxDataOutputFromXml(OutputXml); 445 | 446 | /* 447 | * nested output! 448 | */ 449 | else if (OutputXml.find(PROCESS_OUTPUT_TAG_NAME).length > 0) 450 | array[index] = this.createOutputs(OutputXml); 451 | 452 | } 453 | 454 | return array; 455 | 456 | }, 457 | 458 | /** 459 | * TODO outputs vary... no format for literal data but multiple UOMs... 460 | */ 461 | 462 | createLiteralDataOutputFromXml : function(outputXml){ 463 | var title = outputXml.find(TITLE_TAG_NAME).text(); 464 | var abstractValue = outputXml.find(ABSTRACT_TAG_NAME).text() || undefined; 465 | var identifier = outputXml.find(IDENTIFIER_TAG_NAME).text(); 466 | 467 | /* 468 | * literal data input 469 | */ 470 | var formatNodes = this.extractFormatNodes(outputXml); 471 | 472 | /* 473 | * in WPS 1.0 there is no format for a literal otput! 474 | * 475 | * but in WPS 2.0 there is! 476 | * 477 | * Hence, we just add an "|| undefined" 478 | */ 479 | var formatArray = this.createFormatArray(formatNodes) ||undefined; 480 | 481 | var literalDataDomainArray = this.createLiteralDataDomainArray(outputXml.find(LITERAL_DATA_TAG_NAME)); 482 | 483 | return this.createLiteralDataOutput(title, abstractValue, identifier, 484 | formatArray, literalDataDomainArray); 485 | }, 486 | 487 | createComplexDataOutputFromXml : function(outputXml) { 488 | 489 | var title = outputXml.find(TITLE_TAG_NAME).text(); 490 | var abstractValue = outputXml.find(ABSTRACT_TAG_NAME).text() || undefined; 491 | var identifier = outputXml.find(IDENTIFIER_TAG_NAME).text(); 492 | 493 | /* 494 | * complex data input 495 | */ 496 | var formatNodes = this.extractFormatNodes(outputXml); 497 | 498 | var formatArray = this.createFormatArray(formatNodes); 499 | 500 | return this.createComplexDataOutput(title, abstractValue, 501 | identifier, formatArray); 502 | }, 503 | 504 | createBboxDataOutputFromXml : function(outputXml) { 505 | 506 | var title = outputXml.find(TITLE_TAG_NAME).text(); 507 | var abstractValue = outputXml.find(ABSTRACT_TAG_NAME).text() || undefined; 508 | var identifier = outputXml.find(IDENTIFIER_TAG_NAME).text(); 509 | 510 | var formatNodes = this.extractFormatNodes(outputXml); 511 | /* 512 | * in WPS 1.0 there is no format for a bbox output! 513 | * 514 | * but in WPS 2.0 there is! 515 | * 516 | * Hence, we just add an "|| undefined" 517 | */ 518 | var formatArray = this.createFormatArray(formatNodes) || undefined; 519 | 520 | var supportedCRSs = this.createCrsArray(outputXml.find(CRS_TAG_NAME)); 521 | 522 | return this.createBboxOutput(title, abstractValue, identifier, 523 | formatArray, supportedCRSs); 524 | } 525 | 526 | }); 527 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/response/ExceptionReportResponse.js: -------------------------------------------------------------------------------- 1 | var TEMPLATE_EXCEPTION_REPORT_RESPONSE_MARKUP = '\ 2 |
\ 3 |
\ 4 |
    \ 5 |
\ 6 |
\ 7 |
\ 8 |
'; 9 | 10 | var TEMPLATE_EXCEPTION_MARKUP = '\ 11 |
  • \ 12 | ${code} \ 13 |
  • \ 14 |
  • \ 15 | ${text} \ 16 |
  • '; 17 | 18 | var ExceptionReportResponse = BaseResponse 19 | .extend({ 20 | 21 | createMarkup : function() { 22 | var exceptionsFromResponse = this.xmlResponse 23 | .getElementsByTagNameNS(OWS_11_NAMESPACE, "Exception"); 24 | 25 | console.log("Got exception response!"); 26 | exceptions = jQuery(exceptionsFromResponse); 27 | console.log(exceptions); 28 | 29 | var parsedExceptions = []; 30 | for ( var i = 0; i < exceptions.length; i++) { 31 | var exc = jQuery(exceptions[i]); 32 | 33 | var parsedExc = { 34 | "code" : exc.attr("exceptionCode"), 35 | "text" : exc.text().trim() 36 | }; 37 | parsedExceptions.push(parsedExc); 38 | } 39 | 40 | var properties = {}; 41 | var result = jQuery.tmpl( 42 | TEMPLATE_EXCEPTION_REPORT_RESPONSE_MARKUP, properties); 43 | var exceptionList = result.children('#wps-exception-list'); 44 | 45 | // var extensionDiv = result 46 | // .children('#wps-exception-report-response-extension'); 47 | 48 | // TODO FIXME display exceptions 49 | if (parsedExceptions && !jQuery.isEmptyObject(parsedExceptions)) { 50 | jQuery(parsedExceptions) 51 | .each( 52 | function(key, value) { 53 | alert(key + " - " + value.code + ": " 54 | + value.text); 55 | jQuery 56 | .tmpl( 57 | TEMPLATE_EXCEPTION_MARKUP, 58 | value).appendTo( 59 | exceptionList); 60 | }); 61 | } 62 | 63 | return result; 64 | } 65 | 66 | }); 67 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/response/ExecuteResponse.js: -------------------------------------------------------------------------------- 1 | var ExecuteResponse = BaseResponse.extend({ 2 | 3 | init : function(wpsResponse) { 4 | this.responseDocument = wpsResponse; 5 | 6 | /* 7 | * executeResponse can be instantiated differentely, depending on the 8 | * WPS version and executionMode 9 | * 10 | * Hence, we specify some common parameters, that indicate how to 11 | * interpret the response 12 | */ 13 | this.executeResponse = { 14 | 15 | /* 16 | * type shall be used to indicate the type of document 17 | */ 18 | type : "", 19 | serviceVersion : "", 20 | /* 21 | * document will have varying properties as it will be instantiated 22 | * differently according to the type 23 | */ 24 | responseDocument : {} 25 | }; 26 | 27 | this.instantiate(wpsResponse); 28 | }, 29 | 30 | instantiate : function(wpsResponse) { 31 | /* 32 | * override this method in child classes to instantiate the object 33 | */ 34 | }, 35 | 36 | /** 37 | * will have different properties, depending on the WPS version! 38 | */ 39 | instantiateResultDocument : function() { 40 | this.executeResponse.resultDocument = { 41 | 42 | }; 43 | }, 44 | 45 | /** 46 | * only relevant for WPS 2.0 47 | */ 48 | instantiateStatusInfoDocument : function() { 49 | 50 | }, 51 | 52 | }); 53 | -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/response/ExecuteResponse_v1_xml.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Inspects XML response of WPS 1.0 execute request 3 | */ 4 | var ExecuteResponse_v1_xml = ExecuteResponse 5 | .extend({ 6 | instantiate : function(wpsResponse) { 7 | if ($(wpsResponse).find("wps\\:ExecuteResponse, ExecuteResponse").length > 0) { 8 | /* 9 | * response document! 10 | * 11 | * set the common response parameters 12 | */ 13 | this.executeResponse.serviceVersion = "1.0.0"; 14 | this.executeResponse.type = "responseDocument"; 15 | 16 | this.instantiateResponseDocument(wpsResponse); 17 | } else { 18 | /* 19 | * raw output 20 | */ 21 | this.executeResponse.serviceVersion = "1.0.0"; 22 | this.executeResponse.type = "rawOutput"; 23 | 24 | /* 25 | * check whether response is an XML document. 26 | * In that case return the xmlString, 27 | * else return the response directly 28 | */ 29 | var rawOutput; 30 | if(!(typeof wpsResponse === 'string') && ($(wpsResponse).length > 0)) 31 | rawOutput = (new XMLSerializer()).serializeToString(wpsResponse); 32 | else 33 | rawOutput = wpsResponse; 34 | 35 | this.executeResponse.responseDocument = rawOutput; 36 | } 37 | }, 38 | 39 | instantiateResponseDocument : function(wpsResponse) { 40 | var executeResponse_xmlNode = $(wpsResponse).find( 41 | "wps\\:ExecuteResponse, ExecuteResponse"); 42 | 43 | /* 44 | * service 45 | */ 46 | var service = "WPS"; 47 | var version = "1.0.0"; 48 | var lang = executeResponse_xmlNode.attr("lang") 49 | || executeResponse_xmlNode.attr("xml\\:lang"); 50 | /* 51 | * statusLocation may not exist 52 | */ 53 | var statusLocation = executeResponse_xmlNode 54 | .attr("statusLocation") 55 | || executeResponse_xmlNode.attr("wps\\:statusLocation") 56 | || undefined; 57 | var serviceInstance = executeResponse_xmlNode 58 | .attr("serviceInstance") 59 | || executeResponse_xmlNode.attr("wps\\:serviceInstance"); 60 | 61 | /* 62 | * process 63 | */ 64 | var process_xmlNode = executeResponse_xmlNode.find("wps\\:Process, Process"); 65 | var processId = process_xmlNode.find("ows\\:Identifier, Identifier").text(); 66 | var processTitle = process_xmlNode.find("ows\\:Title, Title").text(); 67 | var process = { 68 | identifier : processId, 69 | title : processTitle 70 | }; 71 | 72 | /* 73 | * status 74 | */ 75 | var status_xmlNode = executeResponse_xmlNode.find("wps\\:Status, Status"); 76 | var statusCreationTime = status_xmlNode.attr("creationTime") 77 | || status_xmlNode.attr("wps\\:creationTime"); 78 | var statusInfo = null; 79 | if (status_xmlNode.find("wps\\:ProcessAccepted, ProcessAccepted").length > 0) 80 | statusInfo = status_xmlNode.find("wps\\:ProcessAccepted, ProcessAccepted").prop( 81 | "tagName"); 82 | else if (status_xmlNode.find("wps\\:ProcessStarted, ProcessStarted").length > 0) 83 | statusInfo = status_xmlNode.find("wps\\:ProcessStarted, ProcessStarted").prop( 84 | "tagName").concat(" - percentCompleted:").concat( 85 | status_xmlNode.find("wps\\:ProcessStarted, ProcessStarted").attr( 86 | "percentCompleted")); 87 | else if (status_xmlNode.find("wps\\:ProcessPaused, ProcessPaused").length > 0) 88 | statusInfo = status_xmlNode.find("wps\\:ProcessPaused, ProcessPaused").prop( 89 | "tagName").concat(" - percentCompleted:").concat( 90 | status_xmlNode.find("wps\\:ProcessPaused, ProcessPaused").attr( 91 | "percentCompleted")); 92 | else if (status_xmlNode.find("wps\\:ProcessSucceeded, ProcessSucceeded").length > 0) 93 | statusInfo = status_xmlNode.find("wps\\:ProcessSucceeded, ProcessSucceeded").prop( 94 | "tagName"); 95 | else 96 | statusInfo = status_xmlNode.find("wps\\:ProcessFailed, ProcessFailed").find( 97 | "wps\\:ExceptionReport, ows\\:ExceptionReport, ExceptionReport").find("wps\\:ExceptionText, ows\\:ExceptionText, ExceptionText").text() 98 | || status_xmlNode.find("wps\\:ProcessFailed, ProcessFailed").find( 99 | "wps\\:ExceptionReport, ows\\:ExceptionReport, ExceptionReport").attr("exceptionCode"); 100 | 101 | var statusInfoTest = status_xmlNode.find("wps\\:ProcessSucceeded, ProcessSucceeded") 102 | .text(); 103 | 104 | var status = { 105 | creationTime : statusCreationTime, 106 | info : statusInfo 107 | }; 108 | 109 | /* 110 | * TODO lineage=true --> include dataInputs and outputs 111 | * definitions? 112 | */ 113 | 114 | /* 115 | * outputs 116 | */ 117 | var processOutputs_xmlNode = executeResponse_xmlNode 118 | .find("wps\\:ProcessOutputs, ProcessOutputs"); 119 | var outputs_xmlNodes = processOutputs_xmlNode.find("wps\\:Output, Output"); 120 | var outputs = this.instantiateOutputs(outputs_xmlNodes); 121 | 122 | /* 123 | * create responseDocument 124 | */ 125 | this.executeResponse.responseDocument = { 126 | service : service, 127 | version : version, 128 | lang : lang, 129 | statusLocation : statusLocation, 130 | serviceInstance : serviceInstance, 131 | process : process, 132 | status : status, 133 | outputs : outputs 134 | }; 135 | 136 | }, 137 | 138 | instantiateOutputs : function(outputs_xmlNodes) { 139 | var outputs = new Array(outputs_xmlNodes.length); 140 | 141 | for (var index = 0; index < outputs_xmlNodes.length; index++) { 142 | var output_xmlNode = $(outputs_xmlNodes[index]); 143 | 144 | var id = output_xmlNode.find("ows\\:Identifier, Identifier").text(); 145 | var title = output_xmlNode.find("ows\\:Title, Title").text(); 146 | var abstractValue = output_xmlNode.find("ows\\:Abstract, Abstract").text() 147 | || undefined; 148 | 149 | /* 150 | * either element "Data" or "Reference" exists 151 | */ 152 | var reference_xmlNode = output_xmlNode.find("wps\\:Reference, Reference"); 153 | var reference = undefined; 154 | if (reference_xmlNode.length > 0) { 155 | reference = { 156 | href : reference_xmlNode.attr("href") 157 | || reference_xmlNode.attr("wps\\:href"), 158 | format : reference_xmlNode.attr("mimeType") 159 | || reference_xmlNode.attr("format") 160 | || undefined, 161 | encoding : reference_xmlNode.attr("encoding") 162 | || undefined, 163 | schema : reference_xmlNode.attr("schema") 164 | || undefined 165 | } 166 | 167 | outputs[index] = { 168 | identifier : id, 169 | title : title, 170 | abstractValue : abstractValue, 171 | reference : reference, 172 | }; 173 | } else { 174 | /* 175 | * Data element 176 | */ 177 | var data_xmlNode = output_xmlNode.find("wps\\:Data, Data"); 178 | 179 | /* 180 | * data can either be a complexData or a LiteralData or 181 | * a BoundingBoxData element 182 | */ 183 | var data; 184 | var complexData_xmlNode = data_xmlNode 185 | .find("wps\\:ComplexData, ComplexData"); 186 | var literalData_xmlNode = data_xmlNode 187 | .find("wps\\:LiteralData, LiteralData"); 188 | var bboxData_xmlNode = data_xmlNode 189 | .find("wps\\:BoundingBoxData, BoundingBoxData"); 190 | if (complexData_xmlNode.length > 0) { 191 | var data = { 192 | complexData : { 193 | mimeType : complexData_xmlNode.attr("mimeType") 194 | || undefined, 195 | schema : complexData_xmlNode.attr("schema") 196 | || undefined, 197 | encoding : complexData_xmlNode.attr("encoding") 198 | || undefined, 199 | value : complexData_xmlNode.html() 200 | } 201 | 202 | } 203 | } else if (bboxData_xmlNode.length > 0) { 204 | 205 | var data = { 206 | boundingBoxData : { 207 | crs : bboxData_xmlNode.attr("crs") || undefined, 208 | dimensions : bboxData_xmlNode 209 | .attr("dimensions") 210 | || undefined, 211 | lowerCorner : bboxData_xmlNode 212 | .attr("lowerCorner") 213 | || bboxData_xmlNode.find("ows\\:LowerCorner, LowerCorner") 214 | .text(), 215 | upperCorner : bboxData_xmlNode 216 | .attr("upperCorner") 217 | || bboxData_xmlNode.find("ows\\:UpperCorner, UpperCorner") 218 | .text() 219 | } 220 | 221 | } 222 | } else { 223 | /* 224 | * literalData 225 | */ 226 | var data = { 227 | literalData : { 228 | dataType : literalData_xmlNode.attr("dataType") 229 | || undefined, 230 | uom : literalData_xmlNode.attr("uom") 231 | || undefined, 232 | value : literalData_xmlNode.text() 233 | } 234 | 235 | } 236 | } 237 | 238 | outputs[index] = { 239 | identifier : id, 240 | title : title, 241 | abstractValue : abstractValue, 242 | data : data, 243 | }; 244 | } 245 | 246 | } // end for 247 | return outputs; 248 | } 249 | }); -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/response/ExecuteResponse_v2_xml.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Inspects XML response of WPS 2.0 execute request 3 | */ 4 | var ExecuteResponse_v2_xml = ExecuteResponse.extend({ 5 | 6 | instantiate : function(wpsResponse) { 7 | /* 8 | * TODO WPS 2.0 specifies different response possibilities 9 | * 10 | * raw data 11 | * 12 | * StatusInfo document 13 | * 14 | * Response/Result Document 15 | * 16 | * Hence, we must implement each possibility and return an appropriate 17 | * response 18 | */ 19 | if ($(wpsResponse).find("wps\\:Result, Result").length > 0) { 20 | /* 21 | * response/result document! 22 | * 23 | * set the common response parameters 24 | */ 25 | this.executeResponse.serviceVersion = "2.0.0"; 26 | this.executeResponse.type = "resultDocument" 27 | 28 | this.instantiateResultDocument(wpsResponse); 29 | } else if ($(wpsResponse).find("wps\\:StatusInfo, StatusInfo").length > 0) { 30 | /* 31 | * response/result document! 32 | * 33 | * set the common response parameters 34 | */ 35 | this.executeResponse.serviceVersion = "2.0.0"; 36 | this.executeResponse.type = "statusInfoDocument"; 37 | 38 | this.instantiateStatusInfoDocument(wpsResponse); 39 | } else { 40 | /* 41 | * raw output 42 | */ 43 | this.executeResponse.serviceVersion = "2.0.0"; 44 | this.executeResponse.type = "rawOutput"; 45 | 46 | /* 47 | * check whether response is an XML document. 48 | * In that case return the xmlString, 49 | * else return the response directly 50 | */ 51 | var rawOutput; 52 | if(!(typeof wpsResponse === 'string') && ($(wpsResponse).length > 0)) 53 | rawOutput = (new XMLSerializer()).serializeToString(wpsResponse); 54 | else 55 | rawOutput = wpsResponse; 56 | 57 | this.executeResponse.responseDocument = rawOutput; 58 | } 59 | }, 60 | 61 | instantiateResultDocument : function(wpsResponse) { 62 | 63 | var result_xmlNode = $(wpsResponse).find("wps\\:Result, Result"); 64 | 65 | var jobId = result_xmlNode.find("wps\\:JobID, JobID").text() || undefined; 66 | var expirationDate = result_xmlNode.find("wps\\:ExpirationDate, ExpirationDate").text() 67 | || undefined; 68 | 69 | var outputs = this.instantiateOutputs(result_xmlNode.find("wps\\:Output, Output")); 70 | 71 | this.executeResponse.responseDocument = { 72 | jobId : jobId, 73 | expirationDate : expirationDate, 74 | outputs : outputs 75 | }; 76 | }, 77 | 78 | instantiateOutputs : function(outputs_xmlNodes) { 79 | var outputs = new Array(outputs_xmlNodes.length); 80 | 81 | for (var index = 0; index < outputs_xmlNodes.length; index++) { 82 | var output_xmlNode = $(outputs_xmlNodes[index]); 83 | 84 | /* 85 | * either element "Data" or "Reference" exists 86 | */ 87 | var reference_xmlNode = output_xmlNode.find("wps\\:Reference, Reference"); 88 | var reference = undefined; 89 | if (reference_xmlNode.length > 0) { 90 | reference = { 91 | href : reference_xmlNode.attr("href") 92 | || reference_xmlNode.attr("wps:href") 93 | || reference_xmlNode.attr("xlin:href") 94 | || reference_xmlNode.attr("xlink:href") 95 | || reference_xmlNode.attr("ows:href") 96 | || reference_xmlNode.attr("wps\\:href") 97 | || reference_xmlNode.attr("xlin\\:href"), 98 | format : reference_xmlNode.attr("mimeType") 99 | || reference_xmlNode.attr("format") 100 | || undefined, 101 | encoding : reference_xmlNode.attr("encoding") 102 | || undefined, 103 | schema : reference_xmlNode.attr("schema") 104 | || undefined 105 | } 106 | 107 | outputs[index] = { 108 | identifier : output_xmlNode.attr("id"), 109 | reference : reference 110 | }; 111 | } 112 | else{ 113 | 114 | /* 115 | * Data node; 116 | * 117 | * in WPS 2.0.0 this node may either have a subnode named: 118 | * - "LiteralValue" or 119 | * - "BoundingBox" or 120 | * - directValue for 121 | * complexOutput --> complex output does not have an own subNode!!! 122 | */ 123 | var data_xmlNode = output_xmlNode.find("wps\\:Data, Data"); 124 | 125 | /* 126 | * data can either be a LiteralValue or a 127 | * BoundingBox element 128 | */ 129 | var data; 130 | var literalData_xmlNode = data_xmlNode.find("wps\\:LiteralValue, LiteralValue"); 131 | var bboxData_xmlNode = data_xmlNode.find("ows\\:BoundingBox, BoundingBox"); 132 | if (literalData_xmlNode.length > 0) { 133 | 134 | /* 135 | * literalData 136 | */ 137 | data = { 138 | literalData : { 139 | dataType : literalData_xmlNode.attr("dataType") 140 | || undefined, 141 | uom : literalData_xmlNode.attr("uom") || undefined, 142 | value : literalData_xmlNode.text() 143 | } 144 | 145 | } 146 | 147 | 148 | } else if (bboxData_xmlNode.length > 0) { 149 | 150 | data = { 151 | boundingBoxData : { 152 | crs : bboxData_xmlNode.attr("crs") || undefined, 153 | dimensions : bboxData_xmlNode.attr("dimensions") 154 | || undefined, 155 | lowerCorner : bboxData_xmlNode.attr("lowerCorner") 156 | || bboxData_xmlNode.find("ows\\:LowerCorner, LowerCorner").text(), 157 | upperCorner : bboxData_xmlNode.attr("upperCorner") 158 | || bboxData_xmlNode.find("ows\\:UpperCorner, UpperCorner").text() 159 | } 160 | 161 | } 162 | } else { 163 | /* 164 | * complex data 165 | */ 166 | data = { 167 | complexData : { 168 | mimeType : data_xmlNode.attr("mimeType") 169 | || undefined, 170 | schema : data_xmlNode.attr("schema") 171 | || undefined, 172 | encoding : data_xmlNode.attr("encoding") 173 | || undefined, 174 | value : data_xmlNode.html() 175 | } 176 | 177 | } 178 | } 179 | 180 | /* 181 | * TODO nested Output! 182 | */ 183 | 184 | outputs[index] = { 185 | identifier : output_xmlNode.attr("id"), 186 | data : data 187 | }; 188 | } // end else data or reference 189 | } // end for 190 | 191 | return outputs; 192 | }, 193 | 194 | instantiateStatusInfoDocument : function(wpsResponse) { 195 | var statusInfo_xmlNode = $(wpsResponse).find("wps\\:StatusInfo, StatusInfo"); 196 | 197 | var jobId = statusInfo_xmlNode.find("wps\\:JobID, JobID").text(); 198 | var status = statusInfo_xmlNode.find("wps\\:Status, Status").text(); 199 | var expirationDate = statusInfo_xmlNode.find("wps\\:ExpirationDate, ExpirationDate").text() 200 | || undefined; 201 | var estimatedCompletion = statusInfo_xmlNode 202 | .find("wps\\:EstimatedCompletion, EstimatedCompletion").text() 203 | || undefined; 204 | var nextPoll = statusInfo_xmlNode.find("wps\\:NextPoll, NextPoll").text() || undefined; 205 | var percentCompleted = statusInfo_xmlNode.find("wps\\:PercentCompleted, PercentCompleted") 206 | .text() 207 | || undefined; 208 | 209 | this.executeResponse.responseDocument = { 210 | jobId : jobId, 211 | status : status, 212 | expirationDate : expirationDate, 213 | estimatedCompletion : estimatedCompletion, 214 | nextPoll : nextPoll, 215 | percentCompleted : percentCompleted 216 | }; 217 | } 218 | 219 | }); -------------------------------------------------------------------------------- /src/web/js/wps-js-lib/response/ResponseFactory.js: -------------------------------------------------------------------------------- 1 | var ResponseFactory = Class.extend({ 2 | 3 | init : function(settings) { 4 | this.settings = settings; 5 | }, 6 | 7 | /** 8 | * Since the returned documents of the WPS differ with respect to the 9 | * service version, the matching result document has to be instantiated 10 | * 11 | * @requestObject the request object that created the responseFactory. It is 12 | * used to resolve the response type 13 | */ 14 | resolveResponseHandler : function(wpsResponse, requestObject) { 15 | 16 | /* 17 | * version and requestType will be compared to constant values from Constants.js 18 | */ 19 | var version = requestObject.settings.version; 20 | var requestType = requestObject.settings.requestType; 21 | 22 | if (requestType == GET_CAPABILITIES_TYPE) { 23 | if (version == WPS_VERSION_1_0_0) 24 | return new CapabilitiesResponse_v1_xml(wpsResponse); 25 | else if (version == WPS_VERSION_2_0_0) 26 | return new CapabilitiesResponse_v2_xml(wpsResponse); 27 | else { 28 | return null; 29 | } 30 | } else if (requestType == DESCRIBE_PROCESS_TYPE) { 31 | 32 | if (version == WPS_VERSION_1_0_0) 33 | return new DescribeProcessResponse_v1_xml(wpsResponse); 34 | else if (version == WPS_VERSION_2_0_0) 35 | return new DescribeProcessResponse_v2_xml(wpsResponse); 36 | else { 37 | return null; 38 | } 39 | } else if (requestType == EXECUTE_TYPE) { 40 | 41 | if (version == WPS_VERSION_1_0_0) 42 | return new ExecuteResponse_v1_xml(wpsResponse); 43 | else if (version == WPS_VERSION_2_0_0) 44 | return new ExecuteResponse_v2_xml(wpsResponse); 45 | else { 46 | return null; 47 | } 48 | } else if (requestType == GET_STATUS_TYPE) { 49 | return new ExecuteResponse_v2_xml(wpsResponse); 50 | 51 | } else if (requestType == GET_RESULT_TYPE) { 52 | return new ExecuteResponse_v2_xml(wpsResponse); 53 | 54 | }else { 55 | // TODO 56 | return new ExceptionReportResponse(wpsResponse); 57 | } 58 | 59 | return null; 60 | } 61 | 62 | }); 63 | -------------------------------------------------------------------------------- /src/web/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 45 | 47 | 49 | 51 | 53 | 55 | 57 | 59 | 61 | 63 | 65 | 67 | 69 | 70 | 71 | 72 | 73 | wps-js example 74 | 75 | 76 | 77 |
    78 |
    79 |

    wps-js example

    80 |

    81 | wps-js is an open source client library for 83 | connecting Javascript client to OGC Web Processing 86 | services. This page demonstrates how you can use it. More 87 | documentation is available in the 52°North Wiki and on GitHub. 92 |

    93 |
    94 |
    95 | 100 |
    101 |
    102 | 103 | 104 | 105 | 106 | 107 |
    108 |
    109 |

    XML

    110 |
    111 | 112 |
    113 |
    114 |
    115 | 347 | 348 | 353 | 354 | 355 | 356 | --------------------------------------------------------------------------------