• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript hittest.point_in_poly函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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
  }
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:46,代码来源:multi_polygons.ts


示例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
  }
开发者ID:Zyell,项目名称:bokeh,代码行数:16,代码来源:marker.ts


示例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]);
       }
     }
   }
 }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:16,代码来源:patches.ts


示例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")
  }
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:17,代码来源:multi_polygons.ts


示例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;
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:17,代码来源:marker.ts


示例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
  }
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:19,代码来源:text.ts


示例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
  }
开发者ID:gully,项目名称:bokeh,代码行数:20,代码来源:hex_tile.ts


示例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
  }
开发者ID:gully,项目名称:bokeh,代码行数:24,代码来源:patches.ts


示例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;
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:24,代码来源:patches.ts


示例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)
 })
开发者ID:jsignell,项目名称:bokeh,代码行数:4,代码来源:hittest.ts



注:本文中的core/hittest.point_in_poly函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript hittest.validate_bbox_coords函数代码示例发布时间:2022-05-24
下一篇:
TypeScript hittest.dist_to_segment函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap