Commit 68f06399 authored by MSantos's avatar MSantos Committed by Jgiannelos
Browse files

Filter zoom levels out of min/max range

parent ce5e0ddf
Pipeline #1309 passed with stages
in 2 minutes and 12 seconds
......@@ -43,7 +43,8 @@ class TileSet:
if tile.z < self.minzoom or tile in self.tileset:
return
self.tileset.add(tile)
if tile.z >= self.minzoom and tile.z <= self.maxzoom:
self.tileset.add(tile)
self.addParent(tile.parent)
def addChildren(self, tiles):
......@@ -52,7 +53,8 @@ class TileSet:
if tile.z > self.maxzoom or tile in self.tileset:
return
self.tileset.add(tile)
if tile.z >= self.minzoom and tile.z <= self.maxzoom:
self.tileset.add(tile)
self.addChildren(tile.children)
def read(self):
......@@ -61,4 +63,5 @@ class TileSet:
tile = self.parse(line)
self.addParent(tile.parent)
self.addChildren(tile.children)
self.tileset.add(tile)
if tile.z >= self.minzoom and tile.z <= self.maxzoom:
self.tileset.add(tile)
......@@ -160,3 +160,25 @@ class TestTileSet(TestCase):
tileset = TileSet(test_input_file, 0, 3)
tileset.read()
self.assertEqual(len(tileset.tileset), 5)
def test_tileset_filter_zoom_in_exact_range_z1_to_z3(self):
test_input = ["0/0/0"]
test_input = "\n".join(test_input)
test_input_file = StringIO()
test_input_file.write(test_input)
test_input_file.seek(0)
tileset = TileSet(test_input_file, 1, 3)
tileset.read()
self.assertEqual(len(tileset.tileset), 84)
def test_tileset_filter_zoom_in_exact_range_z5(self):
test_input = ["0/0/0"]
test_input = "\n".join(test_input)
test_input_file = StringIO()
test_input_file.write(test_input)
test_input_file.seek(0)
tileset = TileSet(test_input_file, 5, 5)
tileset.read()
self.assertEqual(len(tileset.tileset), 1024)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment