Ejemplo n.º 1
0
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new SpecieMySQL();
     }
     return self::$instance;
 }
<?php

require_once '../../config/db.php';
require_once '../../config/smarty.php';
require_once "../../core/model/Specie.php";
require_once '../../core/dao/mysql/SpecieMySQL.php';
$LOCATION_OCCURRENCES_FILES = "http://gisweb.ciat.cgiar.org/distributionMaps";
//   Ubicacion final de los archivos en servidor GISWEB
$GLOBAL_LOCATION_FILES = "/global-summary/";
$specieDAO = SpecieMySQL::getInstance();
// Este caso unicamente aplica cuando es una busqueda de tipo global donde no se especifica ni una especie o genepool en concreto
if ($_GET['map_type']) {
    switch ($_GET['map_type']) {
        // Hay dos tipos de mapa para los resultados globales
        case 'global_species_richness':
            $ubication = new stdClass();
            $url = $LOCATION_OCCURRENCES_FILES . $GLOBAL_LOCATION_FILES . "global_species_richness";
            // Asignando url
            $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']) {
function generateJSONSpecieList()
{
    $specieDAO = SpecieMySQL::getInstance();
    $specieList = $specieDAO->getSpeciesByCropCode();
    $result = array();
    if ($specieList != null) {
        foreach ($specieList as $specie) {
            $r = new stdClass();
            $r->Scientific_name = $specie->getTaxonomy();
            $r->Taxon_ID = $specie->getTaxonID();
            $r->Valid_Taxon_ID = $specie->getValidTaxonID();
            $r->Common_Name = $specie->getCommonName();
            $r->Crop_code = ucfirst($specie->getCropCode());
            array_push($result, $r);
        }
    }
    return json_encode($result);
}