bus-mj 2.1.0 → 2.2.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 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.1",
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
@@ -25,7 +25,18 @@ export function findStopByRef(ref) {
25
25
  * @returns { Stop[] }
26
26
  */
27
27
  export function findStopAll() {
28
- return nodes.filter((node) => node.label != undefined);
28
+ const seen = new Set();
29
+
30
+ return nodes.filter((node) => {
31
+ if (!node.label) return false;
32
+
33
+ if (seen.has(node.label)) {
34
+ return false; // already see → pass
35
+ }
36
+
37
+ seen.add(node.label);
38
+ return true; // first found → keep
39
+ });
29
40
  }
30
41
 
31
42
  /**
@@ -44,7 +55,18 @@ export function findBusDetailById(bus_id) {
44
55
  */
45
56
  export function findBusByOneStop(stop_id) {
46
57
  return relations.filter((relation) => {
47
- return relation.members.some((member) => member.ref === stop_id);
58
+ return relation.members.some((member) => member.ref == stop_id);
59
+ });
60
+ }
61
+
62
+ /**
63
+ * find Bus that have a one stop asked
64
+ * @param {number} stop_label label of stop
65
+ * @returns { Bus[] }
66
+ */
67
+ export function findBusByStopLabel(stop_label) {
68
+ return relations.filter((relation) => {
69
+ return relation.members.some((member) => member.label && member.label.toUpperCase() == stop_label.toUpperCase());
48
70
  });
49
71
  }
50
72
 
@@ -61,6 +83,25 @@ export function findBusByTwoStop(begin, end) {
61
83
  });
62
84
  }
63
85
 
86
+ /**
87
+ * find the right bus of trajet giving
88
+ * @param {string} begin STOP_LABEL - begin of Road
89
+ * @param {string} end STOP_LABEL - end of Road
90
+ * @returns { Bus[] }
91
+ */
92
+ export function findBusByTwoStopLabel(begin, end) {
93
+ let firstRelationsFound = findBusByStopLabel(begin);
94
+ return firstRelationsFound.filter((relation) => {
95
+ const beginIndex = relation.members.findIndex(
96
+ (member) => member.label && member.label.toUpperCase() == begin.toUpperCase()
97
+ );
98
+ const endIndex = relation.members.findIndex(
99
+ (member) => member.label && member.label.toUpperCase() == end.toUpperCase()
100
+ );
101
+ return beginIndex != -1 && endIndex != -1 && beginIndex < endIndex;
102
+ });
103
+ }
104
+
64
105
  /**
65
106
  * list all bus detail of Operator
66
107
  * @param {string} operator_name id of operator ...