def getBinaryMorphologicalOperation(available_app, original_dom_document):
    """
    Let ball as only available structype.
    Split the application according to its filter dilate, erode, opening, closing.
    """
    the_root = original_dom_document
    renameValueField(the_root, "structype.ball.xradius", "name", "The Structuring Element Radius")
    renameValueField(the_root, "structype.ball.xradius", "description", "The Structuring Element Radius")
    remove_dependent_choices(the_root, "structype", "ball")
    remove_other_choices(the_root, "structype", "ball")
    remove_dependent_choices(the_root, "filter", "dilate")
    remove_parameter_by_key(the_root, "structype.ball.yradius")
    the_list = defaultSplit(available_app, the_root, "filter")
    return the_list
def getGrayScaleMorphologicalOperation(available_app, original_dom_document):
    """
    Let ball as only available structype.
    Split the application according to its filter dilate, erode, opening, closing.
    """
    the_root = original_dom_document
    renameValueField(the_root, 'structype.ball.xradius', 'name', 'The Structuring Element Radius')
    renameValueField(the_root, 'structype.ball.xradius', 'description', 'The Structuring Element Radius')
    remove_dependant_choices(the_root, 'structype', 'ball')
    remove_other_choices(the_root, 'structype', 'ball')
    remove_parameter_by_key(the_root, 'structype.ball.yradius')

    split = defaultSplit(available_app, the_root, 'filter')
    return split
def getEdgeExtraction(available_app, original_dom_document):
    """
    Let ball as only available filter (not an oval).
    Split the application according to its filter gradient, sobel, touzi.
    """
    the_root = original_dom_document
    renameValueField(the_root, 'filter.touzi.xradius', 'name', 'The Radius')
    renameValueField(the_root, 'filter.touzi.xradius', 'description', 'The Radius')
    remove_parameter_by_key(the_root, 'filter.touzi.yradius')
    split = split_by_choice(the_root, 'filter')
    the_list = []
    for key in split:
        defaultWrite('%s-%s' % (available_app, key), split[key])
        the_list.append(split[key])
    return the_list
def getCompareImages(available_app, original_dom_document):
    """
    Remove mse, mae, psnr as they are output of the algorithm.
    """
    the_root = original_dom_document
    remove_parameter_by_key(the_root, 'mse')
    remove_parameter_by_key(the_root, 'mae')
    remove_parameter_by_key(the_root, 'psnr')
    defaultWrite(available_app, the_root)
    return [the_root]
def getImageEnvelope(available_app, original_dom_document):
    """
    Delete GEOID and DEM parameter as they are not updated at the creation of the otb algorithms when you launch QGIS.
    The values are picked from the settings.
    """
    the_root = original_dom_document
    remove_parameter_by_key(the_root, 'elev.default')
    remove_parameter_by_key(the_root, 'elev.geoid')
    remove_parameter_by_key(the_root, 'elev.dem')
    defaultWrite(available_app, the_root)
    return [the_root]
def getDimensionalityReduction(available_app, original_dom_document):
    """
    Remove rescale.outmin and rescale.outmax and split by method (ica, maf, napca and pca) and adjust parameters of each resulting app.
    """
    the_root = original_dom_document
    remove_parameter_by_key(the_root, 'rescale.outmin')
    remove_parameter_by_key(the_root, 'rescale.outmax')
    split = split_by_choice(the_root, 'method')
    the_list = []
    for key in split:
        if key == 'maf':
            the_doc = split[key]
            remove_parameter_by_key(the_doc, 'outinv')
            defaultWrite('%s-%s' % (available_app, key), the_doc)
            the_list.append(the_doc)
        else:
            defaultWrite('%s-%s' % (available_app, key), split[key])
            the_list.append(split[key])
    return the_list
def getKMeansClassification(available_app, original_dom_document):
    the_root = original_dom_document
    remove_parameter_by_key(the_root, 'rand')
    defaultWrite(available_app, the_root)
    return [the_root]
def getQuicklook(available_app, original_dom_document):
    the_root = original_dom_document
    remove_parameter_by_key(the_root, 'cl')
    defaultWrite(available_app, the_root)
    return [the_root]
def getExtractROI(available_app, original_dom_document):
    """
    Split by mode (standard, fit)
    Adapt parameters of each resulting app.
    Delete GEOID and DEM parameter as they are not updated at the creation of the otb algorithms when you launch QGIS.
    The values are picked from the settings.
    """
    the_root = original_dom_document
    remove_parameter_by_key(the_root, 'cl')
    deleteGeoidSrtm(the_root)
    split = split_by_choice(the_root, 'mode')
    the_list = []
    for key in split:
        if key == 'standard':
            the_doc = split[key]
            remove_parameter_by_key(the_doc, 'mode.fit.elev.dem')
            remove_parameter_by_key(the_doc, 'mode.fit.elev.geoid')
            remove_parameter_by_key(the_doc, 'mode.fit.elev.default')
            remove_parameter_by_key(the_doc, 'mode.fit.ref')
            defaultWrite('%s-%s' % (available_app, key), the_doc)
            the_list.append(the_doc)
        else:
            #key == 'fit'
            the_doc = split[key]
            remove_parameter_by_key(the_doc, 'startx')
            remove_parameter_by_key(the_doc, 'starty')
            remove_parameter_by_key(the_doc, 'sizex')
            remove_parameter_by_key(the_doc, 'sizey')
            defaultWrite('%s-%s' % (available_app, key), the_doc)
            the_list.append(split[key])
    return the_list
