成人无码视频,亚洲精品久久久久av无码,午夜精品久久久久久毛片,亚洲 中文字幕 日韩 无码

資訊專欄INFORMATION COLUMN

矢量瓦片相關(guān)計(jì)算函數(shù)

ChristmasBoy / 2228人閱讀

摘要:根據(jù)該瓦片和計(jì)算出的行列號(hào),即可取得鼠標(biāo)點(diǎn)擊位置的像素值。指定級(jí)別緯度對(duì)應(yīng)的像素行號(hào)像素坐標(biāo)轉(zhuǎn)瓦片行列號(hào)像素坐標(biāo)轉(zhuǎn)瓦片行列號(hào)

import turf from "turf"
export default {
  TILE_SIZE: 256,
  /*
  * 獲取指定級(jí)別的瓦片數(shù)目
  */
  _getMapSize(level) {
    return Math.pow(2, level);
  },
  /**
     * Convert a longitude coordinate (in degrees) to the tile X number at a
     * certain zoom level.經(jīng)度轉(zhuǎn)瓦片列號(hào)
     * @param longitude
     *            the longitude coordinate that should be converted.
     * @param zoom
     *            the zoom level at which the coordinate should be converted.
     * @return the tile X number of the longitude value.
  */
   longitudeToTileX(longitude, zoom) {
       let px = this.longitudeToPixelX(longitude, zoom);
       return this.pixelXToTileX(px, zoom);
   },
   /**
      * Convert a latitude coordinate (in degrees) to a tile Y number at a
      * certain zoom level.緯度轉(zhuǎn)瓦片行號(hào)
      * @param latitude
      *            the latitude coordinate that should be converted.
      * @param zoom
      *            the zoom level at which the coordinate should be converted.
      * @return the tile Y number of the latitude value.
   */
   latitudeToTileY(latitude, zoom) {
       let py = this.latitudeToPixelY(latitude, zoom);
       return this.pixelYToTileY(py, zoom);
   },
/**
     * Convert a latitude coordinate (in degrees) to a pixel Y coordinate at a
     * certain zoom level.經(jīng)緯度坐標(biāo)(緯度)轉(zhuǎn)屏幕像素坐標(biāo)(Y)
     *
     * @param latitude
     *            the latitude coordinate that should be converted.
     * @param zoom
     *            the zoom level at which the coordinate should be converted.
     * @return the pixel Y coordinate of the latitude value.
     */
    latitudeToPixelY(latitude, zoom) {
        let sinLatitude = Math.sin(latitude * Math.PI / 180);
        return (0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI)) * (this.TILE_SIZE << zoom);
    },
    /**
     * Convert a longitude coordinate (in degrees) to a pixel X coordinate at a
     * certain zoom level.經(jīng)緯度坐標(biāo)(經(jīng)度)轉(zhuǎn)屏幕像素坐標(biāo)(X)
     *
     * @param longitude
     *            the longitude coordinate that should be converted.
     * @param zoom
     *            the zoom level at which the coordinate should be converted.
     * @return the pixel X coordinate of the longitude value.
     */
    longitudeToPixelX(longitude, zoom) {
        return (longitude + 180) / 360 * (this.TILE_SIZE << zoom);
    },
   /*
   * 指定級(jí)別下,將宏觀上的經(jīng)度轉(zhuǎn)換為對(duì)應(yīng)列上的瓦片的像素矩陣列號(hào)(微觀)
     例如:鼠標(biāo)點(diǎn)擊地圖,鼠標(biāo)位置在點(diǎn)擊的瓦片內(nèi)的行列號(hào)(即使像素行列號(hào))。根據(jù)該瓦片(png)和計(jì)算出的行列號(hào),即可取得鼠標(biāo)點(diǎn)擊位置的像素值。
  */
  _lngToPixelX(longitude, level) {
    let x = (longitude + 180) / 360;
    let pixelX = Math.floor(x * this._getMapSize(level) * 256 % 256);
    return pixelX;
  },
  /*
  * 指定級(jí)別緯度對(duì)應(yīng)的像素行號(hào)
  */
  _latToPixelY(latitude, level) {
    let sinLatitude = Math.sin(latitude * Math.PI / 180);
    let y = 0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI);
    let pixelY = Math.floor(y * this._getMapSize(level) * 256 % 256);
    return pixelY;
  },
  /**
     * Convert a pixel X coordinate to the tile X number.
     * 像素坐標(biāo)X轉(zhuǎn)瓦片行列號(hào)X
     * @param pixelX
     *            the pixel X coordinate that should be converted.
     * @param zoom
     *            the zoom level at which the coordinate should be converted.
     * @return the tile X number.
   */
    pixelXToTileX(pixelX, zoom) {
        return Math.floor(Math.min(Math.max(pixelX / this.TILE_SIZE, 0), Math.pow(2, zoom) - 1));
    },
   /**
     * Converts a pixel Y coordinate to the tile Y number.
     * 像素坐標(biāo)Y轉(zhuǎn)瓦片行列號(hào)Y
     * @param pixelY
     *            the pixel Y coordinate that should be converted.
     * @param zoom
     *            the zoom level at which the coordinate should be converted.
     * @return the tile Y number.
    */
    pixelYToTileY(pixelY, zoom) {
        return Math.floor(Math.min(Math.max(pixelY / this.TILE_SIZE, 0), Math.pow(2, zoom) - 1));
    },
}

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://m.hztianpu.com/yun/105767.html

相關(guān)文章

  • JavaScript矢量化地圖庫(kù) – 快速入門(mén)

    摘要:注意在代碼中將其替換為自己剛剛申請(qǐng)的運(yùn)行,顯示地圖修改保存之后點(diǎn)擊運(yùn)行就可以得到一幅矢量地圖了,此過(guò)程可能會(huì)稍微有點(diǎn)長(zhǎng),要耐心多等一會(huì)兒。 VectorMap.js是一個(gè)開(kāi)源地圖渲染JavaScript庫(kù), 可以使用WebGL或者HTML5兩種方式進(jìn)行交互式矢量地圖 (包括矢量瓦片地圖,一般性矢量數(shù)據(jù)地圖)和 柵格瓦片地圖的渲染。 WebGL渲染意味著高性能,大數(shù)據(jù), HTML5渲染意...

    MiracleWong 評(píng)論0 收藏0
  • WebGIS 利用 WebGL 在 MapboxGL 上渲染 DEM 三維空間數(shù)據(jù)

    摘要:畢業(yè)兩年,一直在地圖相關(guān)的公司工作,雖然不是出身,但是也對(duì)地圖有些耳濡目染最近在看的東西,就拿做了一個(gè)關(guān)于的三維數(shù)據(jù)渲染的練手。 畢業(yè)兩年,一直在地圖相關(guān)的公司工作,雖然不是 GIS 出身,但是也對(duì)地圖有些耳濡目染;最近在看 WebGl 的東西,就拿 MapboxGL 做了一個(gè)關(guān)于 WebGL 的三維數(shù)據(jù)渲染的 DEMO 練手。 首先大致看了一下 MapboxGL 的 GLGS 到圖層...

    tracy 評(píng)論0 收藏0
  • WebGIS 利用 WebGL 在 MapboxGL 上渲染 DEM 三維空間數(shù)據(jù)

    摘要:畢業(yè)兩年,一直在地圖相關(guān)的公司工作,雖然不是出身,但是也對(duì)地圖有些耳濡目染最近在看的東西,就拿做了一個(gè)關(guān)于的三維數(shù)據(jù)渲染的練手。 畢業(yè)兩年,一直在地圖相關(guān)的公司工作,雖然不是 GIS 出身,但是也對(duì)地圖有些耳濡目染;最近在看 WebGl 的東西,就拿 MapboxGL 做了一個(gè)關(guān)于 WebGL 的三維數(shù)據(jù)渲染的 DEMO 練手。 首先大致看了一下 MapboxGL 的 GLGS 到圖層...

    RobinTang 評(píng)論0 收藏0
  • WebGIS 利用 WebGL 在 MapboxGL 上渲染 DEM 三維空間數(shù)據(jù)

    摘要:畢業(yè)兩年,一直在地圖相關(guān)的公司工作,雖然不是出身,但是也對(duì)地圖有些耳濡目染最近在看的東西,就拿做了一個(gè)關(guān)于的三維數(shù)據(jù)渲染的練手。 畢業(yè)兩年,一直在地圖相關(guān)的公司工作,雖然不是 GIS 出身,但是也對(duì)地圖有些耳濡目染;最近在看 WebGl 的東西,就拿 MapboxGL 做了一個(gè)關(guān)于 WebGL 的三維數(shù)據(jù)渲染的 DEMO 練手。 首先大致看了一下 MapboxGL 的 GLGS 到圖層...

    sixgo 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

閱讀需要支付1元查看
<