[-62.50, 15.70, -58.50, 17.00], ]; public function __construct(private IngestionService $ingestionService) { parent::__construct(); } protected function configure(): void { $this ->addOption('date', 'd', InputOption::VALUE_OPTIONAL, 'Date à traiter (YYYY-MM-DD). Défaut : hier.', null) ->addOption('zone', 'z', InputOption::VALUE_OPTIONAL, 'Zone spécifique. Défaut : toutes les zones.', null) ->addOption('source', 's', InputOption::VALUE_OPTIONAL, 'Source satellite : Sentinel-2, Sentinel-3, ou auto (S2 avec fallback S3)', 'auto'); } protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $dateStr = $input->getOption('date'); $date = $dateStr ? new \DateTimeImmutable($dateStr) : new \DateTimeImmutable('yesterday'); $source = $input->getOption('source'); $zones = self::ZONES; if ($zoneName = $input->getOption('zone')) { if (!isset(self::ZONES[$zoneName])) { $io->error(sprintf( "Zone inconnue : \"%s\". Zones disponibles : %s", $zoneName, implode(', ', array_keys(self::ZONES)) )); return Command::FAILURE; } $zones = [$zoneName => self::ZONES[$zoneName]]; } $io->title(sprintf('Ingestion %s — %s', $source, $date->format('Y-m-d'))); $errors = 0; foreach ($zones as $name => $bbox) { $io->section("Zone : {$name}"); try { if ($source === 'auto') { $this->ingestionService->ingestWithFallback($bbox, $date); } else { $collection = match (strtolower($source)) { 'sentinel-3' => 'sentinel-3-olci', default => 'sentinel-2-l2a', }; $this->ingestionService->ingest($bbox, $date, $source, $collection); } $io->success("OK — {$name}"); } catch (\Throwable $e) { $io->error("ÉCHEC — {$name} : " . $e->getMessage()); $errors++; } } if ($errors > 0) { $io->warning("{$errors} zone(s) en erreur."); } return $errors === 0 ? Command::SUCCESS : Command::FAILURE; } }