Beispiel #1
0
func (m *Map) RenderToMemoryUTFGrid(lname string, key string, res uint) (string, error) {
	l := &Layer{}
	n := int(C.mapnik_map_layer_count(m.m))
	for i := 0; i < n; i++ {
		ml := C.mapnik_map_get_layer(m.m, C.size_t(i))
		defer C.free(unsafe.Pointer(ml))
		if C.GoString(C.mapnik_layer_name(ml)) == lname {
			l.l = ml
			break
		}
	}
	if l.l == nil {
		return "", fmt.Errorf("no such layer %s", lname)
	}

	cs := C.CString(key)
	defer C.free(unsafe.Pointer(cs))
	g := C.mapnik_map_render_to_grid(m.m, l.l, cs)
	if g == nil {
		return "", m.lastError()
	}
	defer C.mapnik_grid_free(g)
	json := C.mapnik_grid_to_json(g, C.uint(res))
	if json == nil {
		return "", m.lastError()
	}
	defer C.free(unsafe.Pointer(json))
	return C.GoString(json), nil
}
Beispiel #2
0
func (m *Map) SetActiveLayer(lname string) {
	n := int(C.mapnik_map_layer_count(m.m))
	for i := 0; i < n; i++ {
		l := C.mapnik_map_get_layer(m.m, C.size_t(i))
		defer C.free(unsafe.Pointer(l))
		if C.GoString(C.mapnik_layer_name(l)) == lname {
			C.mapnik_layer_set_active(l, 1)
		} else {
			C.mapnik_layer_set_active(l, 0)
		}
	}
}