Esempio n. 1
0
    def CopyMap(self, name, tmp=False, update=False):
        """Make a copy of open vector map

        Note: Attributes are not copied

        :param name: name for a copy
        :param tmp: True for temporary map
        :param bool update: True if copy target vector map (poMapInfoNew)
        exist

        :return: number of copied features
        :return: -1 on error
        """
        if not self.poMapInfo:
            # nothing to copy
            return -1

        poMapInfoNew = pointer(Map_info())

        if not tmp:
            if update:
                open_fn = Vect_open_update
            else:
                open_fn = Vect_open_new
        else:
            if update:
                open_fn = Vect_open_tmp_update
            else:
                open_fn = Vect_open_tmp_new

        if update:
            if open_fn(poMapInfoNew, name, "") == -1:
                return -1
        else:
            is3D = bool(Vect_is_3d(self.poMapInfo))
            if open_fn(poMapInfoNew, name, is3D) == -1:
                return -1

        verbose = G_verbose()
        G_set_verbose(-1)  # be silent

        if Vect_copy_map_lines(self.poMapInfo, poMapInfoNew) == 1:
            G_set_verbose(verbose)
            return -1

        Vect_build(poMapInfoNew)
        G_set_verbose(verbose)

        ret = Vect_get_num_lines(poMapInfoNew)
        Vect_close(poMapInfoNew)

        return ret
Esempio n. 2
0
 def CloseMap(self):
     """Close training areas map - be quiet"""
     verbosity = G_verbose()
     G_set_verbose(0)
     DisplayDriver.CloseMap(self)
     G_set_verbose(verbosity)