예제 #1
0
 def render_to_file(self,*args):
     """
     Routine to render the requested AGG format.
     """
     format = args[2]
     if format in ('tif','tiff'):
         self.timer()
         (handle, png_tmp) = tempfile.mkstemp('.png', 'nik2img-tmp')
         os.close(handle)
         self.world_file_ext = 'wld'
         self.write_wld(png_tmp)
         mapnik.render_to_file(args[0],png_tmp,'png')
         # todo - figure out more reasonable defaults
         opts = ' -ot Byte -co COMPRESS=JPEG -co JPEG_QUALITY=100'
         base_cmd = 'gdal_translate %s %s -a_srs "%s" %s'
         cmd = base_cmd % (png_tmp,args[1],args[0].srs,opts)
         
         #os.system(cmd)
         print call(cmd,fail=True)
         self.stop()
     else:
         self.timer()
         mapnik.render_to_file(*args)
         if self.world_file_ext:
             self.write_wld(args[1])
         self.stop()
예제 #2
0
    def render_to_file(self, *args):
        """
        Routine to render the requested AGG format.
        """
        format = args[2]
        if format in ('tif', 'tiff'):
            self.timer()
            (handle, png_tmp) = tempfile.mkstemp('.png', 'nik2img-tmp')
            os.close(handle)
            self.world_file_ext = 'wld'
            self.write_wld(png_tmp)
            mapnik.render_to_file(args[0], png_tmp, 'png')
            # todo - figure out more reasonable defaults
            opts = ' -ot Byte -co COMPRESS=JPEG -co JPEG_QUALITY=100'
            base_cmd = 'gdal_translate %s %s -a_srs "%s" %s'
            cmd = base_cmd % (png_tmp, args[1], args[0].srs, opts)

            #os.system(cmd)
            print call(cmd, fail=True)
            self.stop()
        else:
            self.timer()
            mapnik.render_to_file(*args)
            if self.world_file_ext:
                self.write_wld(args[1])
            self.stop()
예제 #3
0
    def render_to_file(self, *args):
        """
        Routine to render the requested AGG format.
        """
        format = args[2]
        if format in ("tif", "tiff"):
            self.timer()
            (handle, png_tmp) = tempfile.mkstemp(".png", "nik2img-tmp")
            os.close(handle)
            self.world_file_ext = "wld"
            self.write_wld(png_tmp)
            mapnik.render_to_file(args[0], png_tmp, "png")
            # todo - figure out more reasonable defaults
            opts = " -ot Byte -co COMPRESS=JPEG -co JPEG_QUALITY=100"
            base_cmd = 'gdal_translate %s %s -a_srs "%s" %s'
            cmd = base_cmd % (png_tmp, args[1], args[0].srs, opts)

            # os.system(cmd)
            print call(cmd, fail=True)
            self.stop()
        else:
            self.timer()
            mapnik.render_to_file(*args)
            if self.world_file_ext:
                self.write_wld(args[1])
            self.stop()
        if self.zip_compress:
            self.zip_up(args[1])
예제 #4
0
파일: composer.py 프로젝트: hitzi/nik2img
 def open(self, app=None):
     """
     Routine to open the rendered image or folder of images from the filesystem.
     """
     self.render()
     if not app and self.app:
         app = self.app
     if os.name == 'nt':
         if app:
             self.msg('Overriding default image viewer not supported on Win32')
         call('start %s' % self.image.replace('/','\\'))
     elif platform.uname()[0] == 'Linux':
         if app:
             call('%s %s' % (app,self.image))
         else:
             # make blind and dumb attempt to open images, but don't block while open
             try:
                 cmd = 'xdg-open %s' % self.image
                 Popen(cmd.split(' '))
             except OSError:
                 try:
                     cmd = 'gthumb %s' % self.image
                     Popen(cmd.split(' '))
                 except OSError:
                     try:
                         cmd = 'display %s' % self.image
                         Popen(cmd.split(' '))
                     except OSError:
                         pass
     elif platform.uname()[0] == 'Darwin':
         if app:
             call('open %s -a %s' % (self.image, app))
         else:
             call('open %s' % self.image)
예제 #5
0
 def open(self, app=None):
     """
     Routine to open the rendered image or folder of images from the filesystem.
     """
     self.render()
     if not app and self.app:
         app = self.app
     if os.name == 'nt':
         if app:
             self.msg(
                 'Overriding default image viewer not supported on Win32')
         call('start %s' % self.image.replace('/', '\\'))
     elif platform.uname()[0] == 'Linux':
         if app:
             call('%s %s' % (app, self.image))
         else:
             # make blind and dumb attempt to open images, but don't block while open
             try:
                 cmd = 'xdg-open %s' % self.image
                 Popen(cmd.split(' '))
             except OSError:
                 try:
                     cmd = 'gthumb %s' % self.image
                     Popen(cmd.split(' '))
                 except OSError:
                     try:
                         cmd = 'display %s' % self.image
                         Popen(cmd.split(' '))
                     except OSError:
                         pass
     elif platform.uname()[0] == 'Darwin':
         if app:
             call('open %s -a %s' % (self.image, app))
         else:
             call('open %s' % self.image)
예제 #6
0
 def open(self, app=None):
     """
     Routine to open the rendered image or folder of images from the filesystem.
     """
     self.render()
     if not app and self.app:
         app = self.app
     if os.name == 'nt':
         if app:
             self.msg(
                 'Overriding default image viewer not supported on Win32')
         call('start %s' % self.image.replace('/', '\\'))
     elif platform.uname()[0] == 'Linux':
         if app:
             call('%s %s' % (app, self.image))
         else:
             resp = call('xdg-open %s' % self.image)
             if not resp:
                 resp = call('gthumb %s' % self.image)
                 if not resp:
                     call('display %s' % self.image)
     elif platform.uname()[0] == 'Darwin':
         if app:
             call('open %s -a %s' % (self.image, app))
         else:
             call('open %s' % self.image)
예제 #7
0
 def open(self, app=None):
     """
     Routine to open the rendered image or folder of images from the filesystem.
     """
     self.render()
     if not app and self.app:
         app = self.app
     if os.name == 'nt':
         if app:
             self.msg('Overriding default image viewer not supported on Win32')
         call('start %s' % self.image.replace('/','\\'))
     elif platform.uname()[0] == 'Linux':
         if app:
             call('%s %s' % (app, self.image))
         else:
             resp = call('xdg-open %s' % self.image)
             if not resp:
                 resp = call('gthumb %s' % self.image)
                 if not resp:
                     call('display %s' % self.image)
     elif platform.uname()[0] == 'Darwin':
         if app:
             call('open %s -a %s' % (self.image, app))
         else:
             call('open %s' % self.image)