@situm/react-native 3.0.0-beta.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/LICENSE +21 -0
- package/README.md +656 -0
- package/ReactNativeSitumPlugin.podspec +22 -0
- package/SECURITY-POLICY.md +9 -0
- package/android/.gradle/5.6.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/5.6.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/5.6.4/gc.properties +0 -0
- package/android/.idea/.name +1 -0
- package/android/.idea/codeStyles/Project.xml +116 -0
- package/android/.idea/encodings.xml +6 -0
- package/android/.idea/misc.xml +31 -0
- package/android/.idea/sonarlint/issuestore/index.pb +15 -0
- package/android/.project +34 -0
- package/android/build.gradle +45 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/android/gradlew +172 -0
- package/android/gradlew.bat +84 -0
- package/android/src/main/AndroidManifest.xml +6 -0
- package/android/src/main/java/com/situm/plugin/PluginHelper.java +989 -0
- package/android/src/main/java/com/situm/plugin/SitumMapper.java +1206 -0
- package/android/src/main/java/com/situm/plugin/SitumPackage.java +29 -0
- package/android/src/main/java/com/situm/plugin/SitumPlugin.java +84 -0
- package/android/src/main/java/com/situm/plugin/SitumPluginImpl.java +344 -0
- package/android/src/main/java/com/situm/plugin/utils/ReactNativeJson.java +122 -0
- package/android/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/android/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/android/src/main/res/values/strings.xml +3 -0
- package/android/src/main/res/values/styles.xml +9 -0
- package/ios/Constants.h +14 -0
- package/ios/Constants.m +14 -0
- package/ios/RNSitumReactNativePlugin.xcodeproj/project.pbxproj +272 -0
- package/ios/SitumLocationWrapper.h +112 -0
- package/ios/SitumLocationWrapper.m +1132 -0
- package/ios/SitumPlugin.h +15 -0
- package/ios/SitumPlugin.m +911 -0
- package/lib/commonjs/index.js +25 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/sdk/index.js +399 -0
- package/lib/commonjs/sdk/index.js.map +1 -0
- package/lib/commonjs/sdk/nativeInterface.js +20 -0
- package/lib/commonjs/sdk/nativeInterface.js.map +1 -0
- package/lib/commonjs/sdk/types/index.d.js +6 -0
- package/lib/commonjs/sdk/types/index.d.js.map +1 -0
- package/lib/commonjs/sdk/utils.js +22 -0
- package/lib/commonjs/sdk/utils.js.map +1 -0
- package/lib/commonjs/utils/requestPermission.js +73 -0
- package/lib/commonjs/utils/requestPermission.js.map +1 -0
- package/lib/commonjs/wayfinding/components/MapView.js +220 -0
- package/lib/commonjs/wayfinding/components/MapView.js.map +1 -0
- package/lib/commonjs/wayfinding/hooks/index.js +401 -0
- package/lib/commonjs/wayfinding/hooks/index.js.map +1 -0
- package/lib/commonjs/wayfinding/index.js +45 -0
- package/lib/commonjs/wayfinding/index.js.map +1 -0
- package/lib/commonjs/wayfinding/store/index.js +237 -0
- package/lib/commonjs/wayfinding/store/index.js.map +1 -0
- package/lib/commonjs/wayfinding/store/utils.js +44 -0
- package/lib/commonjs/wayfinding/store/utils.js.map +1 -0
- package/lib/commonjs/wayfinding/styles/colors.js +18 -0
- package/lib/commonjs/wayfinding/styles/colors.js.map +1 -0
- package/lib/commonjs/wayfinding/types/index.d.js +6 -0
- package/lib/commonjs/wayfinding/types/index.d.js.map +1 -0
- package/lib/commonjs/wayfinding/utils/index.js +11 -0
- package/lib/commonjs/wayfinding/utils/index.js.map +1 -0
- package/lib/commonjs/wayfinding/utils/mapper.js +106 -0
- package/lib/commonjs/wayfinding/utils/mapper.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/sdk/index.js +390 -0
- package/lib/module/sdk/index.js.map +1 -0
- package/lib/module/sdk/nativeInterface.js +18 -0
- package/lib/module/sdk/nativeInterface.js.map +1 -0
- package/lib/module/sdk/types/index.d.js +2 -0
- package/lib/module/sdk/types/index.d.js.map +1 -0
- package/lib/module/sdk/utils.js +15 -0
- package/lib/module/sdk/utils.js.map +1 -0
- package/lib/module/utils/requestPermission.js +67 -0
- package/lib/module/utils/requestPermission.js.map +1 -0
- package/lib/module/wayfinding/components/MapView.js +207 -0
- package/lib/module/wayfinding/components/MapView.js.map +1 -0
- package/lib/module/wayfinding/hooks/index.js +392 -0
- package/lib/module/wayfinding/hooks/index.js.map +1 -0
- package/lib/module/wayfinding/index.js +12 -0
- package/lib/module/wayfinding/index.js.map +1 -0
- package/lib/module/wayfinding/store/index.js +202 -0
- package/lib/module/wayfinding/store/index.js.map +1 -0
- package/lib/module/wayfinding/store/utils.js +34 -0
- package/lib/module/wayfinding/store/utils.js.map +1 -0
- package/lib/module/wayfinding/styles/colors.js +11 -0
- package/lib/module/wayfinding/styles/colors.js.map +1 -0
- package/lib/module/wayfinding/types/index.d.js +2 -0
- package/lib/module/wayfinding/types/index.d.js.map +1 -0
- package/lib/module/wayfinding/utils/index.js +4 -0
- package/lib/module/wayfinding/utils/index.js.map +1 -0
- package/lib/module/wayfinding/utils/mapper.js +100 -0
- package/lib/module/wayfinding/utils/mapper.js.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/sdk/index.d.ts +269 -0
- package/lib/typescript/src/sdk/index.d.ts.map +1 -0
- package/lib/typescript/src/sdk/nativeInterface.d.ts +2 -0
- package/lib/typescript/src/sdk/nativeInterface.d.ts.map +1 -0
- package/lib/typescript/src/sdk/utils.d.ts +7 -0
- package/lib/typescript/src/sdk/utils.d.ts.map +1 -0
- package/lib/typescript/src/utils/requestPermission.d.ts +3 -0
- package/lib/typescript/src/utils/requestPermission.d.ts.map +1 -0
- package/lib/typescript/src/wayfinding/components/MapView.d.ts +36 -0
- package/lib/typescript/src/wayfinding/components/MapView.d.ts.map +1 -0
- package/lib/typescript/src/wayfinding/hooks/index.d.ts +53 -0
- package/lib/typescript/src/wayfinding/hooks/index.d.ts.map +1 -0
- package/lib/typescript/src/wayfinding/index.d.ts +5 -0
- package/lib/typescript/src/wayfinding/index.d.ts.map +1 -0
- package/lib/typescript/src/wayfinding/store/index.d.ts +103 -0
- package/lib/typescript/src/wayfinding/store/index.d.ts.map +1 -0
- package/lib/typescript/src/wayfinding/store/utils.d.ts +9 -0
- package/lib/typescript/src/wayfinding/store/utils.d.ts.map +1 -0
- package/lib/typescript/src/wayfinding/styles/colors.d.ts +8 -0
- package/lib/typescript/src/wayfinding/styles/colors.d.ts.map +1 -0
- package/lib/typescript/src/wayfinding/utils/index.d.ts +3 -0
- package/lib/typescript/src/wayfinding/utils/index.d.ts.map +1 -0
- package/lib/typescript/src/wayfinding/utils/mapper.d.ts +17 -0
- package/lib/typescript/src/wayfinding/utils/mapper.d.ts.map +1 -0
- package/package.json +130 -0
- package/security.txt +4 -0
- package/src/index.ts +6 -0
- package/src/sdk/index.ts +656 -0
- package/src/sdk/nativeInterface.ts +18 -0
- package/src/sdk/types/index.d.ts +718 -0
- package/src/sdk/utils.ts +16 -0
- package/src/utils/requestPermission.ts +94 -0
- package/src/wayfinding/components/MapView.tsx +312 -0
- package/src/wayfinding/hooks/index.ts +539 -0
- package/src/wayfinding/index.tsx +11 -0
- package/src/wayfinding/store/index.tsx +254 -0
- package/src/wayfinding/store/utils.ts +40 -0
- package/src/wayfinding/styles/colors.tsx +6 -0
- package/src/wayfinding/types/index.d.ts +56 -0
- package/src/wayfinding/utils/index.ts +5 -0
- package/src/wayfinding/utils/mapper.ts +129 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import React, { createContext, MutableRefObject, useReducer } from "react";
|
|
3
|
+
//@ts-ignore
|
|
4
|
+
import { Building, Poi } from "react-native-situm-plugin";
|
|
5
|
+
|
|
6
|
+
import { createReducer } from "./utils";
|
|
7
|
+
|
|
8
|
+
export interface Location {
|
|
9
|
+
position?: Position;
|
|
10
|
+
accuracy?: number;
|
|
11
|
+
bearing?: {
|
|
12
|
+
degrees: number;
|
|
13
|
+
degreesClockwise: number;
|
|
14
|
+
};
|
|
15
|
+
hasBearing?: boolean;
|
|
16
|
+
status: PositioningStatus;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface Position {
|
|
20
|
+
coordinate: {
|
|
21
|
+
latitude: number;
|
|
22
|
+
longitude: number;
|
|
23
|
+
};
|
|
24
|
+
cartesianCoordinate: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
};
|
|
28
|
+
isIndoor?: boolean;
|
|
29
|
+
isOutdoor?: boolean;
|
|
30
|
+
buildingIdentifier?: string;
|
|
31
|
+
floorIdentifier?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export enum PositioningStatus {
|
|
35
|
+
STARTING = "STARTING",
|
|
36
|
+
CALCULATING = "CALCULATING",
|
|
37
|
+
// This status will always be sent to mapviewer-web, in case we recieve
|
|
38
|
+
// a location from SDK.
|
|
39
|
+
POSITIONING = "POSITIONING",
|
|
40
|
+
USER_NOT_IN_BUILDING = "USER_NOT_IN_BUILDING",
|
|
41
|
+
STOPPED = "STOPPED",
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface SDKNavigation {
|
|
45
|
+
//closestPositionInRoute: any;
|
|
46
|
+
currentIndication?: any;
|
|
47
|
+
//currentStepIndex:number;
|
|
48
|
+
//distanceToEndStep: number;
|
|
49
|
+
distanceToGoal?: number;
|
|
50
|
+
//nextIndication: any;
|
|
51
|
+
points?: any;
|
|
52
|
+
routeStep?: any;
|
|
53
|
+
segments?: any;
|
|
54
|
+
route?: Directions;
|
|
55
|
+
//timeToEndStep: number;
|
|
56
|
+
//timeToGoal: number;
|
|
57
|
+
type?: NavigationUpdateType;
|
|
58
|
+
status: NavigationStatus;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export enum NavigationStatus {
|
|
62
|
+
START = "start",
|
|
63
|
+
STOP = "stop",
|
|
64
|
+
UPDATE = "update",
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export enum NavigationUpdateType {
|
|
68
|
+
progress = "PROGRESS",
|
|
69
|
+
userOutsideRoute = "OUT_OF_ROUTE",
|
|
70
|
+
destinationReached = "DESTINATION_REACHED",
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// TODO: add types
|
|
74
|
+
export type Directions = any;
|
|
75
|
+
|
|
76
|
+
export type NavigateToPoiType = {
|
|
77
|
+
navigationTo: number;
|
|
78
|
+
type?: string;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
interface User {
|
|
82
|
+
email?: string;
|
|
83
|
+
apiKey?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface SDKError {
|
|
86
|
+
code?: number;
|
|
87
|
+
message: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface State {
|
|
91
|
+
webViewRef: MutableRefObject<undefined>;
|
|
92
|
+
sdkInitialized: boolean;
|
|
93
|
+
user?: User;
|
|
94
|
+
location?: Location;
|
|
95
|
+
buildings: Building[];
|
|
96
|
+
currentBuilding: Building;
|
|
97
|
+
pois: Poi[];
|
|
98
|
+
directions?: Directions;
|
|
99
|
+
navigation?: SDKNavigation;
|
|
100
|
+
destinationPoiID?: number;
|
|
101
|
+
error?: SDKError;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export const initialState: State = {
|
|
105
|
+
webViewRef: undefined,
|
|
106
|
+
sdkInitialized: false,
|
|
107
|
+
user: undefined,
|
|
108
|
+
location: { status: PositioningStatus.STOPPED },
|
|
109
|
+
buildings: [],
|
|
110
|
+
currentBuilding: undefined,
|
|
111
|
+
pois: [],
|
|
112
|
+
directions: undefined,
|
|
113
|
+
navigation: { status: NavigationStatus.STOP },
|
|
114
|
+
destinationPoiID: undefined,
|
|
115
|
+
error: undefined,
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const SitumContext = createContext<
|
|
119
|
+
{ state: State; dispatch: React.Dispatch<(s: State) => State> } | undefined
|
|
120
|
+
>(undefined);
|
|
121
|
+
|
|
122
|
+
const Reducer = createReducer<State>({
|
|
123
|
+
setWebViewRef: (state: State, payload: State["webViewRef"]) => {
|
|
124
|
+
return { ...state, webViewRef: payload };
|
|
125
|
+
},
|
|
126
|
+
setSdkInitialized: (state: State, payload: State["sdkInitialized"]) => {
|
|
127
|
+
return { ...state, sdkInitialized: payload };
|
|
128
|
+
},
|
|
129
|
+
setAuth: (state: State, payload: State["user"]) => {
|
|
130
|
+
return { ...state, user: payload };
|
|
131
|
+
},
|
|
132
|
+
setLocation: (state: State, payload: State["location"]) => {
|
|
133
|
+
return { ...state, location: payload };
|
|
134
|
+
},
|
|
135
|
+
setLocationStatus: (state: State, payload: PositioningStatus) => {
|
|
136
|
+
return { ...state, location: { ...state.location, status: payload } };
|
|
137
|
+
},
|
|
138
|
+
resetLocation: (state: State) => {
|
|
139
|
+
return {
|
|
140
|
+
...state,
|
|
141
|
+
location: initialState.location,
|
|
142
|
+
};
|
|
143
|
+
},
|
|
144
|
+
setBuildings: (state: State, payload: State["buildings"]) => {
|
|
145
|
+
return { ...state, buildings: payload };
|
|
146
|
+
},
|
|
147
|
+
setCurrentBuilding: (state: State, payload: State["currentBuilding"]) => {
|
|
148
|
+
return { ...state, currentBuilding: payload };
|
|
149
|
+
},
|
|
150
|
+
setPois: (state: State, payload: State["pois"]) => {
|
|
151
|
+
return { ...state, pois: payload };
|
|
152
|
+
},
|
|
153
|
+
setDirections: (state: State, payload: State["directions"]) => {
|
|
154
|
+
return { ...state, directions: payload };
|
|
155
|
+
},
|
|
156
|
+
setNavigation: (state: State, payload: State["navigation"]) => {
|
|
157
|
+
return { ...state, navigation: payload };
|
|
158
|
+
},
|
|
159
|
+
setDestinationPoiID: (state: State, payload: State["destinationPoiID"]) => {
|
|
160
|
+
return { ...state, destinationPoiID: payload };
|
|
161
|
+
},
|
|
162
|
+
setError: (state: State, payload: State["error"]) => {
|
|
163
|
+
return { ...state, error: payload };
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
export const selectWebViewRef = (state: State) => {
|
|
168
|
+
return state.webViewRef;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export const selectIsSDKInitialized = (state: State) => {
|
|
172
|
+
return state.sdkInitialized;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export const selectUser = (state: State) => {
|
|
176
|
+
return state.user;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export const selectLocation = (state: State) => {
|
|
180
|
+
return state.location;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const selectLocationStatus = (state: State) => {
|
|
184
|
+
return state.location.status;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export const selectBuildings = (state: State) => {
|
|
188
|
+
return state.buildings;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
export const selectCurrentBuilding = (state: State) => {
|
|
192
|
+
return state.currentBuilding;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export const selectPois = (state: State) => {
|
|
196
|
+
return state.pois;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export const selectDirections = (state: State) => {
|
|
200
|
+
return state.directions;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export const selectNavigation = (state: State) => {
|
|
204
|
+
return state.navigation;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export const selectDestinationPoiID = (state: State) => {
|
|
208
|
+
return state.destinationPoiID;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export const selectError = (state: State) => {
|
|
212
|
+
return state.error;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export const {
|
|
216
|
+
setWebViewRef,
|
|
217
|
+
setSdkInitialized,
|
|
218
|
+
setAuth,
|
|
219
|
+
setLocation,
|
|
220
|
+
setLocationStatus,
|
|
221
|
+
resetLocation,
|
|
222
|
+
setBuildings,
|
|
223
|
+
setCurrentBuilding,
|
|
224
|
+
setPois,
|
|
225
|
+
setDirections,
|
|
226
|
+
setNavigation,
|
|
227
|
+
setDestinationPoiID,
|
|
228
|
+
setError,
|
|
229
|
+
} = Reducer.actions;
|
|
230
|
+
|
|
231
|
+
const SitumProvider: React.FC<
|
|
232
|
+
React.PropsWithChildren<{
|
|
233
|
+
email?: string;
|
|
234
|
+
apiKey?: string;
|
|
235
|
+
}>
|
|
236
|
+
> = ({ email, apiKey, children }) => {
|
|
237
|
+
const [state, dispatch] = useReducer(Reducer.reducer, {
|
|
238
|
+
...initialState,
|
|
239
|
+
user: { email, apiKey },
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
return (
|
|
243
|
+
<SitumContext.Provider
|
|
244
|
+
value={{
|
|
245
|
+
state,
|
|
246
|
+
dispatch,
|
|
247
|
+
}}
|
|
248
|
+
>
|
|
249
|
+
{children}
|
|
250
|
+
</SitumContext.Provider>
|
|
251
|
+
);
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
export default SitumProvider;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
|
|
4
|
+
import { SitumContext, State } from "./index";
|
|
5
|
+
|
|
6
|
+
export const createReducer = <T>(
|
|
7
|
+
reducers: Record<string, (state: T, payload: any) => T>
|
|
8
|
+
) => {
|
|
9
|
+
// Actions
|
|
10
|
+
const actions = Object.keys(reducers).reduce((acc, r) => {
|
|
11
|
+
acc[r] = (payload: any) => (state: T) => reducers[r](state, payload);
|
|
12
|
+
return acc;
|
|
13
|
+
}, {} as Record<string, (payload?: any) => (state: T) => T>);
|
|
14
|
+
|
|
15
|
+
// Reducer
|
|
16
|
+
const reducer = (state: T, action: (state: T) => T): T => {
|
|
17
|
+
return action(state);
|
|
18
|
+
};
|
|
19
|
+
return { actions, reducer };
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const useSelector = (selector: (state: State) => any) => {
|
|
23
|
+
const context = useContext(SitumContext);
|
|
24
|
+
|
|
25
|
+
if (!context) {
|
|
26
|
+
throw new Error("No SitumProvider found.");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return selector(context.state);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const useDispatch = () => {
|
|
33
|
+
const context = useContext(SitumContext);
|
|
34
|
+
|
|
35
|
+
if (!context) {
|
|
36
|
+
throw new Error("No SitumProvider found.");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return context.dispatch;
|
|
40
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//@ts-ignore
|
|
2
|
+
import { ErrorName } from "../components/MapView";
|
|
3
|
+
|
|
4
|
+
interface MapViewError {
|
|
5
|
+
name: ErrorName;
|
|
6
|
+
description: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface WayfindingResult {
|
|
10
|
+
status: string;
|
|
11
|
+
message: string;
|
|
12
|
+
}
|
|
13
|
+
export interface OnPoiSelectedResult {
|
|
14
|
+
buildingId: string;
|
|
15
|
+
buildingName: string;
|
|
16
|
+
floorId: string;
|
|
17
|
+
floorName: string;
|
|
18
|
+
poiId: string;
|
|
19
|
+
poiName: string;
|
|
20
|
+
}
|
|
21
|
+
export interface OnPoiDeselectedResult {
|
|
22
|
+
buildingId: string;
|
|
23
|
+
buildingName: string;
|
|
24
|
+
}
|
|
25
|
+
export interface OnFloorChangedResult {
|
|
26
|
+
buildingId: string;
|
|
27
|
+
buildingName: string;
|
|
28
|
+
fromFloorId: string;
|
|
29
|
+
toFloorId: string;
|
|
30
|
+
fromFloorName: string;
|
|
31
|
+
toFloorName: string;
|
|
32
|
+
}
|
|
33
|
+
export interface Point {
|
|
34
|
+
buildingId: string;
|
|
35
|
+
floorId: string;
|
|
36
|
+
latitude: number;
|
|
37
|
+
longitude: number;
|
|
38
|
+
}
|
|
39
|
+
export interface Error {
|
|
40
|
+
code: number;
|
|
41
|
+
message: string;
|
|
42
|
+
}
|
|
43
|
+
export interface Destination {
|
|
44
|
+
category: string;
|
|
45
|
+
identifier?: string;
|
|
46
|
+
name?: string;
|
|
47
|
+
point: Point;
|
|
48
|
+
}
|
|
49
|
+
export interface Navigation {
|
|
50
|
+
status: string;
|
|
51
|
+
destination?: Destination;
|
|
52
|
+
}
|
|
53
|
+
export interface OnNavigationResult {
|
|
54
|
+
navigation: Navigation;
|
|
55
|
+
error?: Error;
|
|
56
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { Destination, Navigation, Point } from "..";
|
|
3
|
+
import {
|
|
4
|
+
Directions,
|
|
5
|
+
Location,
|
|
6
|
+
NavigateToPoiType,
|
|
7
|
+
SDKNavigation,
|
|
8
|
+
} from "../store/index";
|
|
9
|
+
|
|
10
|
+
const mapperWrapper = (type: string, payload: unknown) =>
|
|
11
|
+
JSON.stringify({ type, payload });
|
|
12
|
+
|
|
13
|
+
const Mapper = {
|
|
14
|
+
location: (location: Location) =>
|
|
15
|
+
mapperWrapper("location.update", {
|
|
16
|
+
...(location.position && {
|
|
17
|
+
latitude: location.position.coordinate.latitude,
|
|
18
|
+
longitude: location.position.coordinate.longitude,
|
|
19
|
+
x: location.position.cartesianCoordinate.x,
|
|
20
|
+
y: location.position.cartesianCoordinate.y,
|
|
21
|
+
buildingId: location.position.buildingIdentifier,
|
|
22
|
+
floorId: location.position.floorIdentifier,
|
|
23
|
+
bearing: location.bearing?.degreesClockwise,
|
|
24
|
+
isIndoor: location.position.isIndoor,
|
|
25
|
+
isOutdoor: location.position.isOutdoor,
|
|
26
|
+
accuracy: location.accuracy,
|
|
27
|
+
hasBearing: location.hasBearing,
|
|
28
|
+
}),
|
|
29
|
+
status: location.status,
|
|
30
|
+
}),
|
|
31
|
+
locationStatus: (locationStatus: Location["status"]) =>
|
|
32
|
+
mapperWrapper("location_status.update", locationStatus),
|
|
33
|
+
|
|
34
|
+
route: (directions: Directions) =>
|
|
35
|
+
mapperWrapper("directions.update", directions),
|
|
36
|
+
|
|
37
|
+
navigation: (navigation: Navigation) =>
|
|
38
|
+
mapperWrapper(`navigation.${navigation.status}`, navigation),
|
|
39
|
+
|
|
40
|
+
navigateToPoi: (navigate: NavigateToPoiType) =>
|
|
41
|
+
mapperWrapper(`navigation.start`, { navigationTo: navigate?.navigationTo }),
|
|
42
|
+
|
|
43
|
+
cancelNavigation: () => mapperWrapper(`navigation.cancel`, {}),
|
|
44
|
+
|
|
45
|
+
selectPoi: (poiId: number) =>
|
|
46
|
+
mapperWrapper(`cartography.select_poi`, { identifier: poiId }),
|
|
47
|
+
|
|
48
|
+
followUser: (follow: boolean) => mapperWrapper("camera.follow_user", follow),
|
|
49
|
+
|
|
50
|
+
initialConfiguration: (
|
|
51
|
+
style: any,
|
|
52
|
+
enablePoiClustering: any,
|
|
53
|
+
showPoiNames: any,
|
|
54
|
+
minZoom: any,
|
|
55
|
+
maxZoom: any,
|
|
56
|
+
initialZoom: any,
|
|
57
|
+
useDashboardTheme: any
|
|
58
|
+
) =>
|
|
59
|
+
mapperWrapper("ui.initial_configuration", {
|
|
60
|
+
...(style && {
|
|
61
|
+
style: style,
|
|
62
|
+
}),
|
|
63
|
+
...(enablePoiClustering && {
|
|
64
|
+
enablePoiClustering: enablePoiClustering,
|
|
65
|
+
}),
|
|
66
|
+
...(showPoiNames && {
|
|
67
|
+
showPoiNames: showPoiNames,
|
|
68
|
+
}),
|
|
69
|
+
...(minZoom && {
|
|
70
|
+
minZoom: minZoom,
|
|
71
|
+
}),
|
|
72
|
+
...(maxZoom && {
|
|
73
|
+
maxZoom: maxZoom,
|
|
74
|
+
}),
|
|
75
|
+
...(initialZoom && {
|
|
76
|
+
initialZoom: initialZoom,
|
|
77
|
+
}),
|
|
78
|
+
...(useDashboardTheme && {
|
|
79
|
+
useDashboardTheme: useDashboardTheme,
|
|
80
|
+
}),
|
|
81
|
+
}),
|
|
82
|
+
|
|
83
|
+
routeToResult: (navigation: any): Navigation => {
|
|
84
|
+
//console.log('navigation/route to be mapped:', navigation);
|
|
85
|
+
return {
|
|
86
|
+
status: navigation.status,
|
|
87
|
+
destination: {
|
|
88
|
+
category: navigation?.destinationId ? "POI" : "COORDINATE",
|
|
89
|
+
identifier: navigation?.destinationId,
|
|
90
|
+
//name:, //TODO
|
|
91
|
+
point: {
|
|
92
|
+
buildingId:
|
|
93
|
+
navigation.to.buildingIdentifier ||
|
|
94
|
+
navigation.TO.buildingIdentifier,
|
|
95
|
+
floorId:
|
|
96
|
+
navigation.to.floorIdentifier || navigation.TO.floorIdentifier,
|
|
97
|
+
latitude:
|
|
98
|
+
navigation.to.coordinate.latitude ||
|
|
99
|
+
navigation.TO.coordinate.latitude,
|
|
100
|
+
longitude:
|
|
101
|
+
navigation.to.coordinate.longitude ||
|
|
102
|
+
navigation.TO.coordinate.longitude,
|
|
103
|
+
} as Point,
|
|
104
|
+
} as Destination,
|
|
105
|
+
} as Navigation;
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
navigationToResult: (navigation: SDKNavigation): Navigation => {
|
|
109
|
+
return {
|
|
110
|
+
status: navigation?.type,
|
|
111
|
+
};
|
|
112
|
+
// return {
|
|
113
|
+
// status: navigation.status,
|
|
114
|
+
// destination: {
|
|
115
|
+
// category: navigation.routeStep.TO.destinationId ? 'POI' : 'COORDINATE',
|
|
116
|
+
// identifier: navigation.routeStep.TO.destinationId,
|
|
117
|
+
// //name:, //TODO
|
|
118
|
+
// point: {
|
|
119
|
+
// buildingId: navigation.routeStep.TO.buildingIdentifier,
|
|
120
|
+
// floorId: navigation.routeStep.TO.floorIdentifier,
|
|
121
|
+
// latitude: navigation.routeStep.TO.coordinate.latitude,
|
|
122
|
+
// longitude: navigation.routeStep.TO.coordinate.longitude,
|
|
123
|
+
// } as Point,
|
|
124
|
+
// } as Destination,
|
|
125
|
+
// } as Navigation;
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export default Mapper;
|