Example usage for org.apache.commons.cli Option setArgs

List of usage examples for org.apache.commons.cli Option setArgs

Introduction

In this page you can find the example usage for org.apache.commons.cli Option setArgs.

Prototype

public void setArgs(int num) 

Source Link

Document

Sets the number of argument values this Option can take.

Usage

From source file:org.deegree.tools.coverage.TransformRaster.java

/**
 * @param args//w ww . jav a  2 s .c  om
 */
public static void main(String[] args) {
    CommandLineParser parser = new PosixParser();

    Options options = new Options();

    Option t_srs = new Option("t_srs", "the srs of the target raster");
    t_srs.setRequired(true);
    t_srs.setArgs(1);
    t_srs.setArgName("epsg code");
    options.addOption(t_srs);

    Option s_srs = new Option("s_srs", "the srs of the source raster");
    s_srs.setRequired(true);
    s_srs.setArgs(1);
    s_srs.setArgName("epsg code");
    options.addOption(s_srs);

    Option interpolation = new Option("interpolation",
            "the raster interpolation (nn: nearest neighbour, bl: bilinear");
    interpolation.setArgs(1);
    interpolation.setArgName("nn|bl");
    options.addOption(interpolation);

    Option originLocation = new Option("origin", "originlocation", true,
            "the location of the origin on the upper left pixel (default = center)");
    interpolation.setArgs(1);
    interpolation.setArgName("center|outer");
    options.addOption(originLocation);

    CommandUtils.addDefaultOptions(options);

    // for the moment, using the CLI API there is no way to respond to a help argument; see
    // https://issues.apache.org/jira/browse/CLI-179
    if (args.length == 0 || (args.length > 0 && (args[0].contains("help") || args[0].contains("?")))) {
        printHelp(options);
    }

    try {
        CommandLine line = parser.parse(options, args);

        InterpolationType interpolationType = getInterpolationType(line.getOptionValue(interpolation.getOpt()));
        OriginLocation location = getLocation(line.getOptionValue(originLocation.getOpt()));

        transformRaster(line.getArgs(), line.getOptionValue("s_srs"), line.getOptionValue("t_srs"),
                interpolationType, location);

    } catch (ParseException exp) {
        System.out.println("ERROR: Invalid command line:" + exp.getMessage());
    }
    System.exit(0);
}

From source file:org.deegree.tools.crs.ConfigurationConverger.java

private static Options initOptions() {
    Options options = new Options();

    Option option = new Option("f", OPT_IN_FILE, true,
            "input file to read the crs defintions from (in inFormat).");
    option.setArgs(1);
    option.setRequired(true);/*w  w w  .j a v  a2 s.co m*/
    options.addOption(option);

    option = new Option("o", OPT_OUT_FILE, true, "File to write the new defintions to");
    option.setArgs(1);
    option.setRequired(true);
    options.addOption(option);

    option = new Option("if", OPT_IN_FORM, true,
            "The expected in format, allowed are: " + Arrays.toString(Format.values()));
    option.setArgs(1);
    option.setRequired(true);
    options.addOption(option);

    option = new Option("of", OPT_OUT_FORM, true,
            "The output format, allowed are: " + Arrays.toString(Format.values()));
    option.setArgs(1);
    option.setRequired(true);
    options.addOption(option);

    CommandUtils.addDefaultOptions(options);

    return options;

}

From source file:org.deegree.tools.crs.CoordinateTransform.java

private static Options initOptions() {
    Options options = new Options();
    options.addOption("i", OPT_INVERSE, false, "should an inverse operation be applied as well.");
    Option option = new Option("s", OPT_S_SRS, true, "The name of the source srs, e.g. EPSG:4326.");
    option.setArgs(1);
    option.setRequired(true);//  ww  w  . j a  v  a2 s. c  om
    options.addOption(option);

    option = new Option("t", OPT_T_SRS, true, "The name of the target srs, e.g. EPSG:4326.");
    option.setArgs(1);
    option.setRequired(true);
    options.addOption(option);

    option = new Option("c", OPT_COORD, true,
            "Defines a coordinate (comma separated) in the source crs, e.g. '3.1415 , 2.7182'.");
    option.setArgs(1);
    options.addOption(option);

    option = new Option("f", OPT_FILE, true,
            "a /path/of/a_list_of_coordinates.txt containing a list of coordinate pairs/triples. If supplied the -coordSep (the separator between the ordinates will also be evalutated).");
    option.setArgs(1);
    options.addOption(option);

    option = new Option("sep", OPT_COORD_SEP, true,
            "(only valid with -sourceFile) defining a separator between the coords in the file e.g. a ';' or ',' if omitted a space is assumed.");
    option.setArgs(1);
    options.addOption(option);

    CommandUtils.addDefaultOptions(options);

    return options;

}

From source file:org.deegree.tools.crs.CRSInfo.java

private static Options initOptions() {
    Options options = new Options();
    Option option = new Option("a", OPT_IS_AV, true, "Give an affirmation if the given crs is available");
    option.setArgs(1);
    options.addOption(option);/*from   w w  w . jav a  2 s.c  o  m*/

    option = new Option("f", OPT_FILE, true,
            "If [-isAvailable] is not given, write all configured crs_s to file, if not given standard out will be used");
    option.setArgs(1);
    options.addOption(option);

    options.addOption(OPT_VERIFY, false,
            "if [-isAvailable] is not given, the -verify flag can be used to verify if the provider can create all configured crs_s, thus verifying if the configuration is correct.");

    CommandUtils.addDefaultOptions(options);

    return options;

}

From source file:org.deegree.tools.crs.XMLCoordinateTransform.java

