Subversion Repositories eFlore/Applications.moissonnage

Rev

Rev 31 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

class Maille {
        
        private $latitudeSud;
        private $longitudeOuest;
        private $latitudeNord;
        private $longitudeEst;
        private $indexLatitude;
        private $indexLongitude;
        
        private $stations = array();
        private $observations = array();
        
        
        public function __construct($sud, $ouest, $nord, $est, $indexLat, $indexLng) {
                $this->latitudeSud = $sud;
                $this->longitudeOuest = $ouest;
                $this->latitudeNord = $nord;
                $this->longitudeEst = $est;
                $this->indexLatitude = $indexLat;
                $this->indexLongitude = $indexLng;
        }
        
        public function ajouterStation($station, $source) {
                if (!array_key_exists($source, $this->stations)) {
                        $this->stations[$source] = 1;
                        $this->observations[$source] = $station['observations'];
                } else {
                        $this->stations[$source] += 1;
                        $this->observations[$source] += intval($station['observations']);
                }
        }
        
        public function getLatitudeNord() {
                return $this->latitudeNord;
        }
        
        public function getLongitudeOuest() {
                return $this->longitudeOuest;
        }
        
        public function getLatitudeSud() {
                return $this->latitudeSud;
        }
        
        public function getLongitudeEst() {
                return $this->longitudeEst;
        }
        
        public function getIndexLatitude() {
                return $this->indexLatitude;
        }
        
        public function getIndexLongitude() {
                return $this->indexLongitude;
        }
        
        public function getStations() {
                return $this->stations;
        }
        
        public function getNombreStations() {
                return count($this->stations);
        }
        
        public function getObservations() {
                return $this->observations;
        }
        
        public function combinerMailles($maille, $sourceReference) {
                if (is_array($maille['stations'])) {
                        foreach ($maille['stations'] as $source => $nombreStations) {
                                if (!array_key_exists($source, $this->stations)) {
                                        $this->stations[$source] = $nombreStations;
                                        $this->observations[$source] = $maille['observations'][$source];
                                } else {
                                        $this->stations[$source] += $nombreStations;
                                        $this->observations[$source] += $maille['observations'][$source];
                                }
                        }
                } else {
                        if (!array_key_exists($sourceReference, $this->stations)) {
                                $this->stations[$sourceReference] = $maille['stations'];
                                $this->observations[$sourceReference] = $maille['observations'];
                        } else {
                                $this->stations[$sourceReference] += $maille['stations'];
                                $this->observations[$sourceReference] += $maille['observations'];
                        }
                }
        }
        
}

?>