Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Open Source Library to calculate Longitude and Latitude coordinates and Tile coordinates in GIS Development

2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use open source library to calculate longitude and latitude coordinates and tile coordinates in GIS development. It is very detailed and has a certain reference value. Interested friends must read it!

Using the open source library of github, calculate the number of the map tiles according to the longitude and latitude coordinates and the zoom level of the map, so as to obtain the map slices in the range.

Open source library address:

Https://github.com/CntChen/tile-lnglat-transform" Gaud / Baidu / Google / Tencent / Bing map latitude and longitude coordinates and tile coordinates conversion "based on JavaScript library, what can be done with this, the most common is to crawl map slices, those map downloaders grab map slices is the same principle. In nodejs, install the package with npm and you can use it.

Npm install-- save tile-lnglat-transform take calculation of Amap as an example: definition:

Const TileLnglatTransform = require ('tile-lnglat-transform')

How to convert latitude and longitude to slice number:

Const tileinfo =

TileLnglatTransform.TileLnglatTransformGaode.lnglatToTile (lng,lat,level)

Tileinfo .tileX; horizontal number of tiles of the current level of the map

Tileinfo .tileY,; the vertical number of the tiles of the current level of the map

The pixel coordinates on a certain map level tile are converted into longitude and latitude coordinates. The map tile size is generally 256mm 256 pixel XigelY is the relative pixel value on this slice. If you want to calculate the coordinate range of a slice, you only need to adjust according to the relative pixels.

Const lnglat =

TileLnglatTransform.TileLnglatTransformGaode.pixelToLnglat (pixelX, pixelY, tileX, tileY, level)

In addition, there is a lnglatToPixel method, which can calculate the level of map tiles according to longitude and latitude, including pixel information on tiles. The above is all the contents of the article "how to use open source library to calculate longitude and latitude coordinates and tile coordinates in GIS development". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report