nearestLocations method

List<GeometryLocation?>? nearestLocations(
  1. FacetSequence facetSeq
)

Computes the locations of the nearest points between this sequence and another sequence. The locations are presented in the same order as the input sequences.

@return a pair of {@link GeometryLocation}s for the nearest points

Implementation

List<GeometryLocation?>? nearestLocations(FacetSequence facetSeq) {
  bool isPoint = this.isPoint();
  bool isPointOther = facetSeq.isPoint();
  List<GeometryLocation?>? locs = List.filled(2,null,growable: false);

  if (isPoint && isPointOther) {
    Coordinate pt = pts.getCoordinate(start!);
    Coordinate seqPt = facetSeq.pts.getCoordinate(facetSeq.start!);
    locs.add(GeometryLocation(geom!, start!, Coordinate.fromCoordinate(pt)));
    locs.add(GeometryLocation(facetSeq.geom!, facetSeq.start!,
        new Coordinate.fromCoordinate(seqPt)));
  } else if (isPoint) {
    Coordinate pt = pts.getCoordinate(start!);
    computeDistancePointLine(pt, facetSeq, locs);
  } else if (isPointOther) {
    Coordinate seqPt = facetSeq.pts.getCoordinate(facetSeq.start!);
    computeDistancePointLine(seqPt, this, locs);
    // unflip the locations
    GeometryLocation? tmp = locs[0];
    locs[0] = locs[1];
    locs[1] = tmp;
  } else {
    computeDistanceLineLine(facetSeq, locs);
  }
  return locs;
}