diff --git a/atlas/map.go b/atlas/map.go index abb109190..2b635e5b4 100644 --- a/atlas/map.go +++ b/atlas/map.go @@ -145,7 +145,7 @@ func (m Map) FilterLayersByZoom(zoom uint) Map { var layers []Layer for i := range m.Layers { - if (m.Layers[i].MinZoom <= zoom || m.Layers[i].MinZoom == 0) && (m.Layers[i].MaxZoom >= zoom || m.Layers[i].MaxZoom == 0) { + if m.Layers[i].MinZoom <= zoom && m.Layers[i].MaxZoom >= zoom { layers = append(layers, m.Layers[i]) continue } diff --git a/atlas/map_test.go b/atlas/map_test.go index be889330b..0642a95f0 100644 --- a/atlas/map_test.go +++ b/atlas/map_test.go @@ -81,6 +81,58 @@ func TestMapFilterLayersByZoom(t *testing.T) { }, }, }, + { + atlasMap: atlas.Map{ + Layers: []atlas.Layer{ + { + Name: "layer1", + MinZoom: 0, + MaxZoom: 0, + }, + { + Name: "layer2", + MinZoom: 1, + MaxZoom: 5, + }, + }, + }, + zoom: 2, + expected: atlas.Map{ + Layers: []atlas.Layer{ + { + Name: "layer2", + MinZoom: 1, + MaxZoom: 5, + }, + }, + }, + }, + { + atlasMap: atlas.Map{ + Layers: []atlas.Layer{ + { + Name: "layer1", + MinZoom: 0, + MaxZoom: 0, + }, + { + Name: "layer2", + MinZoom: 1, + MaxZoom: 5, + }, + }, + }, + zoom: 0, + expected: atlas.Map{ + Layers: []atlas.Layer{ + { + Name: "layer1", + MinZoom: 0, + MaxZoom: 0, + }, + }, + }, + }, } for i, tc := range testcases {