Skip to content

Commit

Permalink
defaulted to latest timestamp if time parameter is empty for getFeatu…
Browse files Browse the repository at this point in the history
…reInfo (#246)
  • Loading branch information
edisonguo authored Nov 29, 2018
1 parent 7cb4d43 commit 5df0dc9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions ows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion processor/feature_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down

0 comments on commit 5df0dc9

Please sign in to comment.