Esempio n. 1
0
func (layer *Layer) Wkbs() chan []byte {
	wkbs := make(chan []byte)

	go func() {
		defer close(wkbs)

		C.OGR_L_ResetReading(layer.v)
		for {
			feature := C.OGR_L_GetNextFeature(layer.v)
			if feature == nil {
				break
			}
			geom := C.OGR_F_GetGeometryRef(feature)
			size := C.OGR_G_WkbSize(geom)
			buf := make([]byte, size)
			C.OGR_G_ExportToWkb(geom, C.wkbNDR, (*C.uchar)(&buf[0]))
			wkbs <- buf
			C.OGR_F_Destroy(feature)
		}
	}()
	return wkbs
}
Esempio n. 2
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
}
Esempio n. 3
0
File: ogr.go Progetto: colek42/gdal
// Fetch geometry of this feature
func (feature Feature) Geometry() Geometry {
	geom := C.OGR_F_GetGeometryRef(feature.cval)
	return Geometry{geom}
}