Пример #1
0
    def init_pyramid(self):
        ld(self.zoom_levels)
        prm=Pyramid.profile_class(self.format)(
            dest=self.root,
            options=dict(
                name=os.path.split(self.root)[1],
                tile_format=self.tile_ext[1:]
                )
            )        
        # compute "effective" covered area
        prev_sq=0
        for z in reversed(sorted(self.zoom_levels)):
            ul_zxy,lr_zxy=self.zoom_levels[z]
            ul_c=prm.tile_bounds(ul_zxy)[0]
            lr_c=prm.tile_bounds(lr_zxy)[1]
            sq=(lr_c[0]-ul_c[0])*(ul_c[1]-lr_c[1])
            area_diff=round(prev_sq/sq,5)
            ld('ul_c,lr_c',z,ul_c,lr_c,sq,area_diff)
            if area_diff == 0.25:
                break # this must be an exact zoom of a previous level
            area_coords=[ul_c,lr_c]
            prev_sq=sq

        prm.set_region(area_coords)
        prm.set_zoom_range(','.join(map(str,self.zoom_levels.keys())))
        return prm
    def __init__(self, root=None, options=None, src=None):
        options = LooseDict(options)
        options.isDest = src is not None

        self.root = root
        self.options = options
        self.src = src

        self.srs = self.options.proj4def or self.options.tiles_srs
        self.tilemap_crs = self.options.tiles_srs or self.tilemap_crs
        self.options.tiles_srs = self.srs

        self.zoom_levels = {}
        self.pyramid = Pyramid.profile_class('generic')(options=options)

        if not self.options.isDest:
            assert os.path.exists(
                root), 'No file or directory found: %s' % root
            self.ext = os.path.splitext(root)[1]
            if self.options.zoom:
                self.pyramid.set_zoom_range(self.options.zoom)
            if self.options.region:
                self.pyramid.load_region(self.options.region)
        else:
            basename = os.path.splitext(os.path.basename(self.root
                                                         or src.root))[0]
            df_name = os.path.splitext(basename)[0]
            if self.options.region:
                df_name += '-' + os.path.splitext(self.options.region)[0]
            self.name = self.options.name or df_name

            if not self.root:
                suffix = self.ext if self.ext != src.ext else self.ext + '0'
                self.root = os.path.join(options.dst_dir, self.name + suffix)

            if os.path.exists(self.root):
                if self.options.remove_dest:
                    if os.path.isdir(self.root):
                        shutil.rmtree(self.root, ignore_errors=True)
                    else:
                        os.remove(self.root)
                else:
                    assert self.options.append, 'Destination already exists: %s' % root

            if self.options.convert_tile:
                global tile_converter
                tile_converter = TileConverter.get_class(
                    self.options.convert_tile)(options)
                if not (self.options.nothreads or self.options.debug):
                    self.pool = Pool()
    def __init__(self, root=None, options=None, src=None):
        options = LooseDict(options)
        options.isDest = src is not None

        self.root = root
        self.options = options
        self.src = src

        self.srs = self.options.proj4def or self.options.tiles_srs
        self.tilemap_crs = self.options.tiles_srs or self.tilemap_crs
        self.options.tiles_srs = self.srs

        self.zoom_levels = {}
        self.pyramid = Pyramid.profile_class('generic')(options=options)

        if not self.options.isDest:
            assert os.path.exists(root), 'No file or directory found: %s' % root
            self.ext = os.path.splitext(root)[1]
            if self.options.zoom:
                self.pyramid.set_zoom_range(self.options.zoom)
            if self.options.region:
                self.pyramid.load_region(self.options.region)
        else:
            basename = os.path.splitext(os.path.basename(self.root or src.root))[0]
            df_name = os.path.splitext(basename)[0]
            if self.options.region:
                df_name += '-' + os.path.splitext(self.options.region)[0]
            self.name = self.options.name or df_name

            if not self.root:
                suffix = self.ext if self.ext != src.ext else self.ext + '0'
                self.root = os.path.join(options.dst_dir, self.name + suffix)

            if os.path.exists(self.root):
                if self.options.remove_dest:
                    if os.path.isdir(self.root):
                        shutil.rmtree(self.root, ignore_errors=True)
                    else:
                        os.remove(self.root)
                else:
                    assert self.options.append, 'Destination already exists: %s' % root

            if self.options.convert_tile:
                global tile_converter
                tile_converter = TileConverter.get_class(self.options.convert_tile)(options)
                if not (self.options.nothreads or self.options.debug):
                    self.pool = Pool()
Пример #4
0
    def __init__(self,root,options=None,write=False):
        ld(root)
        self.root=root
        self.write=write
        self.options=options
        self.zoom_levels={}

        if not self.write:
            assert os.path.exists(root), "No file or directory found: %s" % root
        else:
            if not self.options.append and os.path.exists(self.root):
                if os.path.isdir(self.root):
                    shutil.rmtree(self.root,ignore_errors=True)
                else:
                    os.remove(self.root)
            if self.options.region:
                prm=Pyramid.profile_class('zxy')()
                prm.set_zoom_range(self.options.zoom)
                prm.load_region(self.options.region)
                self.my_tile=lambda tile: prm.belongs_to(tile.coord())
Пример #5
0
    def __init__(self,root,options=None,write=False):
        ld(root)
        self.root=root
        self.write=write
        self.options=options
        self.pyramid=None

        if not self.write:
            assert os.path.exists(root), "No file or directory found: %s" % root
        else:
            if not self.options.append and os.path.exists(self.root):
                if os.path.isdir(self.root):
                    shutil.rmtree(self.root,ignore_errors=True)
                else:
                    os.remove(self.root)
            if self.options.region:
                from gdal_tiler import Pyramid
                self.pyramid=Pyramid.profile_class('zxy')()
                self.pyramid.load_region(self.options.region)
                self.pyramid.set_zoom_range(self.options.zoom)

        self.child_init()
Пример #6
0
    def __init__(self, root, options=None, write=False):
        ld(root)
        self.root = root
        self.write = write
        self.options = options
        self.pyramid = None

        if not self.write:
            assert os.path.exists(
                root), "No file or directory found: %s" % root
        else:
            if not self.options.append and os.path.exists(self.root):
                if os.path.isdir(self.root):
                    shutil.rmtree(self.root, ignore_errors=True)
                else:
                    os.remove(self.root)
            if self.options.region:
                from gdal_tiler import Pyramid
                self.pyramid = Pyramid.profile_class('zxy')()
                self.pyramid.load_region(self.options.region)
                self.pyramid.set_zoom_range(self.options.zoom)

        self.child_init()