Beispiel #1
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 #2
0
 def __init__(self, bucket, tilelayout, dry_run=False, s3_host=None, cache_control=None, **kwargs):
     self.client = get_client(s3_host)
     self.bucket = bucket
     self.tilelayout = tilelayout
     self.dry_run = dry_run
     self.cache_control = cache_control
     TileStore.__init__(self, **kwargs)
Beispiel #3
0
    def __init__(
        self,
        container: str,
        tilelayout: TileLayout,
        dry_run: bool = False,
        cache_control: Optional[str] = None,
        client: Optional[BlobServiceClient] = None,
        **kwargs: Any,
    ):
        if client is None:
            if "AZURE_STORAGE_CONNECTION_STRING" in os.environ:
                client = BlobServiceClient.from_connection_string(
                    os.environ.get("AZURE_STORAGE_CONNECTION_STRING"))
            else:
                client = BlobServiceClient(
                    account_url=os.environ["AZURE_STORAGE_ACCOUNT_URL"],
                    credential=DefaultAzureCredential(),
                )

        self.container_client = client.get_container_client(
            container=container)
        self.tilelayout = tilelayout
        self.dry_run = dry_run
        self.cache_control = cache_control
        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'])
     TileStore.__init__(self, **kwargs)
Beispiel #5
0
 def __init__(self, connection, commit=True, **kwargs):
     self.connection = connection
     self.metadata = Metadata(self.connection, commit)
     self.tiles = Tiles(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 #6
0
 def __init__(self, connection, commit=True, **kwargs):
     self.connection = connection
     self.metadata = Metadata(self.connection, commit)
     self.tiles = Tiles(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 #7
0
 def __init__(self,
              format: str,
              tile_size: int = 256,
              border: int = 0,
              **kwargs: Any) -> None:
     self.format = format
     self.tile_size = tile_size
     self.border = border
     TileStore.__init__(self, **kwargs)
Beispiel #8
0
 def __init__(self,
              tilelayouts,
              headers=None,
              allows_no_contenttype=False,
              **kwargs):
     TileStore.__init__(self, **kwargs)
     self.allows_no_contenttype = allows_no_contenttype
     self.tilelayouts = tuple(tilelayouts)
     self.session = requests.session()
     if headers is not None:
         self.session.headers.update(headers)
Beispiel #9
0
 def __init__(self,
              bucket,
              tilelayout,
              dry_run=False,
              s3_host=None,
              **kwargs):
     self.client = get_client(s3_host)
     self.bucket = bucket
     self.tilelayout = tilelayout
     self.dry_run = dry_run
     TileStore.__init__(self, **kwargs)
Beispiel #10
0
 def __init__(self, container, tilelayout, dry_run=False, cache_control=None, **kwargs):
     self.client = BlobServiceClient.from_connection_string(os.getenv("AZURE_STORAGE_CONNECTION_STRING"))
     self.container_name = container
     try:
         self.container = self.client.create_container(container)
     except Exception as e:
         LOGGER.info(e)
     self.tilelayout = tilelayout
     self.dry_run = dry_run
     self.cache_control = cache_control
     TileStore.__init__(self, **kwargs)
Beispiel #11
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"])
     TileStore.__init__(self, **kwargs)
Beispiel #12
0
 def __init__(
     self,
     client: tilecloud.lib.memcached.MemcachedClient,
     tilelayout: TileLayout,
     flags: int = 0,
     exptime: int = 0,
     **kwargs: Any,
 ):
     TileStore.__init__(self, **kwargs)
     self.client = client
     self.tilelayout = tilelayout
     self.flags = flags
     self.exptime = exptime
Beispiel #13
0
 def __init__(
     self,
     tilelayouts: Iterable[TileLayout],
     headers: Optional[Any] = None,
     allows_no_contenttype: bool = False,
     **kwargs: Any,
 ) -> None:
     TileStore.__init__(self, **kwargs)
     self.allows_no_contenttype = allows_no_contenttype
     self.tilelayouts = tuple(tilelayouts)
     self.session = requests.session()
     if headers is not None:
         self.session.headers.update(headers)
Beispiel #14
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 #15
0
 def __init__(self,
              bucket,
              tilelayout,
              dry_run=False,
              s3_host=None,
              cache_control=None,
              **kwargs):
     self._s3_host = s3_host
     self._client = None
     self.bucket = bucket
     self.tilelayout = tilelayout
     self.dry_run = dry_run
     self.cache_control = cache_control
     TileStore.__init__(self, **kwargs)
Beispiel #16
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 #17
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 #18
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 #19
0
 def __init__(
     self,
     bucket: str,
     tilelayout: TileLayout,
     dry_run: bool = False,
     s3_host: Optional[Any] = None,
     cache_control: Optional[Any] = None,
     **kwargs: Any,
 ) -> None:
     self._s3_host = s3_host
     self._client: Optional["botocore.client.S3"] = None
     self.bucket = bucket
     self.tilelayout = tilelayout
     self.dry_run = dry_run
     self.cache_control = cache_control
     TileStore.__init__(self, **kwargs)
Beispiel #20
0
    def __init__(
        self,
        tilegrid: TileGrid,
        mapfile: str,
        data_buffer: int = 128,
        image_buffer: int = 0,
        output_format: str = "png256",
        resolution: int = 2,
        layers_fields: Optional[Dict[str, List[str]]] = None,
        drop_empty_utfgrid: bool = False,
        proj4_literal: Optional[str] = None,
        **kwargs: Any,
    ):
        """
        Constructs a MapnikTileStore.

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

        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 #21
0
 def __init__(self,
              zipfile: zipfile.ZipFile,
              layout: Optional[TileLayout] = None,
              **kwargs: Any):  # pylint: disable=redefined-outer-name
     TileStore.__init__(self, **kwargs)
     self.zipfile = zipfile
     if layout is None:
         extension_count: Dict[str, int] = defaultdict(int)
         for name in self.zipfile.namelist():
             extension_count[os.path.splitext(name)[1]] += 1
         for extension, _ in sorted(extension_count.items(),
                                    key=lambda p: tuple(reversed(p)),
                                    reverse=True):
             if re.match(r"\.(jpe?g|png)\Z", extension, re.I):
                 layout = WrappedTileLayout(OSMTileLayout(),
                                            suffix=extension)
                 break
     if layout is None:
         layout = OSMTileLayout()
     self.layout = layout
Beispiel #22
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 #23
0
 def __init__(self,
              z: int,
              bounds: Tuple[Bounds, Bounds],
              file: Optional[str] = None,
              **kwargs: Any):
     TileStore.__init__(self, **kwargs)
     self.z = z
     self.xbounds, self.ybounds = bounds
     assert self.xbounds.start is not None
     assert self.xbounds.stop is not None
     assert self.ybounds.start is not None
     assert self.ybounds.stop is not None
     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 #24
0
 def __init__(self, tilelayout, file=None, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.tilelayout = tilelayout
     self.file = file
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, tilelayouts, headers=None, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.tilelayouts = tuple(tilelayouts)
     self.headers = headers or {}
 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 #28
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 #29
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 #30
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 #31
0
 def __init__(self, tilelayout, **kwargs):
     TileStore.__init__(self, **kwargs)
     assert tilelayout is not None
     self.tilelayout = tilelayout
Beispiel #32
0
 def __init__(self, bounding_pyramid=None, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.bounding_pyramid = bounding_pyramid or BoundingPyramid()
Beispiel #33
0
 def __init__(self, tilestore, filters, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.tilestore = tilestore
     self.filters = filters
Beispiel #34
0
 def __init__(self, tilestore, filters, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.tilestore = tilestore
     self.filters = filters
Beispiel #35
0
 def __init__(self, tilelayout: RETileLayout, file: IO[str], **kwargs: Any):
     TileStore.__init__(self, **kwargs)
     self.tilelayout = tilelayout
     self.file = file
Beispiel #36
0
 def __init__(self, stores):
     TileStore.__init__(self)
     self._stores = stores
Beispiel #37
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 #38
0
 def __init__(self, color=(0, 0, 0), transparent=True, **kwargs):
     TileStore.__init__(self, content_type='image/png', **kwargs)
     self.color = color
     self.inverse_color = tuple(1.0 - x for x in color)
     self.transparent = transparent
Beispiel #39
0
 def __init__(self, tilestores, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.tilestores = tilestores
Beispiel #40
0
 def __init__(self, tilelayout: TileLayout, **kwargs: Any):
     TileStore.__init__(self, **kwargs)
     assert tilelayout is not None
     self.tilelayout = tilelayout
Beispiel #41
0
 def __init__(self, db, **kwargs):
     self.db = db
     TileStore.__init__(self, **kwargs)
Beispiel #42
0
 def __init__(self, bucket, tile_layout, dry_run=False, **kwargs):
     self.s3bucket = S3Connection().bucket(bucket)
     self.tile_layout = tile_layout
     self.dry_run = dry_run
     TileStore.__init__(self, **kwargs)
Beispiel #43
0
 def __init__(self, tiles=None, **kwargs):
     self.tiles = tiles or {}
     TileStore.__init__(self, **kwargs)
 def __init__(self, tilelayout, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.tilelayout = tilelayout
Beispiel #45
0
 def __init__(self, tilelayout, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.tilelayout = tilelayout
Beispiel #46
0
 def __init__(self, tiles=None, **kwargs):
     self.tiles = tiles or {}
     TileStore.__init__(self, **kwargs)
Beispiel #47
0
 def __init__(self, queue, on_empty=maybe_stop, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.queue = queue
     self.on_empty = maybe_stop
Beispiel #48
0
 def __init__(self, queue, on_empty=maybe_stop, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.queue = queue
     self.on_empty = on_empty
Beispiel #49
0
 def __init__(self, tilelayout, file=None, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.tilelayout = tilelayout
     self.file = file
Beispiel #50
0
 def __init__(self, tilestores, **kwargs):
     TileStore.__init__(self, **kwargs)
     self.tilestores = tilestores
Beispiel #51
0
 def __init__(self, color=(0, 0, 0), **kwargs):
     TileStore.__init__(self, content_type='image/png', **kwargs)
     self.color = color