Skip to content

Commit 30789dd

Browse files
committed
Remove 🔪 obsolete polygon.multitester function [1852]
- Put throwing an error in place should it be called with this parameter shape still. See PR #2944 for the discussion.
1 parent 87d0497 commit 30789dd

File tree

1 file changed

+5
-46
lines changed

1 file changed

+5
-46
lines changed

src/lib/polygon.js

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ var polygon = module.exports = {};
3131
* returns boolean: is pt inside the polygon (including on its edges)
3232
*/
3333
polygon.tester = function tester(ptsIn) {
34-
if(Array.isArray(ptsIn[0][0])) return polygon.multitester(ptsIn);
34+
35+
// Throw an error if any code tries to pass this no
36+
// longer supported argument shape. The local multitester became
37+
// obsolete when introducing click-to-select in PR #2944.
38+
if(Array.isArray(ptsIn[0][0])) throw new Error('multitester called!');
3539

3640
var pts = ptsIn.slice(),
3741
xmin = pts[0][0],
@@ -174,51 +178,6 @@ polygon.tester = function tester(ptsIn) {
174178
};
175179
};
176180

177-
// TODO Somewhat redundant to multiTester in 'lib/select.js'
178-
/**
179-
* Test multiple polygons
180-
*/
181-
polygon.multitester = function multitester(list) {
182-
var testers = [],
183-
xmin = list[0][0][0],
184-
xmax = xmin,
185-
ymin = list[0][0][1],
186-
ymax = ymin;
187-
188-
for(var i = 0; i < list.length; i++) {
189-
var tester = polygon.tester(list[i]);
190-
tester.subtract = list[i].subtract;
191-
testers.push(tester);
192-
xmin = Math.min(xmin, tester.xmin);
193-
xmax = Math.max(xmax, tester.xmax);
194-
ymin = Math.min(ymin, tester.ymin);
195-
ymax = Math.max(ymax, tester.ymax);
196-
}
197-
198-
function contains(pt, arg) {
199-
var yes = false;
200-
for(var i = 0; i < testers.length; i++) {
201-
if(testers[i].contains(pt, arg)) {
202-
// if contained by subtract polygon - exclude the point
203-
yes = testers[i].subtract === false;
204-
}
205-
}
206-
207-
return yes;
208-
}
209-
210-
return {
211-
xmin: xmin,
212-
xmax: xmax,
213-
ymin: ymin,
214-
ymax: ymax,
215-
pts: [],
216-
contains: contains,
217-
isRect: false,
218-
degenerate: false
219-
};
220-
};
221-
222181
/**
223182
* Test if a segment of a points array is bent or straight
224183
*

0 commit comments

Comments
 (0)