예제 #1
0
파일: ogr.go 프로젝트: renderless/imposm3
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
}
예제 #2
0
파일: ogr.go 프로젝트: renderless/imposm3
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
}
예제 #3
0
파일: ogr.go 프로젝트: colek42/gdal
// Destroy this feature
func (feature Feature) Destroy() {
	C.OGR_F_Destroy(feature.cval)
}