codeforamerica/MuniciPal — pull request #14 by techieshark (2014-09-19 21:35:04+00:00)
Title: Adds ability to get district items w/o address or lat/lng

By hitting the root controller with /?district=X you can find items for that district.

To make this work, if `district` param is supplied, we use the ST_PointOnSurface function from PostGIS (we use that instead of ST_Centroid because the centroid of a polygon isn't necessarily inside the polygon, while this function by does return a point on the surface, that is, inside the polygon). It seems to return a point well away from the edges too, which should make it clear which district the marker is inside.

After the point is returned, we grab the lat/lng for it and reverse geocode it. After that the code is no different than if someone had passed lat/lng or address as a url parameter.

This isn't hooked up to any UI elements on the frontend (I'll leave that to @ardouglass). So for now, just type the URL manually.