django / djangopeople

A geographical community site for Django developers
https://people.djangoproject.com
MIT License
86 stars 44 forks source link

Use Leaflet and OSM with density map and clustering #37

Open yohanboniface opened 12 years ago

yohanboniface commented 12 years ago

As we discussed, I'm starting a branch to work on:

About the density map: do we want to group per country? Something like this: http://leaflet.cloudmade.com/examples/choropleth.html ?

About the clustering, maybe using the @danzel plugin could do the job: http://danzel.github.com/Leaflet.markercluster/example/marker-clustering-realworld.388.html

brutasse commented 12 years ago

Thanks for the proposal :)

+1 for leaflet

+1 for OSM tiles, we just need a provider able to handle a decent amount of traffic for free (or in exchange of some sort of acknowledgment on the site like we do with Heroku). I don't know what's the traffic like at the moment though.

+1 for the clustering plugin, coupled with an ajax view that returns geoJSON given a client's bounding box it'd work great.

As for density maps: I was thinking about something a bit more advanced than per-country grouping. E.g. implement the marching squares[0] algorithm to determine the boundaries for a given number of density levels, then simply draw those boundaries as leaflet polygons, with a smoothFactor that makes them look good.

Each polygon could have a solid border and a given opacity, for high density zones they'd stack and the overall opacity would increase as the density increases. What do you think of this approach? Polygons should obviously be computed on a daily (or so) basis and cached somewhere. We have redis or postgres for that.

The main limitation is that the current Heroku database plan doesn't support PostGIS. We could ask @jacobian if we can upgrade it but it's something like 5x more expensive. Naive bounding box queries would work at the moment without postgis though so it's probably not blocking anything.

Ping me on IRC if you need some anonymized data!

[0] http://en.wikipedia.org/wiki/Marching_squares

yohanboniface commented 12 years ago

I suggest an iterative work, something like:

  1. migrating to Leaflet and OSM
  2. making a simple country based density map for low zoom levels
  3. using ajax GeoJSON and clusters for intermediate zoom levels
  4. implementing a better density map algorithm

What do you think?

brutasse commented 12 years ago

Totally agreed, let's not break all the things at once.