diff --git a/ows.go b/ows.go index d85e15b7..b8832f47 100644 --- a/ows.go +++ b/ows.go @@ -153,11 +153,23 @@ func serveWMS(ctx context.Context, params utils.WMSParams, conf *utils.Config, r return } - var timeStr string - if params.Time != nil { - timeStr = fmt.Sprintf(`"time": "%s"`, (*params.Time).Format(utils.ISOFormat)) + if params.Time == nil { + idx, err := utils.GetLayerIndex(params, conf) + if err != nil { + http.Error(w, fmt.Sprintf("Malformed getFeatureInfo request: %s", reqURL), 400) + return + } + + currentTime, err := utils.GetCurrentTimeStamp(conf.Layers[idx].Dates) + if err != nil { + http.Error(w, fmt.Sprintf("%v: %s", err, reqURL), 400) + return + } + params.Time = currentTime } + timeStr := fmt.Sprintf(`"time": "%s"`, (*params.Time).Format(utils.ISOFormat)) + feat_info, err := proc.GetFeatureInfo(ctx, params, conf, *verbose) if err != nil { feat_info = fmt.Sprintf(`"error": "%v"`, err) diff --git a/processor/feature_info.go b/processor/feature_info.go index 66ac3460..bfff2e14 100644 --- a/processor/feature_info.go +++ b/processor/feature_info.go @@ -125,7 +125,7 @@ func GetFeatureInfo(ctx context.Context, params utils.WMSParams, conf *utils.Con func getRaster(ctx context.Context, params utils.WMSParams, conf *utils.Config, verbose bool) ([]utils.Raster, []string, []string, error) { idx, err := utils.GetLayerIndex(params, conf) if err != nil { - return nil, nil, nil, fmt.Errorf("Malformed WMS GetMap request: %v", err) + return nil, nil, nil, fmt.Errorf("Malformed WMS GetFeatureInfo request: %v", err) } if params.Time == nil { return nil, nil, nil, fmt.Errorf("Request should contain a valid time.")