#!/usr/bin/env python3 # /// script # requires-python = ">=3.9" # dependencies = ["matplotlib", "shapely"] # /// """Plot country polygons from a Vanetza country data binary file.""" import argparse import colorsys import struct import sys import matplotlib.pyplot as plt from shapely import wkb EXPECTED_FORMAT_VERSION = 1 def main(): parser = argparse.ArgumentParser(description="Plot country polygons from .bin file") parser.add_argument("input", help="Path to country_data.bin") args = parser.parse_args() fig, ax = plt.subplots(figsize=(16, 8)) with open(args.input, "rb") as f: data = f.read() if len(data) < 2: print("Error: file too short to contain version header", file=sys.stderr) sys.exit(1) version, = struct.unpack_from(" 1.0: centroid = polygon.centroid ax.text(centroid.x, centroid.y, str(m49), fontsize=5, ha="center", va="center") ax.set_aspect("equal") ax.set_xlabel("Longitude") ax.set_ylabel("Latitude") ax.set_title("Country Polygons") plt.tight_layout() plt.show() if __name__ == "__main__": main()