Subversion Repositories eFlore/Applications.moissonnage

Rev

Rev 31 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 31 Rev 34
1
<?php
1
<?php
2
 
2
 
3
class Maille {
3
class Maille {
4
	
4
	
5
	private $latitudeSud;
5
	private $latitudeSud;
6
	private $longitudeOuest;
6
	private $longitudeOuest;
7
	private $latitudeNord;
7
	private $latitudeNord;
8
	private $longitudeEst;
8
	private $longitudeEst;
9
	private $indexLatitude;
9
	private $indexLatitude;
10
	private $indexLongitude;
10
	private $indexLongitude;
11
	
11
	
12
	private $points = array();
-
 
13
	private $nombrePoints;
12
	private $stations = array();
14
	private $observations = array();
-
 
15
	private $nombreObservations;
13
	private $observations = array();
16
	
14
	
17
	
15
	
18
	public function __construct($sud, $ouest, $nord, $est, $indexLat, $indexLng) {
16
	public function __construct($sud, $ouest, $nord, $est, $indexLat, $indexLng) {
19
		$this->latitudeSud = $sud;
17
		$this->latitudeSud = $sud;
20
		$this->longitudeOuest = $ouest;
18
		$this->longitudeOuest = $ouest;
21
		$this->latitudeNord = $nord;
19
		$this->latitudeNord = $nord;
22
		$this->longitudeEst = $est;
20
		$this->longitudeEst = $est;
23
		$this->indexLatitude = $indexLat;
21
		$this->indexLatitude = $indexLat;
24
		$this->indexLongitude = $indexLng;
22
		$this->indexLongitude = $indexLng;
25
	}
23
	}
26
	
24
	
27
	public function ajouterPoint($point) {
25
	public function ajouterStation($station, $source) {
28
		$this->points[] = $point;
26
		if (!array_key_exists($source, $this->stations)) {
29
		$this->nombrePoints ++;
27
			$this->stations[$source] = 1;
-
 
28
			$this->observations[$source] = $station['observations'];
-
 
29
		} else {
30
		$this->observations[] = $point['observations'];
30
			$this->stations[$source] += 1;
-
 
31
			$this->observations[$source] += intval($station['observations']);
31
		$this->nombreObservations += $point['observations'];
32
		}
32
	}
33
	}
33
	
34
	
34
	public function getLatitudeNord() {
35
	public function getLatitudeNord() {
35
		return $this->latitudeNord;
36
		return $this->latitudeNord;
36
	}
37
	}
37
	
38
	
38
	public function getLongitudeOuest() {
39
	public function getLongitudeOuest() {
39
		return $this->longitudeOuest;
40
		return $this->longitudeOuest;
40
	}
41
	}
41
	
42
	
42
	public function getLatitudeSud() {
43
	public function getLatitudeSud() {
43
		return $this->latitudeSud;
44
		return $this->latitudeSud;
44
	}
45
	}
45
	
46
	
46
	public function getLongitudeEst() {
47
	public function getLongitudeEst() {
47
		return $this->longitudeEst;
48
		return $this->longitudeEst;
48
	}
49
	}
49
	
50
	
50
	public function getIndexLatitude() {
51
	public function getIndexLatitude() {
51
		return $this->indexLatitude;
52
		return $this->indexLatitude;
52
	}
53
	}
53
	
54
	
54
	public function getIndexLongitude() {
55
	public function getIndexLongitude() {
55
		return $this->indexLongitude;
56
		return $this->indexLongitude;
56
	}
57
	}
57
	
58
	
58
	public function getPoints() {
59
	public function getStations() {
59
		return $this->points;
60
		return $this->stations;
60
	}
61
	}
61
	
62
	
62
	public function getNombrePoints() {
63
	public function getNombreStations() {
63
		return $this->nombrePoints;
64
		return count($this->stations);
64
	}
65
	}
65
	
66
	
66
	public function getObservations() {
67
	public function getObservations() {
67
		return $this->observations;
68
		return $this->observations;
68
	}
69
	}
69
	
70
	
-
 
71
	public function combinerMailles($maille, $sourceReference) {
-
 
72
		if (is_array($maille['stations'])) {
-
 
73
			foreach ($maille['stations'] as $source => $nombreStations) {
70
	public function getNombreObservations() {
74
				if (!array_key_exists($source, $this->stations)) {
-
 
75
					$this->stations[$source] = $nombreStations;
71
		return $this->nombreObservations;
76
					$this->observations[$source] = $maille['observations'][$source];
72
	}
-
 
73
 
77
				} else {
74
	public function totalNonNul() {
78
					$this->stations[$source] += $nombreStations;
75
		return count($this->points) > 0;
79
					$this->observations[$source] += $maille['observations'][$source];
76
	}
80
				}
-
 
81
			}
-
 
82
		} else {
77
	
83
			if (!array_key_exists($sourceReference, $this->stations)) {
-
 
84
				$this->stations[$sourceReference] = $maille['stations'];
-
 
85
				$this->observations[$sourceReference] = $maille['observations'];
78
	public function combinerMailles(& $maille) {
86
			} else {
79
		$this->nombrePoints += $maille->nombre_sites;
87
				$this->stations[$sourceReference] += $maille['stations'];
-
 
88
				$this->observations[$sourceReference] += $maille['observations'];
-
 
89
			}
80
		$this->nombreObservations += $maille->nombre_observations;
90
		}
81
	}
91
	}
82
	
92
	
83
}
93
}
84
 
94
 
85
?>
95
?>