Exemple #1
0
def main():
    #lazy imports
    import grass.temporal as tgis

    # Get the options
    input = options["input"]
    columns = options["columns"]
    order = options["order"]
    where = options["where"]
    separator = grass.separator(options["separator"])
    method = options["method"]
    header = flags["u"]
    output = options["output"]

    # Make sure the temporal database exists
    tgis.init()

    tgis.list_maps_of_stds("stvds",
                           input,
                           columns,
                           order,
                           where,
                           separator,
                           method,
                           header,
                           outpath=output)
Exemple #2
0
def main():

    # Get the options
    input = options["input"]
    columns = options["columns"]
    order = options["order"]
    where = options["where"]
    separator = grass.separator(options["separator"])
    method = options["method"]
    header = flags["u"]
    output = options["output"]

    # Make sure the temporal database exists
    tgis.init()

    tgis.list_maps_of_stds("stvds", input, columns, order, where, separator, method, header, outpath=output)
Exemple #3
0
def main():

    # Get the options
    input = options["input"]
    columns = options["columns"]
    order = options["order"]
    where = options["where"]
    separator = grass.separator(options["separator"])
    method = options["method"]
    granule = options["granule"]
    header = flags["s"]

    # Make sure the temporal database exists
    tgis.init()

    tgis.list_maps_of_stds("strds", input, columns, order, where, separator,
                           method, header, granule)
Exemple #4
0
def main():
    options, flags = gs.parser()

    # lazy imports
    import grass.temporal as tgis

    # Get the options
    # Parser does not ensure that the input exists.
    input = options["input"]
    columns = options["columns"]
    order = options["order"]
    where = options["where"]
    separator = gs.separator(options["separator"])
    method = options["method"]
    granule = options["granule"]
    header = flags["u"]
    output = options["output"]
    output_format = options["format"]

    if output_format == "csv":
        if len(separator) > 1:
            gs.fatal(
                message_option_value_excludes_option_value(
                    option_name="format",
                    option_value=output_format,
                    excluded_option_name="separator",
                    excluded_option_value=separator,
                    reason=_(
                        "A standard CSV separator (delimiter) is only one character long"
                    ),
                )
            )
        if separator == "|":
            # We use comma as the default for separator, so we override the pipe.
            # This does not allow for users to generate CSV with pipe, but unlike
            # the C API, the Python interface specs does not allow reseting the default
            # except for setting it to an empty string which does not have a precedence
            # in the current code and the behavior is unclear.
            separator = ","
    if output_format in ["json", "yaml"] and header:
        gs.fatal(
            message_option_value_excludes_flag(
                option_name="format",
                option_value=output_format,
                flag_name="u",
                reason=_("Column names are always included"),
            )
        )
        # We ignore when separator is set for JSON and YAML because of the default
        # value which is always there (see above). Having no default and producing
        # an error when set would be more clear and would fit with using different
        # defaults for plain and CSV formats.
    elif (output_format == "line" or method == "comma") and separator == "|":
        # Same as for CSV: Custom default needed.
        # Pipe is currently not supported at all.
        separator = ","

    if method in ["delta", "deltagaps", "gran"]:
        if order:
            gs.fatal(
                message_option_value_excludes_option(
                    option_name="method",
                    option_value=method,
                    excluded_option_name="order",
                    reason=_("Values are always ordered by start_time"),
                )
            )
        if columns:
            columns_list = columns.split(",")
            for column in [
                "semantic_label",
                "creator",
                "temporal_type",
                "creation_time",
                "north",
                "south",
                "west",
                "east",
                "nsres",
                "ewres",
                "cols",
                "rows",
                "number_of_cells",
                "min",
                "max",
            ]:
                if column in columns_list:
                    gs.fatal(
                        message_option_value_excludes_option_value(
                            option_name="method",
                            option_value=method,
                            excluded_option_name="columns",
                            excluded_option_value=columns,
                            reason=_(
                                "Column '{name}' is not available with the method '{method}'"
                            ).format(name=column, method=method),
                        )
                    )
    elif columns:
        columns_list = columns.split(",")
        for column in ["interval_length", "distance_from_begin"]:
            if column in columns_list:
                gs.fatal(
                    message_option_value_excludes_option_value(
                        option_name="method",
                        option_value=method,
                        excluded_option_name="columns",
                        excluded_option_value=columns,
                        reason=_(
                            "Column '{name}' is not available with the method '{method}'"
                        ).format(name=column, method=method),
                    )
                )
    if output_format == "line" or method == "comma":
        columns_list = columns.split(",")
        if len(columns_list) > 1:
            gs.fatal(
                message_option_value_excludes_option_value(
                    option_name="format",
                    option_value=output_format,
                    excluded_option_name="columns",
                    excluded_option_value=columns,
                    reason=_("Only one column is allowed (not {num_columns})").format(
                        num_columns=len(columns_list)
                    ),
                )
            )
    if method == "gran" and where:
        gs.fatal(
            message_option_value_excludes_option(
                option_name="method",
                option_value=method,
                excluded_option_name="where",
                reason=_("All maps are always listed"),
            )
        )

    # Make sure the temporal database exists
    tgis.init()

    tgis.list_maps_of_stds(
        "strds",
        input,
        columns,
        order,
        where,
        separator,
        method,
        header,
        granule,
        outpath=output,
        output_format=output_format,
    )