56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/spf13/cobra"
|
|
producer "starwiz.cn/sjy01/image-proc/pkg/producer"
|
|
)
|
|
|
|
var (
|
|
panImage string
|
|
mssImage string
|
|
outputDir string
|
|
)
|
|
|
|
var fusCmd = &cobra.Command{
|
|
Use: "fus",
|
|
Short: "use GDAL_Pansharpen to merge PAN and MSS images",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
initFUSParams()
|
|
|
|
fusedTiff := filepath.Base(mssImage)
|
|
fusedTiff = strings.Replace(fusedTiff, "MSS", "FUS", -1)
|
|
err := producer.GDALPansharpen(panImage, mssImage, filepath.Join(outputDir, fusedTiff))
|
|
if err != nil {
|
|
logrus.Fatal(err)
|
|
}
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(fusCmd)
|
|
|
|
fusCmd.Flags().StringVarP(&panImage, "pan", "p", "", "path to the PAN image")
|
|
fusCmd.Flags().StringVarP(&mssImage, "mss", "m", "", "path to the MSS image")
|
|
fusCmd.Flags().StringVarP(&outputDir, "output", "o", "", "path to the output directory")
|
|
fusCmd.Flags().StringVarP(¶msXML, "params", "x", "", "path to the XML file containing parameters for GDAL_Pansharpen")
|
|
}
|
|
|
|
func initFUSParams() {
|
|
if paramsXML == "" {
|
|
return
|
|
}
|
|
|
|
task, err := producer.ParseXMLFUSTask(paramsXML)
|
|
if err != nil {
|
|
logrus.Fatal(err)
|
|
}
|
|
|
|
panImage = task.InputFileList.PanTiff
|
|
mssImage = task.InputFileList.MssTiff
|
|
outputDir = task.Params.OutputPath
|
|
}
|