def __init__(self, name, mapset="", *aopen, **kwopen): """The constructor need at least the name of the map *optional* field is the `mapset`. >>> ele = RasterAbstractBase(test_raster_name) >>> ele.name u'abstract_test_map' >>> ele.exist() True .. """ self.mapset = mapset self._name = name ## Private attribute `_fd` that return the file descriptor of the map self._fd = None ## Private attribute `_rows` that return the number of rows # in active window, When the class is instanced is empty and it is set # when you open the file, using Rast_window_rows() self._rows = None ## Private attribute `_cols` that return the number of rows # in active window, When the class is instanced is empty and it is set # when you open the file, using Rast_window_cols() self._cols = None #self.region = Region() self.hist = History(self.name, self.mapset) self.cats = Category(self.name, self.mapset) self.info = Info(self.name, self.mapset) self._aopen = aopen self._kwopen = kwopen self._mtype = 'CELL' self._mode = 'r' self._overwrite = False
def testCategory(self): r = RasterRow(self.name) r.open() cats = r.cats cats1 = Category(self.name) cats1.read() self.assertEqual(cats, cats1) r.close()
def testFirstCat(self): cat0 = ('A', 11, None) cat7 = ('H', 24, None) cat15 = ('P', 44, None) cats = Category(self.name) cats.read() self.assertEqual(cats[0], cat0) self.assertEqual(cats[7], cat7) self.assertEqual(cats[15], cat15)
def testCategory(self): r = RasterRow(self.name) r.open() cats = r.cats cats1 = Category(self.name) cats1.read() # this is not working, I don't know why self.assertEqual(cats, cats1) r.close()
def __init__(self, name, mapset="", *aopen, **kwopen): """The constructor need at least the name of the map *optional* field is the `mapset`. >>> ele = RasterAbstractBase(test_raster_name) >>> ele.name 'abstract_test_map' >>> ele.exist() True .. """ self.mapset = mapset if not mapset: # note that @must_be_in_current_mapset requires mapset to be set mapset = libgis.G_find_raster(name, mapset) if mapset is not None: self.mapset = utils.decode(mapset) self._name = name # Private attribute `_fd` that return the file descriptor of the map self._fd = None # Private attribute `_rows` that return the number of rows # in active window, When the class is instanced is empty and it is set # when you open the file, using Rast_window_rows() self._rows = None # Private attribute `_cols` that return the number of rows # in active window, When the class is instanced is empty and it is set # when you open the file, using Rast_window_cols() self._cols = None # self.region = Region() self.hist = History(self.name, self.mapset) self.cats = Category(self.name, self.mapset) self.info = Info(self.name, self.mapset) self._aopen = aopen self._kwopen = kwopen self._mtype = "CELL" self._mode = "r" self._overwrite = False
def get_cats(self): """Return a category object""" cat = Category(name=self.name, mapset=self.mapset) cat.read() return cat
def testWrite(self): tmpfile = tempfile(False) cats = Category(self.name) cats.read() cats.write_rules(tmpfile) self.assertFilesEqualMd5(tmpfile, 'data/geology_cats')
def get_cats(self): """Return a category object""" cat = Category() cat.read(self) return cat
def testFirstCat(self): cat0 = ('Zml', 1, None) cats = Category(self.name) cats.read() self.assertEqual(cats[0], cat0)