My first approach to resolve this problem was focusing in GIS theory. But I was stuck with some cases and I was sure there was another way plus simple. Finally, I applied image drawing techniques and all was good. The only GIS thing is the conversion latitude / longitude to x / y pixels. In this case, I use an equirectangular projection, but we can use another projection.
In this moment, the application fetch the whole dataset from CartoDB API (70 MB) in GeoJSON format, extracts the geometries, calculates the bounds geometries, calculates the scale with these bounds, and draws the polygons. I implemented the panning and an zoom system that needs improve. All this in 4 seconds.
There is few points for improve performance. In server calls side:
In client rendering (needs monitoring):
context.beginPath()
ans ends with context.closePath()
. Maybe I can call these functions with
groups of polygons, or only one time globally.Of course, investigate the techniques in HTML5 gaming, HTML5 video rendering, streaming, database streaming (like pipelinedb), BI, Big Data (MapReduce), etc. And monitoring, monitoring, monitoring and deciding.
https://code.jquery.com/jquery-2.1.4.min.js