Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 84 lines (52 sloc) 2.541 kb
4ff1aed @alexksikes First commit.
authored
1 NOTE: The current directory '.' refers to sgeo/sgeo.
2
3 1. Download and extract the latest tar ball
4 ===========================================
5
6 wget http://github.com/alexksikes/sgeo/tarball/master; tar xvzf "the tar ball";
7
8 2. Download geo data
9 ====================
10
11 * [Geonames](http://download.geonames.org/export/dump/)
12 * [Zip Codes](http://www.zip-codes.com), purchase a license (~$40)
a3c940f @alexksikes Fixes install and readme.
authored
13 * [MaxMind GeoIP](http://www.maxmind.com/app/geolitecity), get the light version or purchase pro
4ff1aed @alexksikes First commit.
authored
14
15 NOTE: GeoIP is optional.
16 NOTE: You may want to download Geonames to ./data/geonames and zip-codes to ./data/zipcodesdotcom.
17 NOTE: Because Geonames has unprecise zip code geo-information, we had to use of zip-codes.com.
18
19 3. Setup and populate your database
20 ===================================
21
22 Create the databases:
23
24 mysql -pe 'create database geonames character set utf8; create database zipcodesdotcom;'</pre>
25
26 Setup data to be populated:
27
28 Read comments in populate.sql, setup the appropriate paths and perform the formatting.
29
30 Create the required tables and load the data:
31
32 mysql -p geonames < ./sql/geonames.sql
33 mysql -p geonames < ./sql/geonames_more.sql
34 mysql -p geonames < ./sql/geonames_postals.sql
35 mysql -p zipcodesdotcom < ./sql/zipcodesdotcom.sql
36
37 4. Download and install dependecies
38 ===================================
39
40 * [Sphinx](http://sphinxsearch.com/downloads/), the search engine
41 * [webpy](http://webpy.org/download), for the web interface and other tools
42 * [fsphinx](http://github.com/alexksikes/fsphinx/tarball/master), easy faceted search for sphinx and more
a3c940f @alexksikes Fixes install and readme.
authored
43 * [GeoIP python API](http://www.maxmind.com/app/python), IP geolocation (optional)
4ff1aed @alexksikes First commit.
authored
44
45 5. Setup Sphinx
46 ================
47
48 Go over:
49
50 ./config/indexer_example.conf and make sure to rename it config/indexer.conf.
51
52 Create Sphinx index:
53
54 /path-to-sphinx-bin/indexer -c ./config/indexer.conf --all
55
56 Serve Sphinx index:
57
58 /path-to-sphinx-bin/searchd -c ./config/indexer.conf
59
60 NOTE: You should run these commands in sgeo/sgeo if you haven't changed your paths in indexer.conf.
61
62 7. Further configurations
63 =========================
64
65 Go over:
66
67 ./config/__init__example.py and make sure to rename it __init__.py.
68
69 Add sgeo to your PYTHONPATH
70
71 8. You're done!
72 ===============
73
74 in your code:
75
76 import sgeo
77 gc = sgeo.GeoCoder(usa_only=usa)
78 sgeo.get_locations('Newport Beach, CA')
79
80 or use command line interface to test:
81
82 python sgi.py 'Newport Beach, CA'
83
84 Check out the file geo.py for the full API.
Something went wrong with that request. Please try again.