def getColorMapping(available_app, original_dom_document):
    """
    Remove the option colortolabel
    Split by method : custom, continuous, optimal and image and adapt parameters of each resulting app
    """
    the_root = original_dom_document
    remove_independent_choices(the_root, 'op', 'colortolabel')
    remove_choice(the_root, 'op', 'colortolabel')
    split = split_by_choice(the_root, 'method')
    the_list = []
    for key in split:
        if key == 'custom':
            the_doc = split[key]
            remove_parameter_by_key(the_doc, 'method.continuous.lut')
            remove_parameter_by_key(the_doc, 'method.continuous.min')
            remove_parameter_by_key(the_doc, 'method.continuous.max')
            remove_parameter_by_key(the_doc, 'method.optimal.background')
            remove_parameter_by_key(the_doc, 'method.image.in')
            remove_parameter_by_key(the_doc, 'method.image.low')
            remove_parameter_by_key(the_doc, 'method.image.up')
            defaultWrite('%s-%s' % (available_app, key), the_doc)
            the_list.append(the_doc)
        elif key == 'continuous':
            the_doc = split[key]
            remove_parameter_by_key(the_doc, 'method.custom.lut')
            remove_parameter_by_key(the_doc, 'method.optimal.background')
            remove_parameter_by_key(the_doc, 'method.image.in')
            remove_parameter_by_key(the_doc, 'method.image.low')
            remove_parameter_by_key(the_doc, 'method.image.up')
            defaultWrite('%s-%s' % (available_app, key), the_doc)
            the_list.append(the_doc)
        elif key == 'optimal':
            the_doc = split[key]
            remove_parameter_by_key(the_doc, 'method.custom.lut')
            remove_parameter_by_key(the_doc, 'method.continuous.lut')
            remove_parameter_by_key(the_doc, 'method.continuous.min')
            remove_parameter_by_key(the_doc, 'method.continuous.max')
            remove_parameter_by_key(the_doc, 'method.image.in')
            remove_parameter_by_key(the_doc, 'method.image.low')
            remove_parameter_by_key(the_doc, 'method.image.up')
            defaultWrite('%s-%s' % (available_app, key), the_doc)
            the_list.append(the_doc)
        else:
            #key == 'image'
            the_doc = split[key]
            remove_parameter_by_key(the_doc, 'method.custom.lut')
            remove_parameter_by_key(the_doc, 'method.continuous.lut')
            remove_parameter_by_key(the_doc, 'method.continuous.min')
            remove_parameter_by_key(the_doc, 'method.continuous.max')
            remove_parameter_by_key(the_doc, 'method.optimal.background')
            defaultWrite('%s-%s' % (available_app, key), the_doc)
            the_list.append(split[key])
    return the_list
Exemple #11
0
def getReadImageInfo(available_app, original_dom_document):
    """
    Remove parameters that are output of the application.
    """
    the_root = original_dom_document
    remove_parameter_by_key(the_root, 'outkwl')
    remove_parameter_by_key(the_root, 'indexx')
    remove_parameter_by_key(the_root, 'indexy')
    remove_parameter_by_key(the_root, 'sizex')
    remove_parameter_by_key(the_root, 'sizey')
    remove_parameter_by_key(the_root, 'spacingx')
    remove_parameter_by_key(the_root, 'spacingy')
    remove_parameter_by_key(the_root, 'originx')
    remove_parameter_by_key(the_root, 'originy')
    remove_parameter_by_key(the_root, 'estimatedgroundspacingx')
    remove_parameter_by_key(the_root, 'estimatedgroundspacingy')
    remove_parameter_by_key(the_root, 'numberbands')
    remove_parameter_by_key(the_root, 'sensor')
    remove_parameter_by_key(the_root, 'id')
    remove_parameter_by_key(the_root, 'time')
    remove_parameter_by_key(the_root, 'ullat')
    remove_parameter_by_key(the_root, 'ullon')
    remove_parameter_by_key(the_root, 'urlat')
    remove_parameter_by_key(the_root, 'urlon')
    remove_parameter_by_key(the_root, 'lrlat')
    remove_parameter_by_key(the_root, 'lrlon')
    remove_parameter_by_key(the_root, 'lllat')
    remove_parameter_by_key(the_root, 'lllon')
    remove_parameter_by_key(the_root, 'town')
    remove_parameter_by_key(the_root, 'country')
    remove_parameter_by_key(the_root, 'rgb.r')
    remove_parameter_by_key(the_root, 'rgb.g')
    remove_parameter_by_key(the_root, 'rgb.b')
    remove_parameter_by_key(the_root, 'projectionref')
    remove_parameter_by_key(the_root, 'keyword')
    remove_parameter_by_key(the_root, 'gcp.count')
    remove_parameter_by_key(the_root, 'gcp.proj')
    defaultWrite(available_app, the_root)
    return [the_root]
