From 648387af9871087263aa714ecdb1316391173967 Mon Sep 17 00:00:00 2001 From: nuknal Date: Wed, 25 Sep 2024 16:41:19 +0800 Subject: [PATCH] L1A -> L2 --- pkg/producer/meta.go | 2 ++ pkg/producer/warp.go | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/producer/meta.go b/pkg/producer/meta.go index 4cb70d1..860abd4 100644 --- a/pkg/producer/meta.go +++ b/pkg/producer/meta.go @@ -90,6 +90,8 @@ func (r *Registrator) makeProductMeta(scene *Scene) *ProductMeta { MapProjection: "GEOGRAPHIC", EarthEllipsoid: "WGS_84", ProductLevel: "L1A", + UtmZone: -1, + GainLevel: 6, } switch scene.Type { diff --git a/pkg/producer/warp.go b/pkg/producer/warp.go index 3ac46a5..a3eb397 100644 --- a/pkg/producer/warp.go +++ b/pkg/producer/warp.go @@ -50,7 +50,7 @@ func L1AtoL2(in, out, meta, rpb, demtif string) error { sensor = "PAN" } - corners, err := computeBound(out) + corners, width, height, err := computeBound(out) if err != nil { return err } @@ -60,6 +60,8 @@ func L1AtoL2(in, out, meta, rpb, demtif string) error { m.ProductID = id m.ProductLevel = "L2" m.Corners = *corners + m.Width = width + m.Height = height xmlfile := filepath.Join(dir, id+".meta.xml") writeProductMeta(m, xmlfile) @@ -68,17 +70,17 @@ func L1AtoL2(in, out, meta, rpb, demtif string) error { return nil } -func computeBound(tif string) (*Corners, error) { +func computeBound(tif string) (*Corners, int, int, error) { ds, err := godal.Open(tif) if err != nil { log.Printf("Error opening TIFF file %s: %v", tif, err) - return nil, err + return nil, -1, -1, err } defer ds.Close() geotransform, err := ds.GeoTransform() if err != nil { - return nil, err + return nil, -1, -1, err } // Xp = padfTransform[0] + P*padfTransform[1] + L*padfTransform[2]; @@ -98,7 +100,7 @@ func computeBound(tif string) (*Corners, error) { data := make([]uint16, width*height) err = band.Read(0, 0, data, width, height) if err != nil { - return nil, err + return nil, -1, -1, err } nodata, _ := band.NoData() @@ -150,5 +152,5 @@ func computeBound(tif string) (*Corners, error) { corners.LowerRight.Longitude = xmin + float64(index2)*geotransform[1] corners.LowerRight.Latitude = ymin - return &corners, nil + return &corners, width, height, nil }