-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb6876a
commit d9077e2
Showing
11 changed files
with
226 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# what3words | ||
|
||
what3words is a global grid of 57 trillion 3mx3m squares. | ||
Each square has a 3 word address that can be communicated quickly, | ||
easily and with no ambiguity. | ||
|
||
> **Addressing the world** | ||
> Everyone and everywhere now has an address | ||
## Python Example | ||
|
||
**Geocoding 3 Words** | ||
|
||
```python | ||
>>> import geocoder | ||
>>> g = geocoder.w3w('embedded.fizzled.trial') | ||
>>> g.json | ||
... | ||
``` | ||
|
||
**Reverse Geocoding** | ||
|
||
```python | ||
>>> import geocoder | ||
>>> g = geocoder.w3w([45.15, -75.14], method='reverse') | ||
>>> g.json | ||
... | ||
``` | ||
|
||
## Parameters | ||
|
||
> :param **location**: Your search location you want geocoded. | ||
> :param **key**: W3W API key. | ||
> :param **method**: Chose a method (geocode, method) | ||
## References | ||
|
||
<i class="icon-doc"></i> [API Reference](http://developer.what3words.com/) | ||
<i class="icon-key"></i> [Get W3W key](http://developer.what3words.com/api-register/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/usr/bin/python | ||
# coding: utf8 | ||
|
||
from .base import Base | ||
from .keys import w3w_key | ||
|
||
|
||
class W3W(Base): | ||
""" | ||
What3Words | ||
========== | ||
What3Words is a global grid of 57 trillion 3mx3m squares. | ||
Each square has a 3 word address that can be communicated quickly, | ||
easily and with no ambiguity. | ||
Addressing the world | ||
Everyone and everywhere now has an address | ||
Params | ||
------ | ||
:param location: Your search location you want geocoded. | ||
:param key: W3W API key. | ||
:param method: Chose a method (geocode, method) | ||
References | ||
---------- | ||
API Reference: http://developer.what3words.com/ | ||
Get W3W key: http://developer.what3words.com/api-register/ | ||
""" | ||
provider = 'w3w' | ||
method = 'geocode' | ||
|
||
def __init__(self, location, **kwargs): | ||
self.url = 'http://api.what3words.com/w3w' | ||
self.location = location | ||
self.params = { | ||
'string': location, | ||
'key': kwargs.get('key', w3w_key), | ||
} | ||
self._initialize(**kwargs) | ||
|
||
@property | ||
def lat(self): | ||
position = self.parse['position'] | ||
if position: | ||
return position[0] | ||
|
||
@property | ||
def lng(self): | ||
position = self.parse['position'] | ||
if position: | ||
return position[1] | ||
|
||
@property | ||
def position(self): | ||
return self.parse.get('position') | ||
|
||
@property | ||
def language(self): | ||
return self.parse.get('language') | ||
|
||
@property | ||
def type(self): | ||
return self.parse.get('type') | ||
|
||
@property | ||
def words(self): | ||
return self.parse.get('words') | ||
|
||
if __name__ == '__main__': | ||
g = W3W('embedded.fizzled.trial') | ||
import json | ||
print json.dumps(g.json, indent=4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/python | ||
# coding: utf8 | ||
|
||
from .base import Base | ||
from .keys import w3w_key | ||
from .w3w import W3W | ||
from .location import Location | ||
|
||
|
||
class W3WReverse(W3W, Base): | ||
""" | ||
what3words | ||
========== | ||
what3words is a global grid of 57 trillion 3mx3m squares. | ||
Each square has a 3 word address that can be communicated quickly, | ||
easily and with no ambiguity. | ||
Addressing the world | ||
Everyone and everywhere now has an address | ||
Params | ||
------ | ||
:param location: Your search location you want geocoded. | ||
:param key: W3W API key. | ||
:param method: Chose a method (geocode, method) | ||
References | ||
---------- | ||
API Reference: http://developer.what3words.com/ | ||
Get W3W key: http://developer.what3words.com/api-register/ | ||
""" | ||
provider = 'w3w' | ||
method = 'reverse' | ||
|
||
def __init__(self, location, **kwargs): | ||
self.url = 'http://api.what3words.com/position' | ||
location = Location(location) | ||
self.location = location.latlng | ||
self.params = { | ||
'position': self.location, | ||
'key': kwargs.get('key', w3w_key), | ||
} | ||
self._initialize(**kwargs) | ||
|
||
@property | ||
def ok(self): | ||
return bool(self.words) | ||
|
||
if __name__ == '__main__': | ||
g = W3WReverse([45.15, -75.14]) | ||
import json | ||
print json.dumps(g.json, indent=4) | ||
print g.url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters