Generate simctl location start command.
(points, speed_kmh=60, interval=0.1, distance=None, device="booted")
| 31 | return points |
| 32 | |
| 33 | def generate_simctl_command(points, speed_kmh=60, interval=0.1, distance=None, device="booted"): |
| 34 | """Generate simctl location start command.""" |
| 35 | if len(points) < 2: |
| 36 | raise ValueError("Need at least 2 waypoints for simctl location start") |
| 37 | |
| 38 | # Convert km/h to m/s |
| 39 | speed_mps = speed_kmh / 3.6 |
| 40 | |
| 41 | # Format waypoints as lat,lon pairs |
| 42 | waypoint_strings = [f"{lat:.6f},{lon:.6f}" for lat, lon in points] |
| 43 | |
| 44 | # Build command |
| 45 | cmd = ["xcrun", "simctl", "location", device, "start"] |
| 46 | cmd.append(f"--speed={speed_mps:.2f}") |
| 47 | |
| 48 | if distance: |
| 49 | cmd.append(f"--distance={distance}") |
| 50 | else: |
| 51 | cmd.append(f"--interval={interval}") |
| 52 | |
| 53 | cmd.extend(waypoint_strings) |
| 54 | |
| 55 | return cmd |
| 56 | |
| 57 | def main(): |
| 58 | parser = argparse.ArgumentParser( |