@mapsindoors/react-native-maps-indoors-mapbox 0.0.5-beta
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/LICENSE +11 -0
- package/README.md +178 -0
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.4/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.4/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.4/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/7.4/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/7.4/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/compiler.xml +6 -0
- package/android/.idea/gradle.xml +19 -0
- package/android/.idea/jarRepositories.xml +45 -0
- package/android/.idea/misc.xml +10 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/README.md +14 -0
- package/android/build.gradle +169 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +17 -0
- package/android/gradlew +234 -0
- package/android/gradlew.bat +89 -0
- package/android/local.properties +8 -0
- package/android/src/main/AndroidManifest.xml +6 -0
- package/android/src/main/java/com/reactlibrary/DirectionsRendererModule.java +207 -0
- package/android/src/main/java/com/reactlibrary/DirectionsServiceModule.java +130 -0
- package/android/src/main/java/com/reactlibrary/MPDisplayRuleModule.java +816 -0
- package/android/src/main/java/com/reactlibrary/MapControlModule.java +661 -0
- package/android/src/main/java/com/reactlibrary/MapsIndoorsModule.java +327 -0
- package/android/src/main/java/com/reactlibrary/MapsIndoorsPackage.java +46 -0
- package/android/src/main/java/com/reactlibrary/MapsIndoorsViewManager.java +119 -0
- package/android/src/main/java/com/reactlibrary/UtilsModule.java +165 -0
- package/android/src/main/java/com/reactlibrary/models/Bounds.java +19 -0
- package/android/src/main/java/com/reactlibrary/models/Filter.java +77 -0
- package/android/src/main/java/com/reactlibrary/models/Location.java +17 -0
- package/android/src/main/java/com/reactlibrary/models/MPCameraPosition.java +29 -0
- package/android/src/main/java/com/reactlibrary/models/MPCameraUpdate.java +92 -0
- package/android/src/main/java/com/reactlibrary/models/MPError.java +38 -0
- package/android/src/main/java/com/reactlibrary/models/PositionProvider.java +46 -0
- package/android/src/main/java/com/reactlibrary/models/PositionResult.java +117 -0
- package/android/src/main/java/com/reactlibrary/models/Query.java +30 -0
- package/android/src/main/res/values/google_maps_api_key.xml +4 -0
- package/android/src/main/res/values/mapbox_api_key.xml +5 -0
- package/index.ts +184 -0
- package/ios/DirectionsRendererBridge.m +53 -0
- package/ios/DirectionsRendererModule.swift +187 -0
- package/ios/DirectionsServiceBridge.m +46 -0
- package/ios/DirectionsServiceModule.swift +149 -0
- package/ios/MPDisplayRuleBridge.m +410 -0
- package/ios/MPDisplayRuleModule.swift +845 -0
- package/ios/MapControlBridge.m +178 -0
- package/ios/MapControlModule.swift +602 -0
- package/ios/MapsIndoors.xcodeproj/project.pbxproj +318 -0
- package/ios/MapsIndoors.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/MapsIndoors.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/MapsIndoorsBridge.m +98 -0
- package/ios/MapsIndoorsData.swift +203 -0
- package/ios/MapsIndoorsModule.swift +247 -0
- package/ios/MapsIndoorsViewManager.swift +30 -0
- package/ios/MapsIndoorsViewManagerBridge.m +9 -0
- package/ios/ReactPositionProvider.swift +25 -0
- package/ios/UtilsBridge.m +63 -0
- package/ios/UtilsModule.swift +146 -0
- package/ios/helpers.swift +57 -0
- package/ios/react-native-maps-indoors-Bridging-Header.h +6 -0
- package/package.json +52 -0
- package/react-native-maps-indoors-mapbox.podspec +30 -0
- package/src/EventNames.ts +21 -0
- package/src/MPBounds.ts +137 -0
- package/src/MPBuilding.ts +334 -0
- package/src/MPBuildingCollection.ts +57 -0
- package/src/MPBuildingInfo.ts +63 -0
- package/src/MPCameraEvent.ts +17 -0
- package/src/MPCameraEventListener.ts +17 -0
- package/src/MPCameraPosition.ts +83 -0
- package/src/MPCameraUpdate.ts +174 -0
- package/src/MPCameraViewFitMode.ts +21 -0
- package/src/MPCategory.ts +76 -0
- package/src/MPCategoryCollection.ts +62 -0
- package/src/MPCollection.ts +59 -0
- package/src/MPCollisionHandling.ts +12 -0
- package/src/MPDataField.ts +69 -0
- package/src/MPDirectionsRenderer.ts +194 -0
- package/src/MPDirectionsService.ts +119 -0
- package/src/MPDisplayRule.ts +1027 -0
- package/src/MPEntity.ts +60 -0
- package/src/MPEntityInfo.ts +28 -0
- package/src/MPError.ts +122 -0
- package/src/MPFilter.ts +168 -0
- package/src/MPFilterBehavior.ts +95 -0
- package/src/MPFloor.ts +170 -0
- package/src/MPFloorSelectorInterface.ts +63 -0
- package/src/MPGeometry.ts +91 -0
- package/src/MPHighway.ts +14 -0
- package/src/MPIconSize.ts +39 -0
- package/src/MPLocation.ts +386 -0
- package/src/MPLocationPropertyNames.ts +30 -0
- package/src/MPLocationType.ts +16 -0
- package/src/MPMapConfig.ts +211 -0
- package/src/MPMapStyle.ts +57 -0
- package/src/MPMultiPolygon.ts +205 -0
- package/src/MPPoint.ts +165 -0
- package/src/MPPolygon.ts +206 -0
- package/src/MPPositionProviderInterface.ts +45 -0
- package/src/MPPositionResultInterface.ts +42 -0
- package/src/MPPropertyData.ts +215 -0
- package/src/MPQuery.ts +69 -0
- package/src/MPRoute.ts +95 -0
- package/src/MPRouteCoordinate.ts +95 -0
- package/src/MPRouteLeg.ts +128 -0
- package/src/MPRouteProperty.ts +83 -0
- package/src/MPRouteStep.ts +176 -0
- package/src/MPSelectionBehavior.ts +93 -0
- package/src/MPSettings3D.ts +107 -0
- package/src/MPSize.ts +21 -0
- package/src/MPSolution.ts +180 -0
- package/src/MPSolutionConfig.ts +127 -0
- package/src/MPSolutionDisplayRule.ts +13 -0
- package/src/MPUserRole.ts +60 -0
- package/src/MPUserRoleCollection.ts +37 -0
- package/src/MPUtils.ts +157 -0
- package/src/MPVenue.ts +294 -0
- package/src/MPVenueCollection.ts +58 -0
- package/src/MPVenueInfo.ts +62 -0
- package/src/MapControl.ts +861 -0
- package/src/MapView.tsx +34 -0
- package/src/MapsIndoors.ts +530 -0
- package/src/OnBuildingFoundAtCameraTargetListener.ts +17 -0
- package/src/OnFloorSelectionChangedListener.ts +17 -0
- package/src/OnFloorUpdateListener.ts +16 -0
- package/src/OnLegSelectedListener.ts +17 -0
- package/src/OnLiveLocationUpdateListener.ts +17 -0
- package/src/OnLocationSelectedListener.ts +17 -0
- package/src/OnMapClickListener.ts +20 -0
- package/src/OnMarkerClickListener.ts +17 -0
- package/src/OnMarkerInfoWindowClickListener.ts +17 -0
- package/src/OnPositionUpdateListener.ts +17 -0
- package/src/OnVenueFoundAtCameraTargetListener.ts +17 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { MPFloorSelectorInterface, MapControl } from "../index";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This configuration object is used when creating a new {@link MapControl} instance.
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @class MPMapConfig
|
|
8
|
+
* @typedef {MPMapConfig}
|
|
9
|
+
*/
|
|
10
|
+
export default class MPMapConfig {
|
|
11
|
+
/**
|
|
12
|
+
* Whether to use the default map styling used by MapsIndoors, true by default.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
* @readonly
|
|
16
|
+
* @type {boolean}
|
|
17
|
+
*/
|
|
18
|
+
public readonly useDefaultMapsIndoorsStyle: boolean
|
|
19
|
+
/**
|
|
20
|
+
* The name of the typeface family to use on the map (the typeface must be supported on the native platform).
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
* @readonly
|
|
24
|
+
* @type {?string}
|
|
25
|
+
*/
|
|
26
|
+
public readonly typeface?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The color of the label text (a Hex color String (#1f1f1f))
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
* @readonly
|
|
32
|
+
* @type {?string}
|
|
33
|
+
*/
|
|
34
|
+
public readonly color?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Whether to show a white shadow behind the text to make it more readable.
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
* @readonly
|
|
40
|
+
* @type {?boolean}
|
|
41
|
+
*/
|
|
42
|
+
public readonly showHalo?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Changes the text size of the maps marker labels.
|
|
45
|
+
*
|
|
46
|
+
* The size is in dense pixels (DP).
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
* @readonly
|
|
50
|
+
* @type {?number}
|
|
51
|
+
*/
|
|
52
|
+
public readonly textSize?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Enable/Disable showing the floor selector.
|
|
55
|
+
*
|
|
56
|
+
* @public
|
|
57
|
+
* @readonly
|
|
58
|
+
* @type {?boolean}
|
|
59
|
+
*/
|
|
60
|
+
public readonly showFloorSelector?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Enables/Disables the info window on user-selected locations.
|
|
63
|
+
*
|
|
64
|
+
* The info window is shown by default when the user selects a location (by tapping on it).
|
|
65
|
+
*
|
|
66
|
+
* @public
|
|
67
|
+
* @readonly
|
|
68
|
+
* @type {?boolean}
|
|
69
|
+
*/
|
|
70
|
+
public readonly showInfoWindowOnClick?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Renders the positioning puck (blue dot) at the last known user position on the map.
|
|
73
|
+
*
|
|
74
|
+
* @public
|
|
75
|
+
* @readonly
|
|
76
|
+
* @type {?boolean}
|
|
77
|
+
*/
|
|
78
|
+
public readonly showUserPosition?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Enable fade-in effect on MapsIndoors tiles.
|
|
81
|
+
* Changes will be reflected on the map upon changing floors.
|
|
82
|
+
*
|
|
83
|
+
* Default behavior is enabled fade-in.
|
|
84
|
+
*
|
|
85
|
+
* @public
|
|
86
|
+
* @readonly
|
|
87
|
+
* @type {?boolean}
|
|
88
|
+
*/
|
|
89
|
+
public readonly enableTileFadeIn?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Replaces the default FloorSelector with a custom one.
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
* @readonly
|
|
95
|
+
* @type {?MPFloorSelectorInterface}
|
|
96
|
+
*/
|
|
97
|
+
public readonly floorSelector?: MPFloorSelectorInterface;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Creates an instance of MPMapConfig.
|
|
101
|
+
*
|
|
102
|
+
* @constructor
|
|
103
|
+
* @public
|
|
104
|
+
* @param {MPMapConfigParams} params
|
|
105
|
+
*/
|
|
106
|
+
public constructor(params: MPMapConfigParams) {
|
|
107
|
+
this.useDefaultMapsIndoorsStyle = params.useDefaultMapsIndoorsStyle;
|
|
108
|
+
this.typeface = params.mapLabelFont?.typeface;
|
|
109
|
+
this.color = params.mapLabelFont?.color;
|
|
110
|
+
this.showHalo = params.mapLabelFont?.showHalo;
|
|
111
|
+
this.textSize = params.textSize;
|
|
112
|
+
this.showFloorSelector = params.showFloorSelector;
|
|
113
|
+
this.showInfoWindowOnClick = params.showInfoWindowOnClick;
|
|
114
|
+
this.showUserPosition = params.showUserPosition;
|
|
115
|
+
this.enableTileFadeIn = params.enableTileFadeIn;
|
|
116
|
+
this.floorSelector = params.floorSelector;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Collection of label apperance settigns
|
|
122
|
+
*
|
|
123
|
+
* @export
|
|
124
|
+
* @interface MapLabelFont
|
|
125
|
+
* @typedef {MapLabelFont}
|
|
126
|
+
*/
|
|
127
|
+
export interface MapLabelFont {
|
|
128
|
+
/**
|
|
129
|
+
* The name of the typeface family to use on the map (the typeface must be supported on the native platform).
|
|
130
|
+
*
|
|
131
|
+
* @type {string}
|
|
132
|
+
*/
|
|
133
|
+
typeface: string,
|
|
134
|
+
/**
|
|
135
|
+
* The color of the label text (a Hex color String (#1f1f1f))
|
|
136
|
+
*
|
|
137
|
+
* @type {string}
|
|
138
|
+
*/
|
|
139
|
+
color: string,
|
|
140
|
+
/**
|
|
141
|
+
* Whether to show a white shadow behind the text to make it more readable.
|
|
142
|
+
*
|
|
143
|
+
* @type {boolean}
|
|
144
|
+
*/
|
|
145
|
+
showHalo: boolean,
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Parameter interface for {@link MPMapConfig}.
|
|
150
|
+
*
|
|
151
|
+
* @export
|
|
152
|
+
* @interface MPMapConfigParams
|
|
153
|
+
* @typedef {MPMapConfigParams}
|
|
154
|
+
*/
|
|
155
|
+
export interface MPMapConfigParams {
|
|
156
|
+
/**
|
|
157
|
+
* Whether to use the default map styling used by MapsIndoors, true by default.
|
|
158
|
+
*
|
|
159
|
+
* @type {boolean}
|
|
160
|
+
*/
|
|
161
|
+
useDefaultMapsIndoorsStyle: boolean,
|
|
162
|
+
/**
|
|
163
|
+
* A map label configuration object.
|
|
164
|
+
*
|
|
165
|
+
* @type {?MapLabelFont}
|
|
166
|
+
*/
|
|
167
|
+
mapLabelFont?: MapLabelFont,
|
|
168
|
+
/**
|
|
169
|
+
* Changes the text size of the maps marker labels.
|
|
170
|
+
*
|
|
171
|
+
* The size is in dense pixels (DP).
|
|
172
|
+
*
|
|
173
|
+
* @type {?number}
|
|
174
|
+
*/
|
|
175
|
+
textSize?: number,
|
|
176
|
+
/**
|
|
177
|
+
* Enable/Disable showing the floor selector.
|
|
178
|
+
*
|
|
179
|
+
* @type {?boolean}
|
|
180
|
+
*/
|
|
181
|
+
showFloorSelector?: boolean,
|
|
182
|
+
/**
|
|
183
|
+
* Enables/Disables the info window on user-selected locations.
|
|
184
|
+
*
|
|
185
|
+
* The info window is shown by default when the user selects a location (by tapping on it).
|
|
186
|
+
*
|
|
187
|
+
* @type {?boolean}
|
|
188
|
+
*/
|
|
189
|
+
showInfoWindowOnClick?: boolean,
|
|
190
|
+
/**
|
|
191
|
+
* Renders the positioning puck (blue dot) at the last known user position on the map.
|
|
192
|
+
*
|
|
193
|
+
* @type {?boolean}
|
|
194
|
+
*/
|
|
195
|
+
showUserPosition?: boolean,
|
|
196
|
+
/**
|
|
197
|
+
* Enable fade-in effect on MapsIndoors tiles.
|
|
198
|
+
* Changes will be reflected on the map upon changing floors.
|
|
199
|
+
*
|
|
200
|
+
* Default behavior is enabled fade-in.
|
|
201
|
+
*
|
|
202
|
+
* @type {?boolean}
|
|
203
|
+
*/
|
|
204
|
+
enableTileFadeIn?: boolean,
|
|
205
|
+
/**
|
|
206
|
+
* Replaces the default FloorSelector with a custom one.
|
|
207
|
+
*
|
|
208
|
+
* @type {?MPFloorSelectorInterface}
|
|
209
|
+
*/
|
|
210
|
+
floorSelector?: MPFloorSelectorInterface,
|
|
211
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import MPVenue from "./MPVenue";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A tileset used by a specific {@link MPVenue}.
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @class MPMapStyle
|
|
8
|
+
* @typedef {MPMapStyle}
|
|
9
|
+
*/
|
|
10
|
+
export default class MPMapStyle {
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of MPMapStyle.
|
|
13
|
+
*
|
|
14
|
+
* @constructor
|
|
15
|
+
* @private
|
|
16
|
+
* @param {string} folder The folder the style is saved in.
|
|
17
|
+
* @param {string} displayName The name of the style.
|
|
18
|
+
*/
|
|
19
|
+
private constructor(
|
|
20
|
+
public readonly folder: string,
|
|
21
|
+
public readonly displayName: string
|
|
22
|
+
) { }
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Creator for MPMapStyle, used to decode JSON from the MapsIndoors SDK.
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
* @static
|
|
29
|
+
* @param {MPMapStyleParams} object
|
|
30
|
+
* @returns {MPMapStyle}
|
|
31
|
+
*/
|
|
32
|
+
public static create(object: MPMapStyleParams): MPMapStyle {
|
|
33
|
+
return new MPMapStyle(object?.folder, object?.displayName);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Parameter interface for {@link MPMapStyle}.
|
|
39
|
+
*
|
|
40
|
+
* @export
|
|
41
|
+
* @interface MPMapStyleParams
|
|
42
|
+
* @typedef {MPMapStyleParams}
|
|
43
|
+
*/
|
|
44
|
+
export interface MPMapStyleParams {
|
|
45
|
+
/**
|
|
46
|
+
* The folder the style is saved in.
|
|
47
|
+
*
|
|
48
|
+
* @type {string}
|
|
49
|
+
*/
|
|
50
|
+
folder: string,
|
|
51
|
+
/**
|
|
52
|
+
* The name of the style.
|
|
53
|
+
*
|
|
54
|
+
* @type {string}
|
|
55
|
+
*/
|
|
56
|
+
displayName: string,
|
|
57
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { MPPoint, MPGeometry, MPPolygon, MPBounds } from "../index";
|
|
2
|
+
import MPUtils from "./MPUtils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A multiPolygon is a collection of {@link MPPolygon}s that combine
|
|
6
|
+
* to form a single geographical area with multiple bodies.
|
|
7
|
+
*
|
|
8
|
+
* @export
|
|
9
|
+
* @class MPMultiPolygon
|
|
10
|
+
* @typedef {MPMultiPolygon}
|
|
11
|
+
* @extends {MPGeometry}
|
|
12
|
+
*/
|
|
13
|
+
export default class MPMultiPolygon extends MPGeometry {
|
|
14
|
+
/**
|
|
15
|
+
* bounds cache.
|
|
16
|
+
*
|
|
17
|
+
* @private
|
|
18
|
+
* @type {?MPBounds}
|
|
19
|
+
*/
|
|
20
|
+
private _bounds?: MPBounds;
|
|
21
|
+
/**
|
|
22
|
+
* area cache.
|
|
23
|
+
*
|
|
24
|
+
* @private
|
|
25
|
+
* @type {?number}
|
|
26
|
+
*/
|
|
27
|
+
private _area?: number;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Creates an instance of MPMultiPolygon.
|
|
31
|
+
*
|
|
32
|
+
* @constructor
|
|
33
|
+
* @private
|
|
34
|
+
* @param {number[][][][]} _coordinates
|
|
35
|
+
* @param {number[]} _bbox
|
|
36
|
+
*/
|
|
37
|
+
private constructor(
|
|
38
|
+
private _coordinates: number[][][][],
|
|
39
|
+
private _bbox: number[]
|
|
40
|
+
) {
|
|
41
|
+
super();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Update the polygon's bounding box, the bounding box must be in
|
|
46
|
+
* [GeoJson format]{@link https://stevage.github.io/geojson-spec/#section-5}
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
* @type {{}}
|
|
50
|
+
*/
|
|
51
|
+
public set bbox(box: number[]) {
|
|
52
|
+
this._bbox = box;
|
|
53
|
+
this.clearCache();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Get the polygon's bounding box, the bounding box is in
|
|
58
|
+
* [GeoJson format]{@link https://stevage.github.io/geojson-spec/#section-5}
|
|
59
|
+
*
|
|
60
|
+
* @public
|
|
61
|
+
* @type {number[]}
|
|
62
|
+
*/
|
|
63
|
+
public get bbox(): number[] {
|
|
64
|
+
return this._bbox;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Update the coordinates list for the polygon, the coordinates must be in
|
|
69
|
+
* [GeoJSON format]{@link https://stevage.github.io/geojson-spec/#section-3.1.7}
|
|
70
|
+
*
|
|
71
|
+
* @public
|
|
72
|
+
* @type {number[][][][]}
|
|
73
|
+
*/
|
|
74
|
+
public set coordinates(coordinates: number[][][][]) {
|
|
75
|
+
this._coordinates = coordinates;
|
|
76
|
+
this.clearCache();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Get the coordinates as a collection in
|
|
81
|
+
* [GeoJSON format]{@link https://stevage.github.io/geojson-spec/#section-3.1.7}.
|
|
82
|
+
*
|
|
83
|
+
* @public
|
|
84
|
+
* @type {number[][][][]}
|
|
85
|
+
*/
|
|
86
|
+
public get coordinates(): number[][][][] {
|
|
87
|
+
return this._coordinates;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get the polygon's bounds. If {@link bbox} is present then that will be used.
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
* @readonly
|
|
95
|
+
* @type {MPBounds}
|
|
96
|
+
*/
|
|
97
|
+
public get bounds(): MPBounds {
|
|
98
|
+
return this._bounds ??= MPBounds.fromBBox(this._bbox);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Get the polygon's area, this is the combined area of all the polygons in the multi-polygon.
|
|
103
|
+
*
|
|
104
|
+
* @public
|
|
105
|
+
* @async
|
|
106
|
+
* @returns {Promise<number>}
|
|
107
|
+
*/
|
|
108
|
+
public async getArea(): Promise<number> {
|
|
109
|
+
return Promise.resolve(this._area ??= await MPUtils.geometryArea(this));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Creator for MPMultiPolygon, used to decode JSON from the MapsIndoors SDK.
|
|
115
|
+
*
|
|
116
|
+
* @public
|
|
117
|
+
* @static
|
|
118
|
+
* @param {MPMultiPolygonParams} object
|
|
119
|
+
* @returns {MPMultiPolygon}
|
|
120
|
+
*/
|
|
121
|
+
public static create(object: MPMultiPolygonParams): MPMultiPolygon {
|
|
122
|
+
return new MPMultiPolygon(object?.coordinates, object?.bbox);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Calculates the squared distance from the point to the closest edge in the polygon.
|
|
127
|
+
*
|
|
128
|
+
* @public
|
|
129
|
+
* @async
|
|
130
|
+
* @param {MPPoint} point
|
|
131
|
+
* @returns {Promise<number>}
|
|
132
|
+
*/
|
|
133
|
+
public async distanceToClosestEdge(point: MPPoint): Promise<number> {
|
|
134
|
+
return MPUtils.polygonDistanceToClosestEdge(point, this);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Get the position of the polygon, which is roughly its center.
|
|
139
|
+
*
|
|
140
|
+
* @public
|
|
141
|
+
* @readonly
|
|
142
|
+
* @type {MPPoint}
|
|
143
|
+
*/
|
|
144
|
+
public get position(): MPPoint {
|
|
145
|
+
return this.bounds.center;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Get the type of the polygon. see {@link MPGeometry#multiPolygon}
|
|
149
|
+
*
|
|
150
|
+
* @public
|
|
151
|
+
* @readonly
|
|
152
|
+
* @type {string}
|
|
153
|
+
*/
|
|
154
|
+
public get type(): string {
|
|
155
|
+
return MPGeometry.multiPolygon;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Clears area and bounds cache due to geometry recalculation.
|
|
160
|
+
*
|
|
161
|
+
* @private
|
|
162
|
+
*/
|
|
163
|
+
private clearCache() {
|
|
164
|
+
this._area = undefined;
|
|
165
|
+
this._bounds = undefined;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Parses the object to a JSON object that is compatible with the MapsIndoors SDK.
|
|
171
|
+
*
|
|
172
|
+
* @public
|
|
173
|
+
* @returns {MPMultiPolygonParams}
|
|
174
|
+
*/
|
|
175
|
+
public toJSON(): MPMultiPolygonParams {
|
|
176
|
+
return {
|
|
177
|
+
"coordinates": this._coordinates,
|
|
178
|
+
"bbox": this._bbox,
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Parameter interface for {@link MPMultiPolygon}.
|
|
186
|
+
*
|
|
187
|
+
* @export
|
|
188
|
+
* @interface MPMultiPolygonParams
|
|
189
|
+
* @typedef {MPMultiPolygonParams}
|
|
190
|
+
*/
|
|
191
|
+
export interface MPMultiPolygonParams {
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Geometry, as specified in the [GeoJSON format]{@link https://stevage.github.io/geojson-spec/#section-3.1.7}.
|
|
195
|
+
*
|
|
196
|
+
* @type {number[][][][]}
|
|
197
|
+
*/
|
|
198
|
+
coordinates: number[][][][],
|
|
199
|
+
/**
|
|
200
|
+
* bounding box, as specified in the [GeoJson format]{@link https://stevage.github.io/geojson-spec/#section-5}.
|
|
201
|
+
*
|
|
202
|
+
* @type {number[]}
|
|
203
|
+
*/
|
|
204
|
+
bbox?: number[],
|
|
205
|
+
}
|
package/src/MPPoint.ts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import MPGeometry from "./MPGeometry";
|
|
2
|
+
import MPUtils from "./MPUtils";
|
|
3
|
+
|
|
4
|
+
var firstTimeWarned = false
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* MPPoint is a representation of {@link latitude} and {@link longitude} coordinates packaged with
|
|
8
|
+
* a Z-axis representation in {@link floorIndex}.
|
|
9
|
+
*
|
|
10
|
+
* @export
|
|
11
|
+
* @class MPPoint
|
|
12
|
+
* @typedef {MPPoint}
|
|
13
|
+
* @extends {MPGeometry}
|
|
14
|
+
*/
|
|
15
|
+
export default class MPPoint extends MPGeometry {
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Latitude coordinate.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
* @readonly
|
|
22
|
+
* @type {number}
|
|
23
|
+
*/
|
|
24
|
+
public readonly latitude: number;
|
|
25
|
+
/**
|
|
26
|
+
* Longitude coordinate.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
* @readonly
|
|
30
|
+
* @type {number}
|
|
31
|
+
*/
|
|
32
|
+
public readonly longitude: number;
|
|
33
|
+
/**
|
|
34
|
+
* Optional index that defines what floor this point is placed on.
|
|
35
|
+
*
|
|
36
|
+
* If 0 it is placed on the ground floor, or outside.
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
* @readonly
|
|
40
|
+
* @type {?number}
|
|
41
|
+
*/
|
|
42
|
+
public readonly floorIndex?: number;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Creates an instance of MPPoint.
|
|
46
|
+
*
|
|
47
|
+
* @constructor
|
|
48
|
+
* @public
|
|
49
|
+
* @param {number} latitude The position of the point on the latitudal axis (N/S).
|
|
50
|
+
* @param {number} longitude The position of the point on the longitudal axis (E/W).
|
|
51
|
+
* @param {number} [floorIndex=0] The floor index of the point, Will default to 0 if not provided.
|
|
52
|
+
*/
|
|
53
|
+
public constructor(latitude: number, longitude: number, floorIndex: number = 0) {
|
|
54
|
+
super();
|
|
55
|
+
this.latitude = latitude;
|
|
56
|
+
this.longitude = longitude;
|
|
57
|
+
this.floorIndex = floorIndex;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Creator for MPPoint, used to decode JSON from the MapsIndoors SDK.
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
64
|
+
* @static
|
|
65
|
+
* @param {MPPointParams} pointParams
|
|
66
|
+
* @returns {MPPoint}
|
|
67
|
+
*/
|
|
68
|
+
public static create(pointParams: MPPointParams): MPPoint | undefined {
|
|
69
|
+
if (pointParams?.coordinates) {
|
|
70
|
+
return new MPPoint(pointParams.coordinates[1], pointParams.coordinates[0], pointParams.coordinates[2]);
|
|
71
|
+
} else if (pointParams as unknown as number[]){
|
|
72
|
+
return new MPPoint((pointParams as unknown as number[])[0], (pointParams as unknown as number[])[1], (pointParams as unknown as number[])[2]);
|
|
73
|
+
}else {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Calculates the angle between this point and another [MPPoint] in degrees from north.
|
|
80
|
+
*
|
|
81
|
+
* @public
|
|
82
|
+
* @async
|
|
83
|
+
* @param {MPPoint} other
|
|
84
|
+
* @returns {Promise<number>}
|
|
85
|
+
*/
|
|
86
|
+
public async angleBetween(other: MPPoint): Promise<number> {
|
|
87
|
+
return MPUtils.pointAngleBetween(this, other);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Calculates the shortest distance to another point from this point.
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
* @async
|
|
95
|
+
* @param {MPPoint} other
|
|
96
|
+
* @returns {Promise<number>}
|
|
97
|
+
*/
|
|
98
|
+
public async distanceTo(other: MPPoint): Promise<number> {
|
|
99
|
+
return MPUtils.pointDistanceTo(this, other);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* {@link MPGeometry} override, returns this object.
|
|
104
|
+
*
|
|
105
|
+
* @public
|
|
106
|
+
* @readonly
|
|
107
|
+
* @type {MPPoint}
|
|
108
|
+
*/
|
|
109
|
+
public get position(): MPPoint {
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Get the type of the point. see {@link MPGeometry#point}.
|
|
115
|
+
*
|
|
116
|
+
* @public
|
|
117
|
+
* @readonly
|
|
118
|
+
* @type {string}
|
|
119
|
+
*/
|
|
120
|
+
public get type(): string {
|
|
121
|
+
return MPGeometry.point;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* {@link MPGeometry} override, resolves to a non-zero value.
|
|
126
|
+
*
|
|
127
|
+
* @public
|
|
128
|
+
* @async
|
|
129
|
+
* @returns {Promise<number>}
|
|
130
|
+
*/
|
|
131
|
+
public async getArea(): Promise<number> {
|
|
132
|
+
return Promise.resolve(0.5);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Parses the object to a JSON object that is compatible with the MapsIndoors SDK.
|
|
138
|
+
*
|
|
139
|
+
* @public
|
|
140
|
+
* @returns {MPPointParams}
|
|
141
|
+
*/
|
|
142
|
+
public toJSON(): MPPointParams {
|
|
143
|
+
return {
|
|
144
|
+
coordinates: [this.longitude, this.latitude, this.floorIndex ?? 0],
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Parameter interface for {@link MPPoint}.
|
|
151
|
+
*
|
|
152
|
+
* @export
|
|
153
|
+
* @interface MPPointParams
|
|
154
|
+
* @typedef {MPPointParams}
|
|
155
|
+
*/
|
|
156
|
+
export interface MPPointParams {
|
|
157
|
+
/**
|
|
158
|
+
* Coordinate holder for point, on the form:.
|
|
159
|
+
*
|
|
160
|
+
* [LNG, LAT, FLOOR]
|
|
161
|
+
*
|
|
162
|
+
* @type {number[]}
|
|
163
|
+
*/
|
|
164
|
+
coordinates: number[],
|
|
165
|
+
}
|