added simulate stages. Changed GSN_PREDICTOR_GRIB_TTL to 48h
This commit is contained in:
parent
c4f355a32e
commit
fe207f3fab
21 changed files with 978 additions and 137 deletions
|
|
@ -3,11 +3,11 @@
|
|||
package gsn
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-faster/errors"
|
||||
|
||||
"github.com/ogen-go/ogen/conv"
|
||||
"github.com/ogen-go/ogen/middleware"
|
||||
"github.com/ogen-go/ogen/ogenerrors"
|
||||
|
|
@ -17,21 +17,22 @@ import (
|
|||
|
||||
// PerformPredictionParams is parameters of performPrediction operation.
|
||||
type PerformPredictionParams struct {
|
||||
LaunchLatitude OptFloat64
|
||||
LaunchLongitude OptFloat64
|
||||
LaunchDatetime OptDateTime
|
||||
LaunchAltitude OptFloat64
|
||||
Profile OptPerformPredictionProfile
|
||||
AscentRate OptFloat64
|
||||
BurstAltitude OptFloat64
|
||||
DescentRate OptFloat64
|
||||
FloatAltitude OptFloat64
|
||||
StopDatetime OptDateTime
|
||||
AscentCurve OptString
|
||||
DescentCurve OptString
|
||||
Interpolate OptBool
|
||||
Format OptPerformPredictionFormat
|
||||
Dataset OptDateTime
|
||||
LaunchLatitude OptFloat64 `json:",omitempty,omitzero"`
|
||||
LaunchLongitude OptFloat64 `json:",omitempty,omitzero"`
|
||||
LaunchDatetime OptDateTime `json:",omitempty,omitzero"`
|
||||
LaunchAltitude OptFloat64 `json:",omitempty,omitzero"`
|
||||
Profile OptPerformPredictionProfile `json:",omitempty,omitzero"`
|
||||
AscentRate OptFloat64 `json:",omitempty,omitzero"`
|
||||
BurstAltitude OptFloat64 `json:",omitempty,omitzero"`
|
||||
DescentRate OptFloat64 `json:",omitempty,omitzero"`
|
||||
FloatAltitude OptFloat64 `json:",omitempty,omitzero"`
|
||||
StopDatetime OptDateTime `json:",omitempty,omitzero"`
|
||||
AscentCurve OptString `json:",omitempty,omitzero"`
|
||||
DescentCurve OptString `json:",omitempty,omitzero"`
|
||||
SimulateStages []PerformPredictionSimulateStagesItem `json:",omitempty"`
|
||||
Interpolate OptBool `json:",omitempty,omitzero"`
|
||||
Format OptPerformPredictionFormat `json:",omitempty,omitzero"`
|
||||
Dataset OptDateTime `json:",omitempty,omitzero"`
|
||||
}
|
||||
|
||||
func unpackPerformPredictionParams(packed middleware.Parameters) (params PerformPredictionParams) {
|
||||
|
|
@ -143,6 +144,15 @@ func unpackPerformPredictionParams(packed middleware.Parameters) (params Perform
|
|||
params.DescentCurve = v.(OptString)
|
||||
}
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "simulate_stages",
|
||||
In: "query",
|
||||
}
|
||||
if v, ok := packed[key]; ok {
|
||||
params.SimulateStages = v.([]PerformPredictionSimulateStagesItem)
|
||||
}
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "interpolate",
|
||||
|
|
@ -787,6 +797,71 @@ func decodePerformPredictionParams(args [0]string, argsEscaped bool, r *http.Req
|
|||
Err: err,
|
||||
}
|
||||
}
|
||||
// Decode query: simulate_stages.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
Name: "simulate_stages",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.HasParam(cfg); err == nil {
|
||||
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
return d.DecodeArray(func(d uri.Decoder) error {
|
||||
var paramsDotSimulateStagesVal PerformPredictionSimulateStagesItem
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToString(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
paramsDotSimulateStagesVal = PerformPredictionSimulateStagesItem(c)
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
params.SimulateStages = append(params.SimulateStages, paramsDotSimulateStagesVal)
|
||||
return nil
|
||||
})
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
var failures []validate.FieldError
|
||||
for i, elem := range params.SimulateStages {
|
||||
if err := func() error {
|
||||
if err := elem.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: fmt.Sprintf("[%d]", i),
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "simulate_stages",
|
||||
In: "query",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
// Decode query: interpolate.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue