civictechdc / districthousing

District Housing lets caseworkers help clients apply for Section 8 housing by automatically filling out multiple PDF applications using one online form.
http://codefordc.github.io/districthousing/
MIT License
40 stars 64 forks source link

Location encoder #331

Closed tingaloo closed 9 years ago

tingaloo commented 9 years ago

Just working on what Andy started #14

Using Google Geoencoder to parse locations into latitude and longitude.

Limitations:

  1. 2500 requests per 24 hour period.
  2. 5 requests per second.

Location tables now display modal display button Location tables now read from locations instead of long and lat. Location modal now displays popup with name and address

Suggestions:

Use Google Maps instead of OpenStreetMaps for cleaner maps. A master map on housing index page to display ALL possible locations?

It really depends on the clients and the workers, but I am open for UX ideas. Here is what I am thinking.

image

tingaloo commented 9 years ago

Slight bug on load. Pop up skews to the right. Closing and opening again fixes it. Not sure what's causing it.

image

jrunningen commented 9 years ago

Thanks! It'll be nice to finally have mapped locations without having to expose the user directly to lat/long coordinates.

A single map showing all housing locations would be cool. Feel free to implement that if you like.

I see an area for possible improvement. Google's API docs say:

"Geocoding is a time and resource intensive task. Whenever possible, pre-geocode known addresses (using the Geocoding API described here or another geocoding service), and store your results in a temporary cache of your own design."

I recommend we do this, to minimize risk of hitting the API rate limits, and to be a good citizen. We ought to check whether our PDFs have their lat and long attributes already set to something. If so, use those, and don't make a Google API request. If lat and long are blank, but the location attribute is set, then making a geocoding API call, and store the result in the lat/long attributes so we don't need to request the same address again.

tingaloo commented 9 years ago

I am not familiar with pre-caching best practices, is it as simple as how you described it?

jrunningen commented 9 years ago

Pretty simple. All it means is that we should save the coordinates the first time we call the geocoding API for that address, so we don't need to make the same API call again every time we render the housing form. Since it will require writing our own database, this'll have to be done in the HousingForm controller, rather than in the Javascript frontend. Can you make the API call from Ruby?

tingaloo commented 9 years ago

I'll give it a twirl.