Exemple #12
0
def getColorMapping(available_app, original_dom_document):
    """
    Remove the option colortolabel
    Split by method : custom, continuous, optimal and image and adapt parameters of each resulting app
    """
    the_root = original_dom_document
    remove_independant_choices(the_root, 'op', 'colortolabel')
    remove_choice(the_root, 'op', 'colortolabel')
    split = split_by_choice(the_root, 'method')
    the_list = []
    for key in split:
        if key == 'custom':
            the_doc = split[key]
            remove_parameter_by_key(the_doc, 'method.continuous.lut')
            remove_parameter_by_key(the_doc, 'method.continuous.min')
            remove_parameter_by_key(the_doc, 'method.continuous.max')
            remove_parameter_by_key(the_doc, 'method.optimal.background')
            remove_parameter_by_key(the_doc, 'method.image.in')
            remove_parameter_by_key(the_doc, 'method.image.low')
            remove_parameter_by_key(the_doc, 'method.image.up')
            defaultWrite('%s-%s' % (available_app, key), the_doc)
            the_list.append(the_doc)
        elif key == 'continuous':
            the_doc = split[key]
            remove_parameter_by_key(the_doc, 'method.custom.lut')
            remove_parameter_by_key(the_doc, 'method.optimal.background')
            remove_parameter_by_key(the_doc, 'method.image.in')
            remove_parameter_by_key(the_doc, 'method.image.low')
            remove_parameter_by_key(the_doc, 'method.image.up')
            defaultWrite('%s-%s' % (available_app, key), the_doc)
            the_list.append(the_doc)
        elif key == 'optimal':
            the_doc = split[key]
            remove_parameter_by_key(the_doc, 'method.custom.lut')
            remove_parameter_by_key(the_doc, 'method.continuous.lut')
            remove_parameter_by_key(the_doc, 'method.continuous.min')
            remove_parameter_by_key(the_doc, 'method.continuous.max')
            remove_parameter_by_key(the_doc, 'method.image.in')
            remove_parameter_by_key(the_doc, 'method.image.low')
            remove_parameter_by_key(the_doc, 'method.image.up')
            defaultWrite('%s-%s' % (available_app, key), the_doc)
            the_list.append(the_doc)
        else:
            #key == 'image'
            the_doc = split[key]
            remove_parameter_by_key(the_doc, 'method.custom.lut')
            remove_parameter_by_key(the_doc, 'method.continuous.lut')
            remove_parameter_by_key(the_doc, 'method.continuous.min')
            remove_parameter_by_key(the_doc, 'method.continuous.max')
            remove_parameter_by_key(the_doc, 'method.optimal.background')
            defaultWrite('%s-%s' % (available_app, key), the_doc)
            the_list.append(split[key])
    return the_list
def getReadImageInfo(available_app, original_dom_document):
    """
    Remove parameters that are output of the application.
    """
    the_root = original_dom_document
    remove_parameter_by_key(the_root, "outkwl")
    remove_parameter_by_key(the_root, "indexx")
    remove_parameter_by_key(the_root, "indexy")
    remove_parameter_by_key(the_root, "sizex")
    remove_parameter_by_key(the_root, "sizey")
    remove_parameter_by_key(the_root, "spacingx")
    remove_parameter_by_key(the_root, "spacingy")
    remove_parameter_by_key(the_root, "originx")
    remove_parameter_by_key(the_root, "originy")
    remove_parameter_by_key(the_root, "estimatedgroundspacingx")
    remove_parameter_by_key(the_root, "estimatedgroundspacingy")
    remove_parameter_by_key(the_root, "numberbands")
    remove_parameter_by_key(the_root, "sensor")
    remove_parameter_by_key(the_root, "id")
    remove_parameter_by_key(the_root, "time")
    remove_parameter_by_key(the_root, "ullat")
    remove_parameter_by_key(the_root, "ullon")
    remove_parameter_by_key(the_root, "urlat")
    remove_parameter_by_key(the_root, "urlon")
    remove_parameter_by_key(the_root, "lrlat")
    remove_parameter_by_key(the_root, "lrlon")
    remove_parameter_by_key(the_root, "lllat")
    remove_parameter_by_key(the_root, "lllon")
    remove_parameter_by_key(the_root, "town")
    remove_parameter_by_key(the_root, "country")
    remove_parameter_by_key(the_root, "rgb.r")
    remove_parameter_by_key(the_root, "rgb.g")
    remove_parameter_by_key(the_root, "rgb.b")
    remove_parameter_by_key(the_root, "projectionref")
    remove_parameter_by_key(the_root, "keyword")
    remove_parameter_by_key(the_root, "gcp.count")
    remove_parameter_by_key(the_root, "gcp.proj")
    defaultWrite(available_app, the_root)
    return [the_root]
