Permalink
Browse files

Add tc-delete

  • Loading branch information...
1 parent ee725d5 commit b7b23f4e544a88c0493558af736c5fd9ec6e4988 @twpayne twpayne committed Mar 29, 2012
Showing with 41 additions and 0 deletions.
  1. +41 −0 tc-delete
View
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+
+from itertools import imap
+import logging
+from optparse import OptionParser
+import os.path
+import sys
+
+from tilecloud import BoundingPyramid, TileStore, consume
+from tilecloud.filter.logger import Logger
+from tilecloud.store.boundingpyramid import BoundingPyramidTileStore
+
+
+def main(argv):
+ logger = logging.getLogger(os.path.basename(argv[0]))
+ option_parser = OptionParser()
+ option_parser.add_option('-b', '--bounding-pyramid',
+ metavar='BOUNDING-PYRAMID')
+ option_parser.add_option('-v', '--verbose', action='store_true')
+ options, args = option_parser.parse_args(argv[1:])
+ if options.verbose:
+ logging.basicConfig(level=logging.INFO)
+ if options.bounding_pyramid:
+ bounding_pyramid = \
+ BoundingPyramid.from_string(options.bounding_pyramid)
+ else:
+ bounding_pyramid = None
+ for arg in args:
+ tile_store = TileStore.load(arg)
+ if bounding_pyramid:
+ tilestream = BoundingPyramidTileStore(bounding_pyramid).list()
+ else:
+ tilestream = tile_store.list()
+ tilestream = tile_store.delete(tilestream)
+ if options.verbose:
+ tilestream = imap(Logger(logger, logging.INFO, '%(tilecoord)s'), tilestream)
+ consume(tilestream, None)
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))

0 comments on commit b7b23f4

Please sign in to comment.