예제 #1
0
 def test_bbox_output(self):
     bbox = BoundingBoxOutput("bbox", "BBox foo", crss=["EPSG:4326"])
     doc = bbox.describe_xml()
     [outpt] = xpath_ns(doc, "/Output")
     [default_crs] = xpath_ns(doc, "./BoundingBoxOutput/Default/CRS")
     supported = xpath_ns(doc, "./BoundingBoxOutput/Supported/CRS")
     assert default_crs.text == "EPSG:4326"
     assert len(supported) == 1
예제 #2
0
 def test_bbox_output(self):
     bbox = BoundingBoxOutput('bbox', 'BBox foo', crss=["EPSG:4326"])
     doc = bbox.describe_xml()
     [outpt] = xpath_ns(doc, '/Output')
     [default_crs] = xpath_ns(doc, './BoundingBoxOutput/Default/CRS')
     supported = xpath_ns(doc, './BoundingBoxOutput/Supported/CRS')
     assert default_crs.text == 'EPSG:4326'
     assert len(supported) == 1
예제 #3
0
 def test_bbox_output(self):
     bbox = BoundingBoxOutput('bbox', 'BBox foo',
             crss=["EPSG:4326"])
     doc = bbox.describe_xml()
     [outpt] = xpath_ns(doc, '/Output')
     [default_crs] = xpath_ns(doc, './BoundingBoxOutput/Default/CRS')
     supported = xpath_ns(doc, './BoundingBoxOutput/Supported/CRS')
     assert default_crs.text == 'EPSG:4326'
     assert len(supported) == 1
예제 #4
0
 def test_bbox_output(self):
     bbox = BoundingBoxOutput('bbox', 'BBox foo', keywords=['kw1', 'kw2'],
                              crss=["EPSG:4326"])
     doc = bbox.describe_xml()
     [outpt] = xpath_ns(doc, '/Output')
     [default_crs] = xpath_ns(doc, './BoundingBoxOutput/Default/CRS')
     supported = xpath_ns(doc, './BoundingBoxOutput/Supported/CRS')
     assert default_crs.text == 'EPSG:4326'
     assert len(supported) == 1
     [keywords] = xpath_ns(doc, '/Output/ows:Keywords')
     kws = xpath_ns(keywords, './ows:Keyword')
     assert keywords is not None
     assert len(kws) == 2
예제 #5
0
 def test_bbox_output(self):
     bbox = BoundingBoxOutput('bbox', 'BBox foo', keywords=['kw1', 'kw2'],
                              crss=["EPSG:4326"])
     doc = bbox.describe_xml()
     [outpt] = xpath_ns(doc, '/Output')
     [default_crs] = xpath_ns(doc, './BoundingBoxOutput/Default/CRS')
     supported = xpath_ns(doc, './BoundingBoxOutput/Supported/CRS')
     assert default_crs.text == 'EPSG:4326'
     assert len(supported) == 1
     [keywords] = xpath_ns(doc, '/Output/ows:Keywords')
     kws = xpath_ns(keywords, './ows:Keyword')
     assert keywords is not None
     assert len(kws) == 2
예제 #6
0
파일: wps_bbox.py 프로젝트: xhqiao89/emu
    def __init__(self):
        inputs = [
            BoundingBoxInput('bbox',
                             'Bounding Box',
                             abstract='Bounding Box Input.',
                             crss=['epsg:4326', 'epsg:3035'],
                             min_occurs=0)
        ]
        outputs = [
            BoundingBoxOutput('bbox',
                              'Bounding Box',
                              abstract='Bounding Box Output.',
                              crss=['epsg:4326'])
        ]

        super(Box, self).__init__(
            self._handler,
            identifier='bbox',
            version='0.2',
            title="Bounding box in- and out",
            abstract='Give bounding box, return the same',
            metadata=[
                Metadata('Birdhouse', 'http://bird-house.github.io/'),
                Metadata('User Guide', 'http://emu.readthedocs.io/en/latest/')
            ],
            inputs=inputs,
            outputs=outputs,
            store_supported=True,
            status_supported=True)
