暂时使用星下点坐标作为图像左上角坐标
This commit is contained in:
109
pkg/producer/aux.go
Normal file
109
pkg/producer/aux.go
Normal file
@@ -0,0 +1,109 @@
|
||||
package imageproc
|
||||
|
||||
import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"github.com/paulmach/orb"
|
||||
"github.com/paulmach/orb/planar"
|
||||
"starwiz.cn/sjy01/image-proc/pkg/auxilary"
|
||||
"starwiz.cn/sjy01/image-proc/pkg/calculator"
|
||||
)
|
||||
|
||||
func (r *Registrator) LoadAuxData() error {
|
||||
var err error
|
||||
r.auxHeads, r.auxBoxes, r.AuxPlatforms, err = auxilary.ExtractAux(r.Params.AuxRawFile)
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *Registrator) SceneImageTime(scene *Scene) (start, center, end time.Time) {
|
||||
startPosInAux, endPosInAux := r.SceneInAuxIndex(scene)
|
||||
centerPosInAux := (startPosInAux + endPosInAux) / 2
|
||||
|
||||
start = time.Unix(int64(auxilary.ReferenceTime2000)+int64(r.AuxPlatforms[startPosInAux].UTCTimeSec),
|
||||
int64(r.AuxPlatforms[startPosInAux].Microsecond)*1000)
|
||||
center = time.Unix(int64(auxilary.ReferenceTime2000)+int64(r.AuxPlatforms[centerPosInAux].UTCTimeSec),
|
||||
int64(r.AuxPlatforms[centerPosInAux].Microsecond)*1000)
|
||||
end = time.Unix(int64(auxilary.ReferenceTime2000)+int64(r.AuxPlatforms[endPosInAux].UTCTimeSec),
|
||||
int64(r.AuxPlatforms[endPosInAux].Microsecond)*1000)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// FIXME: 位置像元经纬度计算方法,暂时使用星下点替代
|
||||
func (r *Registrator) ScenePosition(scene *Scene) (topLeft, bottomRight orb.Point) {
|
||||
// startPosInAux, endPosInAux := r.SceneInAuxIndex(scene)
|
||||
ap := r.AuxPlatforms[0]
|
||||
// ap1 := r.AuxPlatforms[endPosInAux]
|
||||
lat0, lng0, _ := calculator.WGS84XYZtoLatLngH(ap.WGS84PosX, ap.WGS84PosY, ap.WGS84PosZ)
|
||||
|
||||
lat, lng := calculator.CalculateDestination(lat0, lng0,
|
||||
float64(scene.Width)*scene.Meta.Gsd, float64(-scene.Y)*scene.Meta.Gsd)
|
||||
|
||||
// lat0, lng0, h0 := calculator.WGS84XYZtoLatLngH(ap1.WGS84PosX, ap1.WGS84PosY, ap1.WGS84PosZ)
|
||||
// fmt.Println("Scene Position End:", lat0, lng0, h0)
|
||||
|
||||
lat1, lng1 := calculator.CalculateDestination(lat, lng,
|
||||
float64(scene.Width)*scene.Meta.Gsd, float64(-scene.Height)*scene.Meta.Gsd)
|
||||
|
||||
poly := orb.Polygon{
|
||||
{
|
||||
{lng, lat},
|
||||
{lng1, lat},
|
||||
{lng1, lat1},
|
||||
{lng, lat1},
|
||||
{lng, lat},
|
||||
},
|
||||
}
|
||||
|
||||
centroid, _ := planar.CentroidArea(poly)
|
||||
scene.Meta.CentreLocation.Latitude = centroid.Y()
|
||||
scene.Meta.CentreLocation.Longitude = centroid.X()
|
||||
scene.Meta.Corners.UpperLeft.Latitude = lat
|
||||
scene.Meta.Corners.UpperLeft.Longitude = lng
|
||||
scene.Meta.Corners.UpperRight.Latitude = lat
|
||||
scene.Meta.Corners.UpperRight.Longitude = lng1
|
||||
scene.Meta.Corners.LowerLeft.Latitude = lat1
|
||||
scene.Meta.Corners.LowerLeft.Longitude = lng
|
||||
scene.Meta.Corners.LowerRight.Latitude = lat1
|
||||
scene.Meta.Corners.LowerRight.Longitude = lng1
|
||||
|
||||
scene.Meta.SatPosX = ap.WGS84PosX
|
||||
scene.Meta.SatPosY = ap.WGS84PosY
|
||||
scene.Meta.SatPosZ = ap.WGS84PosZ
|
||||
scene.Meta.Yaw = ap.Eular1 * 180 / math.Pi
|
||||
scene.Meta.Pitch = ap.Eular2 * 180 / math.Pi
|
||||
scene.Meta.Roll = ap.Eular3 * 180 / math.Pi
|
||||
|
||||
// feature := geojson.NewFeature(poly)
|
||||
// fcs.Features = append(fcs.Features, feature)
|
||||
|
||||
// fd, _ := fcs.MarshalJSON()
|
||||
// fmt.Println(string(fd))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (r *Registrator) SceneInAuxIndex(scene *Scene) (int, int) {
|
||||
var auxForImageRow int
|
||||
switch scene.Type {
|
||||
case "MSS":
|
||||
auxForImageRow = 4
|
||||
case "PAN":
|
||||
auxForImageRow = 16
|
||||
case "FUS":
|
||||
auxForImageRow = 16
|
||||
}
|
||||
|
||||
startPosInAux := scene.Y / auxForImageRow
|
||||
if startPosInAux >= len(r.AuxPlatforms) {
|
||||
startPosInAux = len(r.AuxPlatforms) - 1
|
||||
}
|
||||
|
||||
endPosInAux := (scene.Y + scene.Height) / auxForImageRow
|
||||
if endPosInAux >= len(r.AuxPlatforms) {
|
||||
endPosInAux = len(r.AuxPlatforms) - 1
|
||||
}
|
||||
|
||||
return startPosInAux, endPosInAux
|
||||
}
|
||||
Reference in New Issue
Block a user