Beispiel #1
0
 def __init__(self, connection, commit=True, tilecoord_in_topleft=False, **kwargs):
     self.connection = connection
     self.metadata = Metadata(self.connection, commit)
     self.tiles = Tiles(tilecoord_in_topleft, self.connection, commit)
     if 'content_type' not in kwargs and 'format' in self.metadata:
         kwargs['content_type'] = mimetypes.types_map.get('.' + self.metadata['format'], None)
     TileStore.__init__(self, **kwargs)
Beispiel #2
0
    def __init__(
            self, tilegrid, mapfile, data_buffer=128, image_buffer=0, output_format='png256', resolution=2,
            layers_fields={}, drop_empty_utfgrid=False, proj4_literal=None, **kwargs):
        """
        Constructs a MapnikTileStore

        :param tilegrid: the tilegrid.
        :param mapfile: the file used to render the tiles.
        :param buffer_size: the image buffer size default is 128.
        :param output_format: the output format,
            possible values 'jpeg', 'png', 'png256', 'grid',
            default is 'png256'
        :param layers: the layers and fields used in the grid generation,
            example: { 'my_layer': ['my_first_field', 'my_segonf_field']},
            default is {}.
        :param **kwargs: for extended class.
        """

        TileStore.__init__(self, **kwargs)
        self.tilegrid = tilegrid
        self.buffer = image_buffer
        self.output_format = output_format
        self.resolution = resolution
        self.layers_fields = layers_fields
        self.drop_empty_utfgrid = drop_empty_utfgrid

        self.mapnik = mapnik.Map(tilegrid.tile_size, tilegrid.tile_size)
        mapnik.load_map(self.mapnik, mapfile, True)
        self.mapnik.buffer_size = data_buffer
        if proj4_literal is not None:
            self.mapnik.srs = proj4_literal
Beispiel #3
0
 def __init__(self,
              connection,
              commit=True,
              tilecoord_in_topleft=False,
              **kwargs):
     self.connection = connection
     self.tiles = Tiles(tilecoord_in_topleft, self.connection, commit)
     TileStore.__init__(self, **kwargs)
Beispiel #4
0
 def __init__(self,
              connection,
              commit=True,
              tilecoord_in_topleft=False,
              **kwargs):
     self.connection = connection
     self.metadata = Metadata(self.connection, commit)
     self.tiles = Tiles(tilecoord_in_topleft, self.connection, commit)
     if 'content_type' not in kwargs and 'format' in self.metadata:
         kwargs['content_type'] = mimetypes.types_map.get(
             '.' + self.metadata['format'], None)
     TileStore.__init__(self, **kwargs)
