Skip to content

Commit

Permalink
Add core methods to init
Browse files Browse the repository at this point in the history
  • Loading branch information
zachwill committed Mar 12, 2012
1 parent 347d72e commit 7acab5d
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Expand Up @@ -10,9 +10,20 @@ Installation
pip install mapq


Settings
--------

The easiest way to use `mapq` is by setting the `MAPQUEST_API_KEY`
environment variable in your local environment.

export MAPQUEST_API_KEY="my_api_key"


Usage
-----

There are two ways of interacting with `mapq`'s API.

```python
>>> from mapq import Geo
>>> g = Geo('my_api_key')
Expand All @@ -29,3 +40,23 @@ Usage
>>> g.latlng('155 9th St San Francisco, CA')
{'lat': 37.775002, 'lng': -122.418297}
```

You can also use the Mapquest API without interacting with the `Geo`
class.


```python
>>> import mapq

>>> mapq.address('155 9th St San Francisco, CA')
[{'lots': {'of': 'results'}}, ...]

>>> mapq.batch('94103', '1 Infinity Loop Cupertino, CA')
[{'multiple': 'locations'}, ...]

>>> mapq.reverse(37.775002, -122.418297)
{'looks': {'like': '155 9th St'}}

>>> mapq.latlng('155 9th St San Francisco, CA')
{'lat': 37.775002, 'lng': -122.418297}
```
1 change: 1 addition & 0 deletions mapq/__init__.py
@@ -1 +1,2 @@
from .core import address, batch, latlng, reverse
from .geo import Geo
25 changes: 25 additions & 0 deletions mapq/core.py
@@ -0,0 +1,25 @@
"""
Simplified methods for calling Mapquest's Geocoding API.
"""

from .geo import Geo


def address(name):
"""Geocode an address."""
return Geo().address(name)


def batch(*locations):
"""Batch geocode multiple addresses."""
return Geo().batch(*locations)


def latlng(address):
"""Get the latitude and longitude coordinates for an address."""
return Geo().latlng(address)


def reverse(lat, lng):
"""Reverse geocode lat/lng coordinates."""
return Geo().reverse(lat, lng)

0 comments on commit 7acab5d

Please sign in to comment.