private boolean within = false;// 被包含
@Override
protected int inner2innerDim(Geometry g1, Geometry g2) {
LineString l1 = (LineString) g1;
Ring r2 = ((Polygon) g2).getShell();
// 线和环边界分离
if (im.get(Inner, Border) == EmptyDim
&& im.get(Border, Border) == EmptyDim) {
if (r2.containIn(l1.firstPoint())) {
within = true;
return LineDim;
}
return EmptyDim;
}
// 是否有十字交叉
if (_hasCross(r2,l1)) {
cross = true;
return LineDim;
}
// 用自己的折点将线串打断
CoordSeqEditor tLine = new CoordSeqEditor(l1.getPoints());
for (int i = 0, n = r2.size(); i < n; i++) {
CPoint p = r2.getPoint(i);
tLine.tryInsertPoint(p);
}
// 片段在里面
for (int i = 0, n = tLine.size() - 1; i < n; i++) {
LineSegment lseg = tLine.getLineSegment(i);
CPoint mp = lseg.getMiddlePoint();
if (r2.containIn(mp) && !r2.onLineString(mp)) {
return LineDim;
}
}
return EmptyDim;
}