public function computeMissing()
    {
        $Missing = [];
        for ($X = 0; $X <= $this->GridSizeX; $X++) {
            for ($Y = 0; $Y <= $this->GridSizeY; $Y++) {
                if ($this->Points[$X][$Y] == UNKNOWN) {
                    $Missing[] = $X . "," . $Y;
                }
            }
        }
        shuffle($Missing);

        foreach ($Missing as $Pos) {
            $Pos = preg_split("/,/", $Pos);
            $X = $Pos[0];
            $Y = $Pos[1];

            if ($this->Points[$X][$Y] == UNKNOWN) {
                $NearestNeighbor = $this->getNearestNeighbor($X, $Y);

                $Value = 0;
                $Points = 0;
                for ($Xi = $X - $NearestNeighbor; $Xi <= $X + $NearestNeighbor; $Xi++) {
                    for ($Yi = $Y - $NearestNeighbor; $Yi <= $Y + $NearestNeighbor; $Yi++) {
                        if ($Xi >= 0
                            && $Yi >= 0
                            && $Xi <= $this->GridSizeX
                            && $Yi <= $this->GridSizeY
                            && $this->Points[$Xi][$Yi] != UNKNOWN
                            && $this->Points[$Xi][$Yi] != IGNORED
                        ) {
                            $Value = $Value + $this->Points[$Xi][$Yi];
                            $Points++;
                        }
                    }
                }

                if ($Points != 0) {
                    $this->Points[$X][$Y] = $Value / $Points;
                }
            }
        }
    }
public function computeMissing()
    {
        $Missing = [];
        for ($X = 0; $X <= $this->GridSizeX; $X++) {
            for ($Y = 0; $Y <= $this->GridSizeY; $Y++) {
                if ($this->Points[$X][$Y] == UNKNOWN) {
                    $Missing[] = $X . "," . $Y;
                }
            }
        }
        shuffle($Missing);

        foreach ($Missing as $Pos) {
            $Pos = preg_split("/,/", $Pos);
            $X = $Pos[0];
            $Y = $Pos[1];

            if ($this->Points[$X][$Y] == UNKNOWN) {
                $NearestNeighbor = $this->getNearestNeighbor($X, $Y);

                $Value = 0;
                $Points = 0;
                for ($Xi = $X - $NearestNeighbor; $Xi <= $X + $NearestNeighbor; $Xi++) {
                    for ($Yi = $Y - $NearestNeighbor; $Yi <= $Y + $NearestNeighbor; $Yi++) {
                        if ($Xi >= 0
                            && $Yi >= 0
                            && $Xi <= $this->GridSizeX
                            && $Yi <= $this->GridSizeY
                            && $this->Points[$Xi][$Yi] != UNKNOWN
                            && $this->Points[$Xi][$Yi] != IGNORED
                        ) {
                            $Value = $Value + $this->Points[$Xi][$Yi];
                            $Points++;
                        }
                    }
                }

                if ($Points != 0) {
                    $this->Points[$X][$Y] = $Value / $Points;
                }
            }
        }
    }
public function computeMissing ( ) { $ Missing = [ ] ; for ( $ X = 0 ; $ X <= $ this -> GridSizeX ; $ X ++ ) { for ( $ Y = 0 ; $ Y <= $ this -> GridSizeY ; $ Y ++ ) { if ( $ this -> Points [ $ X ] [ $ Y ] == UNKNOWN ) { $ Missing [ ] = $ X . "," . $ Y ; } } } shuffle ( $ Missing ) ; foreach ( $ Missing as $ Pos ) { $ Pos = preg_split ( "/,/" , $ Pos ) ; $ X = $ Pos [ 0 ] ; $ Y = $ Pos [ 1 ] ; if ( $ this -> Points [ $ X ] [ $ Y ] == UNKNOWN ) { $ NearestNeighbor = $ this -> getNearestNeighbor ( $ X , $ Y ) ; $ Value = 0 ; $ Points = 0 ; for ( $ Xi = $ X - $ NearestNeighbor ; $ Xi <= $ X + $ NearestNeighbor ; $ Xi ++ ) { for ( $ Yi = $ Y - $ NearestNeighbor ; $ Yi <= $ Y + $ NearestNeighbor ; $ Yi ++ ) { if ( $ Xi >= 0 && $ Yi >= 0 && $ Xi <= $ this -> GridSizeX && $ Yi <= $ this -> GridSizeY && $ this -> Points [ $ Xi ] [ $ Yi ] != UNKNOWN && $ this -> Points [ $ Xi ] [ $ Yi ] != IGNORED ) { $ Value = $ Value + $ this -> Points [ $ Xi ] [ $ Yi ] ; $ Points ++ ; } } } if ( $ Points != 0 ) { $ this -> Points [ $ X ] [ $ Y ] = $ Value / $ Points ; } } } }
Compute the missing points
Compute the missing points