예제 #7
0
    def try_connect(self, graph, linked_input, downstream_task,
                    downstream_task_input):
        """
        Override TaskPE fct. See TaskPE.try_connect for details.
        The MapPE uses the downstream task input format to set it's own output format and it's set upon connection
        """

        # Set the supported output description which is the same as the downstream task supported input
        if TaskPE.try_connect(self, graph, linked_input, downstream_task,
                              downstream_task_input):
            down_task_in_desc = downstream_task.get_input_desc(
                downstream_task_input)
            params = dict(identifier=self.MAP_OUTPUT, title=self.MAP_OUTPUT)
            if down_task_in_desc.dataType == 'ComplexData':
                params['supported_formats'] = [
                    Format(mime_type=down_task_in_desc.defaultValue.mimeType,
                           schema=down_task_in_desc.defaultValue.schema,
                           encoding=down_task_in_desc.defaultValue.encoding)
                ]
                params['as_reference'] = False
                self.output_desc = Output(
                    ComplexOutput(**params).describe_xml())
                self.output_desc.mimeType = down_task_in_desc.defaultValue.mimeType
            elif down_task_in_desc.dataType == 'BoundingBoxData':
                params['crss'] = down_task_in_desc.supportedValues
                params['as_reference'] = False
                self.output_desc = Output(
                    BoundingBoxOutput(**params).describe_xml())
            else:
                params['data_type'] = down_task_in_desc.dataType
                self.output_desc = Output(
                    LiteralOutput(**params).describe_xml())
            return True
        return False
예제 #8
0
def create_bbox_process():
    def bbox_process(request, response):
        coords = request.inputs['mybbox'][0].data
        assert isinstance(coords, list)
        assert len(coords) == 4
        assert coords[0] == '15'
        response.outputs['outbbox'].data = coords
        return response

    return Process(handler=bbox_process,
                   identifier='my_bbox_process',
                   title='Bbox process',
                   inputs=[BoundingBoxInput('mybbox', 'Input name', ["EPSG:4326"])],
                   outputs=[BoundingBoxOutput('outbbox', 'Output message', ["EPSG:4326"])])
예제 #9
0
    def __init__(self):
        inputs = [BoundingBoxInput('bboxin', 'box in', ['epsg:4326', 'epsg:3035'])]
        outputs = [BoundingBoxOutput('bboxout', 'box out', ['epsg:4326'])]

        super(Box, self).__init__(
            self._handler,
            identifier='boundingbox',
            version='0.1',
            title="Bounding box in- and out",
            abstract='Give bounding box, return the same',
            inputs=inputs,
            outputs=outputs,
            store_supported=True,
            status_supported=True
        )
예제 #10
0
파일: wps_inout.py 프로젝트: agstephens/emu
    def __init__(self):
        inputs = [
            LiteralInput('string',
                         'String',
                         data_type='string',
                         abstract='Enter a simple string.',
                         default="This is just a string"),
            LiteralInput(
                'int',
                'Integer',
                data_type='integer',
                abstract='Choose an integer number from allowed values.',
                default="7",
                allowed_values=[1, 2, 3, 5, 7, 11]),
            LiteralInput('float',
                         'Float',
                         data_type='float',
                         abstract='Enter a float number.',
                         default="3.14"),
            # TODO: boolean default is not displayed in phoenix
            LiteralInput('boolean',
                         'Boolean',
                         data_type='boolean',
                         abstract='Make your choice :)',
                         default='1'),
            LiteralInput('time',
                         'Time',
                         data_type='time',
                         abstract='Enter a time like 12:00:00',
                         default='12:00:00'),
            LiteralInput('date',
                         'Date',
                         data_type='date',
                         abstract='Enter a date like 2012-05-01',
                         default='2012-05-01'),
            LiteralInput('datetime',
                         'Datetime',
                         data_type='dateTime',
                         abstract='Enter a datetime like 2016-09-02T12:00:00Z',
                         default='2016-09-02T12:00:00Z'),
            LiteralInput('string_choice',
                         'String Choice',
                         data_type='string',
                         abstract='Choose one item form list.',
                         allowed_values=['rock', 'paper', 'scissor'],
                         default='scissor'),
            LiteralInput('string_multiple_choice',
                         'String Multiple Choice',
                         abstract='Choose one or two items from list.',
                         metadata=[Metadata('Info')],
                         data_type='string',
                         allowed_values=[
                             'sitting duck', 'flying goose', 'happy pinguin',
                             'gentle albatros'
                         ],
                         min_occurs=0,
                         max_occurs=2,
                         default='gentle albatros'),
            # TODO: bbox is not supported yet by owslib
            # BoundingBoxInput('bbox', 'Bounding Box',
            #                  abstract='Bounding Box with EPSG:4326 and EPSG:3035.',
            #                  crss=['epsg:4326', 'epsg:3035'],
            #                  min_occurs=0),
            ComplexInput('text',
                         'Text',
                         abstract='Enter a URL pointing\
                            to a text document (optional)',
                         metadata=[Metadata('Info')],
                         min_occurs=0,
                         supported_formats=[Format('text/plain')]),
            ComplexInput(
                'dataset',
                'Dataset',
                abstract="Enter a URL pointing to a NetCDF file (optional)",
                metadata=[
                    Metadata(
                        'NetCDF Format',
                        'https://en.wikipedia.org/wiki/NetCDF',
                        role=
                        'http://www.opengis.net/spec/wps/2.0/def/process/description/documentation'
                    )
                ],
                min_occurs=0,
                supported_formats=[Format('application/x-netcdf')]),
        ]
        outputs = [
            LiteralOutput('string', 'String', data_type='string'),
            LiteralOutput('int', 'Integer', data_type='integer'),
            LiteralOutput('float', 'Float', data_type='float'),
            LiteralOutput('boolean', 'Boolean', data_type='boolean'),
            LiteralOutput('time', 'Time', data_type='time'),
            LiteralOutput('date', 'Date', data_type='date'),
            LiteralOutput('datetime', 'DateTime', data_type='dateTime'),
            LiteralOutput('string_choice', 'String Choice',
                          data_type='string'),
            LiteralOutput('string_multiple_choice',
                          'String Multiple Choice',
                          data_type='string'),
            ComplexOutput('text',
                          'Text',
                          abstract='Copy of input text file.',
                          as_reference=True,
                          supported_formats=[Format('text/plain')]),
            ComplexOutput('dataset',
                          'Dataset',
                          abstract='Copy of input netcdf file.',
                          as_reference=True,
                          supported_formats=[
                              Format('application/x-netcdf'),
                              Format('text/plain')
                          ]),
            BoundingBoxOutput('bbox', 'Bounding Box', crss=['epsg:4326']),
        ]

        super(InOut, self).__init__(
            self._handler,
            identifier="inout",
            title="In and Out",
            version="1.0",
            abstract="Testing all WPS input and output parameters.",
            # profile=['birdhouse'],
            metadata=[
                Metadata('Birdhouse', 'http://bird-house.github.io/'),
                Metadata(
                    'User Guide',
                    'http://emu.readthedocs.io/en/latest/',
                    role=
                    'http://www.opengis.net/spec/wps/2.0/def/process/description/documentation'
                )
            ],
            inputs=inputs,
            outputs=outputs,
            status_supported=True,
            store_supported=True)
