@Override
  public SeekableByteChannel truncate(final long newSize) {
    if (newSize < 0L || newSize > Integer.MAX_VALUE) {
      throw new IllegalArgumentException("Size has to be in range 0.. " + Integer.MAX_VALUE);
    }
    if (size > newSize) {
      size = (int) newSize;
    }
    if (position > newSize) {
      position = (int) newSize;
    }
    return this;
  }
Truncates the entity, to which this channel is connected, to the given size.

<p>
This method violates the contract of {@link SeekableByteChannel#truncate} as it will not throw any exception when
invoked on a closed channel.
</p>

@throws IllegalArgumentException if size is negative or bigger than the maximum of a Java integer
planetiler-core/src/main/java/com/onthegomap/planetiler/util/SeekableInMemoryByteChannel.java