double FacetSequence::distance(const FacetSequence& facetSeq) const { bool isPointThis = isPoint(); bool isPointOther = facetSeq.isPoint(); double distance; if(isPointThis && isPointOther) { Coordinate pt = pts->getAt(start); Coordinate seqPt = facetSeq.pts->getAt(facetSeq.start); distance = pt.distance(seqPt); } else if(isPointThis) { Coordinate pt = pts->getAt(start); distance = computeDistancePointLine(pt, facetSeq, nullptr); } else if(isPointOther) { Coordinate seqPt = facetSeq.pts->getAt(facetSeq.start); distance = computeDistancePointLine(seqPt, *this, nullptr); } else { distance = computeDistanceLineLine(facetSeq, nullptr); } return distance; }
/* * Rather than get bent out of shape about returning a pointer * just return the whole mess, since it only ends up holding two * locations. */ std::vector<GeometryLocation> FacetSequence::nearestLocations(const FacetSequence& facetSeq) const { Coordinate pt, seqPt; bool isPointThis = isPoint(); bool isPointOther = facetSeq.isPoint(); std::vector<GeometryLocation> locs; if (isPointThis && isPointOther) { pts->getAt(start, pt); facetSeq.pts->getAt(facetSeq.start, seqPt); GeometryLocation gl1(geom, start, pt); GeometryLocation gl2(facetSeq.geom, facetSeq.start, seqPt); } else if (isPointThis) { pts->getAt(start, pt); computeDistancePointLine(pt, facetSeq, &locs); } else if (isPointOther) { facetSeq.pts->getAt(facetSeq.start, seqPt); computeDistancePointLine(seqPt, *this, &locs); // unflip the locations GeometryLocation tmp = locs[0]; locs[0] = locs[1]; locs[1] = tmp; } else { computeDistanceLineLine(facetSeq, &locs); } return locs; }
double FacetSequence::distance(const FacetSequence & facetSeq) const { bool isPointThis = isPoint(); bool isPointOther = facetSeq.isPoint(); if (isPointThis && isPointOther) { Coordinate pt = pts->getAt(start); Coordinate seqPt = facetSeq.pts->getAt(facetSeq.start); return pt.distance(seqPt); } else if (isPointThis) { Coordinate pt = pts->getAt(start); return computePointLineDistance(pt, facetSeq); } else if (isPointOther) { Coordinate seqPt = facetSeq.pts->getAt(facetSeq.start); return computePointLineDistance(seqPt, *this); } return computeLineLineDistance(facetSeq); }