暂时使用星下点坐标作为图像左上角坐标
This commit is contained in:
@@ -13,12 +13,15 @@ import (
|
||||
)
|
||||
|
||||
type Scene struct {
|
||||
Width int
|
||||
Height int
|
||||
X int // coordinate of the left top corner of the scene
|
||||
Y int
|
||||
Mat []gocv.Mat
|
||||
Tiff string
|
||||
Type string
|
||||
Width int
|
||||
Height int
|
||||
X int // coordinate of the left top corner of the scene
|
||||
Y int
|
||||
Mat []gocv.Mat
|
||||
Tiff string
|
||||
Meta *ProductMeta
|
||||
SceneId string
|
||||
}
|
||||
|
||||
func (s *Scene) Cleanup() {
|
||||
@@ -43,12 +46,17 @@ func (r *Registrator) SubScenes() (panScenes []*Scene, mssScenes []*Scene, err e
|
||||
}
|
||||
|
||||
scene := &Scene{
|
||||
Type: "PAN",
|
||||
Width: 9344,
|
||||
Height: y1 - i*hPAN,
|
||||
X: 0,
|
||||
Y: i * hPAN,
|
||||
}
|
||||
|
||||
name := filepath.Base(r.Params.PanTiffFile)
|
||||
name = strings.TrimSuffix(name, ".tiff")
|
||||
scene.SceneId = fmt.Sprintf("%s_%03d", name, i+1)
|
||||
|
||||
mat := r.PanImage.Region(image.Rect(0, i*hPAN, 9344, y1))
|
||||
scene.Mat = append(scene.Mat, mat)
|
||||
panScenes = append(panScenes, scene)
|
||||
@@ -64,6 +72,7 @@ func (r *Registrator) SubScenes() (panScenes []*Scene, mssScenes []*Scene, err e
|
||||
}
|
||||
|
||||
scene := &Scene{
|
||||
Type: "MSS",
|
||||
Width: 2336,
|
||||
Height: y1 - i*hMSS,
|
||||
X: 0,
|
||||
@@ -75,6 +84,9 @@ func (r *Registrator) SubScenes() (panScenes []*Scene, mssScenes []*Scene, err e
|
||||
scene.Mat = append(scene.Mat, mat)
|
||||
}
|
||||
|
||||
name := filepath.Base(r.Params.MssTiffFile)
|
||||
name = strings.TrimSuffix(name, ".tiff")
|
||||
scene.SceneId = fmt.Sprintf("%s_%03d", name, i+1)
|
||||
mssScenes = append(mssScenes, scene)
|
||||
}
|
||||
|
||||
@@ -91,16 +103,23 @@ func (r *Registrator) SaveScenesToTiff(panScenes []*Scene, mssScenes []*Scene) e
|
||||
dir := filepath.Join(r.Params.OutputDir, fmt.Sprintf("%03d", i+1), "PAN")
|
||||
os.MkdirAll(dir, 0755)
|
||||
|
||||
tiff := filepath.Base(r.Params.PanTiffFile)
|
||||
tiff = strings.TrimSuffix(tiff, ".tiff")
|
||||
filename := fmt.Sprintf("%s_%03d.tiff", tiff, i+1)
|
||||
filename := fmt.Sprintf("%s_L1A.tiff", scene.SceneId)
|
||||
scene.Tiff = filepath.Join(dir, filename)
|
||||
err := savePanToGDALGTiff(scene.Mat[0], scene.Tiff)
|
||||
scene.Meta = r.makeProductMeta(scene)
|
||||
r.ScenePosition(scene)
|
||||
|
||||
err := savePanToGDALGTiff(scene.Mat[0],
|
||||
scene.Meta.Corners.UpperLeft.Longitude,
|
||||
scene.Meta.Corners.UpperLeft.Latitude,
|
||||
scene.Tiff)
|
||||
if err != nil {
|
||||
log.Errorf("save pan scene %d to tiff failed: %v", i+1, err)
|
||||
return err
|
||||
}
|
||||
|
||||
scene.Meta.DataSize = sizeOfFile(scene.Tiff)
|
||||
metaFile := strings.Replace(scene.Tiff, ".tiff", ".meta.xml", 1)
|
||||
r.writeProductMeta(scene.Meta, metaFile)
|
||||
GTiffToJPG(scene.Tiff, strings.Replace(scene.Tiff, ".tiff", ".jpg", 1), false)
|
||||
}
|
||||
|
||||
@@ -108,14 +127,17 @@ func (r *Registrator) SaveScenesToTiff(panScenes []*Scene, mssScenes []*Scene) e
|
||||
dir := filepath.Join(r.Params.OutputDir, fmt.Sprintf("%03d", i+1), "MSS")
|
||||
os.MkdirAll(dir, 0755)
|
||||
|
||||
tiff := filepath.Base(r.Params.MssTiffFile)
|
||||
tiff = strings.TrimSuffix(tiff, ".tiff")
|
||||
filename := fmt.Sprintf("%s_%03d.tiff", tiff, i+1)
|
||||
filename := fmt.Sprintf("%s_L1A.tiff", scene.SceneId)
|
||||
scene.Tiff = filepath.Join(dir, filename)
|
||||
scene.Meta = r.makeProductMeta(scene)
|
||||
r.ScenePosition(scene)
|
||||
|
||||
rgbirImage, _ := r.MergeMSSToBGRNIR(scene.Mat)
|
||||
err := SaveBGRToGDALGTiff(rgbirImage,
|
||||
4, 5,
|
||||
4,
|
||||
scene.Meta.Corners.UpperLeft.Longitude,
|
||||
scene.Meta.Corners.UpperLeft.Latitude,
|
||||
5,
|
||||
[]godal.ColorInterp{godal.CIBlue, godal.CIGreen, godal.CIRed, godal.CIUndefined},
|
||||
scene.Tiff)
|
||||
if err != nil {
|
||||
@@ -123,6 +145,9 @@ func (r *Registrator) SaveScenesToTiff(panScenes []*Scene, mssScenes []*Scene) e
|
||||
return err
|
||||
}
|
||||
|
||||
scene.Meta.DataSize = sizeOfFile(scene.Tiff)
|
||||
metaFile := strings.Replace(scene.Tiff, ".tiff", ".meta.xml", 1)
|
||||
r.writeProductMeta(scene.Meta, metaFile)
|
||||
GTiffToJPG(scene.Tiff, strings.Replace(scene.Tiff, ".tiff", ".jpg", 1), false)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user