Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

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

Shulou Source: shulou.com Published: 2022-06-01 03:45:44 10月03日 Update

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!

Tags: Maps coordinates tiles longitude and latitude latitude and longitude level pixels development content method article scope Gao de value information interest principle address size boy Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei macOS Xiaomi vpn Microsoft