@wemap/geo 10.0.0-alpha.11 → 10.0.0-alpha.6
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/index.d.ts +0 -1
- package/package.json +4 -4
- package/src/coordinates/GeoRef.js +1 -1
- package/src/graph/Network.js +3 -9
- package/src/rotations/Attitude.js +0 -24
- package/src/rotations/Attitude.spec.js +3 -33
package/index.d.ts
CHANGED
|
@@ -85,7 +85,6 @@ declare module '@wemap/geo' {
|
|
|
85
85
|
static unitary(): Attitude;
|
|
86
86
|
static equals(attitude1: Attitude, attitude2: Attitude): boolean;
|
|
87
87
|
static fromJson(json: AttitudeJson): Attitude;
|
|
88
|
-
static diff(attitudeStart: Attitude, attitudeEnd: Attitude): Attitude;
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
export class GeoRef {
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"directory": "packages/geo"
|
|
14
14
|
},
|
|
15
15
|
"name": "@wemap/geo",
|
|
16
|
-
"version": "10.0.0-alpha.
|
|
16
|
+
"version": "10.0.0-alpha.6",
|
|
17
17
|
"bugs": {
|
|
18
18
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
19
19
|
},
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
],
|
|
29
29
|
"license": "ISC",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@wemap/logger": "^
|
|
32
|
-
"@wemap/maths": "^
|
|
31
|
+
"@wemap/logger": "^9.0.0",
|
|
32
|
+
"@wemap/maths": "^9.0.0"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "a2f0ceaabb22c5a9a7b7642993a55abe25c3efba"
|
|
35
35
|
}
|
|
@@ -23,7 +23,7 @@ class GeoRef {
|
|
|
23
23
|
const rotationOffset = Quaternion.fromAxisAngle([0, 0, 1], this.heading);
|
|
24
24
|
const enuToEcefRotationOrigin = Quaternion.multiply(rotationOffset, this.origin.enuToEcefRotation);
|
|
25
25
|
const ecefTranslation = Quaternion.rotate(enuToEcefRotationOrigin, enuTranslationScaled);
|
|
26
|
-
const ecef = Vector3.
|
|
26
|
+
const ecef = Vector3.add(this.origin.ecef, ecefTranslation);
|
|
27
27
|
return Coordinates.fromECEF(ecef);
|
|
28
28
|
}
|
|
29
29
|
|
package/src/graph/Network.js
CHANGED
|
@@ -161,15 +161,8 @@ class Network {
|
|
|
161
161
|
|
|
162
162
|
const network = new Network();
|
|
163
163
|
|
|
164
|
-
const getOrCreateNode = coords =>
|
|
165
|
-
|
|
166
|
-
if (node) {
|
|
167
|
-
return node;
|
|
168
|
-
}
|
|
169
|
-
const newNode = new GraphNode(coords);
|
|
170
|
-
network.nodes.push(newNode);
|
|
171
|
-
return newNode;
|
|
172
|
-
};
|
|
164
|
+
const getOrCreateNode = coords =>
|
|
165
|
+
network.nodes.find(_coords => _coords.equals(coords)) || new GraphNode(coords);
|
|
173
166
|
|
|
174
167
|
|
|
175
168
|
const createEdgeFromNodes = (node1, node2) =>
|
|
@@ -186,6 +179,7 @@ class Network {
|
|
|
186
179
|
network.edges.push(edge);
|
|
187
180
|
}
|
|
188
181
|
|
|
182
|
+
network.nodes.push(currentNode);
|
|
189
183
|
previousNode = currentNode;
|
|
190
184
|
}
|
|
191
185
|
}
|
|
@@ -187,30 +187,6 @@ class Attitude {
|
|
|
187
187
|
clone() {
|
|
188
188
|
return new Attitude(this.quaternion.slice(0), this.time, this.accuracy);
|
|
189
189
|
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Calculate the relative attitude between two given attitudes
|
|
193
|
-
* @param {Attitude} attitudeStart
|
|
194
|
-
* @param {Attitude} attitudeEnd
|
|
195
|
-
* @returns {Attitude}
|
|
196
|
-
*/
|
|
197
|
-
static diff(attitudeStart, attitudeEnd) {
|
|
198
|
-
|
|
199
|
-
const quaternionDiff = Quaternion.multiply(
|
|
200
|
-
Quaternion.inverse(attitudeStart.quaternion),
|
|
201
|
-
attitudeEnd.quaternion
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
const timeDiff = attitudeEnd.time - attitudeStart.time;
|
|
205
|
-
|
|
206
|
-
let accuracyDiff = null;
|
|
207
|
-
if (attitudeStart.accuracy !== null && attitudeEnd.accuracy !== null) {
|
|
208
|
-
// Approximation
|
|
209
|
-
accuracyDiff = Math.max(attitudeEnd.accuracy - attitudeStart.accuracy);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return new Attitude(quaternionDiff, timeDiff, accuracyDiff);
|
|
213
|
-
}
|
|
214
190
|
}
|
|
215
191
|
|
|
216
192
|
export default Attitude;
|
|
@@ -230,19 +230,19 @@ describe('Attitude', () => {
|
|
|
230
230
|
expect(attitude.equals(Attitude.fromJson(attitude.toJson()))).true;
|
|
231
231
|
|
|
232
232
|
attitude = new Attitude([1, 0, 0, 0], 2);
|
|
233
|
-
expect(attitude.toJson()).deep.equals({
|
|
233
|
+
expect(attitude.toJson()).deep.equals({q: [1, 0, 0, 0], time: 2});
|
|
234
234
|
attitudeBis = Attitude.fromJson(attitude.toJson());
|
|
235
235
|
expect(attitude.equals(attitudeBis)).true;
|
|
236
236
|
expect(attitudeBis.time).equals(2);
|
|
237
237
|
|
|
238
238
|
attitude = new Attitude([1, 0, 0, 0], null, 3);
|
|
239
|
-
expect(attitude.toJson()).deep.equals({
|
|
239
|
+
expect(attitude.toJson()).deep.equals({q: [1, 0, 0, 0], accuracy: 3});
|
|
240
240
|
attitudeBis = Attitude.fromJson(attitude.toJson());
|
|
241
241
|
expect(attitude.equals(attitudeBis)).true;
|
|
242
242
|
expect(attitudeBis.accuracy).equals(3);
|
|
243
243
|
|
|
244
244
|
attitude = new Attitude([1, 0, 0, 0], 2, 3);
|
|
245
|
-
expect(attitude.toJson()).deep.equals({
|
|
245
|
+
expect(attitude.toJson()).deep.equals({q: [1, 0, 0, 0], time: 2, accuracy: 3});
|
|
246
246
|
attitudeBis = Attitude.fromJson(attitude.toJson());
|
|
247
247
|
expect(attitude.equals(attitudeBis)).true;
|
|
248
248
|
expect(attitudeBis.time).equals(2);
|
|
@@ -250,34 +250,4 @@ describe('Attitude', () => {
|
|
|
250
250
|
|
|
251
251
|
});
|
|
252
252
|
|
|
253
|
-
it('diff', () => {
|
|
254
|
-
|
|
255
|
-
let startAttitude, endAttitude, diffAttitude;
|
|
256
|
-
|
|
257
|
-
startAttitude = new Attitude(LAYED_PORTRAIT_NORTH, 0, 0);
|
|
258
|
-
endAttitude = new Attitude(LAYED_PORTRAIT_EAST, 2, Math.PI / 4);
|
|
259
|
-
diffAttitude = Attitude.diff(startAttitude, endAttitude);
|
|
260
|
-
checkAngles(diffAttitude.heading, Math.PI / 2);
|
|
261
|
-
expect(Quaternion.equals(diffAttitude.quaternion, Quaternion.fromAxisAngle([0, 0, 1], -Math.PI / 2))).true;
|
|
262
|
-
expect(diffAttitude.time).equals(2);
|
|
263
|
-
expect(diffAttitude.accuracy).equals(Math.PI / 4);
|
|
264
|
-
|
|
265
|
-
endAttitude = new Attitude(LAYED_PORTRAIT_SOUTH);
|
|
266
|
-
diffAttitude = Attitude.diff(startAttitude, endAttitude);
|
|
267
|
-
checkAngles(diffAttitude.heading, Math.PI);
|
|
268
|
-
expect(Quaternion.equals(diffAttitude.quaternion, Quaternion.fromAxisAngle([0, 0, 1], Math.PI))).true;
|
|
269
|
-
|
|
270
|
-
endAttitude = new Attitude(STAND_PORTRAIT_NORTH);
|
|
271
|
-
diffAttitude = Attitude.diff(startAttitude, endAttitude);
|
|
272
|
-
checkAngles(diffAttitude.heading, 0);
|
|
273
|
-
expect(Quaternion.equals(diffAttitude.quaternion, Quaternion.fromAxisAngle([1, 0, 0], Math.PI / 2))).true;
|
|
274
|
-
|
|
275
|
-
startAttitude = new Attitude(STAND_PORTRAIT_SOUTH);
|
|
276
|
-
endAttitude = new Attitude(STAND_PORTRAIT_EAST);
|
|
277
|
-
diffAttitude = Attitude.diff(startAttitude, endAttitude);
|
|
278
|
-
checkAngles(diffAttitude.heading, -Math.PI / 2);
|
|
279
|
-
expect(Quaternion.equals(diffAttitude.quaternion, Quaternion.fromAxisAngle([0, 1, 0], Math.PI / 2))).true;
|
|
280
|
-
|
|
281
|
-
});
|
|
282
|
-
|
|
283
253
|
});
|