qmsk/pngtile/pngtile.py
changeset 236 4ca68e4eb386
child 112 8975a92abaa9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/qmsk/pngtile/pngtile.py	Sat Oct 04 14:35:54 2014 +0300
@@ -0,0 +1,54 @@
+from __future__ import absolute_import
+
+from django.conf import settings
+import django.utils.http
+
+# the top-level pngtile package
+from pngtile.store import (
+        Error,
+        NotFound,
+        InvalidImage,
+        UncachedImage,
+        PNGTileStore,
+)
+
+class Store (PNGTileStore):
+    def __init__ (self, tileserver, **opts):
+        super(Store, self).__init__(**opts)
+
+        self.tileserver = tileserver
+
+    def breadcrumb (self, name):
+        """
+            Yield (name, title) tuples for breadcrumb to name
+        """
+
+        path = [ ]
+
+        for part in name.split('/'):
+            path.append(part)
+
+            yield '/'.join(path), part
+
+    def tiles_url (self, name, **query):
+        """
+            Return a tileserver URL.
+        """
+
+        url = self.tileserver
+
+        if name:
+            url += name
+
+        if query:
+            url += '?' + django.utils.http.urlencode(query)
+
+        return url
+
+STORE = Store(
+    # PNGTileStore
+    image_root  = settings.QMSK_PNGTILE_ROOT,
+    
+    # Store
+    tileserver  = settings.QMSK_PNGTILE_SERVER,
+)