Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove logAndError #839

Merged
merged 1 commit into from
Mar 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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