You are here

function pSurface::computeMissing in Visitors 7

Same name and namespace in other branches
  1. 7.2 pChart/class/pSurface.class.php \pSurface::computeMissing()

File

pChart/class/pSurface.class.php, line 255

Class

pSurface

Code

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 $Key => $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;
      }
    }
  }
}