bus-mj 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +173 -0
- package/index.js +4 -0
- package/package.json +23 -0
- package/src/bus.json +66 -0
- package/src/getBus.js +75 -0
- package/src/read_contenu.js +24 -0
- package/src/stop.js +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# API ho amantarana ny fivezivezian'ny bus eto Mahajanga
|
|
2
|
+
|
|
3
|
+
## <u> TANJONA </u>:
|
|
4
|
+
|
|
5
|
+
#### Ho fanampina ireo vahiny, hitady ny bus tokony andehanany
|
|
6
|
+
|
|
7
|
+
#### Hanamorana ny fitadidiana ny trajet an'bus iray
|
|
8
|
+
|
|
9
|
+
#### Hialana @ tsy fahafantarana ny "arret" tokony ialana
|
|
10
|
+
|
|
11
|
+
#### Ahitana ny:
|
|
12
|
+
- "point de depart" sy "point d'arrivee"
|
|
13
|
+
- distance entre "deux point"
|
|
14
|
+
- temps de circulation
|
|
15
|
+
- ...
|
|
16
|
+
|
|
17
|
+
## <u> FAMPIASA </u>:
|
|
18
|
+
|
|
19
|
+
https://bus-mj.onrender.com/api?depart=star&fin=poste
|
|
20
|
+
|
|
21
|
+
- fanazavana: <br>
|
|
22
|
+
depart: arret du point de depart <br>
|
|
23
|
+
fin: arret du point finnal
|
|
24
|
+
|
|
25
|
+
- ny azo: <br>
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"BUS_ID": "identifiant ny bus",
|
|
29
|
+
"BUS_NAME": "anaran'ilay bus",
|
|
30
|
+
"BUS_PLAQUE": "lokon'ilay plaque",
|
|
31
|
+
"LONG": "halaviran'ny lalana",
|
|
32
|
+
"TIME": "fotoana lany",
|
|
33
|
+
"YOUR_TRAJET": ["filaharan'ireo arret handalovana"]
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- valiny ilay ohatra:
|
|
38
|
+
```json
|
|
39
|
+
|
|
40
|
+
[
|
|
41
|
+
{
|
|
42
|
+
"BUS_ID": 3,
|
|
43
|
+
"BUS_NAME": "ligne 3",
|
|
44
|
+
"BUS_PLAQUE": "",
|
|
45
|
+
"LONG": 22,
|
|
46
|
+
"TIME": 1,
|
|
47
|
+
"YOUR_TRAJET": [
|
|
48
|
+
"star",
|
|
49
|
+
"plaque 7",
|
|
50
|
+
"loterana",
|
|
51
|
+
"bazary kely",
|
|
52
|
+
"csb",
|
|
53
|
+
"croisement cimetiere",
|
|
54
|
+
"jovena",
|
|
55
|
+
"lalatapaka",
|
|
56
|
+
"plaque",
|
|
57
|
+
"miaramila",
|
|
58
|
+
"bazary antanimasaja",
|
|
59
|
+
"pompy",
|
|
60
|
+
"bizo",
|
|
61
|
+
"galana",
|
|
62
|
+
"manjarisoa",
|
|
63
|
+
"jardin Caylah",
|
|
64
|
+
"bain douche",
|
|
65
|
+
"photo sport",
|
|
66
|
+
"hôtel de ville",
|
|
67
|
+
"croix rouge",
|
|
68
|
+
"poste"
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"BUS_ID": 70,
|
|
73
|
+
"BUS_NAME": "ligne 7",
|
|
74
|
+
"BUS_PLAQUE": "bleu",
|
|
75
|
+
"LONG": 32,
|
|
76
|
+
"TIME": 51,
|
|
77
|
+
"YOUR_TRAJET": [
|
|
78
|
+
"star",
|
|
79
|
+
"plaque 7",
|
|
80
|
+
"loterana",
|
|
81
|
+
"bazary kely",
|
|
82
|
+
"csb",
|
|
83
|
+
"croisement cimetiere",
|
|
84
|
+
"jovena",
|
|
85
|
+
"lalatapaka",
|
|
86
|
+
"plaque",
|
|
87
|
+
"miaramila",
|
|
88
|
+
"bazary antanimasaja",
|
|
89
|
+
"pompy",
|
|
90
|
+
"bizo",
|
|
91
|
+
"galana",
|
|
92
|
+
"manjarisoa",
|
|
93
|
+
"jardin Caylah",
|
|
94
|
+
"galax",
|
|
95
|
+
"mahabibo",
|
|
96
|
+
"h\u00f4tel de ville",
|
|
97
|
+
"croix rouge",
|
|
98
|
+
"poste"
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"BUS_ID": 71,
|
|
103
|
+
"BUS_NAME": "ligne 7",
|
|
104
|
+
"BUS_PLAQUE": "rouge",
|
|
105
|
+
"LONG": 5,
|
|
106
|
+
"TIME": 53,
|
|
107
|
+
"YOUR_TRAJET": [
|
|
108
|
+
"star",
|
|
109
|
+
"plaque 7",
|
|
110
|
+
"loterana",
|
|
111
|
+
"bazary kely",
|
|
112
|
+
"csb",
|
|
113
|
+
"croisement cimetiere",
|
|
114
|
+
"jovena",
|
|
115
|
+
"lalatapaka",
|
|
116
|
+
"plaque",
|
|
117
|
+
"miaramila",
|
|
118
|
+
"bazary antanimasaja",
|
|
119
|
+
"pompy",
|
|
120
|
+
"bizo",
|
|
121
|
+
"galana",
|
|
122
|
+
"manjarisoa",
|
|
123
|
+
"jardin Caylah",
|
|
124
|
+
"bain douche",
|
|
125
|
+
"mahabibo",
|
|
126
|
+
"patel",
|
|
127
|
+
"bata",
|
|
128
|
+
"maki-loc",
|
|
129
|
+
"tsaralaza",
|
|
130
|
+
"pont blanc",
|
|
131
|
+
"maman'i phillipine",
|
|
132
|
+
"rond point cité",
|
|
133
|
+
"rond point taxi",
|
|
134
|
+
"croisement soatata",
|
|
135
|
+
"secaline",
|
|
136
|
+
"bar rotsaka",
|
|
137
|
+
"croisement bloc",
|
|
138
|
+
"pharmacie",
|
|
139
|
+
"hopital manarapenitra",
|
|
140
|
+
"caserne",
|
|
141
|
+
"barea",
|
|
142
|
+
"airtel",
|
|
143
|
+
"solima",
|
|
144
|
+
"lycée technique",
|
|
145
|
+
"élevage",
|
|
146
|
+
"roche rouge",
|
|
147
|
+
"maison verte",
|
|
148
|
+
"jardin d'amour",
|
|
149
|
+
"nandrasana",
|
|
150
|
+
"cnaps",
|
|
151
|
+
"bord",
|
|
152
|
+
"akbar",
|
|
153
|
+
"kakal",
|
|
154
|
+
"boa",
|
|
155
|
+
"Bazary be",
|
|
156
|
+
"score",
|
|
157
|
+
"poste"
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## <u> Mbola hanampiana azy </u>:
|
|
165
|
+
|
|
166
|
+
+ donnee de ligne du BUS: 6, 9, 10, 11, 12, 15, 18
|
|
167
|
+
+ temps de circulation
|
|
168
|
+
+ longeur
|
|
169
|
+
+ ireo arret ao anaty ny fokotany irray
|
|
170
|
+
+ depart=_fokotany_ & arrivee=_fokotany_
|
|
171
|
+
+ mamatatra ny hoe mbola miasa ve io bus io @zao (maka ny heure actuel)
|
|
172
|
+
+ mifindra BUS raha tokony hifindra rehefa tonga @arret iray (Oh: belobaka vers petit plage)
|
|
173
|
+
+ ...
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bus-mj",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "package for BUS station in Mahajanga",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/selestinohajaniaina/bus-mahajanga-api.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"api",
|
|
15
|
+
"bus-mahajanga"
|
|
16
|
+
],
|
|
17
|
+
"author": "selestino",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/selestinohajaniaina/bus-mahajanga-api/issues"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/selestinohajaniaina/bus-mahajanga-api#readme"
|
|
23
|
+
}
|
package/src/bus.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": [
|
|
3
|
+
{
|
|
4
|
+
"id": 3,
|
|
5
|
+
"name": "ligne 3",
|
|
6
|
+
"trajet": ["belobaka", "sotema", "mahabibo", "androva"],
|
|
7
|
+
"stop": ["belobaka", "star", "plaque 7", "loterana", "bazary kely", "csb", "croisement cimetiere", "jovena", "lalatapaka", "plaque", "miaramila", "bazary antanimasaja", "pompy", "bizo", "galana", "manjarisoa", "jardin Caylah", "bain douche", "photo sport", "hôtel de ville", "croix rouge", "poste", "bognet", "tribunal", "bfv", "androva"],
|
|
8
|
+
"plaque": "",
|
|
9
|
+
"color": "jaune",
|
|
10
|
+
"bande": "bleu"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"id": 5,
|
|
14
|
+
"name": "ligne 5",
|
|
15
|
+
"trajet": ["betamanga", "mazava huile", "tsaramandroso", "mahabibo", "androva"],
|
|
16
|
+
"stop": ["betamanga", "mazava huile", "ex bar nene", "pont blanc", "tsaralaza", "maki-loc", "patel", "photo sport", "hôtel de ville", "croix rouge", "poste", "bognet", "tribunal", "bfv", "androva"],
|
|
17
|
+
"plaque": "",
|
|
18
|
+
"color": "blanc",
|
|
19
|
+
"bande": "rouge"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": 70,
|
|
23
|
+
"name": "ligne 7",
|
|
24
|
+
"trajet": ["belobaka", "sotema", "mahabibo", "tsaramandroso", "mahavoky atsimo", "la corniche", "majunga be", "mahabibo", "sotema", "belobaka"],
|
|
25
|
+
"stop": ["bain douche", "patel", "maki-loc", "tsaralaza", "pont blanc", "maman'i phillipine", "rond point cité", "rond point taxi", "croisement soatata", "secaline", "bar rotsaka", "croisement bloc", "pharmacie", "hopital manarapenitra", "caserne", "barea", "airtel", "solima", "lycée technique", "élevage", "roche rouge", "maison verte", "jardin d'amour", "nandrasana", "cnaps", "bord", "akbar", "kakal", "boa", "Bazary be", "score", "poste", "croix rouge", "hôtel de ville", "mahabibo", "galax", "jardin Caylah", "manjarisoa", "galana", "bizo", "pompy", "bazary antanimasaja", "miaramila", "plaque", "lalatapaka", "jovena", "croisement cimetiere", "csb", "bazary kely", "loterana", "plaque 7", "star", "belobaka"],
|
|
26
|
+
"plaque": "bleu",
|
|
27
|
+
"color": "jaune",
|
|
28
|
+
"bande": "bleu et rouge"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"id": 71,
|
|
32
|
+
"name": "ligne 7",
|
|
33
|
+
"trajet": ["belobaka", "sotema", "mahabibo", "majunga be", "la corniche", "mahavoky atsimo", "tsaramandroso", "mahabibo", "sotema", "belobaka"],
|
|
34
|
+
"stop": ["bain douche", "photo sport", "hôtel de ville", "croix rouge", "poste", "score", "Bazary be", "boa", "kakal", "akbar", "bord", "cnaps", "nandrasana", "jardin d'amour", "maison verte", "roche rouge", "élevage", "lycée technique", "solima", "airtel", "barea", "caserne", "hopital manarapenitra", "pharmacie", "croisement bloc", "bar rotsaka", "secaline", "croisement soatata", "rond point taxi", "rond point cité", "maman'i phillipine", "pont blanc", "tsaralaza", "maki-loc", "bata", "patel", "mahabibo", "bain douche", "jardin Caylah", "manjarisoa", "galana", "bizo", "pompy", "bazary antanimasaja", "miaramila", "plaque", "lalatapaka", "jovena", "croisement cimetiere", "csb", "bazary kely", "loterana", "plaque 7", "star", "belobaka"],
|
|
35
|
+
"plaque": "rouge",
|
|
36
|
+
"color": "jaune",
|
|
37
|
+
"bande": "bleu et rouge"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"id": 8,
|
|
41
|
+
"name": "ligne 8",
|
|
42
|
+
"trajet": [],
|
|
43
|
+
"stop": ["raseta", "poteau mainty", "eponge", "mazava huile", "bar nene", "pont blanc", "tsaralaza", "maki-loc", "bata", "patel", "mahabibo", "bain douche", "jardin Caylah", "manjarisoa", "galana", "bizo", "pompy", "bazary antanimasaja", "miaramila", "plaque", "lalatapaka", "jovena", "croisement cimetiere", "..."],
|
|
44
|
+
"plaque": "",
|
|
45
|
+
"color": "blanc",
|
|
46
|
+
"bande": "rouge"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"id": 11,
|
|
50
|
+
"name": "ligne 11",
|
|
51
|
+
"trajet": [],
|
|
52
|
+
"plaque": "",
|
|
53
|
+
"color": "blanc",
|
|
54
|
+
"bande": "vert"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"id": 15,
|
|
58
|
+
"name": "ligne 15",
|
|
59
|
+
"trajet": [],
|
|
60
|
+
"stop": ["Antanimalandy", "Plaque", "Mangabe", "Fokotany", "Arabo", "Bazary kely", "Vavahady", "croisement cimetière", "Jovena", "Lala-tapaka", "Plaque", "Miaramila", "Bazary antanimasaja", "Pompy", "Bizo", "Antafa", "Galana", "Manjarisoa", "Jardin cayla", "Bain douche", "police", "jentilal", "patel", "makiloc", "tsaralaza", "bar néné", "jirama", "mazava huile", "eponge", "poto mainty", "raseta", "croisement amborovy", "csb", "epp manarapenitra", "petite plage", "belinta", "grand pavois"],
|
|
61
|
+
"plaque": "",
|
|
62
|
+
"color": "jaune",
|
|
63
|
+
"bande": "vert"
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
package/src/getBus.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const { read_contenu } = require('./read_contenu.js')
|
|
2
|
+
|
|
3
|
+
// declarer une fonction pour avoir le bon bus a prendre: d=debut && f=fin [arret]
|
|
4
|
+
async function getBus(d, f) {
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
|
|
8
|
+
// assigner a un variable les contenus du function read_contenu()
|
|
9
|
+
const bus_contenu = await read_contenu();
|
|
10
|
+
// initialiser une tableau vide pour stoquer les trajets correspondant
|
|
11
|
+
let cible = [];
|
|
12
|
+
|
|
13
|
+
// parcourir la sequence du tableau bus_contenu
|
|
14
|
+
for(let i in bus_contenu) {
|
|
15
|
+
|
|
16
|
+
// si d et f sont incluent dans 'stop' de i parcourue
|
|
17
|
+
if(bus_contenu[i]['stop'].includes(d) && bus_contenu[i]['stop'].includes(f)) {
|
|
18
|
+
|
|
19
|
+
// A et B sont l'index du d et f (debut et fin)
|
|
20
|
+
let A = bus_contenu[i]['stop'].indexOf(d);
|
|
21
|
+
let B = bus_contenu[i]['stop'].indexOf(f);
|
|
22
|
+
// trj est une liste de segment entre A : B
|
|
23
|
+
let trj = bus_contenu[i]['stop'].slice(A , B + 1);
|
|
24
|
+
|
|
25
|
+
// si A > B
|
|
26
|
+
if(A > B) {
|
|
27
|
+
// inverser le segment
|
|
28
|
+
trj = bus_contenu[i]['stop'].slice(B, A + 1);
|
|
29
|
+
trj.reverse();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// et ajouter tableau au cible cette sequence si d et i inclue dans i['stop'] est vrai
|
|
33
|
+
cible.push({
|
|
34
|
+
"BUS_ID": bus_contenu[i]['id'],
|
|
35
|
+
"BUS_NAME": bus_contenu[i]['name'],
|
|
36
|
+
"BUS_PLAQUE": bus_contenu[i]['plaque'],
|
|
37
|
+
"YOUR_TRAJET": trj,
|
|
38
|
+
"TIME": "pas definie",
|
|
39
|
+
"LONG": "pas definie"
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// retourner au fonction la valeur de cible
|
|
46
|
+
return cible;
|
|
47
|
+
|
|
48
|
+
} catch (error) {
|
|
49
|
+
|
|
50
|
+
// signaler s'il y a une erreur
|
|
51
|
+
console.error('Une erreur s\'est produite:', error);
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// declarer une fonction pour avoir tous les bus disponnible
|
|
58
|
+
async function getAllBus() {
|
|
59
|
+
|
|
60
|
+
// assigner a un variable les contenus du function read_contenu()
|
|
61
|
+
const bus_contenu = await read_contenu();
|
|
62
|
+
// initialiser une tableau vide pour stoquer les bus
|
|
63
|
+
let allBus = [];
|
|
64
|
+
|
|
65
|
+
// parcourir le contenus du bus_contenu
|
|
66
|
+
bus_contenu.map((e) => allBus.push({
|
|
67
|
+
"BUS_ID": e['id'],
|
|
68
|
+
"BUS_NAME": e['name'],
|
|
69
|
+
}))
|
|
70
|
+
|
|
71
|
+
// retourner au fonction la valeur du allBus
|
|
72
|
+
return allBus;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = { getBus, getAllBus }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const { readFile } = require('fs').promises;
|
|
2
|
+
|
|
3
|
+
// declarer un fonction asyncronisee pour lire un fichier
|
|
4
|
+
async function read_contenu() {
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
|
|
8
|
+
// lire le fichier bus.js, et assigner a unn variable le contenu
|
|
9
|
+
const data = await readFile('src/bus.json', 'utf8');
|
|
10
|
+
// charger en tant que JSON le contenue
|
|
11
|
+
const jsonData = JSON.parse(data);
|
|
12
|
+
// retourner a la fonction l'objet obtenus
|
|
13
|
+
return jsonData.data;
|
|
14
|
+
|
|
15
|
+
} catch (err) {
|
|
16
|
+
|
|
17
|
+
// signaler s'il y une errerur
|
|
18
|
+
console.error('Erreur lors de la lecture du fichier:', err);
|
|
19
|
+
throw err;
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = { read_contenu }
|
package/src/stop.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const { read_contenu } = require('./read_contenu.js')
|
|
2
|
+
|
|
3
|
+
// declarer un fonction asyncromme pour avoir tous les listes des arrets
|
|
4
|
+
async function getAllStop() {
|
|
5
|
+
|
|
6
|
+
// assigner a un variable les contenus du function read_contenu()
|
|
7
|
+
const bus_contenu = await read_contenu();
|
|
8
|
+
|
|
9
|
+
// initialiser une tableau vide pour lister les arrets de chaque BUS
|
|
10
|
+
let stopArray = [];
|
|
11
|
+
|
|
12
|
+
// initialiser une autre tableau pour stoquer les arrets en eliminant le repetitive
|
|
13
|
+
let stop = [];
|
|
14
|
+
|
|
15
|
+
// parcourir le bus_contenu
|
|
16
|
+
bus_contenu.map((e) => {
|
|
17
|
+
// ajouter au stopArray la valeur du "stop" du bus_contenu
|
|
18
|
+
stopArray.push(e['stop']);
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
// parcourir le contenus (listes) du stopArray
|
|
22
|
+
stopArray.map((e) => {
|
|
23
|
+
|
|
24
|
+
// parcourir le tableau integree de chaque liste du contenu de stopArray
|
|
25
|
+
e.map((stp) => {
|
|
26
|
+
// ajouter a la tableau stop un contenus s'il n'existe pas deja
|
|
27
|
+
if(!stop.includes(stp)){
|
|
28
|
+
stop.push(stp);
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
// retourner a la fonction tout le contenus du stop
|
|
35
|
+
return stop;
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// declarer un fonctiom pour avoir une liste des arrets d'une bus
|
|
40
|
+
async function getStop(bus_id) {
|
|
41
|
+
|
|
42
|
+
// assigner a un variable les contenus du function read_contenu()
|
|
43
|
+
const bus_contenu = await read_contenu();
|
|
44
|
+
|
|
45
|
+
// parcourir le contenus du bus_contenu
|
|
46
|
+
for(let bus in bus_contenu) {
|
|
47
|
+
|
|
48
|
+
// si bus_id==id (du contenue)
|
|
49
|
+
if(bus_contenu[bus]['id'] == bus_id) {
|
|
50
|
+
// retourne au fonction ses arrets
|
|
51
|
+
return bus_contenu[bus]['stop'];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = { getAllStop, getStop }
|