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

bVbvfP8?w=1001&h=610

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));

},

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Cesium矢量瓦片是一种地理数据存储和渲染格式,用于呈现三维地理信息。矢量瓦片采用了类似于栅格瓦片的切片技术,但不同的是它存储的是矢量数据而不是图像数据。 Cesium矢量瓦片使用地理坐标系将地理信息分割成小块,每个小块称为一个矢量瓦片。这些矢量瓦片包含了地理要素的几何形状、属性数据以及可视化样式。与传统的矢量数据不同,矢量瓦片使用了基于Web的标准技术来压缩和存储数据,使得数据加载和渲染更加高效。 使用Cesium矢量瓦片可以实现实时的、交互式的三维地理可视化。由于矢量数据相对于栅格数据更为灵活,可以根据用户需求进行动态渲染和分析,因此矢量瓦片在GIS(地理信息系统)、地图服务和虚拟现实等领域有着广泛的应用。它能够支持多种地理数据类型,包括地形地貌、建筑物、航道、路网等,使得用户能够以更直观、更精细的方式来探索地理数据。 Cesium矢量瓦片的优势在于其高效性和可定制性。它能够在网络上快速加载和传输数据,减少了数据传输和渲染的时间成本。同时,用户可以根据自己的需求对数据进行自定义的样式和符号设置,灵活地呈现地理信息。此外,Cesium矢量瓦片还支持多种数据格式的转换和集成,使得用户可以方便地与其他地理数据格式进行互操作。 总之,Cesium矢量瓦片是一种创新的地理数据存储和渲染格式,它将高效性、可定制性和多样化的地理数据类型相结合,为用户提供了实时、交互式的地理信息可视化体验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值