/**
  * Return the health z-values for the selected city and its average
  * @param string $cityName name of the selected city
  * @return array $cityValues it contains the z-values and a z-values average
  */
 public function healthDomain($cityName)
 {
     if (isset($cityName)) {
         if (strcmp($cityName, '') != 0) {
             $health = new HealthController();
             $sewage = new EnvironmentController();
             //Get the z-value for other water supply
             $waterSupplyOther = $health->waterSupplyOther();
             //Get the z-value for well or spring source
             $wellSpring = $health->wellSpring();
             //Get the z-value for public water supply
             $publicWaterSupply = $health->publicWaterSupply();
             //Get the z-value for drainage Ditch
             $drainageDitch = $sewage->drainageDitch();
             //Get the z-value for river, lake and sea sewerage disposal
             $riverLakeDisposal = $sewage->river_lake_sea_sewerageDisposal();
             //Get the z-value for river, lake and sea sewerage disposal
             $septicTank = $sewage->septicTank();
             $cityHealthInfo = array("Abastecimento de Água - Outros" => $waterSupplyOther[$cityName], "Abastecimento de Água - Poço ou Nascente" => $wellSpring[$cityName], "Abastecimento de Água - Rede Geral" => $publicWaterSupply[$cityName], "Esgotamento Sanitário - Vala" => $drainageDitch[$cityName], "Esgotamento Sanitário - Fossa Séptica" => $septicTank[$cityName], "Esgotamento Sanitário - Rio, lago ou mar" => $riverLakeDisposal[$cityName]);
             $cityHealthValues = CityProfileController::mergeAverage($cityHealthInfo);
             return $cityHealthValues;
         }
     }
     return 0;
 }
Ejemplo n.º 2
0
 /**
  * It will calculate the average of the z-values for Health
  * @return return the average of z-values by key field of each city
  */
 public function healthKeyField()
 {
     $health = new HealthController();
     $sewage = new EnvironmentController();
     //Get the z-value for other water supply
     $waterSupplyOther = $health->waterSupplyOther();
     $waterSupplyOtherInverted = array_map(array($this, "addImpact"), $waterSupplyOther);
     //Get the z-value for well or spring source
     $wellSpring = $health->wellSpring();
     $wellSpringInverted = array_map(array($this, "addImpact"), $wellSpring);
     //Get the z-value for public water supply
     $publicWaterSupply = $health->publicWaterSupply();
     //Get the z-value for drainage Ditch
     $drainageDitch = $sewage->drainageDitch();
     $drainageDitchInverted = array_map(array($this, "addImpact"), $drainageDitch);
     //Get the z-value for river, lake and sea sewerage disposal
     $riverLakeDisposal = $sewage->river_lake_sea_sewerageDisposal();
     $riverLakeDisposalInverted = array_map(array($this, "addImpact"), $riverLakeDisposal);
     //Get the z-value for river, lake and sea sewerage disposal
     $septicTank = $sewage->septicTank();
     //sum z-values
     $sumZvalues = array_map(array($this, "sumCityValues"), $waterSupplyOtherInverted, $wellSpringInverted, $publicWaterSupply, $drainageDitchInverted, $riverLakeDisposalInverted, $septicTank);
     //Divide the sum of z-values to obtain the z-values average of each city
     $zValuesAvg = array_map(array($this, "divideKeyFields"), $sumZvalues, array_fill(0, count($sumZvalues), 6));
     //combine the array keys(cities'name) with the average of z-values gotten
     $zValuesAvg = array_combine(array_keys($septicTank), array_values($zValuesAvg));
     return $zValuesAvg;
 }