/** * * @param type $faze * @param type $Ci * @return type * * Vypocet C pro plodinu */ public function solveC_new($faze, $Ci) { $R = vypocetData::getR(); $valueCSuma = 0; $valueCDay = []; foreach ($faze as $key => $term) { $valueC[$key] = 0; $startTime = strtotime($term['start']); $endTime = strtotime($term['end']); // Loop between timestamps, 1 day at a time do { $year = (int) date("Y", $startTime); $month = (int) date("m", $startTime); $day = (int) date("d", $startTime); $faktor = $R[$month] * $Ci[str_replace('_', '', $key)]; if (!isset($valueCMonth[$year][$month])) { $valueCMonth[$year][$month] = $faktor; } else { $valueCMonth[$year][$month] = $valueCMonth[$year][$month] + $faktor; } //$valueCDay[date("Y-m-d", $startTime)] = $faktor; array_push($valueCDay, ['date' => date("Y-m-d", $startTime), 'val' => $faktor]); $valueC[$key] = $valueC[$key] + $faktor; $valueCSuma = $valueCSuma + $faktor; $startTime = strtotime('+1 day', $startTime); } while ($startTime <= $endTime); } return ['c_plodina' => $valueCSuma, 'c_faze' => $valueC, 'c_month' => $valueCMonth, 'c_day' => $valueCDay]; }
/** * * @return type * Nacitani max. pripustne C, rastrova analyza */ public function action_loadCp() { $this->STOP_PROPAGATION = true; //300 seconds = 5 minutes //maxArea = 5000000; // 500ha -> maximalni plocha pro analyzu ini_set('max_execution_time', 300); // array ID to analyse $id = json_decode($this->request['id_geoms']); $data = []; for ($j = 0; $j < count($id); $j++) { if ($this->idLocation) { $geom = skupinaData::getGeomPB($id[$j]); $data[$j]['cp'] = vypocetData::getCp($geom, (int) $this->request['bilance']); // ulozeni vypoctu do DB if (!empty($data[$j]['cp'])) { skupinaData::setCpForGeom($id[$j], $data[$j]['cp'], (int) $this->request['bilance']); } $data[$j]['id_geom'] = $id[$j]; $data[$j]['bilance'] = (int) $this->request['bilance']; } else { //anonymni vyber $pb = lokalizaceData::getLpisGeomById($id[$j]); $data[$j]['cp'] = vypocetData::getCp($pb['geom'], (int) $this->request['bilance']); $data[$j]['id_geom'] = $id[$j]; $data[$j]['bilance'] = (int) $this->request['bilance']; } } return ["success" => true, "msg" => "OK", 'data_cp' => $data]; }