Skip to content

Commit 41c4706

Browse files
committed
Finished mapChart.php, without errors
1 parent 0fe110b commit 41c4706

File tree

7 files changed

+121
-51
lines changed

7 files changed

+121
-51
lines changed

control/mapChart.php

+57-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,56 @@
66
$pre = $_POST["prefixo"];
77
$prefixo = substr($pre, 0, -1);
88
$ano = $_POST["ano"];
9-
$mes = $_POST["mes"];
9+
$mes_string = $_POST["mes"];
10+
11+
switch($mes_string) {
12+
case "Janeiro":
13+
$mes = "01";
14+
break;
15+
16+
case "Fevereiro":
17+
$mes = "02";
18+
break;
19+
20+
case "Março":
21+
$mes = "03";
22+
break;
23+
24+
case "Abril":
25+
$mes = "04";
26+
break;
27+
28+
case "Maio":
29+
$mes = "05";
30+
break;
31+
32+
case "Junho":
33+
$mes = "06";
34+
break;
35+
36+
case "Julho":
37+
$mes = "07";
38+
break;
39+
40+
case "Agosto":
41+
$mes = "08";
42+
break;
43+
44+
case "Setembro":
45+
$mes = "09";
46+
break;
47+
48+
case "Outubro":
49+
$mes = "10";
50+
break;
51+
52+
case "Novembro":
53+
$mes = "11";
54+
break;
55+
56+
case "Dezembro":
57+
$mes = "12";
58+
}
1059

1160
writeData($prefixo, $ano, $mes);
1261

@@ -19,12 +68,12 @@
1968
<link rel="stylesheet" href="../view/css/estilo.css">
2069
<link rel="stylesheet" type="text/css" href="../view/css/map.css">
2170
<style>
22-
h1 {
71+
#info {
2372
text-align: center;
2473
color: #00BCD4;
2574
font-family: arial, serif, Times;
2675
border-bottom: 1px solid #00BCD4;
27-
font-size: 10px;
76+
font-size: 20px;
2877
}
2978
</style>
3079
</head>
@@ -36,9 +85,8 @@
3685

