adjust
This commit is contained in:
34
producer/util.go
Normal file
34
producer/util.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package imageproc
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/airbusgeo/godal"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func setGeoTransform(ds *godal.Dataset, topLeftX, topLeftY, width, height, resolution float64) {
|
||||
// 设置地理变换(假设左上角坐标为(0,0),PAN每个像素分辨率为1.2米)
|
||||
geotransform := [6]float64{
|
||||
0, // top left x
|
||||
resolution, // w-e pixel resolution
|
||||
0, // rotation, 0 if image is "north up"
|
||||
0, // top left y
|
||||
0, // rotation, 0 if image is "north up"
|
||||
-resolution, // n-s pixel resolution (negative value)
|
||||
}
|
||||
err := ds.SetGeoTransform(geotransform)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to set GeoTransform: %v", err)
|
||||
}
|
||||
|
||||
// 设置投影信息(WGS84)
|
||||
err = ds.SetProjection(calculateProj(topLeftX, topLeftY, width, height, resolution))
|
||||
if err != nil {
|
||||
log.Errorf("Failed to set projection: %v", err)
|
||||
}
|
||||
|
||||
// 设置一些常见的元数据(可选)
|
||||
ds.SetMetadata("TIFFTAG_DATETIME", time.Now().String())
|
||||
ds.SetMetadata("TIFFTAG_SOFTWARE", "StarWiz-SJY01-IMAGE-PROC")
|
||||
}
|
||||
Reference in New Issue
Block a user