'Initialize Mapnik 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, fonts=None, scale_factor=None):

    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.layer = layer
    self.mapnik = None
    engine = mapnik.FontEngine.instance()
    if fonts:
        fontshref = urljoin(layer.config.dirpath, fonts)
        (scheme, h, path, q, p, f) = urlparse(fontshref)
        if (scheme not in ('file', '')):
            raise Exception(('Fonts    from    "%s"    can\'t    be    used    by    Mapnik' % fontshref))
        for font in glob((path.rstrip('/') + '/*.ttf')):
            engine.register_font(str(font))
    self.scale_factor = scale_factor
