#!/usr/bin/env python ''' Check a set of terrain files for corruption ''' import os #from multiprocessing import Pool from multiprocessing.pool import ThreadPool import argparse import time import gzip import shutil import struct import crc16 from terrain_gen import TERRAIN_GRID_BLOCK_SIZE_Y, east_blocks, IO_BLOCK_SIZE, TERRAIN_GRID_FORMAT_VERSION, GridBlock # IO block size is 2048 # CRC the last 1821 bytes of this # Last 22 bytes is the header def check_filled(block, lat_int, lon_int, grid_spacing): '''check a block for validity''' if len(block) != IO_BLOCK_SIZE: print("Bad size {0} of {1}".format(len(block), IO_BLOCK_SIZE)) return False (bitmap, lat, lon, crc, version, spacing) = struct.unpack(" 2 or abs(lon_int - (lon/1E7)) > 2 or spacing != 100 or bitmap != (1<<56)-1): print("Bad fields") return False block = block[:16] + struct.pack("