private static Options initOptions() {

    Options options = new Options();

    Option option = new Option(OPT_S_SRS, true, "Identifier of the source srs, e.g. 'EPSG:4326'.");
    option.setArgs(1);
    options.addOption(option);/*from  ww w.  jav a  2 s .c o m*/

    option = new Option(OPT_T_SRS, true, "Identifier of the target srs, e.g. 'EPSG:4326'.");
    option.setArgs(1);
    option.setRequired(true);
    options.addOption(option);

    option = new Option(OPT_TRANSFORMATION, true,
            "Identifier of the transformation to be used, e.g. 'EPSG:4326'.");
    option.setArgs(1);
    options.addOption(option);

    option = new Option(OPT_INPUT, true, "Filename of the XML file to be transformed");
    option.setArgs(1);
    option.setRequired(true);
    options.addOption(option);

    option = new Option(OPT_GML_VERSION, true,
            "GML version (GML_2, GML_30, GML_31 or GML_32). Defaults to GML_31 if omitted.");
    option.setArgs(1);
    options.addOption(option);

    option = new Option(OPT_OUTPUT, true,
            "Filename of the output file. If omitted, output is directed to console.");
    option.setArgs(1);
    options.addOption(option);

    CommandUtils.addDefaultOptions(options);

    return options;
}

From source file:org.deegree.tools.feature.gml.MappingShortener.java

private static Options initOptions() {

    Options opts = new Options();

    Option opt = new Option("?", "help", false, "print (this) usage information");
    opt.setArgs(0);
    opts.addOption(opt);/*  www .  ja v a 2s  .  co m*/

    opt = new Option(OPT_INPUT_FILE, true, "input filename (one feature type name / property name per line)");
    opt.setRequired(true);
    opts.addOption(opt);

    opt = new Option(OPT_RULES_FILE, true, "rules filename (Java properties file with replacement rules)");
    opt.setRequired(true);
    opts.addOption(opt);
    return opts;
}

From source file:org.deegree.tools.rendering.dem.filtering.DEMRasterFilterer.java

/**
 * @param options//from   www. j a  v a 2s  .c om
 */
private static void addFilterOptions(Options options) {
    Option option = new Option("ks", OPT_KERNEL_SIZE, true, "The kernel size of the filter (default 11).");
    option.setArgs(1);
    options.addOption(option);

    option = new Option("stdCorr", OPT_STANDARD_DEVIATION_CORRECTION, true,
            "Correction factor for the standard deviation, higher value will cause better saving of edges but less error correction (default 1.5).");
    option.setArgs(1);
    options.addOption(option);
}

From source file:org.deegree.tools.rendering.dem.filtering.DEMRasterFilterer.java

/**
 * @param options// w ww . jav  a2s  . c o  m
 */
private static void addOutputOptions(Options options) {

    Option option = new Option("o", OPT_OUTPUT_DIR, true, "Directory where to output the filtered files.");
    option.setArgs(1);
    option.setRequired(true);
    options.addOption(option);

    option = new Option("ot", OPT_OUTPUT_TYPE, true, "Type of the filtered files (default is same as input).");
    option.setArgs(1);
    options.addOption(option);
}

From source file:org.deegree.tools.rendering.manager.DataManager.java

private static Options initOptions() {
    Options options = new Options();

    Option option = new Option(OPT_FILE.substring(0, 1), OPT_FILE, true, "the file containing data to import");
    option.setArgs(1);
    option.setArgName("relative/absolut file location");
    options.addOption(option);/*from  ww w  .  j  ava2s. c om*/

    option = new Option("ql", QL, true, "defines the quality level of the data the action should operate on");
    option.setArgs(1);
    option.setArgName("[1-5] if " + TYPE + "=prototype, '1' is expected");
    options.addOption(option);

    option = new Option("cll", OPT_CREATE_LOWEST_LEVELS, false,
            "A flag defining if the lowest levels (convexhull, protoype box ref) should be created for the buildings.");
    options.addOption(option);

    option = new Option("td", OPT_TEXTURE_DIR, true, "Directory where texture can be found.");
    option.setArgs(1);
    option.setArgName("path to the directory");
    options.addOption(option);

    option = new Option("id", OPT_UUID, true,
            "ID of the building to delete or of a vrml file, if not provided the file name will be used.");
    option.setArgs(1);
    option.setArgName("The id of the building.");
    options.addOption(option);

    option = new Option("tt", OPT_WPVS_TRANSLATION_TO, true,
            "A comma separated vector, translation vector to the nullpoint of the WPVS (see the WPVS-Config for more information).");
    option.setArgs(1);
    option.setArgName("e.g. -tt \"-2568000,-5606000\"  .");
    options.addOption(option);

    option = new Option("sw", OPT_DELETE_SQL, true,
            "SQL where statement which defines a where cause on the db.");
    option.setArgs(1);
    option.setArgName("a delete sql where statement, e.g. \"WHERE id='building_id'");
    options.addOption(option);

    addActionParameters(options);
    addTypeParameters(options);
    addDatabaseParameters(options);
    addVRMLParameters(options);
    addCityGMLParameters(options);

    CommandUtils.addDefaultOptions(options);

    return options;

}

From source file:org.deegree.tools.rendering.manager.DataManager.java

/**
 * @param options//w  ww .  j  ava2s  .c o  m
 */
private static void addActionParameters(Options options) {
    Option option = new Option(ACTION.substring(0, 1), ACTION, true,
            "defines the action the manager should perform");
    option.setArgs(1);
    StringBuilder argNames = new StringBuilder();
    Action[] allActions = Action.values();
    for (int i = 0; i < allActions.length; ++i) {
        Action a = allActions[i];
        argNames.append(a);
        if ((i + 1) < allActions.length) {
            argNames.append("|");
        }
    }
    option.setArgName(argNames.toString());
    option.setRequired(true);
    options.addOption(option);
}