'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.'

def __init__(self, layer, mapfile, fields=None, layers=None, layer_index=0, scale=4, layer_id_key=None):

    self.mapnik = None
    self.layer = layer
    maphref = urljoin(layer.config.dirpath, mapfile)
    (scheme, h, path, q, p, f) = urlparse(maphref)
    if (scheme in ('file', '')):
        self.mapfile = path
    else:
        self.mapfile = maphref
    self.scale = scale
    self.layer_id_key = layer_id_key
    if layers:
        self.layers = layers
    else:
        self.layers = [[(layer_index or 0), fields]]
