/**
  * Return the key fields z-values for the selected city and the key fields z-values average
  * @param string $cityName name of the selected city
  * @return array $cityValues it contains the z-values and a z-values average
  */
 public function profile($cityName)
 {
     if (isset($cityName)) {
         if (strcmp($cityName, '') != 0) {
             $keyFieldsZValues = new RankController();
             $average = new ZtransformController();
             //Retrive the z-values for each key field
             $educationKeyField = $keyFieldsZValues->educationKeyField();
             $governmentExpenKeyField = $keyFieldsZValues->governmentExpendituresKeyField();
             $healthKeyField = $keyFieldsZValues->healthKeyField();
             $economyKeyField = $keyFieldsZValues->economyKeyField();
             $employmentKeyField = $keyFieldsZValues->employmentKeyField();
             $environmentKeyField = $keyFieldsZValues->environmentKeyField();
             //create an array with each z-value of the selected city
             $cityInfo = array('Educação' => $educationKeyField[$cityName], 'Finanças Públicas' => $governmentExpenKeyField[$cityName], 'Saúde' => $healthKeyField[$cityName], 'Economia' => $economyKeyField[$cityName], 'Emprego' => $employmentKeyField[$cityName], 'Meio Ambiente' => $environmentKeyField[$cityName]);
             $cityValues = CityProfileController::mergeAverage($cityInfo);
             return $cityValues;
         }
     }
     return 0;
 }
Пример #2
0
 /**
  * This method will calculate a overall rating from the ranking create for each key field
  * it will sum the ranking values of each key value and then sort them from low to high,
  * once the city that has the lowest score will have the best position
  * @param array $keyFieldsRank It will receive multidimentional array which keeps
  *                             the ranking of each key field
  */
 private function overallRating($keyFieldsRank)
 {
     //Create an array with citie's name as key and each key set as zero
     $overallSort = array_fill_keys(array_keys($keyFieldsRank["education"]), 0);
     $overallRank = array();
     //Sum the cities scores
     foreach ($keyFieldsRank as $key => $keyField) {
         foreach ($keyField as $key => $value) {
             $overallSort[$key] += $value;
         }
     }
     //sort the ranking scores from low to high
     asort($overallSort);
     //Make the ranking from the sum of each city's rank
     $rankingScores = RankController::makeDenseRanking($overallSort);
     return $rankingScores;
 }