def getTrainSVMImagesClassifier(available_app, original_dom_document):
    the_root = original_dom_document
    remove_parameter_by_key(the_root, 'rand')
    defaultWrite(available_app, the_root)
    return [the_root]
def getColorMapping(available_app, original_dom_document):
    """
    Remove the option colortolabel
    Split by method : custom, continuous, optimal and image and adapt parameters of each resulting app
    """
    the_root = original_dom_document
    remove_independent_choices(the_root, "op", "colortolabel")
    remove_choice(the_root, "op", "colortolabel")
    split = split_by_choice(the_root, "method")
    the_list = []
    for key in split:
        if key == "custom":
            the_doc = split[key]
            remove_parameter_by_key(the_doc, "method.continuous.lut")
            remove_parameter_by_key(the_doc, "method.continuous.min")
            remove_parameter_by_key(the_doc, "method.continuous.max")
            remove_parameter_by_key(the_doc, "method.optimal.background")
            remove_parameter_by_key(the_doc, "method.image.in")
            remove_parameter_by_key(the_doc, "method.image.low")
            remove_parameter_by_key(the_doc, "method.image.up")
            defaultWrite("%s-%s" % (available_app, key), the_doc)
            the_list.append(the_doc)
        elif key == "continuous":
            the_doc = split[key]
            remove_parameter_by_key(the_doc, "method.custom.lut")
            remove_parameter_by_key(the_doc, "method.optimal.background")
            remove_parameter_by_key(the_doc, "method.image.in")
            remove_parameter_by_key(the_doc, "method.image.low")
            remove_parameter_by_key(the_doc, "method.image.up")
            defaultWrite("%s-%s" % (available_app, key), the_doc)
            the_list.append(the_doc)
        elif key == "optimal":
            the_doc = split[key]
            remove_parameter_by_key(the_doc, "method.custom.lut")
            remove_parameter_by_key(the_doc, "method.continuous.lut")
            remove_parameter_by_key(the_doc, "method.continuous.min")
            remove_parameter_by_key(the_doc, "method.continuous.max")
            remove_parameter_by_key(the_doc, "method.image.in")
            remove_parameter_by_key(the_doc, "method.image.low")
            remove_parameter_by_key(the_doc, "method.image.up")
            defaultWrite("%s-%s" % (available_app, key), the_doc)
            the_list.append(the_doc)
        else:
            # key == 'image'
            the_doc = split[key]
            remove_parameter_by_key(the_doc, "method.custom.lut")
            remove_parameter_by_key(the_doc, "method.continuous.lut")
            remove_parameter_by_key(the_doc, "method.continuous.min")
            remove_parameter_by_key(the_doc, "method.continuous.max")
            remove_parameter_by_key(the_doc, "method.optimal.background")
            defaultWrite("%s-%s" % (available_app, key), the_doc)
            the_list.append(split[key])
    return the_list
def getPixelValue(available_app, original_dom_document):
    the_root = original_dom_document
    remove_parameter_by_key(the_root, "cl")
    defaultWrite(available_app, the_root)
    return [the_root]
