Ejemplo n.º 1
0
def getComputeModulusAndPhase(available_app, original_dom_document):
    """
    Split the application according the field nbinput.
    For each of the resulting apps, give a new name.
    """
    the_root = original_dom_document
    splitted = split_by_choice(the_root, 'nbinput')
    the_list = []
    for key in splitted:
        if key == 'one':
            the_doc = splitted[key]
            old_app_name = the_doc.find('key').text
            the_doc.find('key').text = '%s-%s' % (old_app_name, 'OneEntry')
            old_longname = the_doc.find('longname').text
            the_doc.find('longname').text = '%s (%s)' % (old_app_name, 'OneEntry')
            defaultWrite('%s-%s' % (available_app, 'OneEntry'), the_doc)
            the_list.append(the_doc)
        else :
            the_doc = splitted[key]
            old_app_name = the_doc.find('key').text
            the_doc.find('key').text = '%s-%s' % (old_app_name, 'TwoEntries')
            old_longname = the_doc.find('longname').text
            the_doc.find('longname').text = '%s (%s)' % (old_app_name, 'TwoEntries')
            defaultWrite('%s-%s' % (available_app, 'TwoEntries'), the_doc)
            the_list.append(the_doc)
    return the_list
Ejemplo n.º 2
0
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)
    splitted = split_by_choice(the_root, 'mode')
    the_list = []
    for key in splitted:
        if key == 'standard':
            the_doc = splitted[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 = splitted[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(splitted[key])
    return the_list
Ejemplo n.º 3
0
def getFusionOfClassifications(available_app, original_dom_document):
    """
    Split by method of fusion of classification (dempstershafer, majorityvoting)
    """
    the_root = original_dom_document
    splitted = split_by_choice(the_root, 'method')
    the_list = []
    for key in splitted:
        defaultWrite('%s-%s' % (available_app, key), splitted[key])
        the_list.append(splitted[key])
    return the_list
Ejemplo n.º 4
0
def getRigidTransformResample(available_app, original_dom_document):
    """
    split by transformation (id, rotation, translation)
    """
    the_root = original_dom_document
    splitted = split_by_choice(the_root, 'transform.type')
    the_list = []
    for key in splitted:
        defaultWrite('%s-%s' % (available_app, key), splitted[key])
        the_list.append(splitted[key])
    return the_list
Ejemplo n.º 5
0
def getPansharpening(available_app, original_dom_document):
    """
    Split by method (bayes, lmvm, rcs)
    """
    the_root = original_dom_document
    splitted = split_by_choice(the_root, 'method')
    the_list = []
    for key in splitted:
        defaultWrite('%s-%s' % (available_app, key), splitted[key])
        the_list.append(splitted[key])
    return the_list
Ejemplo n.º 6
0
def getColorMapping(available_app, original_dom_document):
    """
    Remove the option colortolabel
    Split by method : custom, continous, 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')
    splitted = split_by_choice(the_root, 'method')
    the_list = []
    for key in splitted:
        if key == 'custom':
            the_doc = splitted[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 = splitted[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 = splitted[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 = splitted[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(splitted[key])
    return the_list
Ejemplo n.º 7
0
def getTrainImagesClassifier(available_app, original_dom_document):
    """
    Split by  classifier (ann, bayes, boost, dt, gbt, knn, libsvm, rf, svm)
    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
    deleteGeoidSrtm(the_root)
    splitted = split_by_choice(the_root, 'classifier')
    the_list = []
    for key in splitted:
        defaultWrite('%s-%s' % (available_app, key), splitted[key])
        the_list.append(splitted[key])
    return the_list
Ejemplo n.º 8
0
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')
    splitted = split_by_choice(the_root, 'filter')
    the_list = []
    for key in splitted:
        defaultWrite('%s-%s' % (available_app, key), splitted[key])
        the_list.append(splitted[key])
    return the_list
Ejemplo n.º 9
0
def getComputeConfusionMatrix(available_app, original_dom_document):
    """
    Split by ref (raster, vector)
    """
    the_root = original_dom_document
    #remove_independant_choices(the_root, 'ref', 'vector')
    #remove_choice(the_root, 'ref', 'vector')
    #defaultWrite(available_app, the_root)

    splitted = split_by_choice(the_root, 'ref')
    the_list = []
    for key in splitted:
        defaultWrite('%s-%s' % (available_app, key), splitted[key])
        the_list.append(splitted[key])
    return the_list

    return [the_root]
Ejemplo n.º 10
0
def getSegmentation(available_app, original_dom_document):
    """
    Remove the choice raster and split by filter (cc, edison, meanshift, mprofiles, watershed)
    """
    the_root = original_dom_document
    #remove_choice(the_root, 'filter', 'edison')
    #remove_independant_choices(the_root, 'filter', 'edison')
    #remove_choice(the_root, 'filter', 'meanshift')
    #remove_independant_choices(the_root, 'filter', 'meanshift')
    remove_choice(the_root, 'mode', 'raster')
    remove_independant_choices(the_root, 'mode', 'raster')
    splitted = split_by_choice(the_root, 'filter')
    the_list = []
    for key in splitted:
        defaultWrite('%s-%s' % (available_app, key), splitted[key])
        the_list.append(splitted[key])
    return the_list
Ejemplo n.º 11
0
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')
    splitted = split_by_choice(the_root, 'method')
    the_list = []
    for key in splitted:
        if key == 'maf':
            the_doc = splitted[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), splitted[key])
            the_list.append(splitted[key])
    return the_list
Ejemplo n.º 12
0
def getSmoothing(available_app, original_dom_document):
    """
    Split by type (anidif, gaussian, mean)
    """

    #import copy
    #the_root = copy.deepcopy(original_dom_document)
    #remove_dependant_choices(the_root, 'type', 'anidif')
    #remove_other_choices(the_root, 'type', 'anidif')
    #defaultWrite('%s-anidif' % available_app, the_root)

    #the_root = copy.deepcopy(original_dom_document)
    #remove_independant_choices(the_root, 'type', 'anidif')
    #remove_choice(the_root, 'type', 'anidif')
    #defaultWrite(available_app, the_root)

    the_root = original_dom_document
    splitted = split_by_choice(the_root, 'type')
    the_list = []
    for key in splitted:
        defaultWrite('%s-%s' % (available_app, key), splitted[key])
        the_list.append(splitted[key])

    return the_list
Ejemplo n.º 13
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)




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

    for key in splitted:
        if key == 'utm':
            the_doc = splitted[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 = splitted[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')
    old_longname = merged.find('longname').text
    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')
    old_longname = emptyMap.find('longname').text
    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