cropOutsideWay method
An alternative cropping method that reduces the nodes of a way that are
outside the given boundingBox.
This is a less aggressive optimization than cropWay and is used in specific scenarios.
Implementation
/// outside the given [boundingBox].
///
/// This is a less aggressive optimization than [cropWay] and is used in
/// specific scenarios.
Wayholder? cropOutsideWay(Wayholder wayholder, BoundingBox boundingBox) {
List<Waypath> inner = wayholder.innerRead.map((test) => Waypath(path: _reduceOutside(test, boundingBox))).toList()
..removeWhere((Waypath test) => test.isEmpty);
List<Waypath> closedOuters = wayholder.closedOutersRead.map((test) => Waypath(path: _reduceOutside(test, boundingBox))).toList()
..removeWhere((Waypath test) => test.isEmpty);
List<Waypath> openOuters = wayholder.openOutersRead.map((test) => Waypath(path: _reduceOutside(test, boundingBox))).toList()
..removeWhere((Waypath test) => test.isEmpty);
if (inner.isEmpty && closedOuters.isEmpty && openOuters.isEmpty) return null;
if (closedOuters.isEmpty && openOuters.isEmpty) {
// only inner is set, move the first inner to the respective outer
Waypath waypath = inner.first;
inner.remove(waypath);
if (waypath.isClosedWay()) {
closedOuters.add(waypath);
} else {
openOuters.add(waypath);
}
}
// return a new wayholder instance
Wayholder? result = wayholder.cloneWith(inner: inner, closedOuters: closedOuters, openOuters: openOuters);
return result;
}