From c7f64bc7e063c4a2640285cf09d779ed4712440c Mon Sep 17 00:00:00 2001 From: Galvanic Date: Wed, 6 Aug 2014 20:31:29 +0100 Subject: [PATCH 1/6] Change Stamen BaseProvider to take a tile_format, default to 'png'. Terrain and Watercolor are now jpg while Toner stays png. This corresponds to what is said on the website: http://maps.stamen.com/ --- ModestMaps/Stamen.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ModestMaps/Stamen.py b/ModestMaps/Stamen.py index 11bc977..57b942d 100644 --- a/ModestMaps/Stamen.py +++ b/ModestMaps/Stamen.py @@ -9,11 +9,11 @@ >>> p = TerrainProvider() >>> p.getTileUrls(Coordinate(25322, 10507, 16)) #doctest: +ELLIPSIS -('http://tile.stamen.com/terrain/16/10507/25322.png',) +('http://tile.stamen.com/terrain/16/10507/25322.jpg',) >>> p = WatercolorProvider() >>> p.getTileUrls(Coordinate(25322, 10507, 16)) #doctest: +ELLIPSIS -('http://tile.stamen.com/watercolor/16/10507/25322.png',) +('http://tile.stamen.com/watercolor/16/10507/25322.jpg',) """ from math import pi @@ -25,12 +25,13 @@ import random, Tiles class BaseProvider(IMapProvider): - def __init__(self, style): + def __init__(self, style, tile_format='png'): # the spherical mercator world tile covers (-π, -π) to (π, π) t = deriveTransformation(-pi, pi, 0, 0, pi, pi, 1, 0, -pi, -pi, 0, 1) self.projection = MercatorProjection(0, t) self.style = style + self.tile_format = tile_format def tileWidth(self): return 256 @@ -40,7 +41,7 @@ def tileHeight(self): def getTileUrls(self, coordinate): zoom, column, row = coordinate.zoom, coordinate.column, coordinate.row - return ('http://tile.stamen.com/%s/%d/%d/%d.png' % (self.style, zoom, column, row),) + return ('http://tile.stamen.com/%s/%d/%d/%d.%s' % (self.style, zoom, column, row, self.tile_format),) class TonerProvider(BaseProvider): def __init__(self): @@ -48,11 +49,11 @@ def __init__(self): class TerrainProvider(BaseProvider): def __init__(self): - BaseProvider.__init__(self, 'terrain') + BaseProvider.__init__(self, 'terrain', 'jpg') class WatercolorProvider(BaseProvider): def __init__(self): - BaseProvider.__init__(self, 'watercolor') + BaseProvider.__init__(self, 'watercolor', 'jpg') if __name__ == '__main__': import doctest From 4d4df8f8993d19f67e6ec24590301cee7e8c1cc4 Mon Sep 17 00:00:00 2001 From: Galvanic Date: Wed, 6 Aug 2014 20:41:58 +0100 Subject: [PATCH 2/6] Add TonerHybridProvider flavor. --- ModestMaps/Stamen.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ModestMaps/Stamen.py b/ModestMaps/Stamen.py index 57b942d..5892208 100644 --- a/ModestMaps/Stamen.py +++ b/ModestMaps/Stamen.py @@ -14,6 +14,10 @@ >>> p = WatercolorProvider() >>> p.getTileUrls(Coordinate(25322, 10507, 16)) #doctest: +ELLIPSIS ('http://tile.stamen.com/watercolor/16/10507/25322.jpg',) + +>>> p = TonerHybridProvider() +>>> p.getTileUrls(Coordinate(25322, 10507, 16)) #doctest: +ELLIPSIS +('http://tile.stamen.com/toner-hybrid/16/10507/25322.png',) """ from math import pi @@ -55,6 +59,10 @@ class WatercolorProvider(BaseProvider): def __init__(self): BaseProvider.__init__(self, 'watercolor', 'jpg') +class TonerHybridProvider(BaseProvider): + def __init__(self): + BaseProvider.__init__(self, 'toner-hybrid', 'png') + if __name__ == '__main__': import doctest doctest.testmod() From f2e7dbcae9d58fb37262fc58a13af46a2715624b Mon Sep 17 00:00:00 2001 From: Galvanic Date: Wed, 6 Aug 2014 20:44:13 +0100 Subject: [PATCH 3/6] Add TonerLabelsProvider. --- ModestMaps/Stamen.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ModestMaps/Stamen.py b/ModestMaps/Stamen.py index 5892208..0066afa 100644 --- a/ModestMaps/Stamen.py +++ b/ModestMaps/Stamen.py @@ -18,6 +18,10 @@ >>> p = TonerHybridProvider() >>> p.getTileUrls(Coordinate(25322, 10507, 16)) #doctest: +ELLIPSIS ('http://tile.stamen.com/toner-hybrid/16/10507/25322.png',) + +>>> p = TonerLabelsProvider() +>>> p.getTileUrls(Coordinate(25322, 10507, 16)) #doctest: +ELLIPSIS +('http://tile.stamen.com/toner-labels/16/10507/25322.png',) """ from math import pi @@ -63,6 +67,10 @@ class TonerHybridProvider(BaseProvider): def __init__(self): BaseProvider.__init__(self, 'toner-hybrid', 'png') +class TonerLabelsProvider(BaseProvider): + def __init__(self): + BaseProvider.__init__(self, 'toner-labels', 'png') + if __name__ == '__main__': import doctest doctest.testmod() From a27a99f69ade70a9d077500ac65b7cc347da556c Mon Sep 17 00:00:00 2001 From: Galvanic Date: Wed, 6 Aug 2014 20:46:14 +0100 Subject: [PATCH 4/6] Add TonerLinesProvider." --- ModestMaps/Stamen.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ModestMaps/Stamen.py b/ModestMaps/Stamen.py index 0066afa..db00902 100644 --- a/ModestMaps/Stamen.py +++ b/ModestMaps/Stamen.py @@ -22,6 +22,10 @@ >>> p = TonerLabelsProvider() >>> p.getTileUrls(Coordinate(25322, 10507, 16)) #doctest: +ELLIPSIS ('http://tile.stamen.com/toner-labels/16/10507/25322.png',) + +>>> p = TonerLinesProvider() +>>> p.getTileUrls(Coordinate(25322, 10507, 16)) #doctest: +ELLIPSIS +('http://tile.stamen.com/toner-lines/16/10507/25322.png',) """ from math import pi @@ -71,6 +75,10 @@ class TonerLabelsProvider(BaseProvider): def __init__(self): BaseProvider.__init__(self, 'toner-labels', 'png') +class TonerLinesProvider(BaseProvider): + def __init__(self): + BaseProvider.__init__(self, 'toner-lines', 'png') + if __name__ == '__main__': import doctest doctest.testmod() From 534eb96ae909f02be9f893f571d0a8c3ba5ac23f Mon Sep 17 00:00:00 2001 From: Galvanic Date: Wed, 6 Aug 2014 20:47:29 +0100 Subject: [PATCH 5/6] Add TonerBackgroundProvider. --- ModestMaps/Stamen.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ModestMaps/Stamen.py b/ModestMaps/Stamen.py index db00902..1dc52c3 100644 --- a/ModestMaps/Stamen.py +++ b/ModestMaps/Stamen.py @@ -26,6 +26,10 @@ >>> p = TonerLinesProvider() >>> p.getTileUrls(Coordinate(25322, 10507, 16)) #doctest: +ELLIPSIS ('http://tile.stamen.com/toner-lines/16/10507/25322.png',) + +>>> p = TonerBackgroundProvider() +>>> p.getTileUrls(Coordinate(25322, 10507, 16)) #doctest: +ELLIPSIS +('http://tile.stamen.com/toner-background/16/10507/25322.png',) """ from math import pi @@ -79,6 +83,10 @@ class TonerLinesProvider(BaseProvider): def __init__(self): BaseProvider.__init__(self, 'toner-lines', 'png') +class TonerBackgroundProvider(BaseProvider): + def __init__(self): + BaseProvider.__init__(self, 'toner-background', 'png') + if __name__ == '__main__': import doctest doctest.testmod() From f2122dd1c08aa86031e35c376a22c19503f5dd97 Mon Sep 17 00:00:00 2001 From: Galvanic Date: Wed, 6 Aug 2014 20:48:47 +0100 Subject: [PATCH 6/6] Add TonerLiteProvider. --- ModestMaps/Stamen.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ModestMaps/Stamen.py b/ModestMaps/Stamen.py index 1dc52c3..bc2f3ac 100644 --- a/ModestMaps/Stamen.py +++ b/ModestMaps/Stamen.py @@ -30,6 +30,10 @@ >>> p = TonerBackgroundProvider() >>> p.getTileUrls(Coordinate(25322, 10507, 16)) #doctest: +ELLIPSIS ('http://tile.stamen.com/toner-background/16/10507/25322.png',) + +>>> p = TonerLiteProvider() +>>> p.getTileUrls(Coordinate(25322, 10507, 16)) #doctest: +ELLIPSIS +('http://tile.stamen.com/toner-lite/16/10507/25322.png',) """ from math import pi @@ -87,6 +91,10 @@ class TonerBackgroundProvider(BaseProvider): def __init__(self): BaseProvider.__init__(self, 'toner-background', 'png') +class TonerLiteProvider(BaseProvider): + def __init__(self): + BaseProvider.__init__(self, 'toner-lite', 'png') + if __name__ == '__main__': import doctest doctest.testmod()