@wemap/geo 0.3.8 → 0.3.9

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/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "directory": "packages/geo"
13
13
  },
14
14
  "name": "@wemap/geo",
15
- "version": "0.3.8",
15
+ "version": "0.3.9",
16
16
  "bugs": {
17
17
  "url": "https://github.com/wemap/wemap-utils-js/issues"
18
18
  },
@@ -31,5 +31,5 @@
31
31
  "lodash.isnumber": "^3.0.3",
32
32
  "lodash.isstring": "^4.0.1"
33
33
  },
34
- "gitHead": "6e107eebc85ff97f17371feac903ddb53657678b"
34
+ "gitHead": "84a60e64b0968bc45f0f76cc26c08e165dbe6985"
35
35
  }
@@ -113,7 +113,7 @@ class Level {
113
113
  if (second.isInside(first.val)) {
114
114
  return first;
115
115
  }
116
- return first;
116
+ return null;
117
117
  }
118
118
  if (first.isRange && second.isRange) {
119
119
  const up = Math.min(first.up, second.up);
@@ -119,6 +119,20 @@ describe('Level', () => {
119
119
  expect(Level.equalsTo(new Level(-1.5, 1).clone(), new Level(-1.5, 1))).true;
120
120
  });
121
121
 
122
+ it('isInside', () => {
123
+ expect(new Level(0).isInside(0)).true;
124
+ expect(new Level(1).isInside(0)).false;
125
+ expect(new Level(-1).isInside(0)).false;
126
+ expect(new Level(0).isInside(1)).false;
127
+ expect(new Level(0).isInside(-1)).false;
128
+ expect(new Level(0, 2).isInside(0)).true;
129
+ expect(new Level(0, 2).isInside(1)).true;
130
+ expect(new Level(0, 2).isInside(-1)).false;
131
+ expect(new Level(2, 0).isInside(0)).true;
132
+ expect(new Level(2, 0).isInside(1)).true;
133
+ expect(new Level(2, 0).isInside(-1)).false;
134
+ });
135
+
122
136
  it('intersect', () => {
123
137
  expect(Level.intersect(null, null)).is.null;
124
138
 
@@ -138,6 +152,8 @@ describe('Level', () => {
138
152
  expect(Level.equalsTo(Level.intersect(new Level(-3, -1), new Level(-1, 2)), new Level(-1)));
139
153
  expect(Level.intersect(new Level(-3, -2), new Level(-1, 2))).is.null;
140
154
  expect(Level.intersect(new Level(-1, 2), new Level(-3, -2))).is.null;
155
+ expect(Level.intersect(new Level(0), new Level(1, 2))).is.null;
156
+ expect(Level.intersect(new Level(1, 2), new Level(0))).is.null;
141
157
  });
142
158
 
143
159
  it('union', () => {
@@ -159,6 +175,8 @@ describe('Level', () => {
159
175
  expect(Level.equalsTo(Level.union(new Level(-3, -1), new Level(-1, 2)), new Level(-3, 2)));
160
176
  expect(Level.equalsTo(Level.union(new Level(-3, -2), new Level(-1, 2)), new Level(-3, 2)));
161
177
  expect(Level.equalsTo(Level.union(new Level(-1, 2), new Level(-3, -2)), new Level(-3, 2)));
178
+ expect(Level.equalsTo(Level.union(new Level(0), new Level(1, 2)), new Level(0, 2)));
179
+ expect(Level.equalsTo(Level.union(new Level(1, 2), new Level(0)), new Level(0, 2)));
162
180
  });
163
181
 
164
182
  });
@@ -34,10 +34,6 @@ describe('MapMatching', () => {
34
34
  it('matching node levels', () => {
35
35
  let currentPosition, projection;
36
36
 
37
- /**
38
- * Projection on Nodes
39
- */
40
-
41
37
  currentPosition = new WGS84(43.6091773, 3.8842584, null, null);
42
38
  projection = mapMatching.getProjection(currentPosition);
43
39
  expect(projection).is.null;
@@ -57,10 +53,6 @@ describe('MapMatching', () => {
57
53
  it('matching edge levels', () => {
58
54
  let currentPosition, projection;
59
55
 
60
- /**
61
- * Projection on Edges
62
- */
63
-
64
56
  currentPosition = new WGS84(43.6092811, 3.8842406, null, null);
65
57
  projection = mapMatching.getProjection(currentPosition);
66
58
  expect(projection).is.null;
@@ -80,10 +72,6 @@ describe('MapMatching', () => {
80
72
  it('matching stairs nodes levels', () => {
81
73
  let currentPosition, projection;
82
74
 
83
- /**
84
- * Projection on Edges
85
- */
86
-
87
75
  currentPosition = new WGS84(43.6093691, 3.8842057, null, null);
88
76
  projection = mapMatching.getProjection(currentPosition);
89
77
  expect(projection).is.null;
@@ -103,10 +91,6 @@ describe('MapMatching', () => {
103
91
  it('matching stairs edge levels', () => {
104
92
  let currentPosition, projection;
105
93
 
106
- /**
107
- * Projection on Edges
108
- */
109
-
110
94
  currentPosition = new WGS84(43.6093476, 3.8841978, null, null);
111
95
  projection = mapMatching.getProjection(currentPosition);
112
96
  expect(projection).is.null;
@@ -125,4 +109,25 @@ describe('MapMatching', () => {
125
109
 
126
110
  });
127
111
 
112
+ it('useMultiLevelSegments', () => {
113
+ let currentPosition, projection;
114
+
115
+ // On Nodes
116
+
117
+ currentPosition = new WGS84(43.6093691, 3.8842057, null, new Level(0));
118
+ projection = mapMatching.getProjection(currentPosition, true, false, false);
119
+ expect(projection).is.null;
120
+
121
+ // Next two are complex cases and not yet handled by our system
122
+
123
+ // currentPosition = new WGS84(43.6093691, 3.8842057, null, new Level(1));
124
+ // projection = mapMatching.getProjection(currentPosition, true, false, false);
125
+ // expect(projection.nearestElement).equals(nodes[14]);
126
+
127
+ // currentPosition = new WGS84(43.6093691, 3.8842057, null, new Level(2));
128
+ // projection = mapMatching.getProjection(currentPosition, true, false, false);
129
+ // expect(projection.nearestElement).equals(nodes[11]);
130
+
131
+ });
132
+
128
133
  });