예제 #11
0
    def __init__(self):
        inputs = [
            LiteralInput('string',
                         'String',
                         data_type='string',
                         abstract='Enter a simple string.',
                         default="This is just a string",
                         mode=MODE.SIMPLE),
            LiteralInput(
                'int',
                'Integer',
                data_type='integer',
                abstract='Choose an integer number from allowed values.',
                default="7",
                allowed_values=[1, 2, 3, 5, 7, 11]),
            LiteralInput('float',
                         'Float',
                         data_type='float',
                         abstract='Enter a float number.',
                         default="3.14",
                         min_occurs=0,
                         max_occurs=5),
            # TODO: boolean default is not displayed in phoenix
            LiteralInput('boolean',
                         'Boolean',
                         data_type='boolean',
                         abstract='Make your choice :)',
                         default='1'),
            LiteralInput('angle',
                         'Angle',
                         data_type='angle',
                         abstract='Enter an angle [0, 360] :)',
                         default='90'),
            LiteralInput('time',
                         'Time',
                         data_type='time',
                         abstract='Enter a time like 12:00:00',
                         default='12:00:00'),
            LiteralInput('date',
                         'Date',
                         data_type='date',
                         abstract='Enter a date like 2012-05-01',
                         default='2012-05-01'),
            LiteralInput('datetime',
                         'Datetime',
                         data_type='dateTime',
                         abstract='Enter a datetime like 2016-09-02T12:00:00Z',
                         default='2016-09-02T12:00:00Z'),
            LiteralInput('string_choice',
                         'String Choice',
                         data_type='string',
                         abstract='Choose one item form list.',
                         allowed_values=['rock', 'paper', 'scissor'],
                         default='scissor'),
            LiteralInput('string_multiple_choice',
                         'String Multiple Choice',
                         abstract='Choose one or two items from list.',
                         data_type='string',
                         allowed_values=[
                             'sitting duck', 'flying goose', 'happy pinguin',
                             'gentle albatros'
                         ],
                         min_occurs=0,
                         max_occurs=2,
                         default='gentle albatros'),
            LiteralInput(
                'int_range',
                'Integer Range',
                abstract=
                'Choose number from range: 1-10 (step 1), 100-200 (step 10)',
                metadata=[
                    Metadata(
                        'AllowedValue PyWPS Docs',
                        'https://pywps.readthedocs.io/en/master/api.html#pywps.inout.literaltypes.AllowedValue'
                    ),  # noqa
                    Metadata(
                        'AllowedValue Example',
                        'http://docs.opengeospatial.org/is/14-065/14-065.html#98'
                    ),  # noqa
                ],
                data_type='integer',
                default='1',
                allowed_values=[
                    AllowedValue(minval=1, maxval=10),
                    AllowedValue(minval=100, maxval=200, spacing=10)
                ],
                mode=MODE.SIMPLE,
            ),
            LiteralInput(
                'any_value',
                'Any Value',
                abstract='Enter any value.',
                metadata=[
                    Metadata(
                        'AnyValue PyWPS Docs',
                        'https://pywps.readthedocs.io/en/master/api.html#pywps.inout.literaltypes.AnyValue'
                    ),  # noqa
                ],
                allowed_values=AnyValue(),
                default='any value',
                mode=MODE.SIMPLE,
            ),
            LiteralInput(
                'ref_value',
                'Referenced Value',
                abstract='Choose a referenced value',
                metadata=[
                    Metadata(
                        'PyWPS Docs',
                        'https://pywps.readthedocs.io/en/master/_modules/pywps/inout/literaltypes.html'
                    ),  # noqa
                ],
                data_type='string',
                allowed_values=ValuesReference(
                    reference=
                    "https://en.wikipedia.org/w/api.php?action=opensearch&search=scotland&format=json"
                ),  # noqa
                default='Scotland',
                mode=MODE.SIMPLE,
            ),
            # TODO: bbox is not supported yet by owslib
            # BoundingBoxInput('bbox', 'Bounding Box',
            #                  abstract='Bounding Box with EPSG:4326 and EPSG:3035.',
            #                  crss=['epsg:4326', 'epsg:3035'],
            #                  min_occurs=0),
            ComplexInput(
                'text',
                'Text',
                abstract='Enter a URL pointing to a text document (optional)',
                metadata=[Metadata('Info')],
                min_occurs=0,
                supported_formats=[Format('text/plain')]),
            ComplexInput(
                'dataset',
                'Dataset',
                abstract="Enter a URL pointing to a NetCDF file (optional)",
                metadata=[
                    Metadata(
                        'NetCDF Format',
                        'https://en.wikipedia.org/wiki/NetCDF',
                        role=
                        'http://www.opengis.net/spec/wps/2.0/def/process/description/documentation'
                    )
                ],
                min_occurs=0,
                supported_formats=[FORMATS.NETCDF]),
        ]
        outputs = [
            LiteralOutput('string', 'String', data_type='string'),
            LiteralOutput('int', 'Integer', data_type='integer'),
            LiteralOutput('float', 'Float', data_type='float'),
            LiteralOutput('boolean', 'Boolean', data_type='boolean'),
            LiteralOutput('angle', 'Angle', data_type='angle'),
            LiteralOutput('time', 'Time', data_type='time'),
            LiteralOutput('date', 'Date', data_type='date'),
            LiteralOutput('datetime', 'DateTime', data_type='dateTime'),
            LiteralOutput('string_choice', 'String Choice',
                          data_type='string'),
            LiteralOutput('string_multiple_choice',
                          'String Multiple Choice',
                          data_type='string'),
            LiteralOutput('int_range', 'Integer Range', data_type='integer'),
            LiteralOutput('any_value', 'Any Value', data_type='string'),
            LiteralOutput('ref_value', 'Referenced Value', data_type='string'),
            ComplexOutput('text',
                          'Text',
                          abstract='Copy of input text file.',
                          as_reference=False,
                          supported_formats=[
                              FORMATS.TEXT,
                          ]),
            ComplexOutput('dataset',
                          'Dataset',
                          abstract='Copy of input netcdf file.',
                          as_reference=True,
                          supported_formats=[FORMATS.NETCDF, FORMATS.TEXT]),
            BoundingBoxOutput('bbox', 'Bounding Box', crss=['epsg:4326']),
        ]

        super(InOut, self).__init__(
            self._handler,
            identifier="inout",
            title="In and Out",
            version="1.0",
            abstract="Testing all WPS input and output parameters.",
            # profile=['birdhouse'],
            metadata=[
                Metadata('Birdhouse', 'http://bird-house.github.io/'),
                MetadataUrl(
                    'User Guide',
                    'http://emu.readthedocs.io/en/latest/',
                    role=
                    'http://www.opengis.net/spec/wps/2.0/def/process/description/documentation',
                    anonymous=True),
            ],
            inputs=inputs,
            outputs=outputs,
            status_supported=True,
            store_supported=True)