#!/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 # Actual size is 1821 bytes # Last 227 bytes is filling def check_filled(block, lat_int, lon_int, grid_spacing): '''check a block for validity''' if len(block) != IO_BLOCK_SIZE - 227: 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: print("Bad lat/lon: {0}, {1}".format((lat/1E7), (lon/1E7))) return False if spacing != 100: print("Bad spacing: " + str(spacing)) return False if bitmap != (1<<56)-1: print("Bad bitmap") return False block = block[:16] + struct.pack("