openlexington / WhatsMyDistrict

DEPRECATED - see whats_my_district_redux

Home Page:https://github.com/openlexington/whats_my_district_redux

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What's My District?

Build Status

See an example at whatsmydistrict.org.

Requirements

  • Ruby 1.9.3
  • postgresql -- brew install postgres
  • postgis -- brew install postgis

To get started:

Clone this repository. The rest of the commands should happen in the directory containing this project.

Vagrant

  1. Download & Install Virtualbox
  2. Download & Install Vagrant
  3. vagrant plugin install vagrant-berkshelf
  4. vagrant plugin install vagrant-omnibus
  5. vagrant up
  6. vagrant ssh
  7. cd WhatsMyDistrict
  8. sudo bundle install
  9. psql -U postgres
  10. create database districts;
  11. \q
  12. psql -U postgres -d districts < sql/wmd.sql
  13. foreman start
  14. Open browser to http://localhost:4567
  15. Hack

MacOS X

  1. bundle

  2. puma to start the server at localhost:9292.

  3. For a new postgresql install in OS X:

     mkdir -p ~/Library/LaunchAgents
     cp /usr/local/Cellar/postgresql/9.2.1/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
     launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
     initdb /usr/local/var/postgres -E utf8
     pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
    

    See also Postgres.app.

  4. Create the database: createdb -p 5432 -h localhost districts

  5. Add necessary postgis functions to the database: psql -p 5432 -h localhost -d districts -f /usr/local/share/postgis/postgis.sql and psql -p 5432 -h localhost -d districts -f /usr/local/share/postgis/spatial_ref_sys.sql -- thanks to PostGres - PostGIS on OS X Lion.

Linux (Ubuntu-based, no vagrant)

  • sudo apt-get install postgresql-9.1 postgresql-9.1-postgis postgis libpq
  • bundle install
  • Create the database:
$ sudo -u postgres psql
# \password
  sorandomwow
  sorandomwow
# create database districts;
# \q
  • Add PostGIS extensions:
sudo -u postgres psql -U postgres -d districts -f `pg_config --sharedir`/contrib/postgis-*/postgis.sql`
sudo -u postgres psql -U postgres -d districts -f `pg_config --sharedir`/contrib/postgis-*/spatial_ref_sys.sql
  • psql -U postgres -d districts < sql/wmd.sql
  • cp dotenv.sample .env
  • foreman start
  • Open browser to http://localhost:4567.
  • Hack.

Production

Remember to either set relevant values in .env file or to set ENV values.

To update the database:

  1. Download the new shape file from data.lexingtonky.gov -- for example, under Community, Board of Elections - Voting Precincts.

  2. Run shp2pgsql -c -D -s 4269 -I shapefile.shp tablename > filename.sql. For example:

     $ shp2pgsql -c -D -s 4269 -I VotingPrecinct.shp voting > VotingPrecinct.sql
     Shapefile type: Polygon
     Postgis type: MULTIPOLYGON[2]
    

Another example:

    ~/Downloads/PostOffice
    % shp2pgsql -c -D -s 4269 -I PostOffice.shp post_office > PostOffice.sql
    Shapefile type: Point
    Postgis type: POINT[2]
  1. In psql, drop the table you will be updating.
  2. Run psql -d database -f file.sql, for example psql -p 5432 -h localhost -d districts -f VotingPrecinct.sql.

About

DEPRECATED - see whats_my_district_redux

https://github.com/openlexington/whats_my_district_redux

License:MIT License


Languages

Language:Ruby 93.5%Language:CSS 3.9%Language:JavaScript 2.6%