-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tony Tung
committed
May 16, 2018
1 parent
413e566
commit e39f1ae
Showing
15 changed files
with
191 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
from __future__ import absolute_import, division, print_function, unicode_literals | ||
|
||
from ._formats import ImageFormat | ||
from ._imagepartition import ImagePartition | ||
from ._collection import Collection | ||
from ._tile import Tile | ||
from ._tocpartition import TocPartition | ||
from ._tileset import TileSet | ||
from .io import Reader, Writer, v0_0_0 | ||
|
||
|
||
__all__ = [ | ||
Collection, | ||
ImageFormat, | ||
ImagePartition, | ||
Reader, | ||
Tile, | ||
TocPartition, | ||
TileSet, | ||
Writer, | ||
v0_0_0, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from __future__ import absolute_import, division, print_function, unicode_literals | ||
|
||
from ._tileset import TileSet | ||
|
||
|
||
class Collection(object): | ||
def __init__(self, extras=None): | ||
self.extras = extras | ||
self._partitions = dict() | ||
|
||
def validate(self): | ||
pass | ||
|
||
def add_partition(self, name, partition): | ||
self._partitions[name] = partition | ||
|
||
def all_tilesets(self): | ||
"""Return all tilesets in this collection, directly or indirectly, as (name, tileset) tuples.""" | ||
for name, partition in self._partitions.items(): | ||
if isinstance(partition, Collection): | ||
for descendant_name, descendant_tileset in partition.all_tilesets(): | ||
yield descendant_name, descendant_tileset | ||
elif isinstance(partition, TileSet): | ||
yield name, partition | ||
|
||
def find_tileset(self, name): | ||
for partition_name, image_partition in self.all_tilesets(): | ||
if name == partition_name: | ||
return image_partition | ||
return None | ||
|
||
def tiles(self, filter_fn=lambda _: True): | ||
result = [] | ||
for partion_name, image_partition in self.all_tilesets(): | ||
result.extend(image_partition.tiles(filter_fn)) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.