3786
echo '
3887
<section>
39-
<div id="container">
40-
<h1 id="info"> Media Chuva ao ano p/ Mês: '.$mes.' / '.$ano.' </h1>
41-
<div id="map_4"></div>
88+
<h1 id="info"> Media Chuva ao ano p/ Mês: '.$mes_string.' / '.$ano.' </h1>
89+
<div id="map_4">
4290
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
4391
<script src="http://d3js.org/d3.v4.min.js" charset="utf-8"></script>
4492
<script src="http://d3js.org/topojson.v1.min.js"></script>
@@ -62,7 +110,9 @@ function writeData($prefixo, $ano, $mes) {
62110
$texto = "municipio,prefixo,bacia,latitude,longitude,media\n";
63111
$file = fopen("../view/data/map.csv","w+");
64112

65-
for($i = 0; $ i < sizeof($medias); $i++) {
113+
echo sizeof($medias);
114+
115+
for($i = 0; $i < sizeof($medias); $i++) {
66116
$texto .= $postos[$i]->getMunicipio().",".$postos[$i]->getPrefixo().",".
67117
$postos[$i]->getBacia().",".substr($postos[$i]->getLatitude(), 1).",".
68118
substr($postos[$i]->getLongitude(), 1).",".$medias[$i]."\n";

dao/PostoDAO.php

-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ function getInfoPosto() {
140140
"'F4-004', 'C4-034.dat', 'E3-041', 'C4-019', 'C3-031', 'B6-014', 'D2-021', 'E3-003', 'E2-045', ".
141141
"'E4-056', 'E2-022', 'B6-032') GROUP BY prefixo;");
142142

143-
$sql->bindValue(1, $prefixo);
144143
$sql->execute();
145144

146145
$postos = array();

dao/PrecipitacaoDAO.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,8 @@ function getMediaChuvaMesPostos($ano, $mes) {
104104
"'D3-002.dat', 'E5-047.dat', 'E3-038.dat', 'C8-043.dat', 'B4-001.dat', 'E3-002.dat', 'E4-135.dat', 'E4-023.dat', 'C5-025.dat', "."'B7-008.dat', 'E3-025.dat', 'D4-064.dat', 'D6-010.dat', 'E3-264.dat', 'D4-002.dat', 'D8-003.dat', ".
105105
"'F4-004.dat', 'C4-034.dat', 'E3-041.dat', 'C4-019.dat', 'C3-031.dat', 'B6-014.dat', 'D2-021.dat', 'E3-003.dat', 'E2-045.dat', ".
106106
"'E4-056.dat', 'E2-022.dat', 'B6-032.dat') ".
107-
"and ano=? and mes=?;");
107+
"and ano='".$ano."' and mes='".$mes."';");
108108

109-
$sql->bindValue(1, $ano);
110-
$sql->bindValue(2, $mes);
111109
$sql->execute();
112110
$pre = array();
113111

model/Posto.php

+36-36
Original file line numberDiff line numberDiff line change
@@ -3,114 +3,114 @@
33
class Posto {
44
private $prefixo, $nome, $municipio, $bacia, $altitude, $latitude, $longitude, $ano_ini, $ano_fim, $intervalo;
55

6-
function __construct(){}
6+
function Posto(){}
77

88
function postoConstructor1($prefixo, $nome, $municipio, $bacia, $altitude, $latitude, $longitude, $ano_ini, $ano_fim, $intervalo) {
9-
$this->$prefixo = $prefixo;
10-
$this->$nome = $nome;
11-
$this->$municipio = $municipio;
12-
$this->$bacia = $bacia;
13-
$this->$altitude = $altitude;
14-
$this->$latitude = $latitude;
15-
$this->$longitude = $longitude;
16-
$this->$ano_ini = $ano_ini;
17-
$this->$ano_fim = $ano_fim;
18-
$this->$intervalo = $intervalo;
9+
$this->prefixo = $prefixo;
10+
$this->nome = $nome;
11+
$this->municipio = $municipio;
12+
$this->bacia = $bacia;
13+
$this->altitude = $altitude;
14+
$this->latitude = $latitude;
15+
$this->longitude = $longitude;
16+
$this->ano_ini = $ano_ini;
17+
$this->ano_fim = $ano_fim;
18+
$this->intervalo = $intervalo;
1919
}
2020

2121
function postoConstructor2($prefixo, $municipio, $bacia, $latitude, $longitude) {
22-
$this->$prefixo = $prefixo;
23-
$this->$municipio = $municipio;
24-
$this->$bacia = $bacia;
25-
$this->$latitude = $latitude;
26-
$this->$longitude = $longitude;
22+
$this->prefixo = $prefixo;
23+
$this->municipio = $municipio;
24+
$this->bacia = $bacia;
25+
$this->latitude = $latitude;
26+
$this->longitude = $longitude;
2727
}
2828

2929
function getPrefixo() {
30-
return $this->$prefixo;
30+
return $this->prefixo;
3131
}
3232

3333
function setPrefixo($prefixo) {
34-
$this->$prefixo = $prefixo;
34+
$this->prefixo = $prefixo;
3535
}
3636

3737

3838
function getNome() {
39-
return $this->$nome;
39+
return $this->nome;
4040
}
4141

4242
function setNome($nome) {
43-
$this->$nome = $nome;
43+
$this->nome = $nome;
4444
}
4545

4646

4747
function getMunicipio() {
48-
return $this->$municipio;
48+
return $this->municipio;
4949
}
5050

5151
function setMunicipio($municipio) {
52-
$this->$municipio = $municipio;
52+
$this->municipio = $municipio;
5353
}
5454

5555

5656
function getBacia() {
57-
return $this->$bacia;
57+
return $this->bacia;
5858
}
5959

6060
function setBacia($bacia) {
61-
$this->$bacia = $bacia;
61+
$this->bacia = $bacia;
6262
}
6363

6464

6565
function getAltitude() {
66-
return $this->$altitude;
66+
return $this->altitude;
6767
}
6868

6969
function setAltitude($altitude) {
70-
$this->$altitude = $altitude;
70+
$this->altitude = $altitude;
7171
}
7272

7373

7474
function getLatitude() {
75-
return $this->$latitude;
75+
return $this->latitude;
7676
}
7777

7878
function setLatitude($latitude) {
79-
$this->$latitude = $latitude;
79+
$this->latitude = $latitude;
8080
}
8181

8282

8383
function getLongitude() {
84-
return $this->$longitude;
84+
return $this->longitude;
8585
}
8686

8787
function setLongitude($longitude) {
88-
$this->$longitude = $longitude;
88+
$this->longitude = $longitude;
8989
}
9090

9191

9292
function getAno_ini() {
93-
return $this->$ano_ini;
93+
return $this->ano_ini;
9494
}
9595

9696
function setAno_ini($ano_ini) {
97-
$this->$ano_ini = $ano_ini;
97+
$this->ano_ini = $ano_ini;
9898
}
9999

100100
function getAno_fim() {
101-
return $this->$ano_fim;
101+
return $this->ano_fim;
102102
}
103103

104104
function setAno_fim($ano_fim) {
105-
$this->$ano_fim = $ano_fim;
105+
$this->ano_fim = $ano_fim;
106106
}
107107

108108
function getIntervalo() {
109-
return $this->$intervalo;
109+
return $this->intervalo;
110110
}
111111

112112
function setIntervalo($intervalo) {
113-
$this->$intervalo = $intervalo;
113+
$this->intervalo = $intervalo;
114114
}
115115
}
116116

view/css/estilo.css

+5
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,9 @@ footer {
143143
#container svg {
144144
margin-left: 160px;
145145
margin-top: 20px;
146+
}
147+
148+
#map_4 {
149+
margin-left: 160px;
150+
margin-top: 20px;
146151
}

view/data/map.csv

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
municipio,prefixo,bacia,latitude,longitude,media
2+
FRANCA,B4-001,BAGRES,2031,4724,128.17
3+
BARRETOS,B5-002,PITANGUEIRAS,2034,4834,138.57
4+
"SAO JOSE DO RIO PRETO",B6-014,PRETO,2049,4925,136.73
5+
VOTUPORANGA,B6-032,"SAO JOSE DOS DOURADOS",2030,4957,0.00
6+
JALES,B7-008,"RIBEIRAO DO MARIMBONDO",2018,5033,0.00
7+
ARACATUBA,B7-047,"TIETE (MEDIO E INFERIOR)",2055,5050,0.00
8+
"SAO JOAO DA BOA VISTA",C3-031,JAGUARI-MIRIM,2157,4648,154.80
9+
"SAO CARLOS",C4-019,TURVO,2147,4747,101.13
10+
ARARAQUARA,C5-008,"JACARE GUACU",2145,4814,158.83
11+
JABOTICABAL,C5-025,"CORREGO RICO",2115,4818,183.90
12+
DRACENA,C8-043,"NOVA PALMEIRA",2128,5132,0.00
13+
"SAO JOSE DOS CAMPOS",D2-021,JAGUARI,2255,4558,107.73
14+
CAMPINAS,D3-002,ATIBAIA,2256,4654,124.70
15+
PIRACICABA,D4-002,PIRACICABA,2244,4739,0.00
16+
AMERICANA,D4-004,PIRACICABA,2242,4717,160.00
17+
LIMEIRA,D4-064,PIRACICABA,2234,4722,115.80
18+
BOTUCATU,D5-019,CAPIVARA,2249,4826,98.07
19+

view/js/mapDraw.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ function createNYCMap(){
2525
var svg = d3.select("#map_4")
2626
.append("svg")
2727
.attr("width", width_4)
28-
.attr("height", height_4)
29-
.style("margin-left", 100);
28+
.attr("height", height_4);
3029

3130
// Define the g for each neighborhood
3231
var g = svg.append("g");
@@ -76,8 +75,8 @@ function createNYCMap(){
7675
"Media:" + '<strong id="media"></strong>'
7776
)
7877
// Place the tooltip
79-
div.style("left", (d3.mouse(this)[0]) + "px")
80-
.style("top", (d3.mouse(this)[1]) + "px");
78+
div.style("left", ((d3.mouse(this)[0]) + 200) + "px")
79+
.style("top", ((d3.mouse(this)[1]) + 300) + "px");
8180

8281
// Load CSV for filling the missing info on tooltip
8382
d3.csv("../view/data/map.csv", function(data) {

0 commit comments

Comments
 (0)