getZoomlevelRangeWay method

ZoomlevelRange? getZoomlevelRangeWay(
  1. Waypath waypath,
  2. ITagCollection tags
)

Returns the widest possible zoomrange which may accept the given argument. Returns null if if the argument will never accepted.

Implementation

ZoomlevelRange? getZoomlevelRangeWay(Waypath waypath, ITagCollection tags) {
  bool isClosedWay = waypath.isClosedWay();
  ZoomlevelRange? result = isClosedWay ? closedWayMatchingCache[tags] : openWayMatchingCache[tags];
  if (result != null) {
    if (result == const ZoomlevelRange.none()) return null;
    return result;
  }
  //    ZoomlevelRange? result;
  for (var rule in rulesList) {
    ZoomlevelRange? range = isClosedWay ? rule.getZoomlevelRangeClosedWay(tags) : rule.getZoomlevelRangeOpenWay(tags);
    if (range != null) {
      result = result?.widenTo(range) ?? range;
    }
  }
  if (isClosedWay) {
    closedWayMatchingCache[tags] = result ?? const ZoomlevelRange.none();
  } else {
    openWayMatchingCache[tags] = result ?? const ZoomlevelRange.none();
  }
  return result;
}