Esempio n. 1
0
    def __init__(self, layer, osmFile, watermark, cacheDir):
        import TileCache.Service
        from TileCache.Caches.Disk import Disk
        from TileCache.Layers.Mapnik import Mapnik

        self.layer = Mapnik(layer,
                            mapfile=osmFile,
                            watermarkimage=watermark,
                            watermarkopacity=1.0)
        self.tileService = TileCache.Service(Disk(cacheDir),
                                             {"layer": self.layer})
Esempio n. 2
0
def get_eb_layer(name):
    # svc = Service.load(settings.TILECACHE_CONFIG)
    mapfile = r"/data/oceancolor/terra/L3m/2017/001/T2017001_L3m_DAY_NSST_sst_4km.map"
    svc = Service(
        Disk('/tmp/somecache'),  # See "Cache Invalidation", below
        {
            "raster":
            MS.MapServer("basic",
                         mapfile,
                         layers="raster",
                         srs='EPSG:4326',
                         debug=False),
        })
    '''
    svc = Service(
        Disk('/tmp/somecache'),  # See "Cache Invalidation", below
        { 
            "raster": WMS.WMS("basic", r"http://localhost/cgi-bin/mapserv.cgi?map=/data/oceancolor/aqua/L3m/2017/001/A2017001.L3m_DAY_SST_sst_4km.map&mode=map&layer=raster", srs='EPSG:4326', width='256', height='256'),
        }
    )
    '''
    return svc.layers[name]
Esempio n. 3
0
# hackish way to grab style obj and avoid parsing XML each request...
m = mapnik.Map(1, 1)
mapnik.load_map(m, settings.MAPNIK_STYLESHEET)
style = m.find_style('style')
del m

srv = None

if settings.CACHE_SEARCH_METHOD == 'mem':
    srv = Service(
        Memcached(),
        {},  # layers are dynamic
    )
else:
    srv = Service(
        Disk(settings.CACHE_SEARCH_DISK_PATH),
        {},  # layers are dynamic
    )

query_hash = {}


class TileResponse(object):
    def __init__(self, tile_bytes):
        self.tile_bytes = tile_bytes

    def __call__(self, extension='png'):
        if self.tile_bytes:
            # mod_python handler in django borkes unless mimetype is string
            return HttpResponse(self.tile_bytes,
                                mimetype=str('image/%s' % extension))
 def set(self, tile, data):
     data = optimize_png(data)
     Disk.set(self, tile, data)
Esempio n. 5
0
 def set(self, tile, data):
     data = optimize_png(data)
     Disk.set(self, tile, data)
Esempio n. 6
0
 def __init__ (self, **kwargs):
     Disk.__init__(self, **kwargs)
     warnings.warn("GoogleDisk type is deprecated. use a Disk cache and set the structure to google", DeprecationWarning)