def main(file, dir, move_local_files, expand_only): """ Given an input layers file and a directory, print the compiled XML file to stdout and save any encountered external image files to the named directory. """ print cascadenik.compile(file, dir=dir, move_local_files=False, expand_only=expand_only) return 0
def main(file, dir): """ Given an input layers file and a directory, print the compiled XML file to stdout and save any encountered external image files to the named directory. """ print cascadenik.compile(file, dir) return 0
def compile(self, url, compile_callback): """ retrieve and compile a mapnik xml file. only called when the map is not already in static cache. calls compile_callback when """ self.mapnik_maps[url] = mapnik.Map(self.tilesize, self.tilesize) open("%s_compiled.xml" % self.filecache(url), 'w').write( cascadenik.compile(self.filecache(url), urlcache=True)) mapnik.load_map(self.mapnik_maps[url], "%s_compiled.xml" % self.filecache(url)) compile_callback(self.mapnik_maps[url])
def load_mml(self, refresh=False): self.from_mapfile = True self.mapfile_format = 'Cascadenik mml' if self.loaded_mapfile and refresh: mapfile = self.loaded_mapfile else: mapfile = QFileDialog.getOpenFileName(None, "Open file dialog", '', "Cascadenik MML (*.mml)") if mapfile: self.mapnik_map = mapnik.Map(1, 1) import cascadenik if hasattr(cascadenik, 'VERSION'): major = int(cascadenik.VERSION.split('.')[0]) if major < 1: from cascadenik import compile compiled = '%s_compiled.xml' % os.path.splitext( str(mapfile))[0] open(compiled, 'w').write(compile(str(mapfile))) mapnik.load_map(self.mapnik_map, compiled) elif major == 1: output_dir = os.path.dirname(str(mapfile)) cascadenik.load_map(self.mapnik_map, str(mapfile), output_dir, verbose=False) elif major > 1: raise NotImplementedError( 'This nik2img version does not yet support Cascadenik > 1.x, please upgrade nik2img to the latest release' ) else: from cascadenik import compile compiled = '%s_compiled.xml' % os.path.splitext( str(mapfile))[0] #if os.path.exits(compiled): #pass open(compiled, 'w').write(compile(str(mapfile))) mapnik.load_map(self.mapnik_map, compiled) if self.loaded_mapfile and refresh: self.set_mapnik_to_canvas() else: self.set_canvas_from_mapnik() self.loaded_mapfile = str(mapfile)
def load_mml(self, refresh=False): self.from_mapfile = True self.mapfile_format = "Cascadenik mml" if self.loaded_mapfile and refresh: mapfile = self.loaded_mapfile else: mapfile = QFileDialog.getOpenFileName(None, "Open file dialog", "", "Cascadenik MML (*.mml)") if mapfile: self.mapnik_map = mapnik.Map(1, 1) import cascadenik if hasattr(cascadenik, "VERSION"): major = int(cascadenik.VERSION.split(".")[0]) if major < 1: from cascadenik import compile compiled = "%s_compiled.xml" % os.path.splitext(str(mapfile))[0] open(compiled, "w").write(compile(str(mapfile))) mapnik.load_map(self.mapnik_map, compiled) elif major == 1: output_dir = os.path.dirname(str(mapfile)) cascadenik.load_map(self.mapnik_map, str(mapfile), output_dir, verbose=False) elif major > 1: raise NotImplementedError( "This nik2img version does not yet support Cascadenik > 1.x, please upgrade nik2img to the latest release" ) else: from cascadenik import compile compiled = "%s_compiled.xml" % os.path.splitext(str(mapfile))[0] # if os.path.exits(compiled): # pass open(compiled, "w").write(compile(str(mapfile))) mapnik.load_map(self.mapnik_map, compiled) if self.loaded_mapfile and refresh: self.set_mapnik_to_canvas() else: self.set_canvas_from_mapnik() self.loaded_mapfile = str(mapfile)
def load_mml(self,m): from cascadenik import compile compiled = '%s_compiled.xml' % os.path.splitext(self.mapfile)[0] open(compiled, 'w').write(compile(self.mapfile)) mapnik.load_map(m, compiled)
def load_mml(self, m): from cascadenik import compile compiled = "%s_compiled.xml" % os.path.splitext(self.mapfile)[0] open(compiled, "w").write(compile(self.mapfile)) mapnik.load_map(m, compiled)