本文整理汇总了TypeScript中core/hittest.point_in_poly函数的典型用法代码示例。如果您正苦于以下问题:TypeScript point_in_poly函数的具体用法?TypeScript point_in_poly怎么用?TypeScript point_in_poly使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了point_in_poly函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _hit_point
protected _hit_point(geometry: PointGeometry): Selection {
const {sx, sy} = geometry
const x = this.renderer.xscale.invert(sx)
const y = this.renderer.yscale.invert(sy)
const candidates = this.index.indices({minX: x, minY: y, maxX: x, maxY: y})
const hole_candidates = this.hole_index.indices({minX: x, minY: y, maxX: x, maxY: y})
const hits = []
for (let i = 0, end = candidates.length; i < end; i++) {
const idx = candidates[i]
const sxs = this.sxs[idx]
const sys = this.sys[idx]
for (let j = 0, endj = sxs.length; j < endj; j++) {
const nk = sxs[j].length
if (hittest.point_in_poly(sx, sy, (sxs[j][0] as number[]), (sys[j][0] as number[]))) {
if (nk == 1) {
hits.push(idx)
} else if (hole_candidates.indexOf(idx) == -1) {
hits.push(idx)
} else if (nk > 1) {
let in_a_hole = false
for (let k = 1; k < nk; k++) {
const sxs_k = sxs[j][k] as number[]
const sys_k = sys[j][k] as number[]
if (hittest.point_in_poly(sx, sy, sxs_k, sys_k)) {
in_a_hole = true
break
} else {
continue
}
}
if (!in_a_hole) {
hits.push(idx)
}
}
}
}
}
const result = hittest.create_empty_hit_test_result()
result.indices = hits
return result
}
示例2: _hit_poly
protected _hit_poly(geometry: PolyGeometry): Selection {
const {sx, sy} = geometry
// TODO (bev) use spatial index to pare candidate list
const candidates = range(0, this.sx.length)
const hits = []
for (let i = 0, end = candidates.length; i < end; i++) {
const idx = candidates[i]
if (hittest.point_in_poly(this.sx[i], this.sy[i], sx, sy))
hits.push(idx)
}
const result = hittest.create_empty_hit_test_result()
result.indices = hits
return result
}
示例3: scy
scy(i, sx, sy) {
if (this.renderer.syss[i].length === 1) {
// We don't have discontinuous objects so we're ok
return this._get_snap_coord(this.sys[i]);
} else {
// We have discontinuous objects, so we need to find which
// one we're in, we can use point_in_poly again
const sxs = this.renderer.sxss[i];
const sys = this.renderer.syss[i];
for (let j = 0, end = sxs.length; j < end; j++) {
if (hittest.point_in_poly(sx, sy, sxs[j], sys[j])) {
return this._get_snap_coord(sys[j]);
}
}
}
}
示例4: scentery
scentery(i: number, sx: number, sy: number): number {
if (this.sys[i].length == 1) {
// We don't have discontinuous objects so we're ok
return this._get_snap_coord(this.sys[i][0][0])
} else {
// We have discontinuous objects, so we need to find which
// one we're in, we can use point_in_poly again
const sxs = this.sxs[i]
const sys = this.sys[i]
for (let j = 0, end = sxs.length; j < end; j++) {
if (hittest.point_in_poly(sx, sy, (sxs[j][0] as number[]), (sys[j][0] as number[])))
return this._get_snap_coord(sys[j][0])
}
}
throw new Error("unreachable code")
}
示例5: _hit_poly
_hit_poly(geometry) {
const {sx, sy} = geometry;
// TODO (bev) use spatial index to pare candidate list
const candidates = range(0, this.sx.length);
const hits = [];
for (let i = 0, end = candidates.length; i < end; i++) {
const idx = candidates[i];
if (hittest.point_in_poly(this.sx[i], this.sy[i], sx, sy)) {
hits.push(idx);
}
}
const result = hittest.create_hit_test_result();
result['1d'].indices = hits;
return result;
}
示例6: _hit_point
protected _hit_point(geometry: PointGeometry): Selection {
const {sx, sy} = geometry
const hits = []
for (let i = 0; i < this._sxs.length; i++) {
const sxs = this._sxs[i]
const sys = this._sys[i]
const n = sxs.length
for (let j = 0, endj = n; j < endj; j++) {
const [sxr, syr] = this._rotate_point(sx, sy, sxs[n-1][0], sys[n-1][0], -this._angle[i])
if (hittest.point_in_poly(sxr, syr, sxs[j], sys[j])) {
hits.push(i)
}
}
}
const result = hittest.create_empty_hit_test_result()
result.indices = hits
return result
}
示例7: _hit_point
protected _hit_point(geometry: PointGeometry): Selection {
const {sx, sy} = geometry
const x = this.renderer.xscale.invert(sx)
const y = this.renderer.yscale.invert(sy)
const candidates = this.index.indices({minX: x, minY: y, maxX: x, maxY: y})
const hits = []
for (const i of candidates) {
if (hittest.point_in_poly(sx-this.sx[i], sy-this.sy[i], this.svx, this.svy)) {
hits.push(i)
}
}
const result = hittest.create_empty_hit_test_result()
result.indices = hits
return result
}
示例8: _hit_point
protected _hit_point(geometry: PointGeometry): Selection {
const {sx, sy} = geometry
const x = this.renderer.xscale.invert(sx)
const y = this.renderer.yscale.invert(sy)
const candidates = this.index.indices({minX: x, minY: y, maxX: x, maxY: y})
const hits = []
for (let i = 0, end = candidates.length; i < end; i++) {
const idx = candidates[i]
const sxs = this.sxss[idx]
const sys = this.syss[idx]
for (let j = 0, endj = sxs.length; j < endj; j++) {
if (hittest.point_in_poly(sx, sy, sxs[j], sys[j])) {
hits.push(idx)
}
}
}
const result = hittest.create_empty_hit_test_result()
result.indices = hits
return result
}
示例9: _hit_point
_hit_point(geometry) {
const {sx, sy} = geometry;
const x = this.renderer.xscale.invert(sx);
const y = this.renderer.yscale.invert(sy);
const candidates = this.index.indices({minX: x, minY: y, maxX: x, maxY: y});
const hits = [];
for (let i = 0, end = candidates.length; i < end; i++) {
const idx = candidates[i];
const sxs = this.renderer.sxss[idx];
const sys = this.renderer.syss[idx];
for (let j = 0, endj = sxs.length; j < endj; j++) {
if (hittest.point_in_poly(sx, sy, sxs[j], sys[j])) {
hits.push(idx);
}
}
}
const result = hittest.create_hit_test_result();
result['1d'].indices = hits;
return result;
}
示例10: it
it("should return false if (x,y) point is outside a polygon, true if inside", () => {
expect(hittest.point_in_poly(1.5, 5, [1,2,2,1], [4,5,8,9])).to.be.equal(true)
expect(hittest.point_in_poly(1.01, 4, [1,2,2,1], [4,5,8,9])).to.be.equal(false)
})