/** * Creates and returns a GeoAnalysis object from a data row. * The row data is expected to be an array with the indexes: * - majgd_id: geodispersion analysis ID * - majgd_descr: geodispersion analysis description/title * - majgd_sublevel: Analysis level * - majgd_useflagsgen: Use flags in places display * - majgd_detailsgen: Number of top places * - majgd_map: file name of the map * - majgd_toplevel: parent level for the map * * @param array $row * @return GeoAnalysis */ protected function loadGeoAnalysisFromRow($row) { $options = new GeoDisplayOptions(); $options->setUsingFlags($row['majgd_useflagsgen'] == 'yes')->setMaxDetailsInGen($row['majgd_detailsgen']); if ($row['majgd_map']) { $options->setMap(new OutlineMap($row['majgd_map']))->setMapLevel($row['majgd_toplevel']); } $enabled = true; if (isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') { $enabled = false; } return new GeoAnalysis($this->tree, $row['majgd_id'], $row['majgd_descr'], $row['majgd_sublevel'], $options, $enabled); }
/** * Return the dispersion analysis tables. * Two arrays are returned : * - the General analysis, which returns the number of ancestors for each place found, plus 4 additional indicators : * - knownsum : Number of known places * - unknown : Number of unknown places * - max : Maximum count of ancestors within a place * - other : Other places (not in the top level area) * - the Generations analysis, which returns the number of ancestors for each place found for each generation, plus 3 additional indicators within each generation : * - sum : Number of known places * - unknown : Number of unknown places * - other : Other places (not in the top level area) * * @param array $sosalist List of all sosas * @return array Array of the general and generations table */ public function getAnalysisResults($sosalist) { $placesDispGeneral = null; $placesDispGenerations = null; if ($sosalist && count($sosalist) > 0) { $placesDispGeneral['knownsum'] = 0; $placesDispGeneral['unknown'] = 0; $placesDispGeneral['max'] = 0; $placesDispGeneral['places'] = array(); foreach ($sosalist as $sosaid => $gens) { $sosa = Individual::getIntance($sosaid, $this->tree); $place = $sosa->getSignificantPlace(); $genstab = explode(',', $gens); $isUnknown = true; if ($sosa->getDerivedRecord()->canShow() && !is_null($place)) { $levels = array_reverse(array_map('trim', explode(',', $place))); if (count($levels) >= $this->analysis_level) { $toplevelvalues = array(); if ($this->hasMap() && ($toplevelvalue = $this->options->getMap()->getTopLevelName())) { $toplevelvalues = array_map('trim', explode(',', strtolower($toplevelvalue))); } if (!$this->hasMap() || is_null($this->options->getMapLevel()) || $this->options->getMap()->getTopLevelName() == '*' || $this->options->getMapLevel() <= $this->analysis_level && $this->options->getMapLevel() > 0 && count($levels) >= $this->options->getMapLevel() && in_array(strtolower($levels[$this->options->getMapLevel() - 1]), $toplevelvalues)) { $placest = implode(I18N::$list_separator, array_slice($levels, 0, $this->analysis_level)); if (isset($placesDispGeneral['places'][$placest])) { $placesDispGeneral['places'][$placest] += 1; } else { $placesDispGeneral['places'][$placest] = 1; } if ($placesDispGeneral['places'][$placest] > $placesDispGeneral['max']) { $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; } foreach ($genstab as $gen) { if (isset($placesDispGenerations[$gen]['places'][$placest])) { $placesDispGenerations[$gen]['places'][$placest] += 1; } else { $placesDispGenerations[$gen]['places'][$placest] = 1; } if (isset($placesDispGenerations[$gen]['sum'])) { $placesDispGenerations[$gen]['sum'] += 1; } else { $placesDispGenerations[$gen]['sum'] = 1; } } } else { if (isset($placesDispGeneral['other'])) { $placesDispGeneral['other'] += 1; } else { $placesDispGeneral['other'] = 1; } foreach ($genstab as $gen) { if (isset($placesDispGenerations[$gen]['other'])) { $placesDispGenerations[$gen]['other'] += 1; } else { $placesDispGenerations[$gen]['other'] = 1; } } } $placesDispGeneral['knownsum'] += 1; $isUnknown = false; } } if ($isUnknown) { $placesDispGeneral['unknown'] += 1; foreach ($genstab as $gen) { if (isset($placesDispGenerations[$gen]['unknown'])) { $placesDispGenerations[$gen]['unknown'] += 1; } else { $placesDispGenerations[$gen]['unknown'] = 1; } } } } } return array($placesDispGeneral, $placesDispGenerations); }