-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more params to search, fix test, importing shapely now
bumped version
- Loading branch information
Showing
6 changed files
with
328 additions
and
6 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 |
---|---|---|
@@ -1,16 +1,27 @@ | ||
import requests | ||
from shapely import geometry | ||
|
||
class NoResultException(Exception): | ||
pass | ||
|
||
def gbif_search_GET(url, args, **kwargs): | ||
if args['geometry'] != None: | ||
if args['geometry'].__class__ == list: | ||
b = args['geometry'] | ||
args['geometry'] = geometry.box(b[0], b[1], b[2], b[3]).wkt | ||
out = requests.get(url, params=args, **kwargs) | ||
out.raise_for_status() | ||
stopifnot(out.headers['content-type']) | ||
return out.json() | ||
|
||
def gbif_GET(url, args, **kwargs): | ||
out = requests.get(url, params=args, **kwargs) | ||
out.raise_for_status() | ||
stopifnot(out.headers['content-type']) | ||
return out.json() | ||
|
||
def stopifnot(x): | ||
if x != 'application/json': | ||
raise NoResultException("content-type did not = application/json") | ||
if x != 'application/json': | ||
raise NoResultException("content-type did not = application/json") | ||
|
||
gbif_baseurl = "http://api.gbif.org/v1/" |
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
Oops, something went wrong.