需求:
一个大的区段
有小半径曲线段,复合曲线,平曲线和竖曲线各个不同数量不同长度的多个区段
这些区段可能覆盖,交叉或完全不重叠

求:不与任意特殊区段有关联的多个直线段

公共方法:

public List<ImportSectionVO> filterQd(List<ImportSectionVO> filterList, List<ImportSectionVO> zxdList, String name) {
ImportSectionVO zxd;
ImportSectionVO filter;

for (int i = 0; i < filterList.size(); i++) {
filter = filterList.get(i);
for (int j = zxdList.size() - 1; j >= 0; j--) {
zxd = zxdList.get(j);
if (filter.getEndMile() <= zxd.getStartMile() || filter.getStartMile() >= zxd.getEndMile()) {
continue;
} else if (filter.getStartMile() <= zxd.getStartMile() && filter.getEndMile() >= zxd.getEndMile()) {
zxdList.remove(j);
} else if (filter.getStartMile() >= zxd.getStartMile() && filter.getEndMile() <= zxd.getEndMile()) {
zxdList.remove(j);
zxdList.add(j, new ImportSectionVO(name, zxd.getStartMile(), filter.getStartMile()));
zxdList.add(j + 1, new ImportSectionVO(name, filter.getEndMile(), zxd.getEndMile()));
j += 2;
} else if (filter.getStartMile() > zxd.getStartMile() && filter.getStartMile() < zxd.getEndMile()) {
zxdList.remove(j);
zxdList.add(new ImportSectionVO(name, zxd.getStartMile(), filter.getStartMile()));
j += 1;
} else if (filter.getEndMile() > zxd.getStartMile() && filter.getEndMile() < zxd.getEndMile()) {
zxdList.remove(j);
zxdList.add(new ImportSectionVO(name, filter.getEndMile(), zxd.getEndMile()));
j += 1;
}
}
}

return zxdList;
}

公共方法的应用:

public List<List<ImportSectionVO>> selectXlxx(String xianbie, String xingbie, Double startMile, Double endMile) {
List<List<ImportSectionVO>> res = new ArrayList<>();
// 顺序依次是竖曲线,平曲线,复合曲线,小半径曲线
List<ImportSectionVO> sqx = baseMapper.selectSqx(xianbie,
xingbie,
startMile,
endMile);
List<ImportSectionVO> pqx = baseMapper.selectPqx(xianbie,
xingbie,
startMile,
endMile);
List<ImportSectionVO> fhqx = baseMapper.selectFhqx(xianbie,
xingbie,
startMile,
endMile);
List<ImportSectionVO> xbjqx = baseMapper.selectSmallRadiusSection(xianbie,
xingbie,
startMile,
endMile);

String name = "复合曲线";
fhqx = filterQd(xbjqx, fhqx, name);

name = "平曲线";
pqx = filterQd(xbjqx, pqx, name);
pqx = filterQd(fhqx, pqx, name);

name = "竖曲线";
sqx = filterQd(xbjqx, sqx, name);
sqx = filterQd(fhqx, sqx, name);
sqx = filterQd(pqx, sqx, name);

// 直线段:筛选出所有不是任何特殊区段的区段就是直线段
List<ImportSectionVO> zxd = new ArrayList<>();
name = "直线段";
zxd.add(new ImportSectionVO(name, startMile, endMile));
filterQd(xbjqx, zxd, name);
filterQd(fhqx, zxd, name);
filterQd(pqx, zxd, name);
filterQd(sqx, zxd, name);

res.add(sqx);
res.add(pqx);
res.add(fhqx);
res.add(xbjqx);
res.add(zxd);

return res;
}