This is an automated email from the git hooks/post-receive script. sebastic pushed a commit to branch master in repository tilestache.
commit 4f62fef75b24de02cfbaf7af73283106832e05f6 Author: Bas Couwenberg <sebas...@xs4all.nl> Date: Mon Oct 17 08:30:29 2016 +0200 Imported Upstream version 1.49.11 --- PKG-INFO | 2 +- TileStache/Core.py | 2 ++ TileStache/Providers.py | 49 ++++++++++++++++++++++++++++++++++++++----- TileStache/VERSION | 2 +- TileStache/Vector/__init__.py | 2 +- TileStache/__init__.py | 8 +++---- doc/TileStache.Providers.html | 16 +++++++++++--- doc/TileStache.html | 4 ++-- doc/index.html | 14 ++++++++++++- 9 files changed, 81 insertions(+), 18 deletions(-) diff --git a/PKG-INFO b/PKG-INFO index 3203a25..cf8cbe7 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: TileStache -Version: 1.49.10 +Version: 1.49.11 Summary: A stylish alternative for caching your map tiles. Home-page: http://tilestache.org Author: Michal Migurski diff --git a/TileStache/Core.py b/TileStache/Core.py index f9be3cc..c89eee7 100644 --- a/TileStache/Core.py +++ b/TileStache/Core.py @@ -655,6 +655,8 @@ class Layer: if palette256 is not None: self.palette256 = bool(palette256) + else: + self.palette256 = None class KnownUnknown(Exception): """ There are known unknowns. That is to say, there are things that we now know we don't know. diff --git a/TileStache/Providers.py b/TileStache/Providers.py index 8cc7b6d..0d309e7 100644 --- a/TileStache/Providers.py +++ b/TileStache/Providers.py @@ -200,8 +200,12 @@ class Proxy: Provider name string from Modest Maps built-ins. See ModestMaps.builtinProviders.keys() for a list. Example: "OPENSTREETMAP". + - timeout (optional) + Defines a timeout in seconds for the request. + If not defined, the global default timeout setting will be used. - One of the above is required. When both are present, url wins. + + Either url or provider is required. When both are present, url wins. Example configuration: @@ -210,7 +214,7 @@ class Proxy: "url": "http://tile.openstreetmap.org/{Z}/{X}/{Y}.png" } """ - def __init__(self, layer, url=None, provider_name=None): + def __init__(self, layer, url=None, provider_name=None, timeout=None): """ Initialize Proxy provider with layer and url. """ if url: @@ -225,6 +229,8 @@ class Proxy: else: raise Exception('Missing required url or provider parameter to Proxy provider') + self.timeout = timeout + @staticmethod def prepareKeywordArgs(config_dict): """ Convert configured parameters to keyword args for __init__(). @@ -237,6 +243,9 @@ class Proxy: if 'provider' in config_dict: kwargs['provider_name'] = config_dict['provider'] + if 'timeout' in config_dict: + kwargs['timeout'] = config_dict['timeout'] + return kwargs def renderTile(self, width, height, srs, coord): @@ -245,8 +254,12 @@ class Proxy: img = None urls = self.provider.getTileUrls(coord) + # Explicitly tell urllib2 to get no proxies + proxy_support = urllib2.ProxyHandler({}) + url_opener = urllib2.build_opener(proxy_support) + for url in urls: - body = urllib.urlopen(url).read() + body = url_opener.open(url, timeout=self.timeout).read() tile = Verbatim(body) if len(urls) == 1: @@ -278,11 +291,18 @@ class UrlTemplate: - referer (optional) String to use in the "Referer" header when making HTTP requests. + - source projection (optional) + Projection to transform coordinates into before making request + - timeout (optional) + Defines a timeout in seconds for the request. + If not defined, the global default timeout setting will be used. + More on string substitutions: - http://docs.python.org/library/string.html#template-strings """ - def __init__(self, layer, template, referer=None): + def __init__(self, layer, template, referer=None, source_projection=None, + timeout=None): """ Initialize a UrlTemplate provider with layer and template string. http://docs.python.org/library/string.html#template-strings @@ -290,6 +310,8 @@ class UrlTemplate: self.layer = layer self.template = Template(template) self.referer = referer + self.source_projection = source_projection + self.timeout = timeout @staticmethod def prepareKeywordArgs(config_dict): @@ -300,6 +322,12 @@ class UrlTemplate: if 'referer' in config_dict: kwargs['referer'] = config_dict['referer'] + if 'source projection' in config_dict: + kwargs['source_projection'] = Geography.getProjectionByName(config_dict['source projection']) + + if 'timeout' in config_dict: + kwargs['timeout'] = config_dict['timeout'] + return kwargs def renderArea(self, width, height, srs, xmin, ymin, xmax, ymax, zoom): @@ -307,6 +335,17 @@ class UrlTemplate: Each argument (width, height, etc.) is substituted into the template. """ + if self.source_projection is not None: + ne_location = self.layer.projection.projLocation(Point(xmax, ymax)) + ne_point = self.source_projection.locationProj(ne_location) + ymax = ne_point.y + xmax = ne_point.x + sw_location = self.layer.projection.projLocation(Point(xmin, ymin)) + sw_point = self.source_projection.locationProj(sw_location) + ymin = sw_point.y + xmin = sw_point.x + srs = self.source_projection.srs + mapping = {'width': width, 'height': height, 'srs': srs, 'zoom': zoom} mapping.update({'xmin': xmin, 'ymin': ymin, 'xmax': xmax, 'ymax': ymax}) @@ -316,7 +355,7 @@ class UrlTemplate: if self.referer: req.add_header('Referer', self.referer) - body = urllib2.urlopen(req).read() + body = urllib2.urlopen(req, timeout=self.timeout).read() tile = Verbatim(body) return tile diff --git a/TileStache/VERSION b/TileStache/VERSION index 300ca1e..041c636 100644 --- a/TileStache/VERSION +++ b/TileStache/VERSION @@ -1 +1 @@ -1.49.10 +1.49.11 diff --git a/TileStache/Vector/__init__.py b/TileStache/Vector/__init__.py index 9ed0d49..6ab0b08 100644 --- a/TileStache/Vector/__init__.py +++ b/TileStache/Vector/__init__.py @@ -450,7 +450,7 @@ def _open_layer(driver_name, parameters, dirpath): layer = datasource.GetLayer(0) if layer.GetSpatialRef() is None and driver_name != 'SQLite': - raise KnownUnknown('Couldn\'t get a layer from data source %s' % source_name) + raise KnownUnknown('The layer has no spatial reference: %s' % source_name) # # Return the layer and the datasource. diff --git a/TileStache/__init__.py b/TileStache/__init__.py index b1a519b..2375b4b 100644 --- a/TileStache/__init__.py +++ b/TileStache/__init__.py @@ -224,9 +224,6 @@ def requestHandler2(config_hint, path_info, query_string=None, script_name=''): except KeyError: callback = None - if layer.allowed_origin: - headers.setdefault('Access-Control-Allow-Origin', layer.allowed_origin) - # # Special case for index page. # @@ -255,7 +252,10 @@ def requestHandler2(config_hint, path_info, query_string=None, script_name=''): else: status_code, headers, content = layer.getTileResponse(coord, extension) - + + if layer.allowed_origin: + headers.setdefault('Access-Control-Allow-Origin', layer.allowed_origin) + if callback and 'json' in headers['Content-Type']: headers['Content-Type'] = 'application/javascript; charset=utf-8' content = '%s(%s)' % (callback, content) diff --git a/doc/TileStache.Providers.html b/doc/TileStache.Providers.html index 168a443..7e637eb 100644 --- a/doc/TileStache.Providers.html +++ b/doc/TileStache.Providers.html @@ -126,8 +126,12 @@ Additional arguments:<br> Provider name string from Modest Maps built-ins.<br> See ModestMaps.builtinProviders.keys() for a list.<br> Example: "OPENSTREETMAP".<br> +- timeout (optional)<br> + Defines a timeout in seconds for the request.<br> + If not defined, the global default timeout setting will be used.<br> <br> -One of the above is required. When both are present, url wins.<br> + <br> +Either url or provider is required. When both are present, url wins.<br> <br> Example configuration:<br> <br> @@ -137,7 +141,7 @@ Example configuration:<br> }<br> </tt></td></tr> <tr><td> </td> <td width="100%">Methods defined here:<br> -<dl><dt><a name="Proxy-__init__"><strong>__init__</strong></a>(self, layer, url<font color="#909090">=None</font>, provider_name<font color="#909090">=None</font>)</dt><dd><tt>Initialize <a href="#Proxy">Proxy</a> provider with layer and url.</tt></dd></dl> +<dl><dt><a name="Proxy-__init__"><strong>__init__</strong></a>(self, layer, url<font color="#909090">=None</font>, provider_name<font color="#909090">=None</font>, timeout<font color="#909090">=None</font>)</dt><dd><tt>Initialize <a href="#Proxy">Proxy</a> provider with layer and url.</tt></dd></dl> <dl><dt><a name="Proxy-renderTile"><strong>renderTile</strong></a>(self, width, height, srs, coord)</dt></dl> @@ -164,11 +168,17 @@ Additional arguments:<br> - referer (optional)<br> String to use in the "Referer" header when making HTTP requests.<br> <br> +- source projection (optional)<br> + Projection to transform coordinates into before making request<br> +- timeout (optional)<br> + Defines a timeout in seconds for the request.<br> + If not defined, the global default timeout setting will be used.<br> + <br> More on string substitutions:<br> - <a href="http://docs.python.org/library/string.html#template-strings">http://docs.python.org/library/string.html#template-strings</a><br> </tt></td></tr> <tr><td> </td> <td width="100%">Methods defined here:<br> -<dl><dt><a name="UrlTemplate-__init__"><strong>__init__</strong></a>(self, layer, template, referer<font color="#909090">=None</font>)</dt><dd><tt>Initialize a <a href="#UrlTemplate">UrlTemplate</a> provider with layer and template string.<br> +<dl><dt><a name="UrlTemplate-__init__"><strong>__init__</strong></a>(self, layer, template, referer<font color="#909090">=None</font>, source_projection<font color="#909090">=None</font>, timeout<font color="#909090">=None</font>)</dt><dd><tt>Initialize a <a href="#UrlTemplate">UrlTemplate</a> provider with layer and template string.<br> <br> <a href="http://docs.python.org/library/string.html#template-strings">http://docs.python.org/library/string.html#template-strings</a></tt></dd></dl> diff --git a/doc/TileStache.html b/doc/TileStache.html index 1cc721a..0561bf0 100644 --- a/doc/TileStache.html +++ b/doc/TileStache.html @@ -6,7 +6,7 @@ <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> <tr bgcolor="#7799ee"> <td valign=bottom> <br> -<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>TileStache</strong></big></big> (version 1.49.10)</font></td +<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>TileStache</strong></big></big> (version 1.49.11)</font></td ><td align=right valign=bottom ><font color="#ffffff" face="helvetica, arial"><a >href=".">index</a></font></td></tr></table> <p><tt>A stylish alternative for caching your map tiles.<br> @@ -190,6 +190,6 @@ Fractions of a second may be present if <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr> <tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td> -<td width="100%"><strong>__version__</strong> = '1.49.10'<br> +<td width="100%"><strong>__version__</strong> = '1.49.11'<br> <strong>stdout</strong> = <open file '<stdout>', mode 'w'></td></tr></table> </body></html> \ No newline at end of file diff --git a/doc/index.html b/doc/index.html index 2a2a83c..1472da6 100644 --- a/doc/index.html +++ b/doc/index.html @@ -76,7 +76,7 @@ </p> <p> - <strong>This document covers TileStache version 1.49.10</strong>. + <strong>This document covers TileStache version 1.49.11</strong>. </p> <p> @@ -1082,6 +1082,10 @@ Proxy provider parameters: <code>ModestMaps.builtinProviders.keys()</code> for a list. Example: <samp>"OPENSTREETMAP"</samp>. </dd> + <dt>timeout</dt> + Defines a timeout in seconds for the request. + If not defined, the global default timeout setting will be used. + </dd> </dl> <p> @@ -1312,6 +1316,14 @@ UrlTemplate provider parameters: Some WMS servers use the Referer request header to authenticate requests; this parameter provides one. </dd> + <dt>source projection</dt> + Names a geographic projection, explained in <a href="#projections">Projections</a>, that + coordinates should be transformed to for requests. + </dd> + <dt>timeout</dt> + Defines a timeout in seconds for the request. + If not defined, the global default timeout setting will be used. + </dd> </dl> <p> -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/tilestache.git _______________________________________________ Pkg-grass-devel mailing list Pkg-grass-devel@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel