def generateXml(self, contourDB, contourFile, mapfile): config = Config.get() regionClusters = Utils.read_features( config.get("MapData", "clusters_with_region_id")) regionIds = sorted( set( int(region['cluster_id']) for region in regionClusters.values())) regionIds = map(str, regionIds) countryBorders = Utils.read_features( config.get("GeneratedFiles", "country_borders")) colorFactory = Colors.ColorSelector(countryBorders, Config.getColorWheel()) colors = colorFactory.optimalColoring() ms = MapStyler(config, colors) imgfile = config.get("MapOutput", "img_src_name") ms.addCustomFonts(config.get("MapResources", "fontDir")) ms.makeMap(contourFile, config.get("MapData", "countries_geojson"), regionIds, contourDB) ms.saveMapXml(config.get("MapData", "countries_geojson"), mapfile) ms.saveImage(mapfile, imgfile + ".png") ms.saveImage(mapfile, imgfile + ".svg")
def __init__(self, semObject, className, modelPath=None): # Use the AToM3 Tkinter root window self.className = className root = self.rootInitilization(semObject, modelPath) if (not root): return self.root = root self.mainHandler = MainHandler.MainHandler(self) root.bind("<Key>", self.mainHandler.onKey) root.bind("<Shift-Key>", self.mainHandler.onShiftKey) root.bind("<Control-Key>", self.mainHandler.onControlKey) zoom = 1.0 self.menuBar = Tools.MenuBar(root, self, self.mainHandler) #goes to top by itself self.statusBar = Tools.StatusBar(root, "", zoom, 0, 0) #goes to bottom by itself self.colorSelector = Colors.ColorSelector( root, self.mainHandler) #goes to bottom by itself self.toolFrame = Tkinter.Frame(root, relief=Tkinter.RAISED, bd=1) self.toolSelector = Tools.ToolSelector(self.toolFrame, self.mainHandler, Tkinter.TOP) self.outlineFillOptionSelector = Tools.OutlineFillOptionSelector( self.toolFrame, self.mainHandler, Tkinter.TOP) self.lineWidthSelector = Tools.LineWidthSelector( self.toolFrame, self.mainHandler, Tkinter.TOP) self.toolFrame.pack(side=Tkinter.LEFT) self.workspace = Workspace(self, self.CANVAS_SIZE_TUPLE[2], self.CANVAS_SIZE_TUPLE[3], self.CANVAS_SIZE_TUPLE[2], self.CANVAS_SIZE_TUPLE[3], self.mainHandler, zoom) #goes to the right by itself self.workspace.setZoom(zoom, 0, 0) self.canvas = self.workspace.getCanvas() self.scripting = Scripting() ## self.GFs = self.open() self.GFs = [] self.extendedInitilization(semObject) self.clipboardList = [] self.undoStack = [] self.mainHandler.start() self.compositionVisitor = GFVisitors.CompositionVisitor(self) self.colorVisitor = GFVisitors.ColorVisitor() self.widthVisitor = GFVisitors.WidthVisitor() self.optionVisitor = GFVisitors.OptionVisitor(self) # Carefully try to load the GF model (may fail for random reasons) try: self.GFs = self.open() except: raise
def run(self): config = Config.get() colorWheel = Config.getColorWheel() countryBorders = Utils.read_features( config.get("GeneratedFiles", "country_borders")) colorFactory = Colors.ColorSelector(countryBorders, colorWheel) colors = colorFactory.optimalColoring() ms = MapStyler(config, colors) ms = MapStyler(config, colorWheel) ms.saveImage(config.get("MapOutput", "map_file_density"), config.get("MapOutput", "img_src_name") + ".png") ms.saveImage(config.get("MapOutput", "map_file_density"), config.get("MapOutput", "img_src_name") + ".svg")