def test_bbox(self): if not PY2: self.skipTest('OWSlib not python 3 compatible') client = client_for(Service(processes=[create_bbox_process()])) request_doc = WPS.Execute(OWS.Identifier('my_bbox_process'), WPS.DataInputs( WPS.Input( OWS.Identifier('mybbox'), WPS.Data( WPS.BoundingBoxData( OWS.LowerCorner('15 50'), OWS.UpperCorner('16 51'), )))), version='1.0.0') resp = client.post_xml(doc=request_doc) assert_response_success(resp) [output ] = xpath_ns(resp.xml, '/wps:ExecuteResponse' '/wps:ProcessOutputs/Output') self.assertEqual('outbbox', xpath_ns(output, './ows:Identifier')[0].text) self.assertEqual( '15 50', xpath_ns(output, './ows:BoundingBox/ows:LowerCorner')[0].text)
def execute_xml(self): doc = WPS.Output( OWS.Identifier(self.identifier), OWS.Title(self.title) ) if self.abstract: doc.append(OWS.Abstract(self.abstract)) if self.keywords: kws = map(OWS.Keyword, self.keywords) doc.append(OWS.Keywords(*kws)) data_doc = WPS.Data() bbox_data_doc = OWS.BoundingBox() bbox_data_doc.attrib['crs'] = self.crs bbox_data_doc.attrib['dimensions'] = str(self.dimensions) bbox_data_doc.append(OWS.LowerCorner('{0[0]} {0[1]}'.format(self.data))) bbox_data_doc.append(OWS.UpperCorner('{0[2]} {0[3]}'.format(self.data))) data_doc.append(bbox_data_doc) doc.append(data_doc) return doc
def execute_xml(self): """ :return: execute response element """ doc = WPS.Input( OWS.Identifier(self.identifier), OWS.Title(self.title) ) if self.abstract: doc.append(OWS.Abstract(self.abstract)) bbox_data_doc = OWS.BoundingBox() bbox_data_doc.attrib['crs'] = self.crs bbox_data_doc.attrib['dimensions'] = str(self.dimensions) bbox_data_doc.append( OWS.LowerCorner('{0[0]} {0[1]}'.format(self.data))) bbox_data_doc.append( OWS.UpperCorner('{0[2]} {0[3]}'.format(self.data))) doc.append(bbox_data_doc) return doc
def _execute_xml_data(self): """Return Data node """ doc = WPS.Data() bbox_data_doc = WPS.BoundingBoxData() if self.crs: bbox_data_doc.attrib['crs'] = self.crs if self.dimensions: bbox_data_doc.attrib['dimensions'] = str(self.dimensions) bbox_data_doc.append( OWS.LowerCorner('{0[0]} {0[1]}'.format(self.data))) bbox_data_doc.append( OWS.UpperCorner('{0[2]} {0[3]}'.format(self.data))) doc.append(bbox_data_doc) return doc
def test_bbox_input(self): if not PY2: self.skipTest('OWSlib not python 3 compatible') request_doc = WPS.Execute( OWS.Identifier('request'), WPS.DataInputs( WPS.Input( OWS.Identifier('bbox'), WPS.Data( WPS.BoundingBoxData(OWS.LowerCorner('40 50'), OWS.UpperCorner('60 70')))))) rv = get_inputs_from_xml(request_doc) bbox = rv['bbox'][0] assert isinstance(bbox, BoundingBox) assert bbox.minx == '40' assert bbox.miny == '50' assert bbox.maxx == '60' assert bbox.maxy == '70'