def _resultProducer(self, jobID, abortEvent, params): #params = ['first.tif'] #params = ['--s_srs','EPSG:4326','/Users/klokan/Desktop/fox-denali-alaska-644060-xl.jpg'] if self.resume and params[0] != '--resume': params.insert(0, '--resume') # TODO : adapter wxGDAL2Tiles à gdal2tiles:multiprocess self.config_g2t = wxgdal.wxGDAL2Tiles( params ) self.tile_g2t = self.config_g2t.create_tile() wx.PostEvent(self, GenericGuiEvent(_("Opening the input files"))) self.out_data_g2t,self.profile_g2t=self.config_g2t.open_input(self.tile_g2t) # Opening and preprocessing of the input file self.config_g2t.setEventHandler( self ) if not abortEvent() and not self.config_g2t.stopped: wx.PostEvent(self, GenericGuiEvent(_("Generating viewers and metadata"))) # Generation of main metadata files and HTML viewers # TODO : adapter wxGDAL2Tiles à gdal2tiles:multiprocess gdal2tiles.generate_metadata(self.config_g2t,self.profile_g2t,self.tile_g2t,self.out_data_g2t) if not abortEvent() and not self.config_g2t.stopped: wx.PostEvent(self, GenericGuiEvent(_("Rendering the base tiles"))) # Generation of the lowest tiles # TODO : adapter wxGDAL2Tiles à gdal2tiles:multiprocess gdal2tiles.generate_base_tiles(self.config_g2t,self.profile_g2t,self.tile_g2t,self.out_data_g2t) if not abortEvent() and not self.config_g2t.stopped: wx.PostEvent(self, GenericGuiEvent(_("Rendering the overview tiles in the pyramid"))) # Generation of the overview tiles (higher in the pyramid) # TODO : adapter wxGDAL2Tiles à gdal2tiles:multiprocess gdal2tiles.generate_overview_tiles(self.config_g2t,self.profile_g2t,self.tile_g2t,self.out_data_g2t)
def SetStep(self, step): self.step = step if step >= len(steps): config.rendering = False config.resume = False self.SetPage(stepfinal % (config.outputdir, config.outputdir)) return self.SetPage(steps[step]) if step == 1: self.FindWindowByName(config.profile).SetValue(1) elif step == 2: pass elif step == 3: if not config.srs: config.customsrs = config.files[0][6] config.srs = config.customsrs if not config.srs and config.bboxgeoref: config.srsformat = 1 config.srs = config.epsg4326 self.FindWindowByName("srs").SetSelection(config.srsformat) self.FindWindowByName("srs").SetValue(config.srs) elif step == 4: try: from wxgdal2tiles import wxGDAL2Tiles g2t = wxGDAL2Tiles(["--profile", config.profile, "--s_srs", config.srs, str(config.files[0][2])]) g2t.open_input() config.tminz = g2t.tminz config.tmaxz = g2t.tmaxz config.kml = g2t.kml del g2t except Exception, error: wx.MessageBox("%s" % error, _("GDAL2Tiles initialization failed"), wx.ICON_ERROR) self.FindWindowByName("tminz").SetValue(config.tminz) self.FindWindowByName("tmaxz").SetValue(config.tmaxz)
def SetStep(self, step): self.step = step if step >= len(steps): config.rendering = False config.resume = False self.SetPage(stepfinal % (config.outputdir, config.outputdir)) return self.SetPage(steps[step]) if step == 1: self.FindWindowByName(config.profile).SetValue(1) elif step == 2: pass elif step == 3: if not config.srs: config.customsrs = config.files[0][6] config.srs = config.customsrs if not config.srs and config.bboxgeoref: config.srsformat = 1 config.srs = config.epsg4326 self.FindWindowByName('srs').SetSelection(config.srsformat) self.FindWindowByName('srs').SetValue(config.srs) elif step == 4: try: # TODO : adapter wxGDAL2Tiles à gdal2tiles:multiprocess from wxgdal2tiles import wxGDAL2Tiles config_g2t = wxGDAL2Tiles([ '--profile', config.profile, '--s_srs', config.srs, str(config.files[0][2]) ]) tile_g2t = config_g2t.create_tile() out_data_g2t, profile_g2t = config_g2t.open_input(tile_g2t) config.tminz = tile_g2t.tminz config.tmaxz = tile_g2t.tmaxz config.kml = config_g2t.kml del config_g2t, tile_g2t, out_data_g2t, profile_g2t except Exception, error: wx.MessageBox("%s" % error, _("GDAL2Tiles initialization failed"), wx.ICON_ERROR) self.FindWindowByName('tminz').SetValue(config.tminz) self.FindWindowByName('tmaxz').SetValue(config.tmaxz)
def _resultProducer(self, jobID, abortEvent, params): #params = ['first.tif'] #params = ['--s_srs','EPSG:4326','/Users/klokan/Desktop/fox-denali-alaska-644060-xl.jpg'] if self.resume and params[0] != '--resume': params.insert(0, '--resume') # TODO : adapter wxGDAL2Tiles à gdal2tiles:multiprocess self.config_g2t = wxgdal.wxGDAL2Tiles(params) self.tile_g2t = self.config_g2t.create_tile() wx.PostEvent(self, GenericGuiEvent(_("Opening the input files"))) self.out_data_g2t, self.profile_g2t = self.config_g2t.open_input( self.tile_g2t) # Opening and preprocessing of the input file self.config_g2t.setEventHandler(self) if not abortEvent() and not self.config_g2t.stopped: wx.PostEvent(self, GenericGuiEvent(_("Generating viewers and metadata"))) # Generation of main metadata files and HTML viewers # TODO : adapter wxGDAL2Tiles à gdal2tiles:multiprocess gdal2tiles.generate_metadata(self.config_g2t, self.profile_g2t, self.tile_g2t, self.out_data_g2t) if not abortEvent() and not self.config_g2t.stopped: wx.PostEvent(self, GenericGuiEvent(_("Rendering the base tiles"))) # Generation of the lowest tiles # TODO : adapter wxGDAL2Tiles à gdal2tiles:multiprocess gdal2tiles.generate_base_tiles(self.config_g2t, self.profile_g2t, self.tile_g2t, self.out_data_g2t) if not abortEvent() and not self.config_g2t.stopped: wx.PostEvent( self, GenericGuiEvent( _("Rendering the overview tiles in the pyramid"))) # Generation of the overview tiles (higher in the pyramid) # TODO : adapter wxGDAL2Tiles à gdal2tiles:multiprocess gdal2tiles.generate_overview_tiles(self.config_g2t, self.profile_g2t, self.tile_g2t, self.out_data_g2t)
def SetStep(self, step): self.step = step if step >= len(steps): config.rendering = False config.resume = False self.SetPage(stepfinal % (config.outputdir, config.outputdir) ) return self.SetPage(steps[step]) if step == 1: self.FindWindowByName(config.profile).SetValue(1) elif step == 2: pass elif step == 3: if not config.srs: config.customsrs = config.files[0][6] config.srs = config.customsrs if not config.srs and config.bboxgeoref: config.srsformat = 1 config.srs = config.epsg4326 self.FindWindowByName('srs').SetSelection(config.srsformat) self.FindWindowByName('srs').SetValue(config.srs) elif step == 4: try: # TODO : adapter wxGDAL2Tiles à gdal2tiles:multiprocess from wxgdal2tiles import wxGDAL2Tiles config_g2t = wxGDAL2Tiles(['--profile',config.profile,'--s_srs', config.srs, str(config.files[0][2]) ]) tile_g2t = config_g2t.create_tile() out_data_g2t,profile_g2t=config_g2t.open_input(tile_g2t) config.tminz = tile_g2t.tminz config.tmaxz = tile_g2t.tmaxz config.kml = config_g2t.kml del config_g2t,tile_g2t,out_data_g2t,profile_g2t except Exception, error: wx.MessageBox("%s" % error , _("GDAL2Tiles initialization failed"), wx.ICON_ERROR) self.FindWindowByName('tminz').SetValue(config.tminz) self.FindWindowByName('tmaxz').SetValue(config.tmaxz)
def SetStep(self, step): self.step = step if step >= len(steps): config.rendering = False config.resume = False self.SetPage(stepfinal % (config.outputdir, config.outputdir) ) return self.SetPage(steps[step]) if step == 1: self.FindWindowByName(config.profile).SetValue(1) elif step == 2: pass #self.FindWindowByName('nodatapanel').SetColor(config.nodata) elif step == 3: if not config.srs: config.customsrs = config.files[0][6] config.srs = config.customsrs if not config.srs and config.bboxgeoref: config.srsformat = 1 config.srs = config.epsg4326 self.FindWindowByName('srs').SetSelection(config.srsformat) self.FindWindowByName('srs').SetValue(config.srs) elif step == 4: g2t = wxGDAL2Tiles(['--profile',config.profile,'--s_srs', config.srs, str(config.files[0][2]) ]) g2t.open_input() config.tminz = g2t.tminz config.tmaxz = g2t.tmaxz config.kml = g2t.kml del g2t self.FindWindowByName('tminz').SetValue(config.tminz) self.FindWindowByName('tmaxz').SetValue(config.tmaxz) if config.profile == 'gearth': self.FindWindowByName('format').SetItems( [ _("PNG - with transparency"), _("JPEG - smaller but without transparency"), _("Hybrid JPEG+PNG - only for Google Earth"), _("Garmin Custom maps KMZ - 256 pixels"), _("Garmin Custom maps KMZ - 512 pixels"), _("Garmin Custom maps KMZ - 1024 pixels") ] ) else: self.FindWindowByName('format').SetItems( [ _("PNG - with transparency"), _("JPEG - smaller but without transparency"), _("Hybrid JPEG+PNG - only for Google Earth") ] ) if not config.format and config.profile == 'gearth': self.FindWindowByName('format').SetSelection(2) # hybrid elif not config.format: self.FindWindowByName('format').SetSelection(0) # png else: self.FindWindowByName('format').SetSelection({'png':0,'jpeg':1,'hybrid':2,'garmin256':3,'garmin512':4,'garmin1024':5}[config.format]) self.Refresh() self.Update() elif step == 5: filename = config.files[0][0] # If this is the first time the user has gone this far, # we try to come up with sensible default output directory. if config.outputdir is None: input_dir = os.path.dirname(filename) # Implicitly we try to place it in the same directory in # which the input file is located. But if this is not possible, # we try to use the current directory. if os.access(input_dir, os.W_OK): base_dir = input_dir else: base_dir = os.getcwd() # Default name is the same as the input file without extensions. config.outputdir = os.path.join(base_dir, os.path.splitext(os.path.basename( filename ))[0] ) # GTK2 doesn't allow to select nonexisting directories, so we have to make it exist. if sys.platform.startswith("linux"): if not os.path.exists(config.outputdir): try: os.makedirs(config.outputdir) config.gtk2_hack_directory = config.outputdir except Exception, e: config.outputdir = os.getcwd() config.gtk2_hack_directory = None # I hate it when I have to do this. wx.MessageBox(_("""\ We are terribly sorry for this error. It is a known issue stemming from the fact that we try hard to \ support all major software platforms -- Microsoft Windos, Mac OS X and UNIX systems. Unfortunately \ they don't have all the same capabilities. You are processing file '%s' for which we can't provide default output directory, because both our \ options -- input file directory '%s' and your current working directory '%s' -- are not writeable. \ Please select the output directory on your own.""") % (filename, input_dir, os.getcwd()), _("Can't create default output directory"), wx.ICON_ERROR) else: config.gtk2_hack_directory = None self.FindWindowByName('outputdir').SetPath(config.outputdir)
def SetStep(self, step): self.step = step if step >= len(steps): config.rendering = False config.resume = False self.SetPage(stepfinal % (config.outputdir, config.outputdir)) return self.SetPage(steps[step]) if step == 1: self.FindWindowByName(config.profile).SetValue(1) elif step == 2: pass #self.FindWindowByName('nodatapanel').SetColor(config.nodata) elif step == 3: if not config.srs: config.customsrs = config.files[0][6] config.srs = config.customsrs if not config.srs and config.bboxgeoref: config.srsformat = 1 config.srs = config.epsg4326 self.FindWindowByName('srs').SetSelection(config.srsformat) self.FindWindowByName('srs').SetValue(config.srs) elif step == 4: g2t = wxGDAL2Tiles([ '--profile', config.profile, '--s_srs', config.srs, str(config.files[0][2]) ]) g2t.open_input() config.tminz = g2t.tminz config.tmaxz = g2t.tmaxz config.kml = g2t.kml del g2t self.FindWindowByName('tminz').SetValue(config.tminz) self.FindWindowByName('tmaxz').SetValue(config.tmaxz) if config.profile == 'gearth': self.FindWindowByName('format').SetItems([ _("PNG - with transparency"), _("JPEG - smaller but without transparency"), _("Hybrid JPEG+PNG - only for Google Earth"), _("Garmin Custom maps KMZ - 256 pixels"), _("Garmin Custom maps KMZ - 512 pixels"), _("Garmin Custom maps KMZ - 1024 pixels") ]) else: self.FindWindowByName('format').SetItems([ _("PNG - with transparency"), _("JPEG - smaller but without transparency"), _("Hybrid JPEG+PNG - only for Google Earth") ]) if not config.format and config.profile == 'gearth': self.FindWindowByName('format').SetSelection(2) # hybrid elif not config.format: self.FindWindowByName('format').SetSelection(0) # png else: self.FindWindowByName('format').SetSelection({ 'png': 0, 'jpeg': 1, 'hybrid': 2, 'garmin256': 3, 'garmin512': 4, 'garmin1024': 5 }[config.format]) self.Refresh() self.Update() elif step == 5: filename = config.files[0][0] # If this is the first time the user has gone this far, # we try to come up with sensible default output directory. if config.outputdir is None: input_dir = os.path.dirname(filename) # Implicitly we try to place it in the same directory in # which the input file is located. But if this is not possible, # we try to use the current directory. if os.access(input_dir, os.W_OK): base_dir = input_dir else: base_dir = os.getcwd() # Default name is the same as the input file without extensions. config.outputdir = os.path.join( base_dir, os.path.splitext(os.path.basename(filename))[0]) browseButton = self.FindWindowByName('browsebutton') if browseButton: browseButton.Bind(wx.EVT_BUTTON, self.OnBrowseButtonPressed) self.FindWindowByName('outputdir').SetValue(config.outputdir) elif step == 6: not_hybrid = config.format != 'hybrid' if config.profile == 'mercator': self.FindWindowByName('google').Enable(not_hybrid) self.FindWindowByName('openlayers').Enable(not_hybrid) self.FindWindowByName('kml').Enable(True) elif config.profile == 'geodetic': self.FindWindowByName('google').Enable(False) self.FindWindowByName('openlayers').Enable(not_hybrid) self.FindWindowByName('kml').Enable(True) elif config.profile == 'raster': self.FindWindowByName('google').Enable(False) self.FindWindowByName('openlayers').Enable(not_hybrid) if not config.kml: self.FindWindowByName('kml').Enable(False) elif config.profile == 'gearth': self.FindWindowByName('google').Enable(False) self.FindWindowByName('openlayers').Enable(not_hybrid) self.FindWindowByName('kml').Enable(True) self.FindWindowByName('google').SetValue(config.google) self.FindWindowByName('openlayers').SetValue(config.openlayers) self.FindWindowByName('kml').SetValue(config.kml) elif step == 7: config.title = os.path.basename(config.files[0][0]) self.FindWindowByName('title').SetValue(config.title) self.FindWindowByName('copyright').SetValue(config.copyright) self.FindWindowByName('googlekey').SetValue(config.googlekey) self.FindWindowByName('yahookey').SetValue(config.yahookey)
def SetStep(self, step): self.step = step if step >= len(steps): config.rendering = False config.resume = False self.SetPage(stepfinal % (config.outputdir, config.outputdir) ) return self.SetPage(steps[step]) if step == 1: self.FindWindowByName(config.profile).SetValue(1) elif step == 2: pass #self.FindWindowByName('nodatapanel').SetColor(config.nodata) elif step == 3: if not config.srs: config.customsrs = config.files[0][6] config.srs = config.customsrs if not config.srs and config.bboxgeoref: config.srsformat = 1 config.srs = config.epsg4326 self.FindWindowByName('srs').SetSelection(config.srsformat) self.FindWindowByName('srs').SetValue(config.srs) elif step == 4: g2t = wxGDAL2Tiles(['--profile',config.profile,'--s_srs', config.srs, str(config.files[0][2]) ]) g2t.open_input() config.tminz = g2t.tminz config.tmaxz = g2t.tmaxz config.kml = g2t.kml del g2t self.FindWindowByName('tminz').SetValue(config.tminz) self.FindWindowByName('tmaxz').SetValue(config.tmaxz) if config.profile == 'gearth': self.FindWindowByName('format').SetItems( [ _("PNG - with transparency"), _("JPEG - smaller but without transparency"), _("Hybrid JPEG+PNG - only for Google Earth"), _("Garmin Custom maps KMZ - 256 pixels"), _("Garmin Custom maps KMZ - 512 pixels"), _("Garmin Custom maps KMZ - 1024 pixels") ] ) else: self.FindWindowByName('format').SetItems( [ _("PNG - with transparency"), _("JPEG - smaller but without transparency"), _("Hybrid JPEG+PNG - only for Google Earth") ] ) if not config.format and config.profile == 'gearth': self.FindWindowByName('format').SetSelection(2) # hybrid elif not config.format: self.FindWindowByName('format').SetSelection(0) # png else: self.FindWindowByName('format').SetSelection({'png':0,'jpeg':1,'hybrid':2,'garmin256':3,'garmin512':4,'garmin1024':5}[config.format]) self.Refresh() self.Update() elif step == 5: filename = config.files[0][0] # If this is the first time the user has gone this far, # we try to come up with sensible default output directory. if config.outputdir is None: input_dir = os.path.dirname(filename) # Implicitly we try to place it in the same directory in # which the input file is located. But if this is not possible, # we try to use the current directory. if os.access(input_dir, os.W_OK): base_dir = input_dir else: base_dir = os.getcwd() # Default name is the same as the input file without extensions. config.outputdir = os.path.join(base_dir, os.path.splitext(os.path.basename( filename ))[0] ) browseButton = self.FindWindowByName('browsebutton') if browseButton: browseButton.Bind(wx.EVT_BUTTON, self.OnBrowseButtonPressed) self.FindWindowByName('outputdir').SetValue(config.outputdir) elif step == 6: not_hybrid = config.format != 'hybrid' if config.profile=='mercator': self.FindWindowByName('google').Enable(not_hybrid) self.FindWindowByName('openlayers').Enable(not_hybrid) self.FindWindowByName('kml').Enable(True) elif config.profile=='geodetic': self.FindWindowByName('google').Enable(False) self.FindWindowByName('openlayers').Enable(not_hybrid) self.FindWindowByName('kml').Enable(True) elif config.profile=='raster': self.FindWindowByName('google').Enable(False) self.FindWindowByName('openlayers').Enable(not_hybrid) if not config.kml: self.FindWindowByName('kml').Enable(False) elif config.profile=='gearth': self.FindWindowByName('google').Enable(False) self.FindWindowByName('openlayers').Enable(not_hybrid) self.FindWindowByName('kml').Enable(True) self.FindWindowByName('google').SetValue(config.google) self.FindWindowByName('openlayers').SetValue(config.openlayers) self.FindWindowByName('kml').SetValue(config.kml) elif step == 7: config.title = os.path.basename( config.files[0][0] ) self.FindWindowByName('title').SetValue(config.title) self.FindWindowByName('copyright').SetValue(config.copyright) self.FindWindowByName('googlekey').SetValue(config.googlekey) self.FindWindowByName('yahookey').SetValue(config.yahookey)