当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript projections.wgs84_mercator类代码示例

本文整理汇总了TypeScript中core/util/projections.wgs84_mercator的典型用法代码示例。如果您正苦于以下问题:TypeScript wgs84_mercator类的具体用法?TypeScript wgs84_mercator怎么用?TypeScript wgs84_mercator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了wgs84_mercator类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: get_ticks_no_defaults

  get_ticks_no_defaults(data_low: number, data_high: number, cross_loc: any, desired_n_ticks: number) {
    if (this.dimension == null) {
      throw new Error("MercatorTicker.dimension not configured")
    }

    [data_low, data_high] = clip_mercator(data_low, data_high, this.dimension)
    let proj_low: number, proj_high: number, proj_cross_loc: any

    if (this.dimension === "lon") {
      [proj_low,  proj_cross_loc] = wgs84_mercator.inverse([data_low,  cross_loc]);
      [proj_high, proj_cross_loc] = wgs84_mercator.inverse([data_high, cross_loc])
    } else {
      [proj_cross_loc, proj_low ] = wgs84_mercator.inverse([cross_loc, data_low ]);
      [proj_cross_loc, proj_high] = wgs84_mercator.inverse([cross_loc, data_high])
    }

    const proj_ticks = super.get_ticks_no_defaults(proj_low, proj_high, cross_loc, desired_n_ticks)

    const major: number[] = []
    const minor: number[] = []

    if (this.dimension === "lon") {
      for (const tick of proj_ticks.major) {
        if (in_bounds(tick, 'lon')) {
          const [lon] = wgs84_mercator.forward([tick, proj_cross_loc])
          major.push(lon)
        }
      }
      for (const tick of proj_ticks.minor) {
        if (in_bounds(tick, 'lon')) {
          const [lon] = wgs84_mercator.forward([tick, proj_cross_loc])
          minor.push(lon)
        }
      }
    } else {
      for (const tick of proj_ticks.major) {
        if (in_bounds(tick, 'lat')) {
          const [, lat] = wgs84_mercator.forward([proj_cross_loc, tick])
          major.push(lat)
        }
      }
      for (const tick of proj_ticks.minor) {
        if (in_bounds(tick, 'lat')) {
          const [, lat] = wgs84_mercator.forward([proj_cross_loc, tick])
          minor.push(lat)
        }
      }
    }

    return {
      major: major,
      minor: minor,
    }
  }
开发者ID:Zyell,项目名称:bokeh,代码行数:54,代码来源:mercator_ticker.ts

示例2: it

 it("should compute longitude tick labels when dimension=lon", () => {
   const obj = new MercatorTickFormatter({dimension: 'lon'})
   for (const lat of [-72, -60.5, -30, -2, 1, -0.5, 0, 0.5, 1, 10, 33.7, 42.123, 50]) {
     for (const lon of [-120, -90, -88, -32.7, -10, -1, 0, 0.5, 1, 5, 12.3, 57, 60.123, 95, 110.1, 120, 130]) {
       const [mlon, mlat] = wgs84_mercator.forward([lon, lat])
       const labels = obj.doFormat([mlon], {loc: mlat})
       expect(labels[0]).to.equal(`${lon}`)
     }
   }
 })
开发者ID:jsignell,项目名称:bokeh,代码行数:10,代码来源:mercator_tick_formatter.ts

示例3: doFormat

  doFormat(ticks: number[], axis: Axis): string[] {
    if (this.dimension == null)
      throw new Error("MercatorTickFormatter.dimension not configured")

    if (ticks.length == 0)
      return []

    const n = ticks.length
    const proj_ticks = new Array(n)

    if (this.dimension == "lon") {
      for (let i = 0; i < n; i++) {
        const [lon,] = wgs84_mercator.inverse([ticks[i], axis.loc])
        proj_ticks[i] = lon
      }
    } else {
      for (let i = 0; i < n; i++) {
        const [, lat] = wgs84_mercator.inverse([axis.loc, ticks[i]])
        proj_ticks[i] = lat
      }
    }

    return super.doFormat(proj_ticks, axis)
  }
开发者ID:Zyell,项目名称:bokeh,代码行数:24,代码来源:mercator_tick_formatter.ts

示例4: _get_projected_bounds

 protected _get_projected_bounds(): [number, number, number, number] {
   const [xstart, xend, ystart, yend] = this._get_latlon_bounds()
   const [proj_xstart, proj_ystart] = wgs84_mercator.forward([xstart, ystart])
   const [proj_xend, proj_yend] = wgs84_mercator.forward([xend, yend])
   return [proj_xstart, proj_xend, proj_ystart, proj_yend]
 }
开发者ID:jsignell,项目名称:bokeh,代码行数:6,代码来源:gmap_plot_canvas.ts

示例5: meters_to_geographic

export function meters_to_geographic(mx: number, my: number): [number, number] {
  return wgs84_mercator.inverse([mx, my])
}
开发者ID:Zyell,项目名称:bokeh,代码行数:3,代码来源:tile_utils.ts

示例6: geographic_to_meters

export function geographic_to_meters(xLon: number, yLat: number): [number, number] {
  return wgs84_mercator.forward([xLon, yLat])
}
开发者ID:Zyell,项目名称:bokeh,代码行数:3,代码来源:tile_utils.ts


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