Example #1
0
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new Specie();
     }
     return self::$instance;
 }
            $ubication->url = $url;
            echo generatePublicKmlURL($ubication);
            break;
        case 'global_gap_richness':
            $ubication = new stdClass();
            $url = $LOCATION_OCCURRENCES_FILES . $GLOBAL_LOCATION_FILES . "global_gap_richness";
            // Asignando url
            $ubication->url = $url;
            echo generatePublicKmlURL($ubication);
            break;
    }
}
if ($_GET['specie']) {
    //Busqueda por especie
    $specie = preg_replace('[\\s+]', ' ', $_GET['specie']);
    $specie_object = Specie::getInstance();
    if ($_GET['map_type']) {
        switch ($_GET['map_type']) {
            case 'points':
                if ($specieDAO->getCropCode(str_replace(" ", "_", strtolower($specie)), 0)) {
                    $filemanager = @fopen($LOCATION_OCCURRENCES_FILES . "/gap_" . $specieDAO->getCropCode(str_replace(" ", "_", strtolower($specie)), 0) . "/occurrence_files/" . str_replace("_subsp.", "", str_replace("_var.", "", str_replace(" ", "_", $specieDAO->getSpecieName($specie)))) . ".csv", "r");
                    if ($filemanager) {
                        // Solo proceder en caso de que el archivo exista
                        $array_points = array();
                        while (($data = fgetcsv($filemanager, 1000, ",")) !== FALSE) {
                            // Mientras hay lĂ­neas que leer...
                            $i = 0;
                            foreach ($data as $row) {
                                if ($j == 0) {
                                    //Ignorar la primera fila, unicamente iniciar datos con taxonomia
                                    $specie_object->setTaxonomy($specie);
 public function getSpeciesByCropCode()
 {
     global $db;
     $query = "select s.*, c.Crop_code from cwr_occurrences_species c join species s on s.Valid_Taxon_ID = c.Valid_Taxon_ID \n        WHERE c.Crop_code in ('avena','bambara','bean','cajanus','cicer','cowpea','daucus','eggplant','eleusine',\n        'faba_bean','helianthus','hordeum','ipomoea','lathyrus','lens','lima_bean','malus','medicago','musa',\n        'pennisetum','pisum','potato','rice','secale','sorghum','triticum','vetch') \n        group by s.Taxon_ID order by c.Crop_code";
     $result = $db->getAll($query);
     $species = array();
     foreach ($result as $r) {
         // Se obtiene la informacion de la specie de acuerdo al crop code ingresado
         $specie = new Specie();
         $specie->setTaxonomy($r["Scientific_Name"]);
         $specie->setTaxonID($r["Taxon_ID"]);
         $specie->setValidTaxonID($r["Valid_Taxon_ID"]);
         $specie->setCommonName($r["Common_Name"]);
         $specie->setCropCode($r["Crop_code"]);
         array_push($species, $specie);
     }
     return $species;
 }
function FormAggiungiSpecie()
{
    $specie = new Specie();
    $specie->setDescrizione("");
    $specie->setNome("");
    include 'php/view/admin/PageSpecie.php';
}