}
// The ordered list is for temporarily holding points for
// the current segment as they are placed in the right
// order.
LinkedList orderedList = new LinkedList();
// Everything in the lastSegmentCrossingList has already
// be ordered relative to what's already been searched, so
// we can just add them now to place the new points around
// them accordingly. Also, the lastSegmentCrossingList
// holds BoundaryCrossing objects, and the collection
// passed into this function doesn't have those yet.
orderedList.addAll(lastSegmentCrossingList);
// Clear out the lastSegmetnCrossingList, we'll replenish
// it with the ordered list at the end, so it will be
// ready for the next cycle.
lastSegmentCrossingList.clear();
for (Iterator it = c.iterator(); it.hasNext();) {
Geo current = (Geo) it.next();
double curDist = start.distance(current);
// We just assume that crossing point is going into
// the current region, we'll check later to make sure.
BoundaryCrossing currentBC = new BoundaryCrossing(current, region, true);
int lastCheckedIndex = 0;
BoundaryCrossing lastChecked = null;
for (Iterator it2 = orderedList.iterator(); it2.hasNext(); lastCheckedIndex++) {
lastChecked = (BoundaryCrossing) it2.next();
if (curDist < start.distance(lastChecked.geo)) {
break;
} else {
lastChecked = null;
}
}
if (lastChecked != null) {
orderedList.add(lastCheckedIndex, currentBC);
} else {
orderedList.add(currentBC);
}
}
boolean goinin = !Intersection.isPointInPolygon(start,
region.getPoints());
for (Iterator it = orderedList.iterator(); it.hasNext();) {
BoundaryCrossing bc = (BoundaryCrossing) it.next();
boolean sameRegion = (bc.in == region);
if (sameRegion) {