日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php矢量瓦片,矢量瓦片相关计算函数

發布時間:2023/12/15 php 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php矢量瓦片,矢量瓦片相关计算函数 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

import turf from 'turf'

export default {

TILE_SIZE: 256,

/*

* 獲取指定級別的瓦片數目

*/

_getMapSize(level) {

return Math.pow(2, level);

},

/**

* Convert a longitude coordinate (in degrees) to the tile X number at a

* certain zoom level.經度轉瓦片列號

* @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.緯度轉瓦片行號

* @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.經緯度坐標(緯度)轉屏幕像素坐標(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.經緯度坐標(經度)轉屏幕像素坐標(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);

},

/*

* 指定級別下,將宏觀上的經度轉換為對應列上的瓦片的像素矩陣列號(微觀)

例如:鼠標點擊地圖,鼠標位置在點擊的瓦片內的行列號(即使像素行列號)。根據該瓦片(png)和計算出的行列號,即可取得鼠標點擊位置的像素值。

*/

_lngToPixelX(longitude, level) {

let x = (longitude + 180) / 360;

let pixelX = Math.floor(x * this._getMapSize(level) * 256 % 256);

return pixelX;

},

/*

* 指定級別緯度對應的像素行號

*/

_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.

* 像素坐標X轉瓦片行列號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.

* 像素坐標Y轉瓦片行列號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));

},

}

總結

以上是生活随笔為你收集整理的php矢量瓦片,矢量瓦片相关计算函数的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。