kylebarron / viewshed.js

Implementation of viewshed algorithm in JS
MIT License
1 stars 1 forks source link

Zoom level argument #6

Open kylebarron opened 4 years ago

kylebarron commented 4 years ago

If I plan on doing all computations in pixel coordinates, then I'll need to know how big each pixel is. I can get these distances (at the equator) with these equations from gdal2tiles.py

Basically just

(2 * math.pi * 6378137) / (self.tile_size * 2**zoom)

so you'll want the api to have a zoom and a tile size argument

kylebarron commented 4 years ago

Note that you should only need geodesic distances when an error function that depends on distances is used. If you ask for ask for a viewshed with a uniform error margin of 10m throughout the terrain, you shouldn't need to know the horizontal distance between vertices. Just take them as a given, work in pixel units, and make sure the vertical error is within the bounds.

With most viewsheds, however, you'll want the error margin to increase as you get further away from the viewpoint. For this, you'll need the distance from the point, and you'll need the zoom level