def getOrthoRectification(available_app, original_dom_document):
    """
    Let only mode auto.
    Remove all parameters which should be updated once the input file given.
    Split by SRS : EPSG, fit to ortho, lambert-wgs84 and UTM.
    Each of these SRS have their own parameters modified in this fonction.
    Delete GEOID and DEM parameter as they are not updated at the creation of the otb algorithms when you launch QGIS.
    The values are picked from the settings.
    """
    the_root = original_dom_document

    remove_choice(the_root, 'outputs.mode', 'auto')
    remove_independent_choices(the_root, 'outputs.mode', 'auto')
    remove_choice(the_root, 'outputs.mode', 'outputroi')
    remove_independent_choices(the_root, 'outputs.mode', 'outputroi')
    remove_parameter_by_key(the_root, 'outputs.ulx')
    remove_parameter_by_key(the_root, 'outputs.uly')
    remove_parameter_by_key(the_root, 'outputs.sizex')
    remove_parameter_by_key(the_root, 'outputs.sizey')
    remove_parameter_by_key(the_root, 'outputs.spacingx')
    remove_parameter_by_key(the_root, 'outputs.spacingy')
    remove_parameter_by_key(the_root, 'outputs.lrx')
    remove_parameter_by_key(the_root, 'outputs.lry')
    remove_parameter_by_key(the_root, 'opt.rpc')

    deleteGeoidSrtm(the_root)

    remove_parameter_by_key(the_root, 'outputs.isotropic')

    emptyMap = copy.deepcopy(the_root)

    remove_parameter_by_key(the_root, 'outputs.ortho')
    remove_choice(the_root, 'outputs.mode', 'orthofit')
    remove_independent_choices(the_root, 'outputs.mode', 'orthofit')
    merged = copy.deepcopy(the_root)

    split = split_by_choice(the_root, 'map')
    the_list = []

    for key in split:
        if key == 'utm':
            the_doc = split[key]
            remove_parameter_by_key(the_doc, 'map.epsg.code')
            defaultWrite('%s-%s' % (available_app, key), the_doc)
            the_list.append(the_doc)
        elif key == 'epsg':
            the_doc = split[key]
            remove_parameter_by_key(the_doc, 'map.utm.northhem')
            remove_parameter_by_key(the_doc, 'map.utm.zone')
            defaultWrite('%s-%s' % (available_app, key), the_doc)
            the_list.append(the_doc)

    remove_choice(merged, 'map', 'utm')
    remove_choice(merged, 'map', 'epsg')
    remove_parameter_by_key(merged, 'map.epsg.code')
    remove_parameter_by_key(merged, 'map.utm.northhem')
    remove_parameter_by_key(merged, 'map.utm.zone')
    old_app_name = merged.find('key').text
    merged.find('key').text = '%s-%s' % (old_app_name, 'lambert-WGS84')
    merged.find('longname').text = '%s (%s)' % (old_app_name, 'lambert-WGS84')
    defaultWrite('%s-%s' % (available_app, 'lambert-WGS84'), merged)
    the_list.append(merged)

    remove_parameter_by_key(emptyMap, 'map')
    remove_parameter_by_key(emptyMap, 'map.epsg.code')
    remove_parameter_by_key(emptyMap, 'map.utm.northhem')
    remove_parameter_by_key(emptyMap, 'map.utm.zone')
    remove_choice(emptyMap, 'outputs.mode', 'autosize')
    remove_independent_choices(emptyMap, 'outputs.mode', 'autosize')
    remove_choice(emptyMap, 'outputs.mode', 'autospacing')
    remove_independent_choices(emptyMap, 'outputs.mode', 'autospacing')
    old_app_name = emptyMap.find('key').text
    emptyMap.find('key').text = '%s-%s' % (old_app_name, 'fit-to-ortho')
    emptyMap.find('longname').text = '%s (%s)' % (old_app_name, 'fit-to-ortho')
    defaultWrite('%s-%s' % (available_app, 'fit-to-ortho'), emptyMap)
    the_list.append(emptyMap)

    return the_list
def getRasterization(available_app, original_dom_document):
    """
    Let only rasterization with an reference image
    Let only mode auto.
    Remove all parameters which should be updated once the input file given.
    Split by SRS : EPSG, fit to ortho, lambert-wgs84 and UTM.
    Each of these SRS have their own parameters modified in this fonction.
    Delete GEOID and DEM parameter as they are not updated at the creation of the otb algorithms when you launch QGIS.
    The values are picked from the settings.
    """
    rasterization_image = original_dom_document

    import copy
    rasterization_manual = copy.deepcopy(original_dom_document)

    old_app_name = rasterization_image.find('key').text

    remove_parameter_by_key(rasterization_image, 'szx')
    remove_parameter_by_key(rasterization_image, 'szy')
    remove_parameter_by_key(rasterization_image, 'epsg')
    remove_parameter_by_key(rasterization_image, 'orx')
    remove_parameter_by_key(rasterization_image, 'ory')
    remove_parameter_by_key(rasterization_image, 'spx')
    remove_parameter_by_key(rasterization_image, 'spy')

    remove_parameter_by_key(rasterization_manual, 'im')

    # set a new name according to the choice
    rasterization_image.find('key').text = '%s-%s' % (old_app_name, "image")
    rasterization_image.find('longname').text = '%s (%s)' % (old_app_name,
                                                             "image")
    defaultWrite('%s-%s' % (old_app_name, "image"), rasterization_image)
    rasterization_manual.find('key').text = '%s-%s' % (old_app_name, "manual")
    rasterization_manual.find('longname').text = '%s (%s)' % (old_app_name,
                                                              "manual")
    defaultWrite('%s-%s' % (old_app_name, "manual"), rasterization_manual)
    return [rasterization_image, rasterization_manual]
