report
This commit is contained in:
@@ -23,10 +23,19 @@ var fusCmd = &cobra.Command{
|
||||
|
||||
fusedTiff := filepath.Base(mssImage)
|
||||
fusedTiff = strings.Replace(fusedTiff, "MSS", "FUS", -1)
|
||||
id := strings.TrimSuffix(fusedTiff, filepath.Ext(fusedTiff))
|
||||
err := producer.GDALPansharpen(panImage, mssImage, filepath.Join(outputDir, fusedTiff))
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
var report producer.Report
|
||||
report.Satellite = "SJY01"
|
||||
report.Sensor = "FUS"
|
||||
report.Scenes = append(report.Scenes, producer.ReportScene{
|
||||
TiffData: fusedTiff,
|
||||
})
|
||||
producer.WriteReport(&report, filepath.Join(outputDir, id+"_report.xml"))
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
55
cmd/proc.go
55
cmd/proc.go
@@ -25,13 +25,8 @@ var procCmd = &cobra.Command{
|
||||
config.GViper = config.InitViper(configFile)
|
||||
logrus.SetLevel(config.GCONFIG.LogLevel)
|
||||
|
||||
initParams()
|
||||
|
||||
reg := producer.NewRegistrator(producer.DownSampled)
|
||||
reg.Params = params
|
||||
reg.Params.MssTiffFile = filepath.Join(params.OutputDir, strings.TrimSuffix(filepath.Base(params.MssRawFile), filepath.Ext(params.MssRawFile))+".tiff")
|
||||
reg.Params.PanTiffFile = filepath.Join(params.OutputDir, strings.TrimSuffix(filepath.Base(params.PanRawFile), filepath.Ext(params.PanRawFile))+".tiff")
|
||||
reg.Params.FusTIffFile = strings.Replace(reg.Params.MssTiffFile, ".tiff", "_FUS.tiff", 1)
|
||||
reg.Params = initParams()
|
||||
|
||||
if err := reg.LoadAuxData(); err != nil {
|
||||
logrus.Fatal(err)
|
||||
@@ -77,6 +72,8 @@ var procCmd = &cobra.Command{
|
||||
reg.DoScenePansharpen(panScenes, mssScenes)
|
||||
}
|
||||
|
||||
reg.Report()
|
||||
|
||||
reg.Clean()
|
||||
},
|
||||
}
|
||||
@@ -84,9 +81,9 @@ var procCmd = &cobra.Command{
|
||||
func init() {
|
||||
rootCmd.AddCommand(procCmd)
|
||||
|
||||
procCmd.Flags().StringVarP(¶ms.PanRawFile, "pan", "p", "pan.raw", "PAN image raw file path")
|
||||
procCmd.Flags().StringVarP(¶ms.MssRawFile, "mss", "m", "mss.raw", "MSS image raw file path")
|
||||
procCmd.Flags().StringVarP(¶ms.AuxRawFile, "aux", "a", "pms.aux", "AUX image raw file path")
|
||||
procCmd.Flags().StringVarP(¶ms.PanRawFile, "pan", "p", "", "PAN image raw file path")
|
||||
procCmd.Flags().StringVarP(¶ms.MssRawFile, "mss", "m", "", "MSS image raw file path")
|
||||
procCmd.Flags().StringVarP(¶ms.AuxRawFile, "aux", "a", "", "AUX image raw file path")
|
||||
procCmd.Flags().BoolVarP(¶ms.SaveRegisteredMssRaw, "srmss", "s", false, "save registered MSS image raw file")
|
||||
procCmd.Flags().BoolVarP(¶ms.DoPansharpen, "fus", "", false, "pansharpen using IHS")
|
||||
procCmd.Flags().StringVarP(¶ms.OutputDir, "output-dir", "o", "data", "output directory")
|
||||
@@ -97,26 +94,34 @@ func init() {
|
||||
|
||||
func initParams() producer.Params {
|
||||
taskParams := params
|
||||
taskParams.MssTiffFile = filepath.Join(params.OutputDir, strings.TrimSuffix(filepath.Base(params.MssRawFile),
|
||||
filepath.Ext(params.MssRawFile))+".tiff")
|
||||
taskParams.PanTiffFile = filepath.Join(params.OutputDir,
|
||||
strings.TrimSuffix(filepath.Base(params.PanRawFile),
|
||||
filepath.Ext(params.PanRawFile))+".tiff")
|
||||
taskParams.FusTIffFile = strings.Replace(taskParams.MssTiffFile, ".tiff", "_FUS.tiff", 1)
|
||||
|
||||
if paramsXML == "" {
|
||||
return taskParams
|
||||
if paramsXML != "" {
|
||||
|
||||
task, err := producer.ParseXMLImageTask(paramsXML)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
taskParams.PanRawFile = task.InputFileList.PanData
|
||||
taskParams.MssRawFile = task.InputFileList.MssData
|
||||
taskParams.AuxRawFile = task.InputFileList.AuxData
|
||||
taskParams.DoPansharpen = task.Params.DoPansharpen
|
||||
taskParams.OutputDir = task.Params.OutputPath
|
||||
taskParams.ReportFile = task.Params.ReportFile
|
||||
}
|
||||
|
||||
task, err := producer.ParseXMLImageTask(paramsXML)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
taskParams.MssTiffFile = filepath.Join(taskParams.OutputDir, strings.TrimSuffix(filepath.Base(taskParams.MssRawFile),
|
||||
filepath.Ext(taskParams.MssRawFile))+".tiff")
|
||||
|
||||
taskParams.PanTiffFile = filepath.Join(taskParams.OutputDir,
|
||||
strings.TrimSuffix(filepath.Base(taskParams.PanRawFile),
|
||||
filepath.Ext(taskParams.PanRawFile))+".tiff")
|
||||
|
||||
if taskParams.ReportFile == "" {
|
||||
id := strings.TrimSuffix(filepath.Base(taskParams.PanRawFile), filepath.Ext(taskParams.PanRawFile))
|
||||
id = strings.Replace(id, "PAN", "PMS", 1)
|
||||
taskParams.ReportFile = filepath.Join(taskParams.OutputDir, id+"_report.xml")
|
||||
}
|
||||
|
||||
taskParams.PanRawFile = task.InputFileList.PanData
|
||||
taskParams.MssRawFile = task.InputFileList.MssData
|
||||
taskParams.AuxRawFile = task.InputFileList.AuxData
|
||||
taskParams.DoPansharpen = task.Params.DoPansharpen
|
||||
taskParams.OutputDir = task.Params.OutputPath
|
||||
return taskParams
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@ type Registrator struct {
|
||||
auxHeads []*auxilary.AuxFrameHead
|
||||
auxBoxes []*auxilary.AuxFocalBox
|
||||
AuxPlatforms []*auxilary.AuxPlatform
|
||||
|
||||
report Report
|
||||
}
|
||||
|
||||
func NewRegistrator(rsmethod ResampleMethod) *Registrator {
|
||||
|
||||
@@ -183,3 +183,7 @@ func (r *Registrator) SaveRegisteredMssToRaw(raw string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Registrator) Report() error {
|
||||
return WriteReport(&r.report, r.Params.ReportFile)
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ type Params struct {
|
||||
MssTiffFile string
|
||||
FusTIffFile string
|
||||
SubScenes bool
|
||||
ReportFile string
|
||||
}
|
||||
|
||||
type XMLImageTask struct {
|
||||
|
||||
@@ -121,6 +121,11 @@ func (r *Registrator) SaveScenesToTiff(panScenes []*Scene, mssScenes []*Scene) e
|
||||
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)
|
||||
r.report.Scenes = append(r.report.Scenes, ReportScene{
|
||||
Name: scene.SceneId,
|
||||
TiffData: scene.Tiff,
|
||||
MetaData: metaFile,
|
||||
})
|
||||
}
|
||||
|
||||
for i, scene := range mssScenes {
|
||||
@@ -149,6 +154,11 @@ func (r *Registrator) SaveScenesToTiff(panScenes []*Scene, mssScenes []*Scene) e
|
||||
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)
|
||||
r.report.Scenes = append(r.report.Scenes, ReportScene{
|
||||
Name: scene.SceneId,
|
||||
TiffData: scene.Tiff,
|
||||
MetaData: metaFile,
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -163,6 +173,9 @@ func (r *Registrator) DoScenePansharpen(panScenes []*Scene, mssScenes []*Scene)
|
||||
}
|
||||
|
||||
GTiffToJPG(fusedTiff, strings.Replace(fusedTiff, ".tiff", ".jpg", 1), true)
|
||||
r.report.Scenes = append(r.report.Scenes, ReportScene{
|
||||
TiffData: fusedTiff,
|
||||
})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user