Beispiel #5
0
 def __init__(self, zipfile, layout=None, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.zipfile = zipfile
     self.layout = layout
     if self.layout is None:
         extension_count = defaultdict(int)
         for name in self.zipfile.namelist():
             extension_count[os.path.splitext(name)[1]] += 1
         for extension, count in sorted(extension_count.items(), key=lambda p: tuple(reversed(p)), reverse=True):
             if re.match(r'\.(jpe?g|png)\Z', extension, re.I):
                 self.layout = WrappedTileLayout(OSMTileLayout(), suffix=extension)
                 break
     if self.layout is None:
         self.layout = OSMTileLayout()
Beispiel #6
0
 def __init__(self, z, bounds, file=None, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.z = z
     self.xbounds, self.ybounds = bounds
     self.width = self.xbounds.stop - self.xbounds.start
     self.height = self.ybounds.stop - self.ybounds.start
     if 'bounding_pyramid' not in kwargs:
         self.bounding_pyramid = BoundingPyramid({self.z: (self.xbounds, self.ybounds)})
     if file:
         self.image = PIL.Image.open(file)
         assert self.image.mode == '1'
         assert self.image.size == (self.width, self.height)
     else:
         self.image = PIL.Image.new('1', (self.width, self.height))
     self.pixels = self.image.load()
Beispiel #7
0
 def __init__(self, z, bounds, file=None, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.z = z
     self.xbounds, self.ybounds = bounds
     self.width = self.xbounds.stop - self.xbounds.start
     self.height = self.ybounds.stop - self.ybounds.start
     if 'bounding_pyramid' not in kwargs:
         self.bounding_pyramid = BoundingPyramid(
             {self.z: (self.xbounds, self.ybounds)})
     if file:
         self.image = PIL.Image.open(file)
         assert self.image.mode == '1'
         assert self.image.size == (self.width, self.height)
     else:
         self.image = PIL.Image.new('1', (self.width, self.height))
     self.pixels = self.image.load()
Beispiel #8
0
 def __init__(self, zipfile, layout=None, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.zipfile = zipfile
     self.layout = layout
     if self.layout is None:
         extension_count = defaultdict(int)
         for name in self.zipfile.namelist():
             extension_count[os.path.splitext(name)[1]] += 1
         for extension, count in sorted(extension_count.items(),
                                        key=lambda p: tuple(reversed(p)),
                                        reverse=True):
             if re.match(r'\.(jpe?g|png)\Z', extension, re.I):
                 self.layout = WrappedTileLayout(OSMTileLayout(),
                                                 suffix=extension)
                 break
     if self.layout is None:
         self.layout = OSMTileLayout()
Beispiel #9
0
    def __init__(self,
                 tilegrid,
                 mapfile,
                 data_buffer=128,
                 image_buffer=0,
                 output_format='png256',
                 resolution=2,
                 layers_fields={},
                 drop_empty_utfgrid=False,
                 proj4_literal=None,
                 **kwargs):
        """
        Constructs a MapnikTileStore

        :param tilegrid: the tilegrid.
        :param mapfile: the file used to render the tiles.
        :param buffer_size: the image buffer size default is 128.
        :param output_format: the output format,
            possible values 'jpeg', 'png', 'png256', 'grid',
            default is 'png256'
        :param layers: the layers and fields used in the grid generation,
            example: { 'my_layer': ['my_first_field', 'my_segonf_field']},
            default is {}.
        :param **kwargs: for extended class.
        """

        TileStore.__init__(self, **kwargs)
        self.tilegrid = tilegrid
        self.buffer = image_buffer
        self.output_format = output_format
        self.resolution = resolution
        self.layers_fields = layers_fields
        self.drop_empty_utfgrid = drop_empty_utfgrid

        self.mapnik = mapnik.Map(tilegrid.tile_size, tilegrid.tile_size)
        mapnik.load_map(self.mapnik, mapfile, True)
        self.mapnik.buffer_size = data_buffer
        if proj4_literal is not None:
            self.mapnik.srs = proj4_literal
Beispiel #10
0
 def __init__(self, db, **kwargs):
     self.db = db
     TileStore.__init__(self, **kwargs)
Beispiel #11
0
 def __init__(self, tiles=None, **kwargs):
     self.tiles = tiles or {}
     TileStore.__init__(self, **kwargs)
Beispiel #12
0
 def __init__(self, connection, database, collection, **kwargs):
     self.client = MongoClient("mongodb://"+connection)
     self.db = self.client[database]
     self.collection = self.db[collection]
     TileStore.__init__(self, **kwargs)
Beispiel #13
0
 def __init__(self, bounding_pyramid=None, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.bounding_pyramid = bounding_pyramid or BoundingPyramid()
Beispiel #14
0
 def __init__(self, tilestores, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.tilestores = tilestores
Beispiel #15
0
 def __init__(self, tilelayouts, headers=None, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.tilelayouts = tuple(tilelayouts)
     self.session = requests.session()
     if headers is not None:
         self.session.headers.update(headers)
Beispiel #16
0
 def __init__(self, queue, on_empty=maybe_stop, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.queue = queue
     self.on_empty = maybe_stop
Beispiel #17
0
 def __init__(self, tilelayout, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.tilelayout = tilelayout
Beispiel #18
0
 def __init__(self, tilelayout, file=None, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.tilelayout = tilelayout
     self.file = file
Beispiel #19
0
 def __init__(self, bucket, tilelayout, dry_run=False, **kwargs):
     self.s3bucket = S3Connection().bucket(bucket)
     self.tilelayout = tilelayout
     self.dry_run = dry_run
     TileStore.__init__(self, **kwargs)
Beispiel #20
0
 def __init__(self, queue, on_empty=maybe_stop, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.queue = queue
     self.on_empty = maybe_stop
Beispiel #21
0
 def __init__(self, color=(0, 0, 0), **kwargs):
     TileStore.__init__(self, content_type='image/png', **kwargs)
     self.color = color
Beispiel #22
0
 def __init__(self, client, tilelayout, flags=0, exptime=0, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.client = client
     self.tilelayout = tilelayout
     self.flags = flags
     self.exptime = exptime
Beispiel #23
0
 def __init__(self, format, tile_size=256, border=0, **kwargs):
     self.format = format
     self.tile_size = tile_size
     self.border = border
     TileStore.__init__(self, **kwargs)
Beispiel #24
0
 def __init__(self, tilestore, filters, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.tilestore = tilestore
     self.filters = filters
Beispiel #25
0
 def __init__(self, client, tilelayout, flags=0, exptime=0, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.client = client
     self.tilelayout = tilelayout
     self.flags = flags
     self.exptime = exptime
Beispiel #26
0
 def __init__(self, db, **kwargs):
     self.db = db
     TileStore.__init__(self, **kwargs)
Beispiel #27
0
 def __init__(self, connection, commit=True, tilecoord_in_topleft=False, **kwargs):
     self.connection = connection
     self.tiles = Tiles(tilecoord_in_topleft, self.connection, commit)
     TileStore.__init__(self, **kwargs)
Beispiel #28
0
 def __init__(self, bounding_pyramid=None, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.bounding_pyramid = bounding_pyramid or BoundingPyramid()
Beispiel #29
0
 def __init__(self, tilelayout, file=None, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.tilelayout = tilelayout
     self.file = file
Beispiel #30
0
 def __init__(self, color=(0, 0, 0), **kwargs):
     TileStore.__init__(self, content_type='image/png', **kwargs)
     self.color = color
Beispiel #31
0
 def __init__(self, format, tile_size=256, border=0, **kwargs):
     self.format = format
     self.tile_size = tile_size
     self.border = border
     TileStore.__init__(self, **kwargs)
Beispiel #32
0
 def __init__(self, tilestore, filters, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.tilestore = tilestore
     self.filters = filters
Beispiel #33
0
 def __init__(self, tilestores, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.tilestores = tilestores