当前位置: 首页>>代码示例>>Python>>正文


Python TileStache.parseConfig方法代码示例

本文整理汇总了Python中TileStache.parseConfig方法的典型用法代码示例。如果您正苦于以下问题:Python TileStache.parseConfig方法的具体用法?Python TileStache.parseConfig怎么用?Python TileStache.parseConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TileStache的用法示例。


在下文中一共展示了TileStache.parseConfig方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: clean_resource_cache

# 需要导入模块: import TileStache [as 别名]
# 或者: from TileStache import parseConfig [as 别名]
def clean_resource_cache(tile):
    # get the tile model's bounds
    datatype_factory = DataTypeFactory()
    nodegroup = models.NodeGroup.objects.get(pk=tile.nodegroup_id)
    for node in nodegroup.node_set.all():
        datatype = datatype_factory.get_instance(node.datatype)
        if datatype.should_cache(node) and datatype.should_manage_cache(node):
            bounds = datatype.get_bounds(tile, node)
            if bounds is not None:
                zooms = range(20)
                config = TileStache.parseConfig(
                    get_tileserver_config(node.nodeid))
                layer = config.layers[str(node.nodeid)]
                mimetype, format = layer.getTypeByExtension('pbf')

                lon1, lat1, lon2, lat2 = bounds
                south, west = min(lat1, lat2), min(lon1, lon2)
                north, east = max(lat1, lat2), max(lon1, lon2)

                northwest = Location(north, west)
                southeast = Location(south, east)

                ul = layer.projection.locationCoordinate(northwest)
                lr = layer.projection.locationCoordinate(southeast)

                padding = 0
                coordinates = generateCoordinates(ul, lr, zooms, padding)

                for (offset, count, coord) in coordinates:
                    config.cache.remove(layer, coord, format)
    for key, tile_list in tile.tiles.iteritems():
        for child_tile in tile_list:
            clean_resource_cache(child_tile)
开发者ID:fargeo,项目名称:arches,代码行数:35,代码来源:tileserver.py

示例2: add_config

# 需要导入模块: import TileStache [as 别名]
# 或者: from TileStache import parseConfig [as 别名]
    def add_config(self, kernel_id, **kwargs):
        cache = kwargs.get("cache", self.default_cache)

        self._configs[kernel_id] = ts.parseConfig({
            "cache": cache,
            "layers": {}
        })
开发者ID:OpenGeoscience,项目名称:geonotebook,代码行数:9,代码来源:ktile.py

示例3: seed_resource_cache

# 需要导入模块: import TileStache [as 别名]
# 或者: from TileStache import parseConfig [as 别名]
def seed_resource_cache():
    datatype_factory = DataTypeFactory()
    zooms = range(settings.CACHE_SEED_MAX_ZOOM + 1)
    extension = 'pbf'

    lat1, lon1, lat2, lon2 = GeoUtils().get_bounds_from_geojson(settings.CACHE_SEED_BOUNDS)
    south, west = min(lat1, lat2), min(lon1, lon2)
    north, east = max(lat1, lat2), max(lon1, lon2)

    northwest = Location(north, west)
    southeast = Location(south, east)

    padding = 0

    datatypes = [
        d.pk for d in models.DDataType.objects.filter(isgeometric=True)]
    nodes = models.Node.objects.filter(
        graph__isresource=True, datatype__in=datatypes)
    for node in nodes:
        datatype = datatype_factory.get_instance(node.datatype)
        count = models.TileModel.objects.filter(
            data__has_key=str(node.nodeid)).count()
        if datatype.should_cache(node) and count > 0:
            config = TileStache.parseConfig(get_tileserver_config(node.nodeid))
            layer = config.layers[str(node.nodeid)]
            ul = layer.projection.locationCoordinate(northwest)
            lr = layer.projection.locationCoordinate(southeast)
            coordinates = generateCoordinates(ul, lr, zooms, padding)
            for (offset, count, coord) in coordinates:
                path = '%s/%d/%d/%d.%s' % (layer.name(), coord.zoom,
                                           coord.column, coord.row, extension)

                progress = {"tile": path,
                            "offset": offset + 1,
                            "total": count}

                attempts = 3
                rendered = False

                while not rendered:
                    print '%(offset)d of %(total)d...' % progress,

                    try:
                        mimetype, content = TileStache.getTile(
                            layer, coord, extension, True)

                    except:
                        attempts -= 1
                        print 'Failed %s, will try %s more.' % (progress['tile'], ['no', 'once', 'twice'][attempts])

                        if attempts == 0:
                            print 'Failed %(zoom)d/%(column)d/%(row)d, trying next tile.\n' % coord.__dict__
                            break

                    else:
                        rendered = True
                        progress['size'] = '%dKB' % (len(content) / 1024)

                        print '%(tile)s (%(size)s)' % progress
开发者ID:fargeo,项目名称:arches,代码行数:61,代码来源:tileserver.py

示例4: configuration

# 需要导入模块: import TileStache [as 别名]
# 或者: from TileStache import parseConfig [as 别名]
    (options, args) = parser.parse_args()

    if options.include_paths:
        for p in options.include_paths.split(':'):
            path.insert(0, p)

    import TileStache

    try:
        if options.config is None:
            raise TileStache.Core.KnownUnknown('Missing required configuration (--config) parameter.')

        if options.layer is None:
            raise TileStache.Core.KnownUnknown('Missing required layer (--layer) parameter.')

        config = TileStache.parseConfig(options.config)

        if options.layer not in config.layers:
            raise TileStache.Core.KnownUnknown('"%s" is not a layer I know about. Here are some that I do know about: %s.' % (options.layer, ', '.join(sorted(config.layers.keys()))))

        provider = Provider(config.layers[options.layer], options.verbose, options.ignore_cached)

        try:
            outfile = args[0]
        except IndexError:
            raise BadComposure('Error: Missing output file.')

        if options.center and options.extent:
            raise BadComposure("Error: bad map coverage, center and extent can't both be set.")

        elif options.extent and options.dimensions and options.zoom:
开发者ID:afrith,项目名称:TileStache,代码行数:33,代码来源:tilestache-compose.py


注:本文中的TileStache.parseConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。