Example #1
0
 def test_parse_filter_arg(self):
     """ No filter given and filter required. """
     filt = autils.parse_filter_arg({'filter': 'XXX'}, required=True)
     assert filt is not None
     assert filt == 'XXX'
     filt = autils.parse_filter_arg({'filter': 'shhh'}, required=True)
     assert filt is not None
     assert filt == 'shhh'
Example #2
0
def query_coordinates (args):
    """
    Return some metadata for images which contain the given point.
    """
    co_args = au.parse_cutout_args(args)        # get coordinates
    collection = au.parse_collection_arg(args)  # optional collection restriction
    filt = au.parse_filter_arg(args)            # optional filter restriction
    return jsonify(imgr.query_coordinates(co_args, collection=collection, filt=filt))
Example #3
0
def fetch_cutout_by_filter (args):
    """ Make and return an image cutout for a filtered image.
        The band is specified by the required 'filter' argument. """

    # parse the parameters for the cutout
    co_args = au.parse_cutout_args(args)
    filt = au.parse_filter_arg(args, required=True)  # test for required filter
    collection = au.parse_collection_arg(args)
    return imgr.get_image_or_cutout(co_args, filt=filt, collection=collection)
Example #4
0
def fetch_cutout (args):
    """
    Return an image cutout. if cutout size is not specified, return the entire image.
    """
    # parse the parameters for the cutout
    co_args = au.parse_cutout_args(args)
    collection = au.parse_collection_arg(args)
    filt = au.parse_filter_arg(args)
    return imgr.get_image_or_cutout(co_args, filt=filt, collection=collection)
Example #5
0
def fetch_image_by_filter (args):
    """ Fetch a specific image by filter/collection. """
    filt = au.parse_filter_arg(args, required=True)  # get required filter or error
    collection = au.parse_collection_arg(args)
    istream = imgr.fetch_image_by_filter(filt, collection=collection)
    if (istream is not None):
        return istream
    else:
        coll = f"and collection '{collection}'" if (collection) else ''
        errMsg = f"Image with filter '{filt}' {coll} not found in database"
        current_app.logger.error(errMsg)
        raise exceptions.ImageNotFound(errMsg)
Example #6
0
def image_metadata_by_filter (args):
    """ Return image metadata for all images with a specific filter/collection. """
    filt = au.parse_filter_arg(args, required=True)  # get required filter or error
    collection = au.parse_collection_arg(args)       # optional collection restriction
    return jsonify(imgr.image_metadata_by_filter(filt, collection=collection))
Example #7
0
def query_image (args):
    """ List images which meet the given filter and collection criteria. """
    collection = au.parse_collection_arg(args)    # optional collection restriction
    filt = au.parse_filter_arg(args)              # optional filter restriction
    return jsonify(imgr.query_image(collection=collection, filt=filt))
Example #8
0
 def test_parse_filter_arg_empty_req(self):
     """ Empty filter given and filter required. """
     with pytest.raises(RequestException, match=self.filt_emsg) as reqex:
         autils.parse_filter_arg({'filter': '  '}, required=True)
Example #9
0
 def test_parse_filter_arg_none(self):
     """ None given, but filter not required. """
     filt = autils.parse_filter_arg({'filter': None})
     assert filt is None
Example #10
0
 def test_parse_filter_arg_empty(self):
     """ Empty filter given, but not required. """
     filt = autils.parse_filter_arg({'filter': '  '})
     assert filt is None
Example #11
0
 def test_parse_filter_arg_nofilt(self):
     """ No filter given, but not required. """
     filt = autils.parse_filter_arg({})
     assert filt is None