Needs to be removed again.
2 from caugrid import Grid
7 def dumpGrid(grid, filename):
8 config = ConfigParser.RawConfigParser()
10 config.add_section(meta_section)
11 config.set(meta_section, 'min x', grid.minx)
12 config.set(meta_section, 'max x', grid.maxx)
13 config.set(meta_section, 'min y', grid.miny)
14 config.set(meta_section, 'max y', grid.maxy)
15 config.set(meta_section, 'cell no', len(grid))
17 config.add_section(data_section)
18 config.set(data_section, "cells", ";".join([str(pos) for pos in grid.cells.iterkeys()]))
20 with open(filename, 'wb') as configfile:
21 config.write(configfile)
23 def loadGrid(filename):
24 config = ConfigParser.RawConfigParser()
28 grid.minx = config.getint(meta_section, "min x")
29 grid.maxx = config.getint(meta_section, "max x")
30 grid.miny = config.getint(meta_section, "min y")
31 grid.maxy = config.getint(meta_section, "max y")
33 cells = config.get(data_section, "cells")
34 for cell in cells.split(";"):
35 cell = [int(cell.strip("(),")) for cell in cell.split()]
36 grid.cells[(cell[0], cell[1])] = 1