func (m *Map) Load(stylesheet string) error {
	cs := C.CString(stylesheet)
	defer C.free(unsafe.Pointer(cs))
	if C.mapnik_map_load(m.m, cs) != 0 {
		return m.lastError()
	}
	C.mapnik_apply_layer_off_hack(m.m)
	return nil
}
Load reads in a Mapnik map XML.

Note: Since Mapnik 3 all layers with status="off" are not loaded and cannot
be activated by a custom LayerSelector. As a workaround, all layers with names
starting with '__OFF__' are disabled on load and the '__OFF__' prefix is removed
from the layer name.
package mapnik
import "C"
import (
	"errors"
	"fmt"
	"image"
	"image/color"
	"image/draw"
	"io/ioutil"
	"os"
	"path/filepath"
	"strings"
	"unsafe"
)
type LogLevel int
var (
	None  = LogLevel(C.MAPNIK_NONE)
	Debug = LogLevel(C.MAPNIK_DEBUG)
	Warn  = LogLevel(C.MAPNIK_WARN)
	Error = LogLevel(C.MAPNIK_ERROR)
)
var (
	fontPath   = "/usr/local/lib/mapnik/fonts"
	pluginPath = "/usr/local/lib/mapnik/input"
)
func init() {
	if err := RegisterDatasources(pluginPath); err != nil {
		fmt.Fprintf(os.Stderr, "MAPNIK: %s\n", err)
	}
	if err := RegisterFonts(fontPath); err != nil {
		fmt.Fprintf(os.Stderr, "MAPNIK: %s\n", err)
	}
}
func RegisterDatasources(path string) error {
	fileInfos, err := ioutil.ReadDir(path)
	if err != nil {
		return err
	}
	for _, file := range fileInfos {
		cs := C.CString(filepath.Join(path, file.Name()))
		defer C.free(unsafe.Pointer(cs))
		if C.mapnik_register_datasource(cs) == 0 {
			e := C.GoString(C.mapnik_register_last_error())
			if e != "" {
				return errors.New("registering datasources: " + e)
			}
			return errors.New("error while registering datasources")
		}
	}
	return nil
}
func RegisterFonts(path string) error {
	fileInfos, err := ioutil.ReadDir(path)
	if err != nil {
		return err
	}
	for _, file := range fileInfos {
		fullPath := filepath.Join(path, file.Name())
		if !isFontFile(fullPath) {
			continue
		}
		cs := C.CString(fullPath)
		defer C.free(unsafe.Pointer(cs))
		if C.mapnik_register_font(cs) == 0 {
			e := C.GoString(C.mapnik_register_last_error())
			if e != "" {
				return errors.New("registering fonts: " + e)
			}
			return errors.New("error while registering fonts")
		}
	}
	return nil
}
func isFontFile(path string) bool {
	ext := strings.ToLower(filepath.Ext(path))
	return (ext == ".ttf" ||
		ext == ".otf" ||
		ext == ".woff" ||
		ext == ".ttc" ||
		ext == ".pfa" ||
		ext == ".pfb" ||
		ext == ".dfont")
}
func LogSeverity(level LogLevel) {
	C.mapnik_logging_set_severity(C.int(level))
}
type version struct {
	Numeric int
	Major   int
	Minor   int
	Patch   int
	String  string
}
var Version version
func init() {
	Version.Numeric = int(C.mapnik_version)
	Version.Major = int(C.mapnik_version_major)
	Version.Minor = int(C.mapnik_version_minor)
	Version.Patch = int(C.mapnik_version_patch)
	Version.String = fmt.Sprintf("%d.%d.%d", Version.Major, Version.Minor, Version.Patch)
}
type Map struct {
	m           *C.struct__mapnik_map_t
	width       int
	height      int
	layerStatus []bool
}
func New() *Map {
	return &Map{
		m:      C.mapnik_map(C.uint(800), C.uint(600)),
		width:  800,
		height: 600,
	}
}
func NewSized(width, height int) *Map {
	return &Map{
		m:      C.mapnik_map(C.uint(width), C.uint(height)),
		width:  width,
		height: height,
	}
}
func (m *Map) lastError() error {
	return errors.New("mapnik: " + C.GoString(C.mapnik_map_last_error(m.m)))
}