OutputCollector<Text,VectorWritable> collector,
Reporter reporter) throws IOException {
double minDist = Double.MAX_VALUE;
Canopy closest = null;
boolean isCovered = false;
VectorWritable vw = new VectorWritable();
for (Canopy canopy : canopies) {
double dist = measure.distance(canopy.getCenter().getLengthSquared(), canopy.getCenter(), point);
if (dist < t1) {
isCovered = true;
vw.set(point);
collector.collect(new Text(canopy.getIdentifier()), vw);
reporter.setStatus("Emit Canopy ID:" + canopy.getIdentifier());
} else if (dist < minDist) {
minDist = dist;
closest = canopy;
}
}
// if the point is not contained in any canopies (due to canopy centroid
// clustering), emit the point to the closest covering canopy.
vw.set(point);
if (!isCovered) {
collector.collect(new Text(closest.getIdentifier()), vw);
reporter.setStatus("Emit Closest Canopy ID:" + closest.getIdentifier());
}
}