1
2
3
4
5
6 package org.tailormap.api.geotools.collection;
7
8 import java.util.function.IntConsumer;
9 import org.geotools.data.simple.SimpleFeatureCollection;
10 import org.geotools.data.simple.SimpleFeatureIterator;
11 import org.geotools.feature.collection.DecoratingSimpleFeatureCollection;
12 import org.jspecify.annotations.Nullable;
13
14
15
16
17 public class ProgressReportingFeatureCollection extends DecoratingSimpleFeatureCollection {
18 private final int progressInterval;
19 private final IntConsumer progressCallback;
20
21
22
23
24
25
26
27
28
29
30 public ProgressReportingFeatureCollection(
31 SimpleFeatureCollection delegate, int progressInterval, @Nullable IntConsumer progressCallback) {
32 super(delegate);
33 if (progressInterval <= 0) {
34 throw new IllegalArgumentException("progressInterval must be greater than 0");
35 }
36 this.delegate = delegate;
37 this.progressInterval = progressInterval;
38 this.progressCallback = progressCallback;
39 }
40
41 @Override
42 public SimpleFeatureIterator features() {
43 return new ProgressReportingFeatureIterator(delegate.features(), progressInterval, progressCallback);
44 }
45 }