public function getNearestNeighbor($Xp, $Yp)
    {
        $Nearest = UNKNOWN;
        for ($X = 0; $X <= $this->GridSizeX; $X++) {
            for ($Y = 0; $Y <= $this->GridSizeY; $Y++) {
                if ($this->Points[$X][$Y] != UNKNOWN && $this->Points[$X][$Y] != IGNORED) {
                    $DistanceX = max($Xp, $X) - min($Xp, $X);
                    $DistanceY = max($Yp, $Y) - min($Yp, $Y);
                    $Distance = max($DistanceX, $DistanceY);
                    if ($Distance < $Nearest || $Nearest == UNKNOWN) {
                        $Nearest = $Distance;
                    }
                }
            }
        }
        return $Nearest;
    }