@wemap/geo 9.0.4 → 9.1.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/index.d.ts CHANGED
@@ -27,6 +27,13 @@ declare module '@wemap/geo' {
27
27
  [number, number, null, number] |
28
28
  [number, number, number, [number, number]];
29
29
 
30
+ export type CoordinatesJson = {
31
+ lat: number,
32
+ lng: number,
33
+ alt?: number,
34
+ level?: number | [number, number]
35
+ }
36
+
30
37
  export class Coordinates {
31
38
  lat: number;
32
39
  lng: number;
@@ -54,9 +61,9 @@ declare module '@wemap/geo' {
54
61
  getSegmentProjection(p1: Coordinates, p2: Coordinates): Coordinates | null;
55
62
 
56
63
  toString(): string;
57
- toJson(): { lat: number, lng: number, alt?: number, level?: number | [number, number] };
64
+ toJson(): CoordinatesJson;
58
65
  toCompressedJson(): CoordinatesCompressedJson;
59
- static fromJson(json: { lat: number, lng: number, alt?: number, level?: number | [number, number] }): Coordinates;
66
+ static fromJson(json: CoordinatesJson): Coordinates;
60
67
  static fromCompressedJson(json: CoordinatesCompressedJson): Coordinates;
61
68
 
62
69
  /** @deprecated */
@@ -76,6 +83,28 @@ declare module '@wemap/geo' {
76
83
 
77
84
  }
78
85
 
86
+ export type AttitudeJson = Quaternion_t;
87
+
88
+ export class Attitude {
89
+ constructor(quaternion: Quaternion_t, time?: number, accuracy?: number);
90
+ get quaternion(): Quaternion_t;
91
+ set quaternion(quaternion: Quaternion_t);
92
+ get time(): number;
93
+ set time(time: number);
94
+ get accuracy(): number;
95
+ set accuracy(accuracy: number);
96
+ get eulerAngles(): [number, number, number];
97
+ get eulerAnglesDegrees(): [number, number, number];
98
+ get heading(): number;
99
+ get headingDegrees(): number;
100
+ equals(other: Attitude): boolean;
101
+ toJson() : AttitudeJson;
102
+ clone(): Attitude;
103
+ static unitary(): Attitude;
104
+ static equals(attitude1: Attitude, attitude2: Attitude): boolean;
105
+ static fromJson(json: AttitudeJson): Attitude;
106
+ }
107
+
79
108
  export class GeoRef {
80
109
  origin: Coordinates;
81
110
  scale: number;
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "directory": "packages/geo"
14
14
  },
15
15
  "name": "@wemap/geo",
16
- "version": "9.0.4",
16
+ "version": "9.1.1",
17
17
  "bugs": {
18
18
  "url": "https://github.com/wemap/wemap-modules-js/issues"
19
19
  },
@@ -31,5 +31,5 @@
31
31
  "@wemap/logger": "^9.0.0",
32
32
  "@wemap/maths": "^9.0.0"
33
33
  },
34
- "gitHead": "9d6b6776b86ae16dfa3fb71c3303d48a8289ceed"
34
+ "gitHead": "bf6a54cf4f886ebac773549339ada8f98c0b7f7f"
35
35
  }
@@ -161,8 +161,15 @@ class Network {
161
161
 
162
162
  const network = new Network();
163
163
 
164
- const getOrCreateNode = coords =>
165
- network.nodes.find(_coords => _coords.equals(coords)) || new GraphNode(coords);
164
+ const getOrCreateNode = coords => {
165
+ const node = network.nodes.find(otherNode => otherNode.coords.equals(coords));
166
+ if (node) {
167
+ return node;
168
+ }
169
+ const newNode = new GraphNode(coords);
170
+ network.nodes.push(newNode);
171
+ return newNode;
172
+ };
166
173
 
167
174
 
168
175
  const createEdgeFromNodes = (node1, node2) =>
@@ -179,7 +186,6 @@ class Network {
179
186
  network.edges.push(edge);
180
187
  }
181
188
 
182
- network.nodes.push(currentNode);
183
189
  previousNode = currentNode;
184
190
  }
185
191
  }