becomap 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.
@@ -0,0 +1,4 @@
1
+ /**
2
+ * MapLibre GL JS
3
+ * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v4.4.1/LICENSE.txt
4
+ */
package/lib/index.d.ts ADDED
@@ -0,0 +1,475 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ /**
4
+ * Represents a coordinate in various forms, including:
5
+ * - An instance of BCMapCoordinate
6
+ * - An object with latitude and longitude properties
7
+ * - A tuple containing latitude and longitude as [longitude, latitude]
8
+ */
9
+ export type BCMapCoordinateLike = BCMapCoordinate | {
10
+ longitude: number;
11
+ latitude: number;
12
+ } | {
13
+ longitude: number;
14
+ latitude: number;
15
+ } | [
16
+ number,
17
+ number
18
+ ];
19
+ export interface BCMapCoordinate {
20
+ /**
21
+ * The latitude of the coordinate.
22
+ *
23
+ * @returns The latitude value as a number.
24
+ */
25
+ get latitude(): number;
26
+ /**
27
+ * The longitude of the coordinate.
28
+ *
29
+ * @returns The longitude value as a number.
30
+ */
31
+ get longitude(): number;
32
+ /**
33
+ * Converts the coordinate to an array format: [longitude, latitude].
34
+ *
35
+ * @returns A tuple with longitude as the first element and latitude as the second.
36
+ */
37
+ toArray(): [
38
+ number,
39
+ number
40
+ ];
41
+ /**
42
+ * Checks if this coordinate is equal to another coordinate.
43
+ *
44
+ * @param coordinate - The BCMapCoordinate to compare.
45
+ * @returns `true` if both coordinates have the same latitude and longitude, otherwise `false`.
46
+ */
47
+ equals(coordinate: BCMapCoordinate): boolean;
48
+ /**
49
+ * Calculates the distance from this coordinate to another coordinate.
50
+ *
51
+ * @param coordinate - The target BCMapCoordinate.
52
+ * @returns The distance to the target coordinate in appropriate units (e.g., meters).
53
+ */
54
+ distanceTo(coordinate: BCMapCoordinate): number;
55
+ }
56
+ export interface BCBuilding {
57
+ get buildingId(): string;
58
+ get buildingName(): string;
59
+ }
60
+ export interface BCMapSite {
61
+ /**
62
+ * Unique identifier for the site.
63
+ *
64
+ * @returns The site id as a string.
65
+ */
66
+ get id(): string;
67
+ /**
68
+ * Name of the site.
69
+ *
70
+ * @returns The name of the site as a string.
71
+ */
72
+ get siteName(): string;
73
+ /**
74
+ * Address of the site.
75
+ *
76
+ * @returns The site's address as a string.
77
+ */
78
+ get address(): string;
79
+ /**
80
+ * City where the site is located.
81
+ *
82
+ * @returns The city name as a string.
83
+ */
84
+ get city(): string;
85
+ /**
86
+ * Country code for the site's location (e.g., "US" for the United States).
87
+ *
88
+ * @returns The country code as a string.
89
+ */
90
+ get countryCode(): string;
91
+ /**
92
+ * Postal or ZIP code for the site's location.
93
+ *
94
+ * @returns The postal code as a string.
95
+ */
96
+ get postal(): string;
97
+ /**
98
+ * State or province where the site is located.
99
+ *
100
+ * @returns The state name or abbreviation as a string.
101
+ */
102
+ get state(): string;
103
+ /**
104
+ * Telephone contact number for the site.
105
+ *
106
+ * @returns The telephone number as a string.
107
+ */
108
+ get telephone(): string;
109
+ /**
110
+ * Time zone identifier for the site's location.
111
+ *
112
+ * @returns The time zone ID as a string.
113
+ */
114
+ get tzId(): string;
115
+ /**
116
+ * UTC offset for the site's time zone.
117
+ *
118
+ * @returns The UTC offset as a string (e.g., "-05:00" for Eastern Standard Time).
119
+ */
120
+ get utcOffset(): string;
121
+ /**
122
+ * Link or URL related to the site (e.g., website or documentation link).
123
+ *
124
+ * @returns The URL as a string.
125
+ */
126
+ get link(): string;
127
+ /**
128
+ * Type or category of the site (e.g., "office", "warehouse").
129
+ *
130
+ * @returns The site type as a string.
131
+ */
132
+ get type(): string;
133
+ /**
134
+ * list of buildings of the site (e.g., "Tower 1", "Tower 2").
135
+ *
136
+ * @returns The site buildings as BCBuilding[].
137
+ */
138
+ get buildings(): BCBuilding[];
139
+ }
140
+ declare class BCMarker {
141
+ private _id;
142
+ private _markerElement;
143
+ constructor(id: string, markerElement?: HTMLElement);
144
+ get markerElement(): HTMLElement;
145
+ }
146
+ export interface BCMapNode {
147
+ /**
148
+ * Unique identifier for the map node.
149
+ *
150
+ * @returns The node's ID as a string.
151
+ */
152
+ get id(): string;
153
+ /**
154
+ * The geographic coordinate of the map node.
155
+ *
156
+ * @returns The node's location as a BCMapCoordinate.
157
+ */
158
+ get coordinate(): BCMapCoordinate;
159
+ /**
160
+ * Finds a route from this node to a target node.
161
+ *
162
+ * @param to - The destination BCMapNode.
163
+ * @param checkAccessibility - A flag indicating whether accessibility (e.g., walkable or drivable paths) should be checked.
164
+ * @returns An object containing the path as an array of BCMapNode objects and the total cost of the route,
165
+ * or `null` if no route is found.
166
+ */
167
+ findRout(to: BCMapNode, checkAccessibility: boolean): {
168
+ path: BCMapNode[];
169
+ totalCost: number;
170
+ } | null;
171
+ }
172
+ /**
173
+ * Options for retrieving a specific site.
174
+ *
175
+ * @property clientId - The client ID used for authentication.
176
+ * @property clientSecret - The client secret used for authentication.
177
+ * @property siteIdentifier - The unique identifier of the site to retrieve (e.g., site ID or name).
178
+ */
179
+ export type BCMGetSiteOptions = {
180
+ clientId: string;
181
+ clientSecret: string;
182
+ siteIdentifier: string;
183
+ };
184
+ /**
185
+ * Retrieves site information using the specified authentication and site details.
186
+ *
187
+ * @param siteOptions - An object containing the client ID, client secret, and site identifier for retrieving the site.
188
+ * @returns A promise that resolves to a BCMapSite object containing the site's details, or throws an error if authentication fails.
189
+ *
190
+ * @async
191
+ * @throws Will log and rethrow an error if there is an issue with authentication or retrieval.
192
+ */
193
+ export declare function getSite(siteOptions: BCMGetSiteOptions): Promise<BCMapSite>;
194
+ declare enum BC_STEP_ACTION {
195
+ NONE = "None",
196
+ DEPARTURE = "Departure",
197
+ ARRIVALDESTINATION = "ArrivalDestination",
198
+ ARRIVALWAYPOINT = "ArrivalWaypoint",
199
+ TURN = "Turn",
200
+ SWITCHFLOOR = "SwitchFloor"
201
+ }
202
+ declare enum BC_STEP_DIRECTION {
203
+ NONE = "None",
204
+ STRAIGHT = "Straight",
205
+ RIGHT = "Right",
206
+ SLIGHTRIGHT = "SlightRight",
207
+ UTURNRIGHT = "UTurnRight",
208
+ LEFT = "Left",
209
+ SLIGHTLEFT = "SlightLeft",
210
+ UTURNLEFT = "UTurnLeft",
211
+ UP = "Up",
212
+ DOWN = "Down"
213
+ }
214
+ declare enum BC_STEP_POSITION {
215
+ NONE = "None",
216
+ AT = "At",
217
+ BEFORE = "Before",
218
+ AFTER = "After"
219
+ }
220
+ /**
221
+ * Represents an individual step in a route, providing details on the action, direction, position, and distance.
222
+ */
223
+ export interface BCRouteStep {
224
+ /**
225
+ * The map node where this step occurs.
226
+ *
227
+ * @returns The BCMapNode for this step.
228
+ */
229
+ get node(): BCMapNode;
230
+ /**
231
+ * The action associated with this step (e.g., "Turn", "ArrivalDestination").
232
+ *
233
+ * @returns The BC_STEP_ACTION enum value representing the action.
234
+ */
235
+ get action(): BC_STEP_ACTION;
236
+ /**
237
+ * The direction to take for this step (e.g., "Right", "Straight").
238
+ *
239
+ * @returns The BC_STEP_DIRECTION enum value representing the direction.
240
+ */
241
+ get direction(): BC_STEP_DIRECTION;
242
+ /**
243
+ * The reference position for this step, indicating the relation to a particular point.
244
+ *
245
+ * @returns The BC_STEP_POSITION enum value representing the reference position.
246
+ */
247
+ get reference(): BC_STEP_POSITION;
248
+ /**
249
+ * The distance associated with this step, typically representing the length of the step.
250
+ *
251
+ * @returns The distance as a number.
252
+ */
253
+ get distance(): number;
254
+ }
255
+ export interface BCRouteSegment {
256
+ /**
257
+ * Retrieves the path of the route segment, represented by a sequence of BCMapNode objects.
258
+ *
259
+ * @returns An array of BCMapNode objects indicating the path of this segment.
260
+ */
261
+ get path(): BCMapNode[];
262
+ /**
263
+ * Retrieves the steps that make up this route segment, each represented by a BCRouteStep object.
264
+ *
265
+ * @returns An array of BCRouteStep objects detailing each step in the segment.
266
+ */
267
+ get steps(): BCRouteStep[];
268
+ /**
269
+ * Retrieves the distance of the route segment in appropriate units (e.g., meters or kilometers).
270
+ *
271
+ * @returns The total distance of this segment as a number.
272
+ */
273
+ get distance(): number;
274
+ }
275
+ export interface BCRouteController {
276
+ /**
277
+ * Displays the specified route on the map.
278
+ *
279
+ * @param segments - A single BCRouteSegment or an array of BCRouteSegment objects to display on the map.
280
+ */
281
+ showRoute(segments: BCRouteSegment | BCRouteSegment[]): void;
282
+ /**
283
+ * Initiates a walkthrough of the given route segment, animating through each step of the route.
284
+ *
285
+ * This function will display the route on the map by moving through each step in the provided
286
+ * BCRouteSegment, allowing the user to visually follow the route. Optionally, a callback can be
287
+ * provided that will be executed each time a new step is reached during the animation.
288
+ *
289
+ * @param segment - The BCRouteSegment object representing the route to be walked through.
290
+ * This object contains the sequence of steps that define the route.
291
+ * @param stepCallback - An optional function that will be called with the current BCRouteStep
292
+ * each time the animation reaches a new step. This allows for custom
293
+ * actions to be performed on each step, such as updating the UI or logging
294
+ * information. The callback takes a single parameter:
295
+ * - step (BCRouteStep): The current step being processed in the walkthrough.
296
+ *
297
+ * @example
298
+ * walkThrough(segment, (step) => {
299
+ * console.log(`Now at step: ${step.message}`);
300
+ * });
301
+ */
302
+ walkThrough(segment: BCRouteSegment, stepCallback?: (step: BCRouteStep) => void): void;
303
+ /**
304
+ * Stops the ongoing walkthrough of the route segment.
305
+ */
306
+ stopWalking(): void;
307
+ /**
308
+ * Displays the specified route step on the map.
309
+ *
310
+ * This method highlights the given BCRouteStep on the map, providing visual feedback
311
+ * to the user regarding the current step in the route. This may include showing markers,
312
+ * updating the UI with step details, or animating the map view to focus on the step's
313
+ * associated location.
314
+ *
315
+ * @param step - The BCRouteStep object representing the step to be displayed. This object
316
+ * contains information about the node, the action to be taken, the direction,
317
+ * and other relevant details that can be used to visually represent the step
318
+ * on the map.
319
+ *
320
+ * @example
321
+ * const routeStep: BCRouteStep = /obtain the step from a route segment/;
322
+ * this.showStep(routeStep);
323
+ */
324
+ showStep(step: BCRouteStep): void;
325
+ /**
326
+ * Removes the specified route segment's layers and sources from the map view.
327
+ * @param segment - The BCRouteSegment object to remove.
328
+ */
329
+ remove(segment: BCRouteSegment): void;
330
+ /**
331
+ * Clears the current route from the map by removing the route layer or data from the map view.
332
+ * It relies on the routeController to manage route layers or data.
333
+ */
334
+ clearAllRoutes(): void;
335
+ }
336
+ export interface BCPolygon {
337
+ }
338
+ declare class Polygon implements BCPolygon {
339
+ #private;
340
+ constructor(id: string, coordinates: BCMapCoordinateLike[], color: string, height?: number, opacity?: number);
341
+ toGeoJSON(): GeoJSON.Feature<GeoJSON.Polygon>;
342
+ getId(): string;
343
+ }
344
+ /**
345
+ * Interface for controlling polygon-related operations.
346
+ * Provides methods to add, update, and remove polygons.
347
+ */
348
+ export interface BCPolygonController {
349
+ /**
350
+ * Adds a new polygon to the map or system.
351
+ * @param polygon - The polygon object to be added.
352
+ */
353
+ addPolygon(polygon: Polygon): void;
354
+ /**
355
+ * Updates the height of an existing polygon.
356
+ * @param height - The new height to apply to the polygon.
357
+ * @param polygon - The polygon object to be updated.
358
+ */
359
+ updatePolygonHeight(height: number, polygon: Polygon): void;
360
+ /**
361
+ * Removes a polygon from the map or system.
362
+ * @param polygon - The polygon object to be removed.
363
+ */
364
+ removePolygon(polygon: Polygon): void;
365
+ }
366
+ /**
367
+ * Type definition for a callback function to be executed when the map has loaded.
368
+ *
369
+ * This callback should not take any parameters and does not return any value. It can
370
+ * be used to perform additional actions once the map is fully initialized.
371
+ */
372
+ export type LoadCallback = () => void;
373
+ /**
374
+ * Options for configuring the initial view of the map.
375
+ *
376
+ * This interface allows specifying various parameters that control the
377
+ * appearance and perspective of the map when it is first rendered.
378
+ */
379
+ export interface MapViewOptions {
380
+ /**
381
+ * The geographical center point of the map, represented as a
382
+ * BCMapCoordinateLike object. If not specified, the map will
383
+ * default to its predefined center.
384
+ */
385
+ center?: BCMapCoordinateLike;
386
+ /**
387
+ * The zoom level of the map, which determines the scale of the map
388
+ * view. Higher values indicate closer views (more detail), while lower
389
+ * values provide a wider view. The default zoom level can be defined
390
+ * in the implementation.
391
+ */
392
+ zoom?: number;
393
+ /**
394
+ * The pitch of the map view, which controls the vertical tilt angle
395
+ * of the map. A pitch of 0 indicates a flat, bird's-eye view, while
396
+ * higher values provide an angled perspective. Default pitch can be
397
+ * set in the implementation.
398
+ */
399
+ pitch?: number;
400
+ /**
401
+ * The bearing of the map view, which specifies the rotation angle
402
+ * of the map in degrees. A bearing of 0 means north is at the top.
403
+ * Default bearing can be defined in the implementation.
404
+ */
405
+ bearing?: number;
406
+ }
407
+ /**
408
+ * Class representing a map view, providing methods to manipulate and interact
409
+ * with the map interface.
410
+ */
411
+ export declare class MapView {
412
+ #private;
413
+ /**
414
+ * Constructs a new MapView instance.
415
+ *
416
+ * @param container - The HTML element that will contain the map.
417
+ * @param site - The BCMapSite object that provides context and data for the map.
418
+ * @param options - Optional configuration settings for the initial map view.
419
+ * @param onLoadCallback - An optional callback function to be executed
420
+ * once the map has fully loaded.
421
+ */
422
+ constructor(container: HTMLElement, site: BCMapSite, options?: MapViewOptions, onLoadCallback?: LoadCallback);
423
+ /**
424
+ * Gets the HTML element that contains the map.
425
+ *
426
+ * @returns The HTMLElement representing the map container.
427
+ */
428
+ get container(): HTMLElement;
429
+ /**
430
+ * Provides access to the route controller, which manages routing operations
431
+ * within the map view, such as route rendering.
432
+ * @returns An instance of BCRouteController for managing route operations.
433
+ */
434
+ get routeController(): BCRouteController;
435
+ /**
436
+ * Provides access to the polygon controller, which handles all polygon-related
437
+ * operations within the map view, such as adding, updating, and removing polygons.
438
+ * @returns An instance of BCPolygonController for managing polygon operations.
439
+ */
440
+ get polygonController(): BCPolygonController;
441
+ /**
442
+ * Focuses the map on a specified geographical point, optionally adjusting
443
+ * the zoom level, bearing, and pitch.
444
+ *
445
+ * @param point - The point to focus on, represented as a
446
+ * BCMapCoordinateLike object.
447
+ * @param zoomLevel - Optional zoom level to apply when focusing on
448
+ * the point. Defaults to the current zoom level if not specified.
449
+ * @param bearing - Optional bearing to apply when focusing on the
450
+ * point. Defaults to the current bearing if not specified.
451
+ * @param pitch - Optional pitch to apply when focusing on the point.
452
+ * Defaults to the current pitch if not specified.
453
+ */
454
+ focusOnPoint(point: BCMapCoordinateLike, zoomLevel?: number, bearing?: number, pitch?: number): void;
455
+ setBounds(sw: BCMapCoordinateLike, ne: BCMapCoordinateLike): void;
456
+ addMarker(marker: BCMarker, cordinate: BCMapCoordinate): void;
457
+ getNode(id: string): BCMapNode | null;
458
+ }
459
+ export type BCRoutable = BCMapNode;
460
+ export interface BCRouteOptions {
461
+ maxDistanceThreshold: number;
462
+ getAccessiblePath: boolean;
463
+ }
464
+ /**
465
+ * Retrieves the route from a start point to a goal point, optionally including waypoints and route options.
466
+ *
467
+ * @param start - The starting point of the route, represented by a BCRoutable object.
468
+ * @param goal - The destination point of the route, represented by a BCRoutable object.
469
+ * @param waypoints - Optional array of intermediate points (BCRoutable) to include in the route.
470
+ * @param routeOptions - Optional parameter to specify additional routing preferences or constraints.
471
+ * @returns An array of BCRouteSegment objects representing each segment of the route, or `null` if a route cannot be generated.
472
+ */
473
+ export declare function getRoute(start: BCRoutable, goal: BCRoutable, waypoints?: BCRoutable[], routeOptions?: BCRouteOptions): BCRouteSegment[] | null;
474
+
475
+ export {};
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "becomap",
3
+ "version": "1.0.1",
4
+ "description": "we lib to display becomap",
5
+ "main": "lib/becomap.js",
6
+ "module": "lib/becomap.js",
7
+ "types": "lib/index.d.ts",
8
+ "scripts": {
9
+ "test": "jest --config jestconfig.json",
10
+ "start": "npm run build && npm run serve && npm run watch",
11
+ "serve": "node scripts/serve.js",
12
+ "build": "APP_ENV=production node scripts/build.js",
13
+ "watch": "webpack --watch",
14
+ "format": "prettier --write \"src/**/*.ts\"",
15
+ "lint": "tslint -p tsconfig.json",
16
+ "proto": "./scripts/generate-proto.sh",
17
+ "readproto": "cd ./proto/sample && tsc readbin.ts && node ./readbin.js && cd .. && cd .."
18
+ },
19
+ "keywords": [],
20
+ "author": "",
21
+ "license": "ISC",
22
+ "devDependencies": {
23
+ "@babel/core": "^7.24.7",
24
+ "@babel/preset-env": "^7.24.7",
25
+ "@babel/preset-typescript": "^7.24.7",
26
+ "@types/jest": "^29.5.12",
27
+ "@types/node": "^20.14.5",
28
+ "@types/webpack": "^5.28.5",
29
+ "babel-loader": "^9.1.3",
30
+ "css-loader": "^7.1.2",
31
+ "dotenv": "^16.4.5",
32
+ "dotenv-webpack": "^8.1.0",
33
+ "dts-bundle-generator": "^9.5.1",
34
+ "fs-extra": "^11.2.0",
35
+ "install": "^0.13.0",
36
+ "javascript-obfuscator": "^4.1.1",
37
+ "jest": "^29.7.0",
38
+ "npm": "^10.8.1",
39
+ "prettier": "^3.3.2",
40
+ "rimraf": "^6.0.1",
41
+ "style-loader": "^4.0.0",
42
+ "terser-webpack-plugin": "^5.3.10",
43
+ "ts-jest": "^29.1.5",
44
+ "ts-loader": "^9.5.1",
45
+ "ts-proto": "^2.2.3",
46
+ "tslint": "^6.1.3",
47
+ "tslint-config-prettier": "^1.18.0",
48
+ "typescript": "^5.5.3",
49
+ "webpack": "^5.92.1",
50
+ "webpack-cli": "^5.1.4",
51
+ "webpack-dev-server": "^5.0.4",
52
+ "webpack-obfuscator": "^3.5.1"
53
+ },
54
+ "dependencies": {
55
+ "@turf/turf": "^7.1.0",
56
+ "axios": "^1.7.5",
57
+ "maplibre-gl": "^4.4.1",
58
+ "protobufjs": "^7.4.0"
59
+ }
60
+ }