def read(self, layer, coord, format): body = Disk.read(self, layer, coord, format) self.signal_land_or_sea(body, layer, coord, format) # we should never get here return body
def read(self, layer, coord, format): """ Read a cached tile. """ fullpath = self._fullpath(layer, coord, format) if not exists(fullpath): return None if os.stat(fullpath).st_size == self.empty_size: raise TheTileLeftANote(status_code=404, emit_content_type=False) return Disk.read(self, layer, coord, format)
def signal_land_or_sea(self, body, layer, coord, format): if body: md5sum = self.md5sum(body) second_md5sum = self.md5sum(Disk.read(self, self.second, coord, format)) headers = Headers([('Access-Control-Expose-Headers', 'X-Land-Or-Sea')]) headers.setdefault('X-Land-Or-Sea', '0') if second_md5sum and md5sum == second_md5sum: if md5sum == self.land_md5: headers['X-Land-Or-Sea'] = '1' elif md5sum == self.sea_md5: headers['X-Land-Or-Sea'] = '2' raise TheTileLeftANote(content=body, headers=headers)