fix(input): correct lon mapping
This commit is contained in:
parent
19557f3a62
commit
84d1664b29
20 changed files with 1197 additions and 137 deletions
|
|
@ -68,9 +68,20 @@ const (
|
|||
// Rasterize samples field over req and returns the U/V grid payload.
|
||||
//
|
||||
// Data is laid out in wind-js scan order: row 0 is the northernmost
|
||||
// latitude (la1), each row runs west→east, longitudes increasing. Per-cell
|
||||
// sampling errors (e.g. altitude outside the model) are written as 0 rather
|
||||
// than failing the whole request; a time outside coverage is a hard error.
|
||||
// latitude (la1), each row runs west→east, longitudes increasing.
|
||||
//
|
||||
// Cells that cannot be sampled individually — a regional dataset queried outside
|
||||
// its region — are written as 0 and the request still succeeds, because a partly
|
||||
// covered grid is worth drawing. A grid in which nothing could be sampled is an
|
||||
// error instead. Time is one value for the whole request, so a time past the
|
||||
// dataset's horizon fails every cell, and returning that as zeros made a velocity
|
||||
// layer draw an atmosphere at perfect rest where the honest answer is "we have no
|
||||
// data for this time".
|
||||
//
|
||||
// Known gap: an individual zero-filled cell is indistinguishable from genuine
|
||||
// calm in the payload. The wind-js format expresses missing data as null, which
|
||||
// would mean typing Data as []*float64; there is no consumer to validate that
|
||||
// against since the browser wind layer was removed in the Cesium migration.
|
||||
func Rasterize(field weather.WindField, req Request) (Field, error) {
|
||||
step := req.Step
|
||||
if step <= 0 {
|
||||
|
|
@ -125,6 +136,8 @@ func Rasterize(field weather.WindField, req Request) (Field, error) {
|
|||
v := make([]float64, nx*ny)
|
||||
|
||||
// Row 0 = north (la1); rows descend in latitude.
|
||||
var failed int
|
||||
var firstErr error
|
||||
for j := range ny {
|
||||
lat := maxLat - float64(j)*step
|
||||
for i := range nx {
|
||||
|
|
@ -132,12 +145,20 @@ func Rasterize(field weather.WindField, req Request) (Field, error) {
|
|||
s, err := field.Wind(req.Time, lat, normLng(lng), req.Altitude)
|
||||
idx := j*nx + i
|
||||
if err != nil {
|
||||
continue // leave as 0
|
||||
failed++
|
||||
if firstErr == nil {
|
||||
firstErr = err
|
||||
}
|
||||
continue // leave as 0; see the doc comment on this distinction
|
||||
}
|
||||
u[idx] = s.U
|
||||
v[idx] = s.V
|
||||
}
|
||||
}
|
||||
if failed == nx*ny {
|
||||
return nil, fmt.Errorf("no wind data anywhere in the requested grid at %s: %w",
|
||||
time.Unix(int64(req.Time), 0).UTC().Format(time.RFC3339), firstErr)
|
||||
}
|
||||
|
||||
refTime := time.Unix(int64(req.Time), 0).UTC().Format("2006-01-02T15:04:05.000Z")
|
||||
mk := func(num int, name string, data []float64) Component {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue