Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
velibstats
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
JonathanMM
velibstats
Commits
02c7aef8
Commit
02c7aef8
authored
Feb 16, 2018
by
JonathanMM
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'carteSignalement'
parents
d664d963
716a958e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
200 additions
and
5 deletions
+200
-5
api.php
api.php
+170
-1
index.tpl
index.tpl
+24
-4
style.css
style.css
+6
-0
No files found.
api.php
View file @
02c7aef8
...
...
@@ -126,6 +126,10 @@ switch($_GET['action'])
echo
json_encode
(
getCommunesCarte
(
$idConso
));
exit
();
break
;
case
'getSignalementCarte'
:
echo
json_encode
(
getSignalementCarte
(
$idConso
));
exit
();
break
;
}
function
getBikeInstantane
(
$codeStation
)
...
...
@@ -916,7 +920,7 @@ function getCommunesCarte($idConso)
'lon'
=>
$station
[
'longitude'
],
'lat'
=>
$station
[
'latitude'
],
'lien'
=>
'station.php?code='
.
$station
[
'code'
],
'info'
=>
'Station '
.
sprintf
(
'%05d'
,
$station
[
'code'
])
.
"
\n
"
.
$station
[
'name'
]
.
"
\n
"
.
$s_info1
.
' - '
.
$s_info2
'info'
=>
'Station '
.
displayCodeStation
(
$station
[
'code'
])
.
"
\n
"
.
$station
[
'name'
]
.
"
\n
"
.
$s_info1
.
' - '
.
$s_info2
);
}
...
...
@@ -969,4 +973,169 @@ function getCommunesCarte($idConso)
return
$svg
;
}
function
getDataSignalement
()
{
global
$pdo
;
$hier
=
new
DateTime
(
"-1week"
);
$filtreSemaine
=
$hier
->
format
(
'Y-m-d H:i:s'
);
$requete
=
$pdo
->
query
(
'SELECT *
FROM signalement
WHERE dateSignalement >= "'
.
$filtreSemaine
.
'"
ORDER BY code ASC, dateSignalement ASC'
);
$signalements
=
$requete
->
fetchAll
();
$resumeSignalement
=
array
();
foreach
(
$signalements
as
$sign
)
{
$code
=
$sign
[
'code'
];
if
(
!
isset
(
$resumeSignalement
[
$code
]))
$resumeSignalement
[
$code
]
=
array
(
true
=>
0
,
false
=>
0
);
$resumeSignalement
[
$code
][
$sign
[
'estFonctionnel'
]
==
1
]
++
;
$resumeSignalement
[
$code
][
'dernier'
]
=
$sign
[
'estFonctionnel'
]
==
1
;
}
//On compile
$etatStations
=
array
();
foreach
(
$resumeSignalement
as
$code
=>
$sign
)
{
if
(
$sign
[
true
]
>
$sign
[
false
])
$etatStations
[
$code
]
=
true
;
else
if
(
$sign
[
true
]
<
$sign
[
false
])
$etatStations
[
$code
]
=
false
;
else
$etatStations
[
$code
]
=
$sign
[
'dernier'
];
}
return
$etatStations
;
}
function
getSignalementCarte
(
$idConso
)
{
global
$pdo
;
$dataConso
=
getDataConso
(
$idConso
);
$statusStation
=
$dataConso
[
'data'
];
$signalements
=
getDataSignalement
();
$liste_communes
=
array
();
$objets
=
array
();
define
(
'ETAT_INCONNU'
,
0
);
define
(
'ETAT_FONCTIONNE'
,
1
);
define
(
'ETAT_NON_FONCTIONNE'
,
2
);
$couleur_etat
=
array
(
ETAT_INCONNU
=>
'DodgerBlue'
,
ETAT_FONCTIONNE
=>
'FireBrick'
,
ETAT_NON_FONCTIONNE
=>
'Coral'
);
$nombre_etat
=
array
(
ETAT_INCONNU
=>
0
,
ETAT_FONCTIONNE
=>
0
,
ETAT_NON_FONCTIONNE
=>
0
,
);
foreach
(
$statusStation
as
$station
)
{
$code
=
$station
[
'code'
];
if
(
isset
(
$signalements
[
$code
]))
{
if
(
$signalements
[
$code
])
{
$etat
=
ETAT_FONCTIONNE
;
$s_info1
=
'Signalé comme fonctionnant'
;
}
else
{
$etat
=
ETAT_NON_FONCTIONNE
;
$s_info1
=
'Signalé comme ne fonctionnant pas'
;
}
}
else
{
$etat
=
ETAT_INCONNU
;
$s_info1
=
'Aucun signalement récemment'
;
}
//forme en fonction de l'état annoncé
if
(
$etat
==
ETAT_INCONNU
)
{
$s_point
=
'rond'
;
$s_taille
=
6
;
$s_angle
=
0
;
}
else
{
$s_point
=
'carre'
;
$s_taille
=
6
;
$s_angle
=
45
;
}
//comptage du nombre de stations par etat
$nombre_etat
[
$etat
]
++
;
//récupération de la commune correspondant à la station (d'après son numéro)
$inseeCommune
=
getCommuneStation
(
$station
[
'code'
]);
//ajout à la liste des communes
if
(
!
is_null
(
$inseeCommune
)
&&
!
in_array
(
$inseeCommune
,
$liste_communes
))
{
$liste_communes
[]
=
$inseeCommune
;
}
//texte en fonction du nombre de bornes
switch
(
$station
[
'nbEDock'
])
{
case
0
:
$s_info2
=
'aucune borne'
;
break
;
case
1
:
$s_info2
=
'1 borne'
;
break
;
default
:
$s_info2
=
$station
[
'nbEDock'
]
.
' bornes'
;
break
;
}
$objets
[]
=
array
(
'nature'
=>
'point'
,
'point'
=>
$s_point
,
'taille'
=>
$s_taille
,
'angle'
=>
$s_angle
,
'couleur'
=>
$couleur_etat
[
$etat
],
'lon'
=>
$station
[
'longitude'
],
'lat'
=>
$station
[
'latitude'
],
'lien'
=>
'station.php?code='
.
$code
,
'info'
=>
'Station '
.
displayCodeStation
(
$code
)
.
"
\n
"
.
$station
[
'name'
]
.
"
\n
"
.
$s_info1
.
' - '
.
$s_info2
);
}
//légende (point et texte, affiché uniquement pour les états ayant au moins une station
if
(
$nombre_etat
[
ETAT_INCONNU
])
{
$objets
[]
=
array
(
'point'
=>
'rond'
,
'x'
=>-
58
,
'y'
=>
10
,
'taille'
=>
6
,
'angle'
=>
0
,
'couleur'
=>
$couleur_etat
[
ETAT_INCONNU
]);
$objets
[]
=
array
(
'nature'
=>
'texte'
,
'x'
=>-
60
,
'y'
=>
20
,
'taille'
=>
12
,
'angle'
=>
90
,
'align'
=>
'l'
,
'texte'
=>
'Pas de signalement ('
.
$nombre_etat
[
ETAT_INCONNU
]
.
')'
);
}
if
(
$nombre_etat
[
ETAT_NON_FONCTIONNE
])
{
$objets
[]
=
array
(
'point'
=>
'carre'
,
'x'
=>-
18
,
'y'
=>
210
,
'taille'
=>
6
,
'angle'
=>
45
,
'couleur'
=>
$couleur_etat
[
ETAT_NON_FONCTIONNE
]);
$objets
[]
=
array
(
'nature'
=>
'texte'
,
'x'
=>-
20
,
'y'
=>
220
,
'taille'
=>
12
,
'angle'
=>
90
,
'align'
=>
'l'
,
'texte'
=>
'Ne fonctionne pas ('
.
$nombre_etat
[
ETAT_NON_FONCTIONNE
]
.
')'
);
}
if
(
$nombre_etat
[
ETAT_FONCTIONNE
])
{
$objets
[]
=
array
(
'point'
=>
'carre'
,
'x'
=>-
18
,
'y'
=>
10
,
'taille'
=>
6
,
'angle'
=>
45
,
'couleur'
=>
$couleur_etat
[
ETAT_FONCTIONNE
]);
$objets
[]
=
array
(
'nature'
=>
'texte'
,
'x'
=>-
20
,
'y'
=>
20
,
'taille'
=>
12
,
'angle'
=>
90
,
'align'
=>
'l'
,
'texte'
=>
'Fonctionne ('
.
$nombre_etat
[
ETAT_FONCTIONNE
]
.
')'
);
}
$svg
=
genererCarteSVG
(
800
,
500
,
$liste_communes
,
'commune.php?insee='
,
''
,
''
,
$objets
,
COMMUNE_AVM_VELIB
);
return
$svg
;
}
?>
index.tpl
View file @
02c7aef8
...
...
@@ -39,7 +39,8 @@
<input
type=
"submit"
value=
"Filtrer"
/>
</form>
<a
href=
"http://www.ousontlesvelib.ovh/stations"
>
Suivre l'avancement de l'ouverture des stations
>>
</a><br
/>
<a
href=
"stats.php"
>
Voir plus de statistiques
>
</a>
<a
href=
"stats.php"
>
Voir plus de statistiques
>
</a><br
/>
<a
id=
"toggle-carte"
>
Voir carte des signalements
</a>
</div>
<div
id=
"carteArea"
></div>
</div>
...
...
@@ -164,7 +165,8 @@
filtreDataTable
();
$
(
"#filtreEtat"
).
change
(
filtreDataTable
);
$
(
"#filtrePosition"
).
change
(
filtrePosition
);
recupererCarte
();
toggleCarte
();
$
(
'#toggle-carte'
).
click
(
toggleCarte
);
});
function
filtrePosition
()
...
...
@@ -196,12 +198,29 @@
dt
.
ajax
.
url
(
'api.php?action=getDataConso&idConso=
{
$idConso
}
'
).
load
();
}
function
recupererCarte
()
function
recupererCarte
(
url
)
{
getData
(
'api.php?action=getCommunesCarte&idConso=
{
$idConso
}
'
).
then
(
function
(
svg
)
{
getData
(
url
).
then
(
function
(
svg
)
{
$
(
"#carteArea"
).
html
(
svg
);
});
}
var
carte
=
-
1
;
function
toggleCarte
()
{
if
(
carte
==
0
)
{
//On passe sur la carte des signalements
carte
=
1
;
recupererCarte
(
'api.php?action=getSignalementCarte&idConso=
{
$idConso
}
'
);
$
(
'#toggle-carte'
).
html
(
'Voir la carte des états des stations'
);
}
else
{
//On passe sur la carte des états
carte
=
0
;
recupererCarte
(
'api.php?action=getCommunesCarte&idConso=
{
$idConso
}
'
);
$
(
'#toggle-carte'
).
html
(
'Voir la carte des signalements'
);
}
}
</script>
</div>
{
include
file
=
"footer.tpl"
}
\ No newline at end of file
style.css
View file @
02c7aef8
...
...
@@ -99,4 +99,9 @@ ul
#carteArea
{
margin-left
:
2em
;
}
#toggle-carte
{
cursor
:
pointer
;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment