Skip to content

Commit

Permalink
chore: remove logAndError
Browse files Browse the repository at this point in the history
  • Loading branch information
iwpnd committed Mar 10, 2022
1 parent 2fad340 commit 21da05b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions server/handle_map_layer_zxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@ func (req *HandleMapLayerZXY) parseURI(r *http.Request) error {
return nil
}

func logAndError(w http.ResponseWriter, code int, format string, vals ...interface{}) {
msg := fmt.Sprintf(format, vals...)
log.Info(msg)
http.Error(w, msg, code)
}

// URI scheme: /maps/:map_name/:layer_name/:z/:x/:y
// map_name - map name in the config file
// layer_name - name of the single map layer to render
Expand All @@ -127,15 +121,20 @@ func (req HandleMapLayerZXY) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// filter down the layers we need for this zoom
m = m.FilterLayersByZoom(req.z)
if len(m.Layers) == 0 {
logAndError(w, http.StatusNotFound, "map (%v) has no layers, at zoom %v", req.mapName, req.z)
msg := fmt.Sprintf("map (%v) has no layers, at zoom %v", req.mapName, req.z)
log.Debug(msg)
http.Error(w, msg, http.StatusNotFound)
return
}

if req.layerName != "" {
m = m.FilterLayersByName(req.layerName)
if len(m.Layers) == 0 {
logAndError(w, http.StatusNotFound, "map (%v) has no layers, for LayerName %v at zoom %v", req.mapName, req.layerName, req.z)
msg := fmt.Sprintf("map (%v) has no layers, for LayerName %v at zoom %v", req.mapName, req.layerName, req.z)
log.Debug(msg)
http.Error(w, msg, http.StatusNotFound)
return

}
}

Expand All @@ -147,7 +146,9 @@ func (req HandleMapLayerZXY) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// make a new extent
textent := tile.Extent4326()
if _, intersect := m.Bounds.Intersect(textent); !intersect {
logAndError(w, http.StatusNotFound, "map (%v -- %v) does not contains tile at %v/%v/%v -- %v", req.mapName, m.Bounds, req.z, req.x, req.y, textent)
msg := fmt.Sprintf("map (%v -- %v) does not contains tile at %v/%v/%v -- %v", req.mapName, m.Bounds, req.z, req.x, req.y, textent)
log.Debug(msg)
http.Error(w, msg, http.StatusNotFound)
return
}
}
Expand Down

0 comments on commit 21da05b

Please sign in to comment.