A tool for generating OpenStreetMap overlay heatmap tiles using OpenCL.
The tool takes a set of geographical (WGS84) points with assigned values and generates output tiles based on the selected kernel.
As the kernels are written to run in cartesian coordinate system (though generalizing for using WGS84 directly should be fairly easy), we need to compute a tile->WGS84->cartesian transform. Computing this for each point is however unnecessarily computationally intensive.
cl-heatmap solves this by sampling the transformation a few hundred times and then using linear regression to make a transformation matrix. The transformation is then applied by the GPU for each of the 65536 output pixels. This transformation is relatively precise (at least for the ETRS89-TM33 transformation which was the primary transformation used during development), under one pixel for most zoom levels.
This kernel computes weighted average between the input points, the weights decaying with distance. Also properly checks the distance and makes output points which are too far away from any input point transparent.
This kernel computes multilateration error function. The tool was originally
developed for this application, however given the small number of points involved it outgrew it rapidly. See examples/tdoa
for example input data.
A demo map of the examples/safecast
can be found here. This map was generated
using about a 1 million points (centered around Prague) from the Safecast dataset.
Usage: cl-heatmap [OPTION...]
-b, --boundaries=BOUNDARIES Boundaries in WGS84 '50.12,14.23,51.23,15.33'
-c, --clargs=CLARGS OpenCL compiler arguments
-d, --device=DEVICE OpenCL device to use (-d 0.0)
-f, --prefilter=PREFILTER Do not pass a point to the kernel if it is further
than PREFILTER
-i, --input=INPUT Input JSON
-k, --kernel=KERNEL Kernel to use
-m, --colormap=COLORMAP Colormap to use, available: ["heat"]
-o, --outdir=OUTDIR Output directory
-p, --projection=PROJECTION Proj4 specification of the cartesian projection
(default="+init=epsg:3045")
-z, --zoom=ZOOM Zoomlevel
-?, --help Give this help list
--usage Give a short usage message
-V, --version Print program version
- WGS84 great circle distance support
- Write an actual heatmap kernel (where the points add instead of weighted averaging)
- Add some timing output
- Add custom loadable color palletes
- Support for color gradients with more than 256 colors (currently limited by the PNG output)
This was my first foray to the realm of GPU accelerated computing, so don't expect any sort of stellar performance.