bus-mj 1.1.5 → 1.2.0
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 +52 -196
- package/data/bus.js +125 -0
- package/index.d.ts +11 -14
- package/index.js +3 -3
- package/package.json +1 -1
- package/src/getBus.js +63 -65
- package/src/stop.js +23 -51
- package/src/bus.js +0 -67
- package/src/read_contenu.js +0 -20
package/README.md
CHANGED
|
@@ -17,226 +17,82 @@
|
|
|
17
17
|
## <u> import </u>:
|
|
18
18
|
|
|
19
19
|
```js
|
|
20
|
-
import { getBus, getAllBus, getAllStop, getStop } from 'bus-mj';
|
|
20
|
+
import { getBus, getAllBus, getAllStop, getStop, getStopLabel } from 'bus-mj';
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## <u> usage </u>:
|
|
24
24
|
|
|
25
|
+
- List Bus
|
|
25
26
|
```js
|
|
26
|
-
// declarer une fonction asynchrone
|
|
27
|
-
async function main() {
|
|
28
|
-
|
|
29
27
|
// maka ny lisitry ny bus rehetra
|
|
30
|
-
console.log(
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
main();
|
|
28
|
+
console.log(getAllBus());
|
|
35
29
|
```
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
{
|
|
39
|
-
"BUS_ID":3,
|
|
40
|
-
"BUS_NAME":"ligne 3"
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"BUS_ID":5,
|
|
44
|
-
"BUS_NAME":"ligne 5"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"BUS_ID":70,
|
|
48
|
-
"BUS_NAME":"ligne 7"
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"BUS_ID":71,
|
|
52
|
-
"BUS_NAME":"ligne 7"
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
"BUS_ID":8,
|
|
56
|
-
"BUS_NAME":"ligne 8"
|
|
57
|
-
},
|
|
30
|
+
```typescript
|
|
31
|
+
// result
|
|
58
32
|
{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
33
|
+
L3: {
|
|
34
|
+
label: 'ligne 3',
|
|
35
|
+
color: 'yellow',
|
|
36
|
+
band: ['blue']
|
|
37
|
+
},
|
|
38
|
+
...
|
|
65
39
|
}
|
|
66
|
-
]
|
|
67
40
|
```
|
|
68
41
|
|
|
42
|
+
- List Stops
|
|
69
43
|
```js
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// maka ny lisitry ny arret rehetra
|
|
74
|
-
console.log(await getAllStop());
|
|
75
|
-
|
|
76
|
-
// maka ny lisitry ny arret @bus mitondra id=3
|
|
77
|
-
console.log(await getStop(3));
|
|
78
|
-
|
|
79
|
-
// maka ny lisitry ny bus mandalo @ arret de depart='star' sy arrive='poste'
|
|
80
|
-
console.log(await getBus('star', 'poste'));
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
main();
|
|
44
|
+
// maka ny lisitry ny bus rehetra
|
|
45
|
+
console.log(getAllStop());
|
|
85
46
|
```
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
- ny azo: <br>
|
|
95
|
-
```json
|
|
96
|
-
{
|
|
97
|
-
"BUS_ID": "identifiant ny bus",
|
|
98
|
-
"BUS_NAME": "anaran'ilay bus",
|
|
99
|
-
"BUS_PLAQUE": "lokon'ilay plaque",
|
|
100
|
-
"LONG": "halaviran'ny lalana",
|
|
101
|
-
"TIME": "fotoana lany",
|
|
102
|
-
"YOUR_TRAJET": ["filaharan'ireo arret handalovana"]
|
|
103
|
-
}
|
|
47
|
+
```typescript
|
|
48
|
+
// result
|
|
49
|
+
[
|
|
50
|
+
{ key: 'S48', value: 'jardin kaylah' },
|
|
51
|
+
{ key: 'S49', value: 'jean paul 2' },
|
|
52
|
+
{ key: 'S50', value: 'jentilal' },
|
|
53
|
+
...
|
|
54
|
+
]
|
|
104
55
|
```
|
|
105
56
|
|
|
106
|
-
-
|
|
107
|
-
```
|
|
57
|
+
- Get Label of Stop's id
|
|
58
|
+
```js
|
|
59
|
+
// maka ny anaran'ny arret
|
|
60
|
+
console.log(getStopLabel("S48"));
|
|
61
|
+
```
|
|
62
|
+
```typescript
|
|
63
|
+
// result
|
|
64
|
+
jardin kaylah
|
|
65
|
+
```
|
|
108
66
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
"plaque 7",
|
|
119
|
-
"loterana",
|
|
120
|
-
"bazary kely",
|
|
121
|
-
"csb",
|
|
122
|
-
"croisement cimetiere",
|
|
123
|
-
"jovena",
|
|
124
|
-
"lalatapaka",
|
|
125
|
-
"plaque",
|
|
126
|
-
"miaramila",
|
|
127
|
-
"bazary antanimasaja",
|
|
128
|
-
"pompy",
|
|
129
|
-
"bizo",
|
|
130
|
-
"galana",
|
|
131
|
-
"manjarisoa",
|
|
132
|
-
"jardin Caylah",
|
|
133
|
-
"bain douche",
|
|
134
|
-
"photo sport",
|
|
135
|
-
"hôtel de ville",
|
|
136
|
-
"croix rouge",
|
|
137
|
-
"poste"
|
|
138
|
-
]
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
"BUS_ID": 70,
|
|
142
|
-
"BUS_NAME": "ligne 7",
|
|
143
|
-
"BUS_PLAQUE": "bleu",
|
|
144
|
-
"LONG": 32,
|
|
145
|
-
"TIME": 51,
|
|
146
|
-
"YOUR_TRAJET": [
|
|
147
|
-
"star",
|
|
148
|
-
"plaque 7",
|
|
149
|
-
"loterana",
|
|
150
|
-
"bazary kely",
|
|
151
|
-
"csb",
|
|
152
|
-
"croisement cimetiere",
|
|
153
|
-
"jovena",
|
|
154
|
-
"lalatapaka",
|
|
155
|
-
"plaque",
|
|
156
|
-
"miaramila",
|
|
157
|
-
"bazary antanimasaja",
|
|
158
|
-
"pompy",
|
|
159
|
-
"bizo",
|
|
160
|
-
"galana",
|
|
161
|
-
"manjarisoa",
|
|
162
|
-
"jardin Caylah",
|
|
163
|
-
"galax",
|
|
164
|
-
"mahabibo",
|
|
165
|
-
"h\u00f4tel de ville",
|
|
166
|
-
"croix rouge",
|
|
167
|
-
"poste"
|
|
168
|
-
]
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
"BUS_ID": 71,
|
|
172
|
-
"BUS_NAME": "ligne 7",
|
|
173
|
-
"BUS_PLAQUE": "rouge",
|
|
174
|
-
"LONG": 5,
|
|
175
|
-
"TIME": 53,
|
|
176
|
-
"YOUR_TRAJET": [
|
|
177
|
-
"star",
|
|
178
|
-
"plaque 7",
|
|
179
|
-
"loterana",
|
|
180
|
-
"bazary kely",
|
|
181
|
-
"csb",
|
|
182
|
-
"croisement cimetiere",
|
|
183
|
-
"jovena",
|
|
184
|
-
"lalatapaka",
|
|
185
|
-
"plaque",
|
|
186
|
-
"miaramila",
|
|
187
|
-
"bazary antanimasaja",
|
|
188
|
-
"pompy",
|
|
189
|
-
"bizo",
|
|
190
|
-
"galana",
|
|
191
|
-
"manjarisoa",
|
|
192
|
-
"jardin Caylah",
|
|
193
|
-
"bain douche",
|
|
194
|
-
"mahabibo",
|
|
195
|
-
"patel",
|
|
196
|
-
"bata",
|
|
197
|
-
"maki-loc",
|
|
198
|
-
"tsaralaza",
|
|
199
|
-
"pont blanc",
|
|
200
|
-
"maman'i phillipine",
|
|
201
|
-
"rond point cité",
|
|
202
|
-
"rond point taxi",
|
|
203
|
-
"croisement soatata",
|
|
204
|
-
"secaline",
|
|
205
|
-
"bar rotsaka",
|
|
206
|
-
"croisement bloc",
|
|
207
|
-
"pharmacie",
|
|
208
|
-
"hopital manarapenitra",
|
|
209
|
-
"caserne",
|
|
210
|
-
"barea",
|
|
211
|
-
"airtel",
|
|
212
|
-
"solima",
|
|
213
|
-
"lycée technique",
|
|
214
|
-
"élevage",
|
|
215
|
-
"roche rouge",
|
|
216
|
-
"maison verte",
|
|
217
|
-
"jardin d'amour",
|
|
218
|
-
"nandrasana",
|
|
219
|
-
"cnaps",
|
|
220
|
-
"bord",
|
|
221
|
-
"akbar",
|
|
222
|
-
"kakal",
|
|
223
|
-
"boa",
|
|
224
|
-
"Bazary be",
|
|
225
|
-
"score",
|
|
226
|
-
"poste"
|
|
227
|
-
]
|
|
228
|
-
}
|
|
229
|
-
]
|
|
67
|
+
- Get Stop of Bus
|
|
68
|
+
```js
|
|
69
|
+
// maka ny arret ny bus
|
|
70
|
+
console.log(getStop("L3"));
|
|
71
|
+
```
|
|
72
|
+
```typescript
|
|
73
|
+
// result
|
|
74
|
+
['S8', 'S72', 'S46', ..., 'S18']
|
|
75
|
+
```
|
|
230
76
|
|
|
77
|
+
- Get The Right Bus
|
|
78
|
+
```js
|
|
79
|
+
// maka ny lisitry ny bus mandalo @ arret de depart S48='jardin kaylah' sy arrive S41='Galana'
|
|
80
|
+
console.log(getBus('S48', 'S41'));
|
|
81
|
+
```
|
|
82
|
+
```typescript
|
|
83
|
+
// result
|
|
84
|
+
[
|
|
85
|
+
{ BUS_ID: 'L3', ROAD: [ 'S48', 'S63', 'S41' ] },
|
|
86
|
+
...
|
|
87
|
+
]
|
|
231
88
|
```
|
|
232
89
|
|
|
233
90
|
## <u> Mbola hanampiana azy </u>:
|
|
234
91
|
|
|
235
|
-
+ donnee de ligne du BUS: 6, 9,
|
|
92
|
+
+ donnee de ligne du BUS: 6, 9, 12, 18
|
|
236
93
|
+ temps de circulation
|
|
237
94
|
+ longeur
|
|
238
95
|
+ ireo arret ao anaty ny fokotany irray
|
|
239
|
-
+ depart=_fokotany_ & arrivee=_fokotany_
|
|
240
96
|
+ mamatatra ny hoe mbola miasa ve io bus io @zao (maka ny heure actuel)
|
|
241
97
|
+ mifindra BUS raha tokony hifindra rehefa tonga @arret iray (Oh: belobaka vers petit plage)
|
|
242
98
|
+ ...
|
package/data/bus.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"BUS": {
|
|
3
|
+
"L3": { "label": "ligne 3", "color": "yellow", "band": ["blue"] },
|
|
4
|
+
"L5": { "label": "ligne 5", "color": "white", "band": ["red"] },
|
|
5
|
+
"L6": { "label": "ligne 6", "color": "white", "band": ["green"] },
|
|
6
|
+
"L70": { "label": "ligne 7", "color": "yellow", "band": ["blue", "red"] },
|
|
7
|
+
"L71": { "label": "ligne 7", "color": "yellow", "band": ["blue", "red"] },
|
|
8
|
+
"L8": { "label": "ligne 9", "color": "white", "band": ["red"] },
|
|
9
|
+
"L9": { "label": "ligne 9", "color": "blue", "band": ["yellow"] },
|
|
10
|
+
"L11": { "label": "ligne 11", "color": "white", "band": ["green"] },
|
|
11
|
+
"L12": { "label": "ligne 12", "color": "white", "band": ["yellow"] },
|
|
12
|
+
"L15": { "label": "ligne 15", "color": "yellow", "band": ["green"] },
|
|
13
|
+
"L180": { "label": "ligne 18", "color": "yellow", "band": ["red"] },
|
|
14
|
+
"L181": { "label": "ligne 18", "color": "yellow", "band": ["red"] }
|
|
15
|
+
},
|
|
16
|
+
"STOPS": {
|
|
17
|
+
"S1": "airtel",
|
|
18
|
+
"S2": "akbar",
|
|
19
|
+
"S3": "alexia",
|
|
20
|
+
"S4": "androva",
|
|
21
|
+
"S5": "antanimalandy",
|
|
22
|
+
"S6": "arabo",
|
|
23
|
+
"S7": "atafa",
|
|
24
|
+
"S8": "bain douche",
|
|
25
|
+
"S9": "bar nene",
|
|
26
|
+
"S10": "bar rotsaka",
|
|
27
|
+
"S11": "barea",
|
|
28
|
+
"S12": "bata",
|
|
29
|
+
"S13": "bazary antanimasaja",
|
|
30
|
+
"S14": "bazary be",
|
|
31
|
+
"S15": "bazary kely",
|
|
32
|
+
"S16": "be fleur",
|
|
33
|
+
"S17": "belinta",
|
|
34
|
+
"S18": "belobaka",
|
|
35
|
+
"S19": "betamanga",
|
|
36
|
+
"S20": "bfv",
|
|
37
|
+
"S21": "bizo",
|
|
38
|
+
"S22": "boa",
|
|
39
|
+
"S23": "bognet",
|
|
40
|
+
"S24": "boina beach(caveau,elevage)",
|
|
41
|
+
"S25": "bois sacré",
|
|
42
|
+
"S26": "bonet",
|
|
43
|
+
"S27": "bord",
|
|
44
|
+
"S28": "caserne",
|
|
45
|
+
"S29": "cnaps",
|
|
46
|
+
"S30": "croisement amborovy",
|
|
47
|
+
"S31": "croisement bloc",
|
|
48
|
+
"S32": "croisement cimetiere",
|
|
49
|
+
"S33": "croisement soatata",
|
|
50
|
+
"S34": "croix rouge",
|
|
51
|
+
"S35": "csb",
|
|
52
|
+
"S36": "elevage",
|
|
53
|
+
"S37": "eponge",
|
|
54
|
+
"S38": "epp manarapenitra",
|
|
55
|
+
"S39": "esige",
|
|
56
|
+
"S40": "fokotany",
|
|
57
|
+
"S41": "galana",
|
|
58
|
+
"S42": "galax",
|
|
59
|
+
"S43": "grand pavois",
|
|
60
|
+
"S44": "gymnase",
|
|
61
|
+
"S45": "hopital manarapenitra",
|
|
62
|
+
"S46": "hôtel de ville",
|
|
63
|
+
"S47": "jardin d'amour",
|
|
64
|
+
"S48": "jardin kaylah",
|
|
65
|
+
"S49": "jean paul 2",
|
|
66
|
+
"S50": "jentilal",
|
|
67
|
+
"S51": "jirama amboboka",
|
|
68
|
+
"S52": "jovena",
|
|
69
|
+
"S53": "kakal",
|
|
70
|
+
"S54": "lalatapaka",
|
|
71
|
+
"S55": "loterana",
|
|
72
|
+
"S56": "lycée technique",
|
|
73
|
+
"S57": "mahabibo",
|
|
74
|
+
"S58": "maison vert",
|
|
75
|
+
"S59": "maki-loc",
|
|
76
|
+
"S60": "maman'i phillipine",
|
|
77
|
+
"S61": "mangabe (tsararano)",
|
|
78
|
+
"S62": "mangatoka",
|
|
79
|
+
"S63": "manjarisoa",
|
|
80
|
+
"S64": "masera",
|
|
81
|
+
"S65": "maternite",
|
|
82
|
+
"S66": "mazava huile",
|
|
83
|
+
"S67": "miaramila",
|
|
84
|
+
"S68": "nandrasana",
|
|
85
|
+
"S69": "patel",
|
|
86
|
+
"S70": "petite plage",
|
|
87
|
+
"S71": "pharmacie",
|
|
88
|
+
"S72": "photo sport",
|
|
89
|
+
"S73": "plaque",
|
|
90
|
+
"S74": "plaque 7",
|
|
91
|
+
"S75": "police mahabibo",
|
|
92
|
+
"S76": "pompy",
|
|
93
|
+
"S77": "pont blanc",
|
|
94
|
+
"S78": "poste",
|
|
95
|
+
"S79": "poto mainty",
|
|
96
|
+
"S80": "raseta",
|
|
97
|
+
"S81": "roche rouge",
|
|
98
|
+
"S82": "rond point cité",
|
|
99
|
+
"S83": "rond point taxi",
|
|
100
|
+
"S84": "score",
|
|
101
|
+
"S85": "secaline",
|
|
102
|
+
"S86": "solima",
|
|
103
|
+
"S87": "star",
|
|
104
|
+
"S88": "television",
|
|
105
|
+
"S89": "terminus",
|
|
106
|
+
"S90": "tribunal",
|
|
107
|
+
"S91": "tsaralaza",
|
|
108
|
+
"S92": "université ambondrona",
|
|
109
|
+
"S93": "vim"
|
|
110
|
+
},
|
|
111
|
+
"BUS_STOPS": {
|
|
112
|
+
"L3": ["S87", "S74", "S55", "S49", "S40", "S88", "S6", "S15", "S35", "S32", "S52", "S54", "S73", "S67", "S13", "S76", "S21", "S41", "S63", "S48", "S8", "S72", "S46", "S34", "S78", "S23", "S90", "S20", "S4"],
|
|
113
|
+
"L5": ["S19", "S66", "S51", "S9", "S77", "S91", "S59", "S69", "S72", "S46", "S34", "S78", "S23", "S90", "S20", "S4"],
|
|
114
|
+
"L6": [],
|
|
115
|
+
"L70": ["S8", "S75", "S50", "S69", "S59", "S91", "S77", "S60", "S82", "S83", "S33", "S85", "S10", "S31", "S71", "S45", "S28", "S11", "S1", "S86", "S56", "S36", "S81", "S58", "S47", "S68", "S29", "S27", "S2", "S53", "S22", "S14", "S84", "S78", "S34", "S46", "S57", "S42", "S48", "S63", "S41", "S21", "S76", "S13", "S67", "S73", "S54", "S52", "S32", "S35", "S15", "S6", "S88", "S40", "S49", "S55", "S74", "S87", "S18"],
|
|
116
|
+
"L71": ["S8", "S72", "S46", "S34", "S78", "S84", "S14", "S22", "S53", "S2", "S27", "S29", "S68", "S47", "S58", "S81", "S36", "S56", "S86", "S1", "S11", "S28", "S45", "S71", "S31", "S10", "S85", "S33", "S83", "S82", "S60", "S77", "S91", "S59", "S69", "S50", "S57", "S42", "S48", "S63", "S41", "S21", "S76", "S13", "S67", "S73", "S54", "S52", "S32", "S35", "S15", "S6", "S88", "S40", "S49", "S55", "S74", "S87", "S18"],
|
|
117
|
+
"L8": ["S80", "S79", "S37", "S66", "S51", "S9", "S77", "S91", "S59", "S12", "S69", "S57", "S8", "S48", "S63", "S41", "S21", "S76", "S13", "S67", "S73", "S54", "S52", "S32", "S62"],
|
|
118
|
+
"L9": [],
|
|
119
|
+
"L11": ["S92", "S3", "S64", "S61", "S93", "S16", "S39", "S13", "S76", "S21", "S7", "S41", "S63", "S48", "S8", "S75", "S50", "S69", "S59", "S65", "S25", "S44", "S78", "S26", "S90", "S20", "S27", "S29", "S47", "S58", "S24", "S56", "S89"],
|
|
120
|
+
"L12": [],
|
|
121
|
+
"L15": ["S5", "S73", "S49", "S40", "S88", "S6", "S15", "S35", "S32", "S52", "S54", "S73", "S67", "S13", "S76", "S21", "S41", "S63", "S48", "S8", "S75", "S50", "S69", "S59", "S91", "S9", "S51", "S66", "S37", "S79", "S80", "S30", "S35", "S38", "S70", "S17", "S43"],
|
|
122
|
+
"L180": [],
|
|
123
|
+
"L181": []
|
|
124
|
+
}
|
|
125
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
// index.d.ts
|
|
2
|
-
|
|
3
1
|
declare module 'bus-mj' {
|
|
4
|
-
export function getBus(
|
|
5
|
-
BUS_ID:
|
|
6
|
-
|
|
7
|
-
BUS_PLAQUE: string,
|
|
8
|
-
LONG: string,
|
|
9
|
-
TIME: string,
|
|
10
|
-
YOUR_TRAJET: []
|
|
2
|
+
export function getBus(start: string, end: string): [{
|
|
3
|
+
BUS_ID: string,
|
|
4
|
+
ROAD: string[]
|
|
11
5
|
}];
|
|
12
6
|
export function getAllBus(): [{
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
label: string,
|
|
8
|
+
color: string,
|
|
9
|
+
band: string[]
|
|
15
10
|
}];
|
|
16
|
-
export function
|
|
17
|
-
export function
|
|
18
|
-
|
|
11
|
+
export function busAt(busId: string): {label: string,color: string,band: string[]};
|
|
12
|
+
export function getAllStop(): { key: string, value: string }[];
|
|
13
|
+
export function getStop(busId: string): string[];
|
|
14
|
+
export function getStopLabel(stopId: string): string[];
|
|
15
|
+
}
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { getBus, getAllBus } = require('./src/getBus.js');
|
|
2
|
-
const { getAllStop, getStop } = require('./src/stop.js');
|
|
1
|
+
const { getBus, getAllBus, busAt } = require('./src/getBus.js');
|
|
2
|
+
const { getAllStop, getStop, getStopLabel } = require('./src/stop.js');
|
|
3
3
|
|
|
4
|
-
module.exports = { getBus, getAllBus, getAllStop, getStop }
|
|
4
|
+
module.exports = { getBus, getAllBus, getAllStop, getStop, getStopLabel, busAt }
|
package/package.json
CHANGED
package/src/getBus.js
CHANGED
|
@@ -1,75 +1,73 @@
|
|
|
1
|
-
const {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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);
|
|
1
|
+
const { BUS, BUS_STOPS } = require('../data/bus.js');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* find the right bus of trajet giving
|
|
5
|
+
* @param {string} begin STOP_ID - begin of Road
|
|
6
|
+
* @param {string} end STOP_ID - end of Road
|
|
7
|
+
* @returns {Number[]}
|
|
8
|
+
*/
|
|
9
|
+
function getBus(begin, end) {
|
|
10
|
+
|
|
11
|
+
let bus = [];
|
|
12
|
+
|
|
13
|
+
// format object STOPS to { BUS_ID: string, ROAD: string[] }
|
|
14
|
+
Object.entries(BUS_STOPS).map((e)=> bus.push({BUS_ID: e[0], ROAD: e[1]}))
|
|
24
15
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
16
|
+
let cible = [];
|
|
17
|
+
|
|
18
|
+
for(let item of bus) {
|
|
19
|
+
|
|
20
|
+
let trajet = [];
|
|
21
|
+
|
|
22
|
+
if(item.ROAD.includes(begin) && item.ROAD.includes(end) ) {
|
|
23
|
+
/**
|
|
24
|
+
* beginPosition : position of begin road (BUS_ID)
|
|
25
|
+
* endPosition : position of end road (BUS_ID)
|
|
26
|
+
*/
|
|
27
|
+
let beginPosition = item.ROAD.indexOf(begin);
|
|
28
|
+
let endPosition = item.ROAD.indexOf(end);
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* cut the road just interval of trajet
|
|
32
|
+
* [condition]: Verify if the index of begin is less than end
|
|
33
|
+
* [else condition]: Verify if the index of begin is more than end
|
|
34
|
+
*/
|
|
35
|
+
if(beginPosition < endPosition) {
|
|
36
|
+
|
|
37
|
+
// slice the array ROAD in beginPosition and endPosition
|
|
38
|
+
trajet = item.ROAD.slice(beginPosition, endPosition + 1);
|
|
39
|
+
cible.push({BUS_ID: item.BUS_ID, ROAD: trajet});
|
|
40
|
+
|
|
41
|
+
} else if (beginPosition > endPosition) {
|
|
42
|
+
|
|
43
|
+
// revese the slice of ROAD array
|
|
44
|
+
trajet = item.ROAD.slice(endPosition, beginPosition + 1).reverse();
|
|
45
|
+
cible.push({BUS_ID: item.BUS_ID, ROAD: trajet});
|
|
41
46
|
}
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// retourner au fonction la valeur de cible
|
|
46
|
-
return cible;
|
|
47
|
-
|
|
48
|
-
} catch (error) {
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
console.error('Une erreur s\'est produite:', error);
|
|
48
|
+
}
|
|
52
49
|
|
|
53
50
|
}
|
|
54
51
|
|
|
52
|
+
return cible;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* fetch all bus
|
|
57
|
+
* @returns { BUS{} }
|
|
58
|
+
*/
|
|
59
|
+
function getAllBus() {
|
|
60
|
+
|
|
61
|
+
return BUS;
|
|
55
62
|
}
|
|
56
63
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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;
|
|
64
|
+
/**
|
|
65
|
+
* fetch the description of bus
|
|
66
|
+
* @param {string} busId reference of bus
|
|
67
|
+
* @returns description of bus
|
|
68
|
+
*/
|
|
69
|
+
function busAt(busId) {
|
|
70
|
+
return BUS[busId];
|
|
73
71
|
}
|
|
74
72
|
|
|
75
|
-
module.exports = { getBus, getAllBus }
|
|
73
|
+
module.exports = { getBus, getAllBus, busAt }
|
package/src/stop.js
CHANGED
|
@@ -1,61 +1,33 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { STOPS, BUS_STOPS } = require('../data/bus.js');
|
|
2
2
|
|
|
3
|
-
// declarer un fonction asyncromme pour avoir tous les listes des arrets
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @returns
|
|
4
|
+
* list all STOPS in data
|
|
5
|
+
* @returns { [] }
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// initialiser une autre tableau pour stoquer les arrets en eliminant le repetitive
|
|
17
|
-
let stop = [];
|
|
18
|
-
|
|
19
|
-
// parcourir le bus_contenu
|
|
20
|
-
bus_contenu.map((e) => {
|
|
21
|
-
// ajouter au stopArray la valeur du "stop" du bus_contenu
|
|
22
|
-
stopArray.push(e['stop']);
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
// parcourir le contenus (listes) du stopArray
|
|
26
|
-
stopArray.map((e) => {
|
|
27
|
-
|
|
28
|
-
// parcourir le tableau integree de chaque liste du contenu de stopArray
|
|
29
|
-
e.map((stp) => {
|
|
30
|
-
// ajouter a la tableau stop un contenus s'il n'existe pas deja
|
|
31
|
-
if(!stop.includes(stp)){
|
|
32
|
-
stop.push(stp);
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
// retourner a la fonction tout le contenus du stop
|
|
39
|
-
return stop;
|
|
40
|
-
|
|
7
|
+
function getAllStop() {
|
|
8
|
+
|
|
9
|
+
let stops = [];
|
|
10
|
+
|
|
11
|
+
// format object STOPS to { key: string, value: string }
|
|
12
|
+
Object.entries(STOPS).map((e)=> stops.push({key: e[0], value: e[1]}))
|
|
13
|
+
|
|
14
|
+
return stops;
|
|
41
15
|
}
|
|
42
16
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
17
|
+
/**
|
|
18
|
+
* list the stop of bus
|
|
19
|
+
* @param {String} bus_id id of bus L3 or L5 ...
|
|
20
|
+
* @returns {}
|
|
21
|
+
*/
|
|
22
|
+
function getStop(bus_id) {
|
|
48
23
|
|
|
49
|
-
//
|
|
50
|
-
|
|
24
|
+
// get the stops of bus
|
|
25
|
+
return BUS_STOPS[bus_id]
|
|
26
|
+
}
|
|
51
27
|
|
|
52
|
-
|
|
53
|
-
if(bus_contenu[bus]['id'] == bus_id) {
|
|
54
|
-
// retourne au fonction ses arrets
|
|
55
|
-
return bus_contenu[bus]['stop'];
|
|
56
|
-
}
|
|
28
|
+
function getStopLabel(stop_id) {
|
|
57
29
|
|
|
58
|
-
|
|
30
|
+
return STOPS[stop_id];
|
|
59
31
|
}
|
|
60
32
|
|
|
61
|
-
module.exports = { getAllStop, getStop }
|
|
33
|
+
module.exports = { getAllStop, getStop, getStopLabel }
|
package/src/bus.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
const datao = [
|
|
2
|
-
{
|
|
3
|
-
"id": 3,
|
|
4
|
-
"name": "ligne 3",
|
|
5
|
-
"trajet": ["belobaka", "sotema", "mahabibo", "androva"],
|
|
6
|
-
"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"],
|
|
7
|
-
"plaque": "",
|
|
8
|
-
"color": "jaune",
|
|
9
|
-
"bande": "bleu"
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
"id": 5,
|
|
13
|
-
"name": "ligne 5",
|
|
14
|
-
"trajet": ["betamanga", "mazava huile", "tsaramandroso", "mahabibo", "androva"],
|
|
15
|
-
"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"],
|
|
16
|
-
"plaque": "",
|
|
17
|
-
"color": "blanc",
|
|
18
|
-
"bande": "rouge"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"id": 70,
|
|
22
|
-
"name": "ligne 7",
|
|
23
|
-
"trajet": ["belobaka", "sotema", "mahabibo", "tsaramandroso", "mahavoky atsimo", "la corniche", "majunga be", "mahabibo", "sotema", "belobaka"],
|
|
24
|
-
"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"],
|
|
25
|
-
"plaque": "bleu",
|
|
26
|
-
"color": "jaune",
|
|
27
|
-
"bande": "bleu et rouge"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"id": 71,
|
|
31
|
-
"name": "ligne 7",
|
|
32
|
-
"trajet": ["belobaka", "sotema", "mahabibo", "majunga be", "la corniche", "mahavoky atsimo", "tsaramandroso", "mahabibo", "sotema", "belobaka"],
|
|
33
|
-
"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"],
|
|
34
|
-
"plaque": "rouge",
|
|
35
|
-
"color": "jaune",
|
|
36
|
-
"bande": "bleu et rouge"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"id": 8,
|
|
40
|
-
"name": "ligne 8",
|
|
41
|
-
"trajet": [""],
|
|
42
|
-
"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", "..."],
|
|
43
|
-
"plaque": "",
|
|
44
|
-
"color": "blanc",
|
|
45
|
-
"bande": "rouge"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"id": 11,
|
|
49
|
-
"name": "ligne 11",
|
|
50
|
-
"trajet": [""],
|
|
51
|
-
"stop": ["université ambondrona", "alexia", "masera", "mangabe (tsararano)", "misy arret hafa koa eto f ts aiko f ef nandalovako ", "vim", "be fleur", "esige", "bazary antanimasaja", "pompy mahatsinjo", "biso", "atafa", "galana", "manjarisoa", "jardin cayla", "bain douche", "police mahabibo", "jentilal (concoorde)", "patel (5 etage)", "makiloc", "maternite (csb avy aty ambony)", "bois sacrÉ", "gymnase", "poste ( don bosco)", "bonet", "tribunal", "bfv", "bord (finance)", "cnaps taloha", "jardin damour", "maison vert", "boina beach(caveau,elevage)", "lycee technique (terrain)", "terminus"],
|
|
52
|
-
"plaque": "",
|
|
53
|
-
"color": "blanc",
|
|
54
|
-
"bande": "vert"
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
"id": 15,
|
|
58
|
-
"name": "ligne 15",
|
|
59
|
-
"trajet": [""],
|
|
60
|
-
"stop": ["antanimalandy", "plaque", "mangabe (antanimalandy)", "fokotany", "arabo", "bazary kely", "vavahady", "croisement cimetière", "jovena", "lalatapaka", "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
|
-
|
|
67
|
-
module.exports = { datao }
|
package/src/read_contenu.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const { datao } = require('./bus.js')
|
|
2
|
-
|
|
3
|
-
// declarer un fonction asyncronisee pour lire un fichier
|
|
4
|
-
async function read_contenu() {
|
|
5
|
-
|
|
6
|
-
try {
|
|
7
|
-
|
|
8
|
-
// retourner la variable datao qui contien tous les donnees
|
|
9
|
-
return datao;
|
|
10
|
-
|
|
11
|
-
} catch (err) {
|
|
12
|
-
|
|
13
|
-
// signaler s'il y une errerur
|
|
14
|
-
console.error('Erreur lors de la lecture du fichier:', err);
|
|
15
|
-
throw err;
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
module.exports = { read_contenu }
|