1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
// 1. 质检引擎主类
public class QualityInspectionEngine {
private ConfigManager configManager;
private DataAdapter dataAdapter;
private ResultProcessor resultProcessor;
public void execute(String configPath) throws Exception {
// 加载配置
List<QCLayerConfig> layers = configManager.loadConfig(configPath);
// 遍历所有图层
for (QCLayerConfig layerConfig : layers) {
processLayer(layerConfig);
}
// 生成最终报告
resultProcessor.generateReport();
}
private void processLayer(QCLayerConfig layerConfig) {
// 创建空间索引上下文
QCContext context = new QCContext();
try (FeatureIterator features = dataAdapter.getFeatures(layerConfig)) {
// 构建空间索引(用于跨要素检查)
STRtree spatialIndex = buildSpatialIndex(features);
context.addSpatialIndex(layerConfig.getName(), spatialIndex);
// 分页处理要素(示例:每页500条)
int pageSize = 500;
FeatureCollection collection = dataAdapter.getFeaturesByPage(layerConfig, pageSize);
while (!collection.isEmpty()) {
// 执行当前页的质检
processFeatureCollection(layerConfig, collection, context);
// 获取下一页
collection = dataAdapter.getNextPage();
}
}
}
private void processFeatureCollection(QCLayerConfig layerConfig,
FeatureCollection features,
QCContext context) {
try (FeatureIterator it = features.features()) {
while (it.hasNext()) {
Feature feature = it.next();
// 遍历该图层的所有检查项
for (CheckItem check : layerConfig.getChecks()) {
QualityChecker checker = CheckerFactory.createChecker(check.getType());
// 执行检查并收集结果
List<QualityError> errors = checker.execute(layerConfig, feature, context);
// 处理检查结果
resultProcessor.handleErrors(layerConfig.getName(), feature.getID(), errors);
}
}
}
}
// 空间索引构建(使用JTS STRtree)
private STRtree buildSpatialIndex(FeatureIterator features) {
STRtree index = new STRtree();
while (features.hasNext()) {
Feature f = features.next();
Geometry geom = (Geometry) f.getDefaultGeometryProperty().getValue();
index.insert(geom.getEnvelopeInternal(), f);
}
index.build();
return index;
}
}
|
Preview: