Exemplo n.º 1
0
func (layer *Layer) Wkts() chan string {
	wkts := make(chan string)

	go func() {
		defer close(wkts)

		C.OGR_L_ResetReading(layer.v)
		for {
			feature := C.OGR_L_GetNextFeature(layer.v)
			if feature == nil {
				break
			}
			geom := C.OGR_F_GetGeometryRef(feature)
			var res *C.char
			C.OGR_G_ExportToWkt(geom, &res)
			wkts <- C.GoString(res)
			C.CPLFree(unsafe.Pointer(res))
			C.OGR_F_Destroy(feature)

		}
	}()

	return wkts
}
Exemplo n.º 2
0
Arquivo: ogr.go Projeto: colek42/gdal
// Fetch geometry as WKT
func (geom Geometry) ToWKT() (string, error) {
	var p *C.char
	err := C.OGR_G_ExportToWkt(geom.cval, &p).Err()
	wkt := C.GoString(p)
	return wkt, err
}