示例#1
0
 def get_map(self, query):
     if self.res_range and not self.res_range.contains(query.bbox, query.size,
                                                       query.srs):
         raise BlankImage()
     if self.coverage and not self.coverage.intersects(query.bbox, query.srs):
         raise BlankImage()
     
     try:
         resp = self.render(query)
     except RuntimeError, ex:
         log.error('could not render Mapnik map: %s', ex)
         reraise_exception(SourceError(ex.args[0]), sys.exc_info())
示例#2
0
 def _get_sub_query(self, query, format):
     size, offset, bbox = bbox_position_in_image(query.bbox, query.size, self.extent.bbox_for(query.srs))
     if size[0] == 0 or size[1] == 0:
         raise BlankImage()
     src_query = MapQuery(bbox, size, query.srs, format)
     resp = self.client.retrieve(src_query, format)
     return SubImageSource(resp, size=query.size, offset=offset, image_opts=self.image_opts)
示例#3
0
 def get_map(self, query):
     if self.res_range and not self.res_range.contains(query.bbox, query.size,
                                                       query.srs):
         raise BlankImage()
     if self.coverage and not self.coverage.intersects(query.bbox, query.srs):
         raise BlankImage()
     try:
         resp = self._get_map(query)
         if self.transparent_color:
             resp = make_transparent(resp, self.transparent_color,
                                     self.transparent_color_tolerance)
         resp.opacity = self.opacity
         return resp
         
     except HTTPClientError, e:
         log.warn('could not retrieve WMS map: %s', e)
         reraise_exception(SourceError(e.args[0]), sys.exc_info())
示例#4
0
    def get_map(self, query):
        if self.grid.tile_size != query.size:
            ex = InvalidSourceQuery(
                'tile size of cache and tile source do not match: %s != %s' %
                (self.grid.tile_size, query.size))
            log_config.error(ex)
            raise ex

        if self.grid.srs != query.srs:
            ex = InvalidSourceQuery(
                'SRS of cache and tile source do not match: %r != %r' %
                (self.grid.srs, query.srs))
            log_config.error(ex)
            raise ex

        if self.res_range and not self.res_range.contains(
                query.bbox, query.size, query.srs):
            raise BlankImage()
        if self.coverage and not self.coverage.intersects(
                query.bbox, query.srs):
            raise BlankImage()

        _bbox, grid, tiles = self.grid.get_affected_tiles(
            query.bbox, query.size)

        if grid != (1, 1):
            raise InvalidSourceQuery('BBOX does not align to tile')

        tile_coord = next(tiles)

        try:
            return self.client.get_tile(tile_coord, format=query.format)
        except HTTPClientError as e:
            if self.error_handler:
                resp = self.error_handler.handle(e.response_code, query)
                if resp:
                    return resp
            log.warn('could not retrieve tile: %s', e)
            reraise_exception(SourceError(e.args[0]), sys.exc_info())
示例#5
0
 def get_map(self, query):
     raise BlankImage()
示例#6
0
 def contains(self, bbox, srs):
     if srs != SRS(3857):
         if not is_valid_transformation(bbox, srs, SRS(3857)):
             raise BlankImage()
     return True