bus-mj 2.1.0 → 2.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 CHANGED
@@ -2,11 +2,8 @@
2
2
 
3
3
  ## <u> TANJONA </u>:
4
4
 
5
- #### Ho fanampina ireo vahiny, hitady ny bus tokony andehanany
5
+ #### Ho fanampina ireo "developer" hanamboatra vahaolana
6
6
 
7
- #### Hanamorana ny fitadidiana ny trajet an'bus iray
8
-
9
- #### Hialana @ tsy fahafantarana ny "arret" tokony ialana
10
7
 
11
8
  ## <u> import </u>:
12
9
 
@@ -16,7 +13,14 @@ import {
16
13
  findStopAll,
17
14
  findBusDetailById,
18
15
  findBusByOneStop,
19
- findBusByTwoStop
16
+ findBusByTwoStop,
17
+ findOperatorAll,
18
+ findZoneAll,
19
+ findBusDetailByOperator,
20
+ findOpenHoursAll,
21
+ findStopByRef,
22
+ findBusByStopLabel,
23
+ findBusByTwoStopLabel
20
24
  } from "bus-mj";
21
25
  ```
22
26
 
@@ -263,6 +267,82 @@ console.log( findBusByTwoStop( 2006531160, 11029976167 ) );
263
267
  ];
264
268
  ```
265
269
 
270
+
271
+ - List Bus
272
+
273
+ ```js
274
+ // maka ny lisitry ny koperativa ny bus rehetra
275
+ console.log( findOperatorAll() );
276
+ ```
277
+
278
+ ```typescript
279
+ // result
280
+ [
281
+ 'MAMI',
282
+ 'KOFIBE/ KOFIMARE',
283
+ 'MAHATSINJO',
284
+ 'TAMBATRA',
285
+ 'NY ANTSIKA',
286
+ 'AMBONDRONA',
287
+ 'MIRAY',
288
+ 'KOFIMARE',
289
+ 'AINA'
290
+ ]
291
+ ```
292
+
293
+ - Find The Right Bus of 2 stop's label
294
+
295
+ ```js
296
+ // maka ny lisitry ny bus mandalo @ arret roa
297
+ // ex1: 'abad' - arret bus Abad (Sotema)
298
+ // ex2: 'bord' - arret bus Bord (Majunga be)
299
+ console.log( findBusByTwoStopLabel( 'abad', 'bord' ) );
300
+ ```
301
+
302
+ ```typescript
303
+ // result
304
+ [
305
+ {
306
+ type: "relation",
307
+ id: 16057683,
308
+ members: [
309
+ ...
310
+ {
311
+ type: "node",
312
+ id: 2006531160,
313
+ lat: -15.706214,
314
+ lon: 46.3799647,
315
+ label: "Abad",
316
+ },
317
+ ...
318
+ {
319
+ type: 'node',
320
+ id: 11029976167,
321
+ lat: -15.7211965,
322
+ lon: 46.3047163,
323
+ label: 'Bord'
324
+ },
325
+ ...
326
+ ],
327
+ tags: {
328
+ colour: "orange",
329
+ fee: "yes",
330
+ from: "Belobaka",
331
+ name: "Ligne 7 Plaque Mena",
332
+ network: "Zone Urbaine",
333
+ opening_hours: "Mo-Su 04:00-22:00",
334
+ operator: "MAMI",
335
+ "public_transport:version": "2",
336
+ ref: "7",
337
+ route: "bus",
338
+ to: "Belobaka",
339
+ type: "route",
340
+ },
341
+ },
342
+ ...
343
+ ];
344
+ ```
345
+
266
346
  ## <u> Mbola hanampiana azy </u>:
267
347
 
268
348
  - fanavahana ireo arret bus rehetra ao anaty ny fokotany iray
package/data/nodes.js CHANGED
@@ -73,7 +73,7 @@ export default [
73
73
  "id": 11029740956,
74
74
  "lat": -15.7162443,
75
75
  "lon": 46.36241,
76
- "label": "Fokotany"
76
+ "label": "Fokontany"
77
77
  },
78
78
  {
79
79
  "type": "node",
package/index.d.ts CHANGED
@@ -3,7 +3,7 @@ type Bus = {
3
3
  id: number,
4
4
  members: Stop[],
5
5
  tags: {
6
- colour: string,
6
+ color: string,
7
7
  band: string[],
8
8
  board: string |null,
9
9
  fee: string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bus-mj",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "package for BUS station in Mahajanga",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -27,7 +27,24 @@
27
27
  },
28
28
  "keywords": [
29
29
  "api",
30
- "bus-mahajanga"
30
+ "bus-mahajanga",
31
+ "bus mahajanga",
32
+ "bus-mahajanga-api",
33
+ "bus mahajanga api",
34
+ "api bus mahajanga",
35
+ "api-bus-mahajanga",
36
+ "mahajanga",
37
+ "bus",
38
+ "mahajanga bus",
39
+ "mahajanga-bus",
40
+ "transport",
41
+ "public-transport",
42
+ "public transport",
43
+ "madagascar",
44
+ "bus-api",
45
+ "bus api",
46
+ "bus-api-mahajanga",
47
+ "bus api mahajanga"
31
48
  ],
32
49
  "author": "selestino",
33
50
  "license": "ISC",
package/src/getBus.js CHANGED
@@ -44,7 +44,18 @@ export function findBusDetailById(bus_id) {
44
44
  */
45
45
  export function findBusByOneStop(stop_id) {
46
46
  return relations.filter((relation) => {
47
- return relation.members.some((member) => member.ref === stop_id);
47
+ return relation.members.some((member) => member.ref == stop_id);
48
+ });
49
+ }
50
+
51
+ /**
52
+ * find Bus that have a one stop asked
53
+ * @param {number} stop_label label of stop
54
+ * @returns { Bus[] }
55
+ */
56
+ export function findBusByStopLabel(stop_label) {
57
+ return relations.filter((relation) => {
58
+ return relation.members.some((member) => member.label && member.label.toUpperCase() == stop_label.toUpperCase());
48
59
  });
49
60
  }
50
61
 
@@ -61,6 +72,25 @@ export function findBusByTwoStop(begin, end) {
61
72
  });
62
73
  }
63
74
 
75
+ /**
76
+ * find the right bus of trajet giving
77
+ * @param {string} begin STOP_LABEL - begin of Road
78
+ * @param {string} end STOP_LABEL - end of Road
79
+ * @returns { Bus[] }
80
+ */
81
+ export function findBusByTwoStopLabel(begin, end) {
82
+ let firstRelationsFound = findBusByStopLabel(begin);
83
+ return firstRelationsFound.filter((relation) => {
84
+ const beginIndex = relation.members.findIndex(
85
+ (member) => member.label && member.label.toUpperCase() == begin.toUpperCase()
86
+ );
87
+ const endIndex = relation.members.findIndex(
88
+ (member) => member.label && member.label.toUpperCase() == end.toUpperCase()
89
+ );
90
+ return beginIndex != -1 && endIndex != -1 && beginIndex < endIndex;
91
+ });
92
+ }
93
+
64
94
  /**
65
95
  * list all bus detail of Operator
66
96
  * @param {string} operator_name id of operator ...