def getReadImageInfo(available_app, original_dom_document):
    """
    Remove parameters that are output of the application.
    """
    the_root = original_dom_document
    remove_parameter_by_key(the_root, 'outkwl')
    remove_parameter_by_key(the_root, 'indexx')
    remove_parameter_by_key(the_root, 'indexy')
    remove_parameter_by_key(the_root, 'sizex')
    remove_parameter_by_key(the_root, 'sizey')
    remove_parameter_by_key(the_root, 'spacingx')
    remove_parameter_by_key(the_root, 'spacingy')
    remove_parameter_by_key(the_root, 'originx')
    remove_parameter_by_key(the_root, 'originy')
    remove_parameter_by_key(the_root, 'estimatedgroundspacingx')
    remove_parameter_by_key(the_root, 'estimatedgroundspacingy')
    remove_parameter_by_key(the_root, 'numberbands')
    remove_parameter_by_key(the_root, 'sensor')
    remove_parameter_by_key(the_root, 'id')
    remove_parameter_by_key(the_root, 'time')
    remove_parameter_by_key(the_root, 'ullat')
    remove_parameter_by_key(the_root, 'ullon')
    remove_parameter_by_key(the_root, 'urlat')
    remove_parameter_by_key(the_root, 'urlon')
    remove_parameter_by_key(the_root, 'lrlat')
    remove_parameter_by_key(the_root, 'lrlon')
    remove_parameter_by_key(the_root, 'lllat')
    remove_parameter_by_key(the_root, 'lllon')
    remove_parameter_by_key(the_root, 'town')
    remove_parameter_by_key(the_root, 'country')
    remove_parameter_by_key(the_root, 'rgb.r')
    remove_parameter_by_key(the_root, 'rgb.g')
    remove_parameter_by_key(the_root, 'rgb.b')
    remove_parameter_by_key(the_root, 'projectionref')
    remove_parameter_by_key(the_root, 'keyword')
    remove_parameter_by_key(the_root, 'gcp.count')
    remove_parameter_by_key(the_root, 'gcp.proj')
    defaultWrite(available_app, the_root)
    return [the_root]
Exemple #20
0
def getTrainSVMImagesClassifier(available_app, original_dom_document):
    the_root = original_dom_document
    remove_parameter_by_key(the_root, 'rand')
    defaultWrite(available_app, the_root)
    return [the_root]
Exemple #21
0
def getOpticalCalibration(available_app, original_dom_document):
    """
    Remove toc options (let toa) and remove all about atmo
    """
    #the_list = defaultSplit(available_app, original_dom_document, 'level')
    the_root = original_dom_document
    remove_independant_choices(the_root, 'level', 'toc')
    remove_choice(the_root, 'level', 'toc')
    remove_parameter_by_key(the_root, 'atmo.aerosol')
    remove_parameter_by_key(the_root, 'atmo.oz')
    remove_parameter_by_key(the_root, 'atmo.wa')
    remove_parameter_by_key(the_root, 'atmo.pressure')
    remove_parameter_by_key(the_root, 'atmo.opt')
    remove_parameter_by_key(the_root, 'atmo.aeronet')
    remove_parameter_by_key(the_root, 'radius')
    defaultWrite(available_app, the_root)
    return [the_root]
def getKMeansClassification(available_app, original_dom_document):
    the_root = original_dom_document
    remove_parameter_by_key(the_root, 'rand')
    defaultWrite(available_app, the_root)
    return [the_root]
def getQuicklook(available_app, original_dom_document):
    the_root = original_dom_document
    remove_parameter_by_key(the_root, 'cl')
    defaultWrite(available_app, the_root)
    return [the_root]
Exemple #24
0
def getOrthoRectification(available_app, original_dom_document):
    """
    Let only mode auto.
    Remove all parameters which should be updated once the input file given.
    Split by SRS : EPSG, fit to ortho, lambert-wgs84 and UTM.
    Each of these SRS have their own parameters modified in this fonction.
    Delete GEOID and DEM parameter as they are not updated at the creation of the otb algorithms when you launch QGIS.
    The values are picked from the settings.
    """
    the_root = original_dom_document

    remove_choice(the_root, 'outputs.mode', 'auto')
    remove_independant_choices(the_root, 'outputs.mode', 'auto')
    remove_choice(the_root, 'outputs.mode', 'outputroi')
    remove_independant_choices(the_root, 'outputs.mode', 'outputroi')
    remove_parameter_by_key(the_root, 'outputs.ulx')
    remove_parameter_by_key(the_root, 'outputs.uly')
    remove_parameter_by_key(the_root, 'outputs.sizex')
    remove_parameter_by_key(the_root, 'outputs.sizey')
    remove_parameter_by_key(the_root, 'outputs.spacingx')
    remove_parameter_by_key(the_root, 'outputs.spacingy')
    remove_parameter_by_key(the_root, 'outputs.lrx')
    remove_parameter_by_key(the_root, 'outputs.lry')
    remove_parameter_by_key(the_root, 'opt.rpc')

    deleteGeoidSrtm(the_root)

    remove_parameter_by_key(the_root, 'outputs.isotropic')

    emptyMap = copy.deepcopy(the_root)

    remove_parameter_by_key(the_root, 'outputs.ortho')
    remove_choice(the_root, 'outputs.mode', 'orthofit')
    remove_independant_choices(the_root, 'outputs.mode', 'orthofit')
    merged = copy.deepcopy(the_root)




    split = split_by_choice(the_root, 'map')
    the_list = []

    for key in split:
        if key == 'utm':
            the_doc = split[key]
            remove_parameter_by_key(the_doc, 'map.epsg.code')
            defaultWrite('%s-%s' % (available_app, key), the_doc)
            the_list.append(the_doc)
        elif key == 'epsg':
            the_doc = split[key]
            remove_parameter_by_key(the_doc, 'map.utm.northhem')
            remove_parameter_by_key(the_doc, 'map.utm.zone')
            defaultWrite('%s-%s' % (available_app, key), the_doc)
            the_list.append(the_doc)

    remove_choice(merged, 'map', 'utm')
    remove_choice(merged, 'map', 'epsg')
    remove_parameter_by_key(merged, 'map.epsg.code')
    remove_parameter_by_key(merged, 'map.utm.northhem')
    remove_parameter_by_key(merged, 'map.utm.zone')
    old_app_name = merged.find('key').text
    merged.find('key').text = '%s-%s' % (old_app_name, 'lambert-WGS84')
    merged.find('longname').text = '%s (%s)' % (old_app_name, 'lambert-WGS84')
    defaultWrite('%s-%s' % (available_app, 'lambert-WGS84'), merged)
    the_list.append(merged)

    remove_parameter_by_key(emptyMap, 'map')
    remove_parameter_by_key(emptyMap, 'map.epsg.code')
    remove_parameter_by_key(emptyMap, 'map.utm.northhem')
    remove_parameter_by_key(emptyMap, 'map.utm.zone')
    remove_choice(emptyMap, 'outputs.mode', 'autosize')
    remove_independant_choices(emptyMap, 'outputs.mode', 'autosize')
    remove_choice(emptyMap, 'outputs.mode', 'autospacing')
    remove_independant_choices(emptyMap, 'outputs.mode', 'autospacing')
    old_app_name = emptyMap.find('key').text
    emptyMap.find('key').text = '%s-%s' % (old_app_name, 'fit-to-ortho')
    emptyMap.find('longname').text = '%s (%s)' % (old_app_name, 'fit-to-ortho')
    defaultWrite('%s-%s' % (available_app, 'fit-to-ortho'), emptyMap)
    the_list.append(emptyMap)

    return the_list
def getRasterization(available_app, original_dom_document):
    """
    Let only rasterization with an reference image
    Let only mode auto.
    Remove all parameters which should be updated once the input file given.
    Split by SRS : EPSG, fit to ortho, lambert-wgs84 and UTM.
    Each of these SRS have their own parameters modified in this fonction.
    Delete GEOID and DEM parameter as they are not updated at the creation of the otb algorithms when you launch QGIS.
    The values are picked from the settings.
    """
    rasterization_image = original_dom_document

    import copy

    rasterization_manual = copy.deepcopy(original_dom_document)

    old_app_name = rasterization_image.find("key").text

    remove_parameter_by_key(rasterization_image, "szx")
    remove_parameter_by_key(rasterization_image, "szy")
    remove_parameter_by_key(rasterization_image, "epsg")
    remove_parameter_by_key(rasterization_image, "orx")
    remove_parameter_by_key(rasterization_image, "ory")
    remove_parameter_by_key(rasterization_image, "spx")
    remove_parameter_by_key(rasterization_image, "spy")

    remove_parameter_by_key(rasterization_manual, "im")

    # set a new name according to the choice
    rasterization_image.find("key").text = "%s-%s" % (old_app_name, "image")
    rasterization_image.find("longname").text = "%s (%s)" % (old_app_name, "image")
    defaultWrite("%s-%s" % (old_app_name, "image"), rasterization_image)
    rasterization_manual.find("key").text = "%s-%s" % (old_app_name, "manual")
    rasterization_manual.find("longname").text = "%s (%s)" % (old_app_name, "manual")
    defaultWrite("%s-%s" % (old_app_name, "manual"), rasterization_manual)
    return [rasterization_image, rasterization_manual]
def getOpticalCalibration(available_app, original_dom_document):
    """
    Remove toc options (let toa) and remove all about atmo
    """
    #the_list = defaultSplit(available_app, original_dom_document, 'level')
    the_root = original_dom_document
    remove_independent_choices(the_root, 'level', 'toc')
    remove_choice(the_root, 'level', 'toc')
    remove_parameter_by_key(the_root, 'atmo.aerosol')
    remove_parameter_by_key(the_root, 'atmo.oz')
    remove_parameter_by_key(the_root, 'atmo.wa')
    remove_parameter_by_key(the_root, 'atmo.pressure')
    remove_parameter_by_key(the_root, 'atmo.opt')
    remove_parameter_by_key(the_root, 'atmo.aeronet')
    remove_parameter_by_key(the_root, 'radius')
    defaultWrite(available_app, the_root)
    return [the_root]
def getOrthoRectification(available_app, original_dom_document):
    """
    Let only mode auto.
    Remove all parameters which should be updated once the input file given.
    Split by SRS : EPSG, fit to ortho, lambert-wgs84 and UTM.
    Each of these SRS have their own parameters modified in this fonction.
    Delete GEOID and DEM parameter as they are not updated at the creation of the otb algorithms when you launch QGIS.
    The values are picked from the settings.
    """
    the_root = original_dom_document

    remove_choice(the_root, "outputs.mode", "auto")
    remove_independent_choices(the_root, "outputs.mode", "auto")
    remove_choice(the_root, "outputs.mode", "outputroi")
    remove_independent_choices(the_root, "outputs.mode", "outputroi")
    remove_parameter_by_key(the_root, "outputs.ulx")
    remove_parameter_by_key(the_root, "outputs.uly")
    remove_parameter_by_key(the_root, "outputs.sizex")
    remove_parameter_by_key(the_root, "outputs.sizey")
    remove_parameter_by_key(the_root, "outputs.spacingx")
    remove_parameter_by_key(the_root, "outputs.spacingy")
    remove_parameter_by_key(the_root, "outputs.lrx")
    remove_parameter_by_key(the_root, "outputs.lry")
    remove_parameter_by_key(the_root, "opt.rpc")

    deleteGeoidSrtm(the_root)

    remove_parameter_by_key(the_root, "outputs.isotropic")

    emptyMap = copy.deepcopy(the_root)

    remove_parameter_by_key(the_root, "outputs.ortho")
    remove_choice(the_root, "outputs.mode", "orthofit")
    remove_independent_choices(the_root, "outputs.mode", "orthofit")
    merged = copy.deepcopy(the_root)

    split = split_by_choice(the_root, "map")
    the_list = []

    for key in split:
        if key == "utm":
            the_doc = split[key]
            remove_parameter_by_key(the_doc, "map.epsg.code")
            defaultWrite("%s-%s" % (available_app, key), the_doc)
            the_list.append(the_doc)
        elif key == "epsg":
            the_doc = split[key]
            remove_parameter_by_key(the_doc, "map.utm.northhem")
            remove_parameter_by_key(the_doc, "map.utm.zone")
            defaultWrite("%s-%s" % (available_app, key), the_doc)
            the_list.append(the_doc)

    remove_choice(merged, "map", "utm")
    remove_choice(merged, "map", "epsg")
    remove_parameter_by_key(merged, "map.epsg.code")
    remove_parameter_by_key(merged, "map.utm.northhem")
    remove_parameter_by_key(merged, "map.utm.zone")
    old_app_name = merged.find("key").text
    merged.find("key").text = "%s-%s" % (old_app_name, "lambert-WGS84")
    merged.find("longname").text = "%s (%s)" % (old_app_name, "lambert-WGS84")
    defaultWrite("%s-%s" % (available_app, "lambert-WGS84"), merged)
    the_list.append(merged)

    remove_parameter_by_key(emptyMap, "map")
    remove_parameter_by_key(emptyMap, "map.epsg.code")
    remove_parameter_by_key(emptyMap, "map.utm.northhem")
    remove_parameter_by_key(emptyMap, "map.utm.zone")
    remove_choice(emptyMap, "outputs.mode", "autosize")
    remove_independent_choices(emptyMap, "outputs.mode", "autosize")
    remove_choice(emptyMap, "outputs.mode", "autospacing")
    remove_independent_choices(emptyMap, "outputs.mode", "autospacing")
    old_app_name = emptyMap.find("key").text
    emptyMap.find("key").text = "%s-%s" % (old_app_name, "fit-to-ortho")
    emptyMap.find("longname").text = "%s (%s)" % (old_app_name, "fit-to-ortho")
    defaultWrite("%s-%s" % (available_app, "fit-to-ortho"), emptyMap)
    the_list.append(emptyMap)

    return the_list
def getExtractROI(available_app, original_dom_document):
    """
    Split by mode (standard, fit)
    Adapt parameters of each resulting app.
    Delete GEOID and DEM parameter as they are not updated at the creation of the otb algorithms when you launch QGIS.
    The values are picked from the settings.
    """
    the_root = original_dom_document
    remove_parameter_by_key(the_root, 'cl')
    deleteGeoidSrtm(the_root)
    split = split_by_choice(the_root, 'mode')
    the_list = []
    for key in split:
        if key == 'standard':
            the_doc = split[key]
            remove_parameter_by_key(the_doc, 'mode.fit.elev.dem')
            remove_parameter_by_key(the_doc, 'mode.fit.elev.geoid')
            remove_parameter_by_key(the_doc, 'mode.fit.elev.default')
            remove_parameter_by_key(the_doc, 'mode.fit.ref')
            defaultWrite('%s-%s' % (available_app, key), the_doc)
            the_list.append(the_doc)
        else:
            #key == 'fit'
            the_doc = split[key]
            remove_parameter_by_key(the_doc, 'startx')
            remove_parameter_by_key(the_doc, 'starty')
            remove_parameter_by_key(the_doc, 'sizex')
            remove_parameter_by_key(the_doc, 'sizey')
            defaultWrite('%s-%s' % (available_app, key), the_doc)
            the_list.append(split[key])
    return the_list