public static void fetch(OsmInputFile infile, Path outfile, PlanetilerConfig config, Profile profile, Stats stats,
    Duration maxAge, int updateLimit) {

    var timer = stats.startStage("wikidata");
    int processThreads = Math.max(1, config.threads() - 1);
    LOGGER.info("Starting with {} process threads", processThreads);

    WikidataTranslations oldMappings = load(outfile, maxAge, updateLimit);
    try (
      Writer writer = Files.newBufferedWriter(outfile);
      OsmBlockSource osmSource = infile.get()
    ) {
      HttpClient client = HttpClient.newBuilder().connectTimeout(config.httpTimeout()).build();
      Wikidata fetcher = new Wikidata(writer, Client.wrap(client), 5_000, profile, config);
      fetcher.loadExisting(oldMappings);

      String pbfParsePrefix = "pbfwikidata";
      var pipeline = WorkerPipeline.start("wikidata", stats)
        .fromGenerator("pbf", osmSource::forEachBlock)
        .addBuffer("pbf_blocks", processThreads * 2)
        .addWorker("filter", processThreads, fetcher::filter)
        .addBuffer("fetch_queue", 1_000_000, 100)
        .sinkTo("fetch", 1, prev -> {
          for (Long id : prev) {
            fetcher.fetch(id);
          }
          fetcher.flush();
        });

      ProgressLoggers loggers = ProgressLoggers.create()
        .addRateCounter("blocks", fetcher.blocks)
        .addRateCounter("nodes", fetcher.nodes, true)
        .addRateCounter("ways", fetcher.ways, true)
        .addRateCounter("rels", fetcher.rels, true)
        .addRateCounter("wiki", fetcher.wikidatas)
        .addFileSize(outfile)
        .newLine()
        .addProcessStats()
        .newLine()
        .addThreadPoolStats("parse", pbfParsePrefix + "-pool")
        .addPipelineStats(pipeline);

      pipeline.awaitAndLog(loggers, config.logInterval());
      LOGGER.info("DONE fetched: {}", fetcher.wikidatas.get());
    } catch (IOException e) {
      throw new UncheckedIOException(e);
    }

    timer.stop();
  }
Loads any existing translations from {@code outfile}, then downloads translations for any wikidata element in
{@code infile} that have not already been downloaded and writes the results to {@code outfile}.

@throws UncheckedIOException if an error occurs
planetiler-core/src/main/java/com/onthegomap/planetiler/util/Wikidata.java