71 lines
2.1 KiB
Go
71 lines
2.1 KiB
Go
package imageproc
|
|
|
|
import (
|
|
"encoding/xml"
|
|
"io/ioutil"
|
|
)
|
|
|
|
// 定义与XML结构对应的Go结构体
|
|
type ProductMeta struct {
|
|
XMLName xml.Name `xml:"ProductMeta"`
|
|
Satellite string `xml:"Satellite"`
|
|
Sensor string `xml:"Sensor"`
|
|
ProductID string `xml:"ProductID"`
|
|
ProductLevel string `xml:"ProductLevel"`
|
|
OutputFormat string `xml:"OutputFormat"`
|
|
ProductGenTime string `xml:"ProductGenTime"`
|
|
StartTime string `xml:"StartTime"`
|
|
EndTime string `xml:"EndTime"`
|
|
CentreTime string `xml:"CentreTime"`
|
|
Bands int `xml:"Bands"`
|
|
CentreLocation Location `xml:"CentreLocation"`
|
|
Corners Corners `xml:"Corners"`
|
|
SunAzimuth float64 `xml:"SunAzimuth"`
|
|
SunElevation float64 `xml:"SunElevation"`
|
|
SatAzimuth float64 `xml:"SatAzimuth"`
|
|
SatElevation float64 `xml:"SatElevation"`
|
|
Gsd float64 `xml:"Gsd"`
|
|
CloudRate float64 `xml:"CloudRate"`
|
|
Roll float64 `xml:"Roll"`
|
|
Pitch float64 `xml:"Pitch"`
|
|
Yaw float64 `xml:"Yaw"`
|
|
SatPosX float64 `xml:"SatPosX"`
|
|
SatPosY float64 `xml:"SatPosY"`
|
|
SatPosZ float64 `xml:"SatPosZ"`
|
|
Width int `xml:"Width"`
|
|
Height int `xml:"Height"`
|
|
DataSize int64 `xml:"DataSize"`
|
|
MapProjection string `xml:"MapProjection"`
|
|
EarthEllipsoid string `xml:"EarthEllipsoid"`
|
|
UtmZone int `xml:"UtmZone"`
|
|
GainLevel int `xml:"GainLevel"`
|
|
IntegratedLevel int `xml:"IntegratedLevel"`
|
|
IntegratedTime float64 `xml:"IntegratedTime"`
|
|
}
|
|
|
|
type Location struct {
|
|
Longitude float64 `xml:"Longitude"`
|
|
Latitude float64 `xml:"Latitude"`
|
|
}
|
|
|
|
type Corners struct {
|
|
UpperLeft Location `xml:"UpperLeft"`
|
|
UpperRight Location `xml:"UpperRight"`
|
|
LowerRight Location `xml:"LowerRight"`
|
|
LowerLeft Location `xml:"LowerLeft"`
|
|
}
|
|
|
|
func WriteProductMeta(productMeta *ProductMeta, filename string) error {
|
|
output, err := xml.MarshalIndent(productMeta, "", " ")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = ioutil.WriteFile(filename, output, 0644)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|