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