Closed Daylen69 closed 3 months ago
For a map size of 57.344 km, what is the zoom level of the downloaded map image ?
The MapBox API does not specify a zoom level if the grid angle is 0 degrees when capturing still images. Just get the map extent. When acquiring still images using the Mapbox API, the zoom level can only be specified to the second decimal place, so if the grid angle is other than 0 degrees, the zoom level with the least deviation is calculated and requested. Therefore, it changes depending on the size of the map and the latitude and longitude.
Would it be possible to know the longitude and latitude coordinates of the 4 corners of the 'green zone' (playable zone) ?
It is possible to obtain the latitude and longitude of the corner of the playable zone. However, strictly speaking there is a very small discrepancy between the grid and the heightmap. This is by design of Mapbox GL JS and Web Mercator.
Which do you think should be displayed?
I think we should display the one that is closest to the heightmap.
The idea is to delineate the area using these 4 points in order to obtain a map with a desired zoom level. For instance, with Universal Maps Downloader, by entering the coordinates of the 4 points that define the playable area, we could obtain a zoom level 16 map detailed enough to be displayed with the Image Overlay Mod in Cities: Skylines 2.
Do you understand ? My English is very average
I understood. But Universal Maps Downloader doesn't take map rotation into account, so I have to think about it.
I talked about Universal maps downloader just as an example because I used it to obtain a map and I needed the coordinates of the 4 corners of the area (I can't be precise so I have an offset at every time)
I'd welcome this feature too.
I tried manually calculating the bounding box via:
const turf = require('@turf/turf')
const centerPoint = [-111.63, 35.19]
const sideLength = 57.344
const center = turf.point(centerPoint)
const box = turf.bbox(
turf.buffer(center, sideLength / 2, { units: 'kilometers' })
)
const result = {
type: 'Feature',
properties: {},
geometry: {
type: 'Polygon',
coordinates: [
[
[box[0], box[1]],
[box[0], box[3]],
[box[2], box[3]],
[box[2], box[1]],
],
],
},
}
console.log(JSON.stringify(result, null, 2))
Which works, but doesn't seem to give the same coordinates as shown on your tool. Any ideas?
I've digged into the code, and it looks like the 4 values are already calculated when downloading the IMG:
Here, we could probably also add an option to make a separate image query for each tile....
I've hacked a PR, that allows for downloading of 6x6 high-res tile images: https://github.com/nonta1234/terraining-heightmap-generator/pull/10#issue-2211965748
EDIT: Pushed a fix, seems to work now. It also logs the 4 coords to console.
Hi!
The function to get the extent is as follows.
The buffer function may not return a perfect circle, because web Mercator is not conformal. Therefore, after converting to pixel coordinates, use the Pythagorean theorem to calculate the length of the side that is expected to have the least deviation. Also, originally the distance on the map increases towards the poles, but for convenience, the boundaries are acquired so that the latitude and longitude of the center is the center of the extent.
Therefore, if you want to split this extent, I recommend separating on a pixel basis.
v1.4.0
Hi !
For a map size of 57.344 km, what is the zoom level of the downloaded map image ?
Would it be possible to know the longitude and latitude coordinates of the 4 corners of the 'green zone' (playable zone) ?