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矢量瓦片,矢量瓦片相关计算函数相关推荐

  1. 瓦片地图坐标相关计算

    http://www.cnblogs.com/junyuz/archive/2011/04/19/2021035.html 瓦片地图坐标相关计算 在给定level下,把行号tileY和列号tileX转 ...

  2. 国内主要地图瓦片坐标系定义及计算原理

    国内主要地图瓦片坐标系定义及计算原理 作者 CntChen 关注 2016.05.10 20:05* 字数 3144 阅读 1571评论 0喜欢 9 本文将介绍瓦片坐标相关知识,并提供高德地图.百度地 ...

  3. 北科大matlab,北科大matlab第五次作业多项式及其相关计算.doc

    北科大matlab第五次作业多项式及其相关计算.doc <数学实验>报告实验名称多项式及其相关计算学院计算机与通信工程学院专业班级姓名学号2015年5月2一.[实验目的]1.学习多项式的拟 ...

  4. php+数学计算公式,PHP数学计算函数总结

    PHP数学计算函数总结 发布于 2015-01-21 16:53:26 | 189 次阅读 | 评论: 0 | 来源: 网友投递 PHP开源脚本语言PHP(外文名: Hypertext Preproc ...

  5. oracle crc32函数,CSS_ORACLE中实现CRC32的计算函数,SOLARIS平台,声明:这是我07年的一个偶然 - phpStudy...

    ORACLE中实现CRC32的计算函数,SOLARIS平台 声明:这是我07年的一个偶然所得,借助了很多朋友和同事的帮助.希望能对在这个领域里面找寻的同行一些帮助. 首先用C在SOLARIS上编写一个 ...

  6. 零基础带你学习MySQL—字符串相关的函数(十三)

    零基础带你学习MySQL-字符串相关的函数(十三) 一.CHARSET (str)返回子串字符集 二.CONCAT连接子串,将多个列拼接成一列 三.INSTR(string,substring)返回s ...

  7. HEVC: 整个编码流程以及相关的函数介绍

    本文转载自https://blog.csdn.net/qq_39348150/article/details/78422117 来自网上的文档,但是最初来源不知道是哪,谢谢这个作者! 整个流程可以从c ...

  8. php常用的数组相关的函数及面向对象

    内 容 本周学习知识点: 一.PHP的循环结构 二.PHP函数的声明与使用 三.数组的定义以及遍历 四.常用的数组相关的函数 五.面向对象 六.三大特性以及修饰符.关键字 七.抽象类.接口.多态性 八 ...

  9. 融资租赁租金表、收益指标、财务分摊等相关计算原理

    本文主要介绍融资租赁业务中相关计算的原理主要包括:租金表计算.租金表变更计算.irr.xirr收益率计算.财务分摊计算等.通过案例讲解每一种算法的原理以及用excel是怎么计算出来的. 如需要看视频用 ...

最新文章

  1. Python中的特殊成员和魔法方法
  2. .net程序员的盲点(一):参数修饰符ref,out ,params的区别
  3. JAVA程序设计----关于字符串的一些基本问题处理
  4. NFC服务器在Linux,linux 安装 libnfc ,打开串口PN532
  5. asp.net core系列 67 Web压力测试工具WCAT
  6. iOS开发之Xcode开发快捷键大全
  7. opensips1.6.4+freeradius2.1.10+radiusclient0.5.6 problem do accounting
  8. 关于三种主流WEB架构的思考
  9. 视频,多媒体本地化总结
  10. Centos7 固定 ip
  11. Word公式居中,公式编号右对齐
  12. virtualbox下安装雪豹10.6系统(AMD下亲测成功)
  13. 录屏 java_Java小程序—录屏小程序(上半场)
  14. android 文件管理器 apk,Android6.0自带文件管理器无法打开apk文件
  15. socket连接超时问题
  16. timestamp 6 mysql_Oracle timestamp(6)运用
  17. 定时器、Lambda表达式、Stream流
  18. 抖音上一封你的信H5网站源码,可对接支付和106短信
  19. 初次接触DHT11温度传感器
  20. 编程python如何制作动画_用Python Matplotlib 制作动画

热门文章

  1. python中列表元素类型可以不同吗_list列表等同于数组,是一种放数据的容器
  2. c与python 数据传递-详解python如何调用C/C++底层库与互相传值
  3. 华为笔记本搭载鸿蒙系统,华为MatePad Pro2入网!预装鸿蒙系统 搭载麒麟9000
  4. C语言课程学籍管理课程书面报告,C语言学籍管理系统课程设计报告书
  5. physx选择显卡还是cpu_预算有限,该侧重CPU还是显卡?中高端游戏主机这样配
  6. SQL SERVER 数据库如何限制一列不能重复(已经有主键)
  7. 垒骰子|2015年蓝桥杯B组题解析第九题-fishers
  8. MVC Web.Config 配置错误
  9. SpringMvc Intercetor
  10. 一次基于Vue.Js的用户体验优化 (vue drag)