MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / isInsideLine

Method isInsideLine

src/common/overlay/levelRenderer/Area.js:423–449  ·  view source on GitHub ↗

* @function LevelRenderer.Tool.Areal.prototype.isInsideLine * @description 线段包含判断。 * @param {number} x0 - 线起始点横坐标。 * @param {number} y0 - 线起始点纵坐标。 * @param {number} x1 - 线终点横坐标。 * @param {number} y1 - 线终点纵坐标。 * @param {number} lineWidth - 线宽。 * @param {number} x -

(x0, y0, x1, y1, lineWidth, x, y)

Source from the content-addressed store, hash-verified

421 * @returns {boolean} 图形是否包含鼠标位置,true表示坐标处在图形内。
422 */
423 isInsideLine(x0, y0, x1, y1, lineWidth, x, y) {
424 if (lineWidth === 0) {
425 return false;
426 }
427 var _l = Math.max(lineWidth, 5);
428 var _a = 0;
429 var _b = 0;
430 // Quick reject
431 if (
432 (y > y0 + _l && y > y1 + _l)
433 || (y < y0 - _l && y < y1 - _l)
434 || (x > x0 + _l && x > x1 + _l)
435 || (x < x0 - _l && x < x1 - _l)
436 ) {
437 return false;
438 }
439
440 if (x0 !== x1) {
441 _a = (y0 - y1) / (x0 - x1);
442 _b = (x0 * y1 - x1 * y0) / (x0 - x1);
443 } else {
444 return Math.abs(x - x0) <= _l / 2;
445 }
446 var tmp = _a * x - y + _b;
447 var _s = tmp * tmp / (_a * _a + 1);
448 return _s <= _l / 2 * _l / 2;
449 }
450
451 /**
452 * @function LevelRenderer.Tool.Areal.prototype.isInsideCubicStroke

Callers 4

_mathMethodMethod · 0.95
isInsideBrokenLineMethod · 0.95
isInsidePathMethod · 0.95
AreaSpec.jsFile · 0.80

Calls 1

maxMethod · 0.80

Tested by

no test coverage detected