Example #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
}
Example #2
0
File: ogr.go Project: colek42/gdal
// Convert a geometry to well known binary data
func (geom Geometry) ToWKB() ([]uint8, error) {
	b := make([]uint8, geom.WKBSize())
	cString := (*C.uchar)(unsafe.Pointer(&b[0]))
	err := C.OGR_G_ExportToWkb(geom.cval, C.OGRwkbByteOrder(C.wkbNDR), cString).Err()
	return b, err
}