def __init__(self, name, mapset='', mtype='CELL', *args, **kargs): self.name = name self.mapset = mapset self.c_cats = libraster.Categories() libraster.Rast_init_cats("", ctypes.byref(self.c_cats)) self._mtype = mtype self._gtype = None if mtype is None else RTYPE[mtype]['grass type'] super(Category, self).__init__(*args, **kargs)
def _write_cats(self): """Copy from the list data to the C struct""" # reset only the C struct libraster.Rast_init_cats("", ctypes.byref(self.c_cats)) # write to the c struct for cat in self.__iter__(): label, min_cat, max_cat = cat if max_cat is None: max_cat = min_cat self._set_c_cat(label, min_cat, max_cat)
def reset(self): for i in range(len(self) - 1, -1, -1): del(self[i]) libraster.Rast_init_cats("", ctypes.byref(self.c_cats))
def __init__(self, mtype=None, *args, **kargs): self._cats = libraster.Categories() libraster.Rast_init_cats("", ctypes.byref(self._cats)) self._mtype = mtype self._gtype = None if mtype is None else RTYPE[mtype]['grass type'] super(Category, self).__init__(*args, **kargs)