From 2c5c538c81419bb7dc9fccee2cb86f953b72ce0d Mon Sep 17 00:00:00 2001 From: David Huard Date: Mon, 26 Apr 2021 13:51:34 -0400 Subject: [PATCH 1/2] add geojson input to geodata process --- emu/processes/wps_geodata.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/emu/processes/wps_geodata.py b/emu/processes/wps_geodata.py index 8573c68..262af2f 100644 --- a/emu/processes/wps_geodata.py +++ b/emu/processes/wps_geodata.py @@ -4,8 +4,9 @@ Author: Trevor James Smith """ from pathlib import Path -from pywps import Process, ComplexOutput +from pywps import Process, ComplexOutput, ComplexInput from pywps import FORMATS +from pywps.validator.mode import MODE import logging @@ -18,7 +19,13 @@ class GeoData(Process): def __init__(self): - inputs = list() + inputs = [ComplexInput("shape", + "Geometry", + supported_formats=[FORMATS.GEOJSON], + mode=MODE.NONE, # Can be upgraded to STRICT once pywps releases 4.4.3 or 4.5. + min_occurs=1, + max_occurs=1) + ] outputs = [ ComplexOutput( "raster", @@ -50,8 +57,11 @@ def __init__(self): @staticmethod def _handler(request, response): + import json response.update_status("PyWPS Process started.", 0) + json.loads(request.inputs["shape"][0].data) + response.outputs['vector'].file = DATA_DIR / "Olympus_Mons.geojson" response.outputs['raster'].file = DATA_DIR / "Olympus.tif" From 61f1222e0f8152eb917df787c73c410365efc76e Mon Sep 17 00:00:00 2001 From: David Huard Date: Mon, 26 Apr 2021 14:02:09 -0400 Subject: [PATCH 2/2] make geodata shape input optional --- emu/processes/wps_geodata.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/emu/processes/wps_geodata.py b/emu/processes/wps_geodata.py index 262af2f..6a32206 100644 --- a/emu/processes/wps_geodata.py +++ b/emu/processes/wps_geodata.py @@ -23,7 +23,7 @@ def __init__(self): "Geometry", supported_formats=[FORMATS.GEOJSON], mode=MODE.NONE, # Can be upgraded to STRICT once pywps releases 4.4.3 or 4.5. - min_occurs=1, + min_occurs=0, max_occurs=1) ] outputs = [ @@ -60,7 +60,9 @@ def _handler(request, response): import json response.update_status("PyWPS Process started.", 0) - json.loads(request.inputs["shape"][0].data) + if "shape" in request.inputs: + LOGGER.info("Loading `shape`") + json.loads(request.inputs["shape"][0].data) response.outputs['vector'].file = DATA_DIR / "Olympus_Mons.geojson"