# Path: TileStache/py3_compat.py
# def is_string_type(val):
# 
# Path: TileStache/py3_compat.py
# def is_string_type(val):
# 
# Path: TileStache/Core.py
# class KnownUnknown(Exception):
#     """ There are known unknowns. That is to say, there are things that we now know we don't know.
# 
#         This exception gets thrown in a couple places where common mistakes are made.
#     """
#     pass


from time import time
from os.path import exists
from itertools import count
from glob import glob
from tempfile import mkstemp
from .py3_compat import reduce, urlopen, urljoin, urlparse, allocate_lock
from .py3_compat import unichr
from TileStache.Core import KnownUnknown
from TileStache.Geography import getProjectionByName
    from PIL import Image
import os
import logging
import json
    import mapnik
    import Image
          Which layer from the mapfile to render, defaults to 0 (first layer).

        - layers (optional)
          Ordered list of (layer_index, fields) to combine; if provided
          layers overrides both layer_index and fields arguments.
          An empty fields list will return no field names, while a value of null
          is equivalent to all fields.

        - scale (optional)
          Scale factor of output raster, defaults to 4 (64x64).

        - layer_id_key (optional)
          If set, each item in the 'data' property will have its source mapnik
          layer name added, keyed by this value. Useful for distingushing
          between data items.

        Information and examples for UTF Grid:
        - https://github.com/mapbox/utfgrid-spec/blob/master/1.2/utfgrid.md
        - http://mapbox.github.com/wax/interaction-leaf.html
    """
    def __init__(self, layer, mapfile, fields=None, layers=None, layer_index=0, scale=4, layer_id_key=None):
        """ Initialize Mapnik grid provider with layer and mapfile.

            XML mapfile keyword arg comes from TileStache config,
            and is an absolute path by the time it gets here.
        """
        self.mapnik = None
        self.layer = layer

        maphref = urljoin(layer.config.dirpath, mapfile)

# Path: TileStache/py3_compat.py
# def is_string_type(val):
# 
# Path: TileStache/py3_compat.py
# def is_string_type(val):
# 
# Path: TileStache/Core.py
# class KnownUnknown(Exception):
#     """ There are known unknowns. That is to say, there are things that we now know we don't know.
# 
#         This exception gets thrown in a couple places where common mistakes are made.
#     """
#     pass


# Path: TileStache/Mapnik.py
from time import time
from os.path import exists
from itertools import count
from glob import glob
from tempfile import mkstemp
from .py3_compat import reduce, urlopen, urljoin, urlparse, allocate_lock
from .py3_compat import unichr
from TileStache.Core import KnownUnknown
from TileStache.Geography import getProjectionByName
    from PIL import Image
import os
import logging
import json
    import mapnik
    import Image

          Which layer from the mapfile to render, defaults to 0 (first layer).

        - layers (optional)
          Ordered list of (layer_index, fields) to combine; if provided
          layers overrides both layer_index and fields arguments.
          An empty fields list will return no field names, while a value of null
          is equivalent to all fields.

        - scale (optional)
          Scale factor of output raster, defaults to 4 (64x64).

        - layer_id_key (optional)
          If set, each item in the 'data' property will have its source mapnik
          layer name added, keyed by this value. Useful for distingushing
          between data items.

        Information and examples for UTF Grid:
        - https://github.com/mapbox/utfgrid-spec/blob/master/1.2/utfgrid.md
        - http://mapbox.github.com/wax/interaction-leaf.html
    """
    def __init__(self, layer, mapfile, fields=None, layers=None, layer_index=0, scale=4, layer_id_key=None):
        """ Initialize Mapnik grid provider with layer and mapfile.

            XML mapfile keyword arg comes from TileStache config,
            and is an absolute path by the time it gets here.
        """
        self.mapnik = None
        self.layer = layer

        maphref = urljoin(layer.config.dirpath, mapfile)

        scheme, h, path, q, p, f = urlparse(maphref)