示例#1
0
    def apply_model(self, plot: Plot, years: int, value: float):

        Tools.print_log_line('Aplicando cut down sistemática', logging.INFO)

        new_plot = Plot()
        new_plot.clone(plot)

        order_criteria = OrderCriteria()
        order_criteria.add_criteria('dbh')

        search_criteria = SearchCriteria()
        search_criteria.add_criteria('status', None, EQUAL)

        trees = Tree.get_sord_and_order_tree_list(plot.trees,
                                                  search_criteria=search_criteria,
                                                  order_criteria=order_criteria)

        for tree in trees:

            new_tree = Tree()
            new_tree.clone(tree)

            new_tree.add_value('expan', tree.expan * ((100 - value) / 100))
            new_tree.add_value('status', None)
            new_plot.add_tree(new_tree)

            cut_tree = Tree()
            cut_tree.clone(tree)
            cut_tree.add_value('status', 'C')
            cut_tree.add_value('expan', tree.expan - new_tree.expan)

            if cut_tree.expan > 0:
                new_plot.add_tree(cut_tree)

        return new_plot
示例#2
0
    def apply_model(self, plot: Plot, years: int, value: float):

        Tools.print_log_line('Aplicando corta por el menor', logging.INFO)

        accumulator = 0
        cut_all_the_rest = False

        new_plot = Plot()
        new_plot.clone(plot)

        order_criteria = OrderCriteria(ASC)
        order_criteria.add_criteria('dbh')

        search_criteria = SearchCriteria()
        search_criteria.add_criteria('status', None, EQUAL)

        trees = Tree.get_sord_and_order_tree_list(plot.trees,
                                                  search_criteria=search_criteria,
                                                  order_criteria=order_criteria)

        cut_discriminator = self.type.cut_discriminator(trees, value)

        for tree in trees:

            accumulator += self.type.accumulator(tree)

            if not cut_all_the_rest:

                new_tree = Tree()
                new_tree.clone(tree)

                if accumulator >= cut_discriminator:

                    cut_all_the_rest = True
                    new_expan = self.type.compute_expan(tree, accumulator, cut_discriminator)

                    if new_expan <= 0:
                        new_tree.add_value('expan', new_expan)
                        new_tree.add_value('status', 'C')
                    else:
                        cut_tree = Tree()
                        cut_tree.clone(tree)
                        cut_tree.add_value('status', 'C')
                        cut_tree.add_value('expan', new_expan)

                        if cut_tree.expan > 0:
                            new_plot.add_tree(cut_tree)

                        new_tree.sub_value('expan', new_expan)
                        new_tree.add_value('status', None)

                new_plot.add_tree(new_tree)

            else:
                new_tree = Tree()
                new_tree.clone(tree)
                new_tree.add_value('status', 'C')
                new_plot.add_tree(new_tree)

        return new_plot