return ml2.get(0);
}
public static List<CoordinateSeq> splitLine(CoordinateSeq points, CPoint p)
{
CoordinateSeq lineString = (CoordinateSeq)points.clone();
if (!LineAlgorithm.onLineString(points, p))
{
return new ArrayList<CoordinateSeq>();
}
if (onBorder(lineString, p))
{
List<CoordinateSeq> lines = new ArrayList<CoordinateSeq>();
lines.add(points);
return lines;
}
// 分裂
List<CPoint> points1 = new ArrayList<CPoint>();
List<CPoint> points2 = new ArrayList<CPoint>();
for (int i = 0, n = points.size() - 1; i < n; i++)
{
LineSegment lseg = new LineSegment(points.getCoordinate(i), points.getCoordinate(i+1));
if (lseg.onLineSegment(p))
{
List<CPoint> tpoints = subList(points, 0, i + 1);
points1.addAll(tpoints);
points1.add(p);
if (!lseg.onBorder(p))
{
points2.add(p);
}
List<CPoint> tpoints2 = subList(points, i + 1, n + 1);
points2.addAll(tpoints2);
break;
}
}
// 构造多线
CoordinateSeq l1 = new CoordinateArray(points1.toArray(new CPoint[0]));
CoordinateSeq l2 = new CoordinateArray(points2.toArray(new CPoint[0]));
List<CoordinateSeq> lines2 = new ArrayList<CoordinateSeq>();
lines2.add(l1);
lines2.add(l2);
return lines2;
//return null;