OGC Bounding Box¶
CWL Example¶
# Copyright 2025 Terradue
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cwlVersion: v1.2
class: CommandLineTool
label: "Echo OGC BBox"
baseCommand: echo
requirements:
- class: InlineJavascriptRequirement
- class: SchemaDefRequirement
types:
- $import: https://raw.githubusercontent.com/eoap/schemas/main/ogc.yaml
inputs:
aoi:
type: https://raw.githubusercontent.com/eoap/schemas/main/ogc.yaml#BBox
label: "Area of interest"
doc: "Area of interest defined as a bounding box"
inputBinding:
valueFrom: |
${
// Validate the length of bbox to be either 4 or 6
var bboxLength = inputs.aoi.bbox.length;
if (bboxLength !== 4 && bboxLength !== 6) {
throw "Invalid bbox length: bbox must have either 4 or 6 elements.";
}
// Convert bbox array to a space-separated string for echo
return inputs.aoi.bbox.join(' ') + " CRS: " + inputs.aoi.crs;
}
outputs:
echo_output:
type: stdout
stdout: echo_output.txt
Input example¶
# Copyright 2025 Terradue
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
aoi:
class: "https://raw.githubusercontent.com/eoap/schemas/main/ogc.yaml#BBox"
bbox: [100.0, 0.0, 101.0, 1.0]
crs: "CRS84"
Execute the example¶
Run the example with:
cwltool examples/ogc/bbox.cwl examples/ogc/bbox.yaml > output.json
This produces the output:
INFO /opt/hostedtoolcache/Python/3.12.12/x64/bin/cwltool 3.1.20251031082601
INFO Resolved '../../examples/ogc/bbox.cwl' to 'file:///home/runner/work/schemas/schemas/examples/ogc/bbox.cwl'
INFO [job bbox.cwl] /tmp/zik5ylev$ echo \
'100 0 101 1 CRS: CRS84' > /tmp/zik5ylev/echo_output.txt
INFO [job bbox.cwl] completed success
INFO Final process status is success
The content of the echo_output.txt file is:
100 0 101 1 CRS: CRS84