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