def test_wps_response6(): # Build WPS object; service has been down for some time so skip caps here wps = WebProcessingService('http://rsg.pml.ac.uk/wps/vector.cgi', skip_caps=True) # Execute face WPS invocation request = open(resource_file('wps_PMLExecuteRequest6.xml'), 'rb').read() response = open(resource_file('wps_PMLExecuteResponse6.xml'), 'rb').read() execution = wps.execute(None, [], request=request, response=response) # Check execution result assert execution.status == 'ProcessSucceeded' assert execution.url == 'http://rsg.pml.ac.uk/wps/vector.cgi' assert execution.statusLocation == \ 'http://rsg.pml.ac.uk/wps/wpsoutputs/pywps-132084838963.xml' assert execution.serviceInstance == \ 'http://rsg.pml.ac.uk/wps/vector.cgi?service=WPS&request=GetCapabilities&version=1.0.0' assert execution.version == '1.0.0' # check single output output = execution.processOutputs[0] assert output.identifier == 'output' assert output.title == 'Name for output vector map' assert output.mimeType == 'text/xml' assert output.dataType == 'ComplexData' assert output.reference is None response = output.data[0] should_return = '''<ns3:FeatureCollection xmlns:ns3="http://ogr.maptools.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://www.opengis.net/wps/1.0.0" xsi:schemaLocation="http://ogr.maptools.org/ output_0n7ij9D.xsd">\n\t\t\t\t\t <gml:boundedBy xmlns:gml="http://www.opengis.net/gml">\n\t\t\t\t\t <gml:Box>\n\t\t\t\t\t <gml:coord><gml:X>-960123.1421801626</gml:X><gml:Y>4665723.56559387</gml:Y></gml:coord>\n\t\t\t\t\t <gml:coord><gml:X>-101288.6510608822</gml:X><gml:Y>5108200.011823481</gml:Y></gml:coord>\n\t\t\t\t\t </gml:Box>\n\t\t\t\t\t </gml:boundedBy> \n\t\t\t\t\t <gml:featureMember xmlns:gml="http://www.opengis.net/gml">\n\t\t\t\t\t <ns3:output fid="F0">\n\t\t\t\t\t <ns3:geometryProperty><gml:LineString><gml:coordinates>-960123.142180162365548,4665723.565593870356679,0 -960123.142180162365548,4665723.565593870356679,0 -960123.142180162598379,4665723.565593870356679,0 -960123.142180162598379,4665723.565593870356679,0 -711230.141176006174646,4710278.48552671354264,0 -711230.141176006174646,4710278.48552671354264,0 -623656.677859728806652,4848552.374973464757204,0 -623656.677859728806652,4848552.374973464757204,0 -410100.337491964863148,4923834.82589447684586,0 -410100.337491964863148,4923834.82589447684586,0 -101288.651060882242746,5108200.011823480948806,0 -101288.651060882242746,5108200.011823480948806,0 -101288.651060882257298,5108200.011823480948806,0 -101288.651060882257298,5108200.011823480948806,0</gml:coordinates></gml:LineString></ns3:geometryProperty>\n\t\t\t\t\t <ns3:cat>1</ns3:cat>\n\t\t\t\t\t <ns3:id>1</ns3:id>\n\t\t\t\t\t <ns3:fcat>0</ns3:fcat>\n\t\t\t\t\t <ns3:tcat>0</ns3:tcat>\n\t\t\t\t\t <ns3:sp>0</ns3:sp>\n\t\t\t\t\t <ns3:cost>1002619.181</ns3:cost>\n\t\t\t\t\t <ns3:fdist>0</ns3:fdist>\n\t\t\t\t\t <ns3:tdist>0</ns3:tdist>\n\t\t\t\t\t </ns3:output>\n\t\t\t\t\t </gml:featureMember>\n\t\t\t\t\t</ns3:FeatureCollection>''' # noqa assert compare_xml(should_return, response) is True
def test_wps_request3(): # Supply process input argument wfsUrl = "http://igsarm-cida-gdp2.er.usgs.gov:8082/geoserver/wfs" query = WFSQuery("sample:CONUS_States", propertyNames=['the_geom', "STATE"], filters=["CONUS_States.508", "CONUS_States.469"]) featureCollection = WFSFeatureCollection(wfsUrl, query) processid = 'gov.usgs.cida.gdp.wps.algorithm.FeatureWeightedGridStatisticsAlgorithm' inputs = [ ("FEATURE_ATTRIBUTE_NAME", "STATE"), ("DATASET_URI", "dods://igsarm-cida-thredds1.er.usgs.gov:8080/thredds/dodsC/dcp/conus_grid.w_meta.ncml" ), ("DATASET_ID", "ccsm3_a1b_tmax"), ("DATASET_ID", "ccsm3_a1b_pr"), ("DATASET_ID", "ccsm3_a1fi_tmax"), ("TIME_START", "1960-01-01T00:00:00.000Z"), ("TIME_END", "1960-12-31T00:00:00.000Z"), ("REQUIRE_FULL_COVERAGE", "true"), ("DELIMITER", "COMMA"), ("STATISTICS", "MEAN"), ("STATISTICS", "MINIMUM"), ("STATISTICS", "MAXIMUM"), ("STATISTICS", "WEIGHT_SUM"), ("STATISTICS", "VARIANCE"), ("STATISTICS", "STD_DEV"), ("STATISTICS", "COUNT"), ("GROUP_BY", "STATISTIC"), ("SUMMARIZE_TIMESTEP", "true"), ("SUMMARIZE_FEATURE_ATTRIBUTE", "true"), ("FEATURE_COLLECTION", featureCollection) ] output = "OUTPUT" # build XML request for WPS process execution execution = WPSExecution() requestElement = execution.buildRequest(processid, inputs, output=output) request = etree.tostring(requestElement) # Compare to cached XML request _request = open(resource_file('wps_USGSExecuteRequest2.xml'), 'rb').read() assert compare_xml(request, _request) is True
def test_wps_request3(): # Supply process input arguments polygon = [(-102.8184, 39.5273), (-102.8184, 37.418), (-101.2363, 37.418), (-101.2363, 39.5273), (-102.8184, 39.5273)] featureCollection = GMLMultiPolygonFeatureCollection([polygon]) processid = 'gov.usgs.cida.gdp.wps.algorithm.FeatureWeightedGridStatisticsAlgorithm' inputs = [("FEATURE_ATTRIBUTE_NAME", "the_geom"), ("DATASET_URI", "dods://igsarm-cida-thredds1.er.usgs.gov:8080/thredds/dodsC/dcp/conus_grid.w_meta.ncml"), ("DATASET_ID", "ccsm3_a1b_tmax"), ("TIME_START", "1960-01-01T00:00:00.000Z"), ("TIME_END", "1960-12-31T00:00:00.000Z"), ("REQUIRE_FULL_COVERAGE", "true"), ("DELIMITER", "COMMA"), ("STATISTICS", "MEAN"), ("STATISTICS", "MINIMUM"), ("STATISTICS", "MAXIMUM"), ("STATISTICS", "WEIGHT_SUM"), ("STATISTICS", "VARIANCE"), ("STATISTICS", "STD_DEV"), ("STATISTICS", "COUNT"), ("GROUP_BY", "STATISTIC"), ("SUMMARIZE_TIMESTEP", "false"), ("SUMMARIZE_FEATURE_ATTRIBUTE", "false"), ("FEATURE_COLLECTION", featureCollection)] output = "OUTPUT" # build XML request for WPS process execution execution = WPSExecution() requestElement = execution.buildRequest(processid, inputs, output=output) request = etree.tostring(requestElement) # Compare to cached XML request _request = open(resource_file('wps_USGSExecuteRequest3.xml'), 'rb').read() assert compare_xml(request, _request) is True
def test_wps_request9(): # Process input/output arguments processid = "helloworld" inputs = [("user", 'Pingu')] # Build XML request for WPS process execution execution = WPSExecution() requestElement = execution.buildRequest(processid, inputs) request = etree.tostring(requestElement) # Compare to cached XML request _request = open(resource_file('wps_EmuExecuteRequest9.xml'), 'rb').read() assert compare_xml(request, _request) is True
def test_wps_request11_bbox(): processid = "bbox" bbox = BoundingBoxDataInput([51.9, 7.0, 53.0, 8.0]) inputs = [("bbox", bbox)] # Build XML request for WPS process execution execution = WPSExecution() requestElement = execution.buildRequest(processid, inputs) request = etree.tostring(requestElement) # Compare to cached XML request _request = open(resource_file('wps_EmuExecuteRequest11.xml'), 'rb').read() assert compare_xml(request, _request) is True
def test_wps_request5(): # Process input/output arguments processid = "reprojectCoords" inputs = [("coords", "http://rsg.pml.ac.uk/wps/testdata/coords.txt"), ("outputSRS", "EPSG:32630"), ("inputSRS", "EPSG:4326")] # build XML request for WPS process execution execution = WPSExecution() requestElement = execution.buildRequest(processid, inputs) request = etree.tostring(requestElement) # Compare to cached XML request _request = open(resource_file('wps_PMLExecuteRequest5.xml'), 'rb').read() assert compare_xml(request, _request) is True
def test_wps_request4(): # Process input/ouutput arguments processid = "reprojectImage" inputs = [("inputImage", "http://rsg.pml.ac.uk/wps/testdata/elev_srtm_30m.img"), ("outputSRS", "EPSG:4326")] output = "outputImage" # build XML request for WPS process execution execution = WPSExecution() requestElement = execution.buildRequest(processid, inputs, output=[(output, True)]) request = etree.tostring(requestElement) # Compare to cached XML request _request = open(resource_file('wps_PMLExecuteRequest4.xml'), 'rb').read() assert compare_xml(request, _request) is True
def test_wps_request8(): # Process input/ouutput arguments processid = "wordcount" textdoc = ComplexDataInput("Alice was beginning to get very tired ...") inputs = [("text", textdoc), ] outputs = [("output", True), ] # Build XML request for WPS process execution execution = WPSExecution() requestElement = execution.buildRequest(processid, inputs, output=outputs, async=True, lineage=True) request = etree.tostring(requestElement) # Compare to cached XML request _request = open(resource_file('wps_EmuExecuteRequest8.xml'), 'rb').read() assert compare_xml(request, _request) is True
def test_wps_request4(): # Process input/ouutput arguments processid = "reprojectImage" inputs = [("inputImage", "http://rsg.pml.ac.uk/wps/testdata/elev_srtm_30m.img"), ("outputSRS", "EPSG:4326")] output = "outputImage" # build XML request for WPS process execution execution = WPSExecution() requestElement = execution.buildRequest(processid, inputs, output=output) request = etree.tostring(requestElement) # Compare to cached XML request _request = open(resource_file('wps_PMLExecuteRequest4.xml'), 'rb').read() assert compare_xml(request, _request) is True
def test_wps_request6(): # Process input/output arguments processid = "v.net.path" inputs = [("input", "http://rsg.pml.ac.uk/wps/example/graph.gml"), ("file", "1 -960123.1421801624 4665723.56559387 -101288.65106088226 5108200.011823481")] # Build XML request for WPS process execution execution = WPSExecution() requestElement = execution.buildRequest(processid, inputs) request = etree.tostring(requestElement) # Compare to cached XML request _request = open(resource_file('wps_PMLExecuteRequest6.xml'), 'rb').read() assert compare_xml(request, _request) is True
def test_wps_request8(): # Process input/ouutput arguments processid = "wordcount" textdoc = ComplexDataInput("Alice was beginning to get very tired ...") inputs = [("text", textdoc), ] outputs = [("output", True), ] # Build XML request for WPS process execution execution = WPSExecution() requestElement = execution.buildRequest(processid, inputs, output=outputs, mode=ASYNC, lineage=True) request = etree.tostring(requestElement) # Compare to cached XML request _request = open(resource_file('wps_EmuExecuteRequest8.xml'), 'rb').read() assert compare_xml(request, _request) is True
def test_wps_request7(): # Process input/ouutput arguments processid = "wordcount" textdoc = ComplexDataInput("http://emu.readthedocs.org/en/latest/index.html") inputs = [("text", textdoc), ] outputs = [("output", True)] # Build XML request for WPS process execution, sync request execution = WPSExecution() requestElement = execution.buildRequest(processid, inputs, output=outputs, mode=SYNC, lineage=False) request = etree.tostring(requestElement) # Compare to cached XML request _request = open(resource_file('wps_EmuExecuteRequest7.xml'), 'rb').read() print(request) assert compare_xml(request, _request) is True
def test_wps_request6(): # Process input/output arguments processid = "v.net.path" inputs = [ ("input", "http://rsg.pml.ac.uk/wps/example/graph.gml"), ("file", "1 -960123.1421801624 4665723.56559387 -101288.65106088226 5108200.011823481" ) ] # Build XML request for WPS process execution execution = WPSExecution() requestElement = execution.buildRequest(processid, inputs) request = etree.tostring(requestElement) # Compare to cached XML request _request = open(resource_file('wps_PMLExecuteRequest6.xml'), 'rb').read() assert compare_xml(request, _request) is True
def test_wps_request3(): # Supply process input argument wfsUrl = "http://igsarm-cida-gdp2.er.usgs.gov:8082/geoserver/wfs" query = WFSQuery("sample:CONUS_States", propertyNames=['the_geom', "STATE"], filters=["CONUS_States.508", "CONUS_States.469"]) featureCollection = WFSFeatureCollection(wfsUrl, query) processid = 'gov.usgs.cida.gdp.wps.algorithm.FeatureWeightedGridStatisticsAlgorithm' inputs = [("FEATURE_ATTRIBUTE_NAME", "STATE"), ("DATASET_URI", "dods://igsarm-cida-thredds1.er.usgs.gov:8080/thredds/dodsC/dcp/conus_grid.w_meta.ncml"), ("DATASET_ID", "ccsm3_a1b_tmax"), ("DATASET_ID", "ccsm3_a1b_pr"), ("DATASET_ID", "ccsm3_a1fi_tmax"), ("TIME_START", "1960-01-01T00:00:00.000Z"), ("TIME_END", "1960-12-31T00:00:00.000Z"), ("REQUIRE_FULL_COVERAGE", "true"), ("DELIMITER", "COMMA"), ("STATISTICS", "MEAN"), ("STATISTICS", "MINIMUM"), ("STATISTICS", "MAXIMUM"), ("STATISTICS", "WEIGHT_SUM"), ("STATISTICS", "VARIANCE"), ("STATISTICS", "STD_DEV"), ("STATISTICS", "COUNT"), ("GROUP_BY", "STATISTIC"), ("SUMMARIZE_TIMESTEP", "true"), ("SUMMARIZE_FEATURE_ATTRIBUTE", "true"), ("FEATURE_COLLECTION", featureCollection) ] output = "OUTPUT" # build XML request for WPS process execution execution = WPSExecution() requestElement = execution.buildRequest(processid, inputs, output=output) request = etree.tostring(requestElement) # Compare to cached XML request _request = open(resource_file('wps_USGSExecuteRequest2.xml'), 'rb').read() assert compare_xml(request, _request) is True