else if (lines1 != null) {
if (point2 != null) {
// loop through each linesegment and check for the min distance
double minDistance = Double.POSITIVE_INFINITY;
for (int i=0; i<lines1.size(); i++) {
Coordinate c1 = new Coordinate(point2.getRepresentativePoint().getCoordinate());
Coordinate cA = new Coordinate(lines1.get(i).getStartPoint().getCoordinate());
Coordinate cB = new Coordinate(lines1.get(i).getEndPoint().getCoordinate());
double d = CGAlgorithms.distancePointLine(c1, cA, cB);
if ( d < minDistance) {
minDistance = d;
if (minDistance == 0) return 0;
}
}
return minDistance;
}
else if (lines2 != null) {
// loop through each set of linesegments and check for the
// min distance
double minDistance = Double.POSITIVE_INFINITY;
for (int i=0; i<lines1.size(); i++) {
for (int y=0; y<lines2.size(); y++) {
Coordinate A = new Coordinate(lines1.get(i).getStartPoint().getCoordinate());
Coordinate B = new Coordinate(lines1.get(i).getEndPoint().getCoordinate());
Coordinate C = new Coordinate(lines2.get(y).getStartPoint().getCoordinate());
Coordinate D = new Coordinate(lines2.get(y).getEndPoint().getCoordinate());
double d = CGAlgorithms.distanceLineLine(A, B, C, D);
if ( d < minDistance) {
minDistance = d;
if (minDistance == 0) return 0;
}
}
}
return minDistance;
}
}
else if (lines2 != null) {
if (point1 != null) {
// loop through each linesegment and check for the min distance
double minDistance = Double.POSITIVE_INFINITY;
for (int i=0; i<lines2.size(); i++) {
Coordinate c1 = new Coordinate(point1.getRepresentativePoint().getCoordinate());
Coordinate cA = new Coordinate(lines2.get(i).getStartPoint().getCoordinate());
Coordinate cB = new Coordinate(lines2.get(i).getEndPoint().getCoordinate());
double d = CGAlgorithms.distancePointLine(c1, cA, cB);
if ( d < minDistance) {
minDistance = d;
if (minDistance == 0) return 0;
}