retrieveLabels method

  1. @override
Future<JobResult> retrieveLabels(
  1. Job job
)
override

For mapfiles we can either render everything into the images or render just the basic map and rotate the captions while rotating the map. If supported this method returns the captions to draw each time (maybe rotated)

Implementation

@override
Future<JobResult> retrieveLabels(Job job) async {
  Timing timing = Timing(log: _log, active: true);
  // current performance measurements for isolates indicates that isolates are too slow so it makes no sense to use them currently. Seems
  // we need something like 600ms to start an isolate whereas the whole read-process just needs about 200ms
  RenderContext renderContext = RenderContext(job, renderTheme);
  this.renderTheme.prepareScale(job.tile.zoomLevel);

  DatastoreReadResult? mapReadResult;
  IsolateMapReplyParams params = await _datastoreReader.readLabels(
      datastore, job.tile, renderContext.projection, renderContext);
  mapReadResult = params.result;
  renderContext = params.renderContext;
  timing.lap(100,
      "${mapReadResult?.ways.length} ways and ${mapReadResult?.pointOfInterests.length} pois for labels for tile ${renderContext.job.tile}");
  if (mapReadResult == null) {
    return JobResult(null, JOBRESULT.UNSUPPORTED);
  }
  if ((mapReadResult.ways.length) > 100000) {
    _log.warning(
        "Many ways (${mapReadResult.ways.length}) in this readResult, consider shrinking your mapfile.");
  }

  // unfortunately we need the painter for captions in order to determine the size of the caption. In isolates however we cannot access
  // ui code. We are in an isolate here. We are doomed.
  for (RenderInfo renderInfo in renderContext.labels) {
    await renderInfo.createShapePaint(symbolCache);
  }
  List<RenderInfo<Shape>>? renderInfos = LayerUtil.collisionFreeOrdered(
      renderContext.labels, renderContext.projection);
  // this.labelStore.storeMapItems(
  //     job.tile, renderContext.labels, renderContext.projection);
  timing.lap(100,
      "${renderInfos.length} items from collisionFreeOrdered for labels for tile ${renderContext.job.tile}");
  //_log.info("Executing ${job.toString()} returns ${bitmap.toString()}");
  //_log.info("ways: ${mapReadResult.ways.length}, Areas: ${Area.count}, ShapePaintPolylineContainer: ${ShapePaintPolylineContainer.count}");
  return JobResult(null, JOBRESULT.NORMAL, renderInfos);
}