@inovitas/infra3dapi 1.2.1-beta.1 → 1.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
@@ -1,48 +1,50 @@
1
- # Installation
2
-
3
- ### NPM Package
4
-
5
- The API can be installed as a package using npm. To install it from the npm package repository, simply type:
6
-
7
- ```bash
8
- npm install @inovitas/infra3dapi
9
- ```
10
-
11
- ### CDN Download
12
-
13
- Alternatively, you can obtain the API from a CDN. To get the latest version, add the following script to your HTML file:
14
-
15
- ```html
16
- <script src="https://cdn.jsdelivr.net/npm/@inovitas/infra3dapi@latest/infra3dapi.js"></script>
17
- ```
18
-
19
- We recommend using a specific version in your project. To get a specific version, use the following script and adjust the version accordingly:
20
-
21
- ```html
22
- <script src="https://cdn.jsdelivr.net/npm/@inovitas/infra3dapi@1.0.1/infra3dapi.js"></script>
23
- ```
24
-
25
- **Note**: Please do not name the `<div>` in which the viewer is initialized as "infra3d" as this may cause internal conflicts.
26
-
27
- # Core Concept
28
-
29
- To use the API, you can call the init functions in infra3dapi. After loggin in and initializing the view (with [`manager.initView()`](classes/_inovitas_infra3dapi.manager.Manager.html#initView)), you will get a viewer object. This viewer object can then be used to add event-listeners to different events emitted by the viewer (like [`viewer.geoframechanged`](classes/_inovitas_infra3dsdk.Viewer.html#geoframechanged)) or to call some functions (like [`viewer.getRoutes()`](classes/_inovitas_infra3dsdk.Viewer.html#getRoutes) or [`viewer.movePosition()`](classes/_inovitas_infra3dsdk.Viewer.html#movePosition)).
30
-
31
- # Authentication
32
-
33
- 1. Register your OAuth 2.0 application with our sales team to obtain credentials (client_id and client_secret).
34
- 2. Develop a server-side component to securely use these credentials, obtaining an access token from infra3D.
35
- 3. Your server-side component fetches the access token using client credentials, which can then be shared with your client app.
36
- 4. Your client app uses this token to authenticate with infra3D for requested services, refreshing it via the server component when expired. Remember to treat the client_secret like a password, avoiding exposure in client-side environments for enhanced security.
37
-
38
- # Changelog
39
-
1
+ # Installation
2
+
3
+ ### NPM Package
4
+
5
+ The API can be installed as a package using npm. To install it from the npm package repository, simply type:
6
+
7
+ ```bash
8
+ npm install @inovitas/infra3dapi
9
+ ```
10
+
11
+ ### CDN Download
12
+
13
+ Alternatively, you can obtain the API from a CDN. To get the latest version, add the following script to your HTML file:
14
+
15
+ ```html
16
+ <script src="https://cdn.jsdelivr.net/npm/@inovitas/infra3dapi@latest/infra3dapi.js"></script>
17
+ ```
18
+
19
+ We recommend using a specific version in your project. To get a specific version, use the following script and adjust the version accordingly:
20
+
21
+ ```html
22
+ <script src="https://cdn.jsdelivr.net/npm/@inovitas/infra3dapi@1.0.1/infra3dapi.js"></script>
23
+ ```
24
+
25
+ **Note**: Please do not name the `<div>` in which the viewer is initialized as "infra3d" as this may cause internal conflicts.
26
+
27
+ # Core Concept
28
+
29
+ To use the API, you can call the init functions in infra3dapi. After loggin in and initializing the view (with [`manager.initView()`](classes/_inovitas_infra3dapi.manager.Manager.html#initView)), you will get a viewer object. This viewer object can then be used to add event-listeners to different events emitted by the viewer (like [`viewer.geoframechanged`](classes/_inovitas_infra3dsdk.Viewer.html#geoframechanged)) or to call some functions (like [`viewer.getRoutes()`](classes/_inovitas_infra3dsdk.Viewer.html#getRoutes) or [`viewer.movePosition()`](classes/_inovitas_infra3dsdk.Viewer.html#movePosition)).
30
+
31
+ # Authentication
32
+
33
+ 1. Register your OAuth 2.0 application with our sales team to obtain credentials (client_id and client_secret).
34
+ 2. Develop a server-side component to securely use these credentials, obtaining an access token from infra3D.
35
+ 3. Your server-side component fetches the access token using client credentials, which can then be shared with your client app.
36
+ 4. Your client app uses this token to authenticate with infra3D for requested services, refreshing it via the server component when expired. Remember to treat the client_secret like a password, avoiding exposure in client-side environments for enhanced security.
37
+
38
+ # Changelog
39
+
40
40
  ## 1.2.0 - 16.12.2024
41
41
 
42
42
  ### Bugfixes
43
43
 
44
44
  - Improve styling when using global box-sizing style
45
45
  - Style of the scrollbar is no more globally overwritten by the API
46
+ - Resize event listens now on the div and not the whole window
47
+
46
48
 
47
49
  ### Added
48
50
 
@@ -171,3 +173,4 @@ To use the API, you can call the init functions in infra3dapi. After loggin in a
171
173
  ### Added
172
174
 
173
175
  - Edit functionality
176
+
package/infra3dapi.d.ts CHANGED
@@ -1,204 +1,204 @@
1
- declare module "@inovitas/infra3dapi";
2
-
3
- declare type Fn = (arg: any) => void;
4
- declare class EventEmitter {
5
- protected _events: {
6
- [eventType: string]: Fn[];
7
- };
8
- constructor();
9
- on(eventType: string, fn: Fn): void;
10
- off(eventType: string, fn: Fn): void;
11
- fire(eventType: string, data: unknown): void;
12
- private _listens;
13
- }
14
-
15
- declare type ViewerEventType =
16
- | "nodechanged"
17
- | "panorotationchanged"
18
- | "campaignschanged"
19
- | "lookazimuthchanged";
20
-
21
- interface IViewer {
22
- fire<T>(type: ViewerEventType, event: T): void;
23
- off<T>(type: ViewerEventType, handler: (event: T) => void): void;
24
- on<T>(type: ViewerEventType, handler: (event: T) => void): void;
25
- }
26
-
27
- interface ViewerEvent {
28
- target: IViewer;
29
- type: ViewerEventType;
30
- }
31
-
32
- interface NodechangedEvent extends ViewerEvent {
33
- lat: number;
34
- lon: number;
35
- height: number;
36
- campaign_id: string;
37
- date: string;
38
- type: "nodechanged";
39
- }
40
-
41
- interface CampaignschangedEvent extends ViewerEvent {
42
- id: number;
43
-
44
- project: number;
45
-
46
- description: string;
47
-
48
- type: "campaignschanged";
49
- }
50
-
51
- interface PanorotationchangedEvent extends ViewerEvent {
52
- fov: number;
53
-
54
- lat: number;
55
-
56
- lon: number;
57
-
58
- type: "panorotationchanged";
59
- }
60
-
61
- interface LookazimuthchangedEvent extends ViewerEvent {
62
- value: number;
63
-
64
- type: "lookazimuthchanged";
65
- }
66
-
67
- declare class InternalViewer {}
68
- declare class GeoJSON {}
69
- declare class ApmBase {}
70
-
71
- declare class Viewer extends EventEmitter implements IViewer {
72
- private _sdk_viewer;
73
- constructor(sdk_viewer: InternalViewer);
74
- moveToCampaign(campaignID: string): Promise<void>;
75
- moveToPosition(
76
- easting: number,
77
- northing: number,
78
- height?: number,
79
- maxdist?: number,
80
- epsg?: number
81
- ): Promise<void>;
82
- lookAtPosition(
83
- easting: number,
84
- northing: number,
85
- height?: number,
86
- maxdist?: number,
87
- epsg?: number
88
- ): Promise<void>;
89
- getRoutes(simplify?: number): Promise<GeoJSON>;
90
- attachToMeasurementTool(
91
- toolname: "lengthMeasure" | "areaMeasure",
92
- onmeasured: (value: number, geometry: number[][]) => void
93
- ): void;
94
- attachToMeasurementTool(
95
- toolname: "pointMeasure",
96
- onmeasured: (value: undefined, geometry: number[]) => void
97
- ): void;
98
- private _processMeasurementResult;
99
- off(type: "nodechanged", handler: (event: NodechangedEvent) => void): void;
100
- off(
101
- type: "campaignschanged",
102
- handler: (event: CampaignschangedEvent) => void
103
- ): void;
104
- off(
105
- type: "panorotationchanged",
106
- handler: (event: PanorotationchangedEvent) => void
107
- ): void;
108
- off(
109
- type: "lookazimuthchanged",
110
- handler: (event: LookazimuthchangedEvent) => void
111
- ): void;
112
- on(type: "nodechanged", handler: (event: NodechangedEvent) => void): void;
113
- on(
114
- type: "campaignschanged",
115
- handler: (event: CampaignschangedEvent) => void
116
- ): void;
117
- on(
118
- type: "panorotationchanged",
119
- handler: (event: PanorotationchangedEvent) => void
120
- ): void;
121
- on(
122
- type: "lookazimuthchanged",
123
- handler: (event: LookazimuthchangedEvent) => void
124
- ): void;
125
- }
126
-
127
- declare type applicationProps = {
128
- name: string;
129
- url: string;
130
- };
131
- declare type cardProps = {
132
- uid: string;
133
- name: string;
134
- description: string;
135
- applications: applicationProps[];
136
- created_by: string;
137
- creation_date: string | Date;
138
- tags: Array<{
139
- name: string;
140
- font_color: string;
141
- background_color: string;
142
- }>;
143
- };
144
-
145
- declare class Manager extends EventEmitter {
146
- static viewinitialized: string;
147
- static viewerset: string;
148
- static tokenset: string;
149
- private _apm;
150
- private _tokens;
151
- constructor(apm: ApmBase);
152
- initViewer(options: {
153
- project_uid: string;
154
- start_position?: {
155
- easting: number;
156
- northing: number;
157
- epsg?: number;
158
- };
159
- start_campaign?: {
160
- id: string;
161
- };
162
- map_expand?: boolean;
163
- show_cockpit?: boolean;
164
- show_mapWindow?: boolean;
165
- show_toolbar?: boolean;
166
- toolbar?: string;
167
- show_topbar?: boolean;
168
- }): Promise<Viewer>;
169
- getProjects(): Promise<cardProps[]>;
170
- setViewer(viewer: InternalViewer): void;
171
- setTokens(tokens: any): void;
172
- setApmUserContext(userContext?: {
173
- id?: string;
174
- username?: string;
175
- email?: string;
176
- }): void;
177
- }
178
-
179
- declare type accessTokenResponseType = {
180
- access_token: string;
181
- expires_in: number;
182
- token_type: "Bearer";
183
- };
184
-
185
- export declare function getAccessToken(
186
- url: string,
187
- client_id: string,
188
- client_secret: string
189
- ): Promise<accessTokenResponseType>;
190
-
191
- export declare function init(
192
- rootId: string,
193
- token: string,
194
- userContext?: {
195
- id?: string;
196
- username?: string;
197
- email?: string;
198
- }
199
- ): Promise<Manager>;
200
- export declare function destroy(): void;
201
- export declare function getManager(): Manager;
202
- export declare function getGuestAccessToken(): Promise<accessTokenResponseType>;
203
- export declare function refreshToken(token: string): void;
1
+ declare module "@inovitas/infra3dapi";
2
+
3
+ declare type Fn = (arg: any) => void;
4
+ declare class EventEmitter {
5
+ protected _events: {
6
+ [eventType: string]: Fn[];
7
+ };
8
+ constructor();
9
+ on(eventType: string, fn: Fn): void;
10
+ off(eventType: string, fn: Fn): void;
11
+ fire(eventType: string, data: unknown): void;
12
+ private _listens;
13
+ }
14
+
15
+ declare type ViewerEventType =
16
+ | "nodechanged"
17
+ | "panorotationchanged"
18
+ | "campaignschanged"
19
+ | "lookazimuthchanged";
20
+
21
+ interface IViewer {
22
+ fire<T>(type: ViewerEventType, event: T): void;
23
+ off<T>(type: ViewerEventType, handler: (event: T) => void): void;
24
+ on<T>(type: ViewerEventType, handler: (event: T) => void): void;
25
+ }
26
+
27
+ interface ViewerEvent {
28
+ target: IViewer;
29
+ type: ViewerEventType;
30
+ }
31
+
32
+ interface NodechangedEvent extends ViewerEvent {
33
+ lat: number;
34
+ lon: number;
35
+ height: number;
36
+ campaign_id: string;
37
+ date: string;
38
+ type: "nodechanged";
39
+ }
40
+
41
+ interface CampaignschangedEvent extends ViewerEvent {
42
+ id: number;
43
+
44
+ project: number;
45
+
46
+ description: string;
47
+
48
+ type: "campaignschanged";
49
+ }
50
+
51
+ interface PanorotationchangedEvent extends ViewerEvent {
52
+ fov: number;
53
+
54
+ lat: number;
55
+
56
+ lon: number;
57
+
58
+ type: "panorotationchanged";
59
+ }
60
+
61
+ interface LookazimuthchangedEvent extends ViewerEvent {
62
+ value: number;
63
+
64
+ type: "lookazimuthchanged";
65
+ }
66
+
67
+ declare class InternalViewer {}
68
+ declare class GeoJSON {}
69
+ declare class ApmBase {}
70
+
71
+ declare class Viewer extends EventEmitter implements IViewer {
72
+ private _sdk_viewer;
73
+ constructor(sdk_viewer: InternalViewer);
74
+ moveToCampaign(campaignID: string): Promise<void>;
75
+ moveToPosition(
76
+ easting: number,
77
+ northing: number,
78
+ height?: number,
79
+ maxdist?: number,
80
+ epsg?: number
81
+ ): Promise<void>;
82
+ lookAtPosition(
83
+ easting: number,
84
+ northing: number,
85
+ height?: number,
86
+ maxdist?: number,
87
+ epsg?: number
88
+ ): Promise<void>;
89
+ getRoutes(simplify?: number): Promise<GeoJSON>;
90
+ attachToMeasurementTool(
91
+ toolname: "lengthMeasure" | "areaMeasure",
92
+ onmeasured: (value: number, geometry: number[][]) => void
93
+ ): void;
94
+ attachToMeasurementTool(
95
+ toolname: "pointMeasure",
96
+ onmeasured: (value: undefined, geometry: number[]) => void
97
+ ): void;
98
+ private _processMeasurementResult;
99
+ off(type: "nodechanged", handler: (event: NodechangedEvent) => void): void;
100
+ off(
101
+ type: "campaignschanged",
102
+ handler: (event: CampaignschangedEvent) => void
103
+ ): void;
104
+ off(
105
+ type: "panorotationchanged",
106
+ handler: (event: PanorotationchangedEvent) => void
107
+ ): void;
108
+ off(
109
+ type: "lookazimuthchanged",
110
+ handler: (event: LookazimuthchangedEvent) => void
111
+ ): void;
112
+ on(type: "nodechanged", handler: (event: NodechangedEvent) => void): void;
113
+ on(
114
+ type: "campaignschanged",
115
+ handler: (event: CampaignschangedEvent) => void
116
+ ): void;
117
+ on(
118
+ type: "panorotationchanged",
119
+ handler: (event: PanorotationchangedEvent) => void
120
+ ): void;
121
+ on(
122
+ type: "lookazimuthchanged",
123
+ handler: (event: LookazimuthchangedEvent) => void
124
+ ): void;
125
+ }
126
+
127
+ declare type applicationProps = {
128
+ name: string;
129
+ url: string;
130
+ };
131
+ declare type cardProps = {
132
+ uid: string;
133
+ name: string;
134
+ description: string;
135
+ applications: applicationProps[];
136
+ created_by: string;
137
+ creation_date: string | Date;
138
+ tags: Array<{
139
+ name: string;
140
+ font_color: string;
141
+ background_color: string;
142
+ }>;
143
+ };
144
+
145
+ declare class Manager extends EventEmitter {
146
+ static viewinitialized: string;
147
+ static viewerset: string;
148
+ static tokenset: string;
149
+ private _apm;
150
+ private _tokens;
151
+ constructor(apm: ApmBase);
152
+ initViewer(options: {
153
+ project_uid: string;
154
+ start_position?: {
155
+ easting: number;
156
+ northing: number;
157
+ epsg?: number;
158
+ };
159
+ start_campaign?: {
160
+ id: string;
161
+ };
162
+ map_expand?: boolean;
163
+ show_cockpit?: boolean;
164
+ show_mapWindow?: boolean;
165
+ show_toolbar?: boolean;
166
+ toolbar?: string;
167
+ show_topbar?: boolean;
168
+ }): Promise<Viewer>;
169
+ getProjects(): Promise<cardProps[]>;
170
+ setViewer(viewer: InternalViewer): void;
171
+ setTokens(tokens: any): void;
172
+ setApmUserContext(userContext?: {
173
+ id?: string;
174
+ username?: string;
175
+ email?: string;
176
+ }): void;
177
+ }
178
+
179
+ declare type accessTokenResponseType = {
180
+ access_token: string;
181
+ expires_in: number;
182
+ token_type: "Bearer";
183
+ };
184
+
185
+ export declare function getAccessToken(
186
+ url: string,
187
+ client_id: string,
188
+ client_secret: string
189
+ ): Promise<accessTokenResponseType>;
190
+
191
+ export declare function init(
192
+ rootId: string,
193
+ token: string,
194
+ userContext?: {
195
+ id?: string;
196
+ username?: string;
197
+ email?: string;
198
+ }
199
+ ): Promise<Manager>;
200
+ export declare function destroy(): void;
201
+ export declare function getManager(): Manager;
202
+ export declare function getGuestAccessToken(): Promise<accessTokenResponseType>;
203
+ export declare function refreshToken(token: string): void;
204
204