コード例 #1
0
 def get_legend(self, query):
     if self.static:
         # prevent caching of static legends for different scales
         legend = Legend(id=self.identifier, scale=None)
     else:
         legend = Legend(id=self.identifier, scale=query.scale)
     if not self._cache.load(legend):
         legends = []
         error_occured = False
         for client in self.clients:
             try:
                 legends.append(client.get_legend(query))
             except HTTPClientError as e:
                 error_occured = True
                 log.error(e.args[0])
             except SourceError as e:
                 error_occured = True
                 # TODO errors?
                 log.error(e.args[0])
         format = split_mime_type(query.format)[1]
         legend = Legend(source=concat_legends(legends, format=format),
                         id=self.identifier,
                         scale=query.scale)
         if not error_occured:
             self._cache.store(legend)
     return legend.source
コード例 #2
0
ファイル: wms.py プロジェクト: cedricmoullet/mapproxy
class WMSLegendSource(LegendSource):
    def __init__(self, clients, legend_cache):
        self.clients = clients
        self.identifier = legend_identifier([c.identifier for c in self.clients])
        self._cache = legend_cache
        self._size = None
    
    @property
    def size(self):
        if not self._size:
            legend = self.get_legend(LegendQuery(format='image/png', scale=None))
            # TODO image size without as_image?
            self._size = legend.as_image().size
        return self._size
    
    def get_legend(self, query):
        legend = Legend(id=self.identifier, scale=query.scale)
        if not self._cache.load(legend):
            legends = []
            error_occured = False
            for client in self.clients:
                try:
                    legends.append(client.get_legend(query))
                except HTTPClientError, e:
                    error_occured = True
                    log.error(e.args[0])
                except SourceError, e:
                    error_occured = True
                    # TODO errors?
                    log.error(e.args[0])
            format = split_mime_type(query.format)[1]
            legend = Legend(source=concat_legends(legends, format=format),
                            id=self.identifier, scale=query.scale)
            if not error_occured:
                self._cache.store(legend)
コード例 #3
0
ファイル: wms.py プロジェクト: imclab/mapproxy
 def get_legend(self, query):
     if self.static:
         # prevent caching of static legends for different scales
         legend = Legend(id=self.identifier, scale=None)
     else:
         legend = Legend(id=self.identifier, scale=query.scale)
     if not self._cache.load(legend):
         legends = []
         error_occured = False
         for client in self.clients:
             try:
                 legends.append(client.get_legend(query))
             except HTTPClientError, e:
                 error_occured = True
                 log.error(e.args[0])
             except SourceError, e:
                 error_occured = True
                 # TODO errors?
                 log.error(e.args[0])
コード例 #4
0
ファイル: wms.py プロジェクト: cedricmoullet/mapproxy
 def get_legend(self, query):
     legend = Legend(id=self.identifier, scale=query.scale)
     if not self._cache.load(legend):
         legends = []
         error_occured = False
         for client in self.clients:
             try:
                 legends.append(client.get_legend(query))
             except HTTPClientError, e:
                 error_occured = True
                 log.error(e.args[0])
             except SourceError, e:
                 error_occured = True
                 # TODO errors?
                 log.error(e.args[0])