Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop/paid api method #413

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Code
* [alechewitt](https://github.com/alechewitt)
* [camponez](https://github.com/camponez)
* [Darumin](https://github.com/Darumin)
* [davidpirogov](https://github.com/davidpirogov)
* [dev-iks](https://github.com/dev-iks)
* [dphildebrandt](https://github.com/dphildebrandt)
* [dstmar](https://github.com/dstmar)
Expand All @@ -27,6 +28,7 @@ Code
* [Tobiaqs](https://github.com/Tobiaqs)
* [txemi](https://github.com/txemi)
* [Wesley-Vos](https://github.com/Wesley-Vos)
* [timsu27](https://github.com/timsu27)

Docs
----
Expand All @@ -45,6 +47,7 @@ Testing

Packaging and Distribution
--------------------------
* [Crozzers](https://github.com/Crozzers)
* [Diapente](https://github.com/Diapente)
* [onkelbeh](https://github.com/onkelbeh)
* [Simone-Zabberoni](https://github.com/Simone-Zabberoni)
Expand Down
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ verify_ssl = true
name = "pypi"

[dev-packages]
Babel = ">=2.9.1"
coverage = "*"
coveralls = "*"
Jinja2 = "*"
Expand Down
686 changes: 380 additions & 306 deletions Pipfile.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ tox
tox-travis
virtualenv
twine
urllib3>=1.26.5
1 change: 0 additions & 1 deletion pyowm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pyowm.owm import OWM
9 changes: 6 additions & 3 deletions pyowm/agroapi10/agro_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from pyowm.agroapi10.polygon import Polygon, GeoPolygon
from pyowm.agroapi10.search import SatelliteImagerySearchResultSet
from pyowm.agroapi10.soil import Soil
from pyowm.agroapi10.uris import ROOT_AGRO_API, POLYGONS_URI, NAMED_POLYGON_URI, SOIL_URI, SATELLITE_IMAGERY_SEARCH_URI
from pyowm.agroapi10.uris import ROOT_AGRO_API, ROOT_DOWNLOAD_PNG_API, ROOT_DOWNLOAD_GEOTIFF_API, POLYGONS_URI, \
NAMED_POLYGON_URI, SOIL_URI, SATELLITE_IMAGERY_SEARCH_URI
from pyowm.commons.http_client import HttpClient
from pyowm.commons.image import Image
from pyowm.commons.tile import Tile
Expand All @@ -33,6 +34,8 @@ def __init__(self, API_key, config):
self.API_key = API_key
assert isinstance(config, dict)
self.http_client = HttpClient(API_key, config, ROOT_AGRO_API)
self.geotiff_downloader_http_client = HttpClient(self.API_key, config, ROOT_DOWNLOAD_GEOTIFF_API)
self.png_downloader_http_client = HttpClient(self.API_key, config, ROOT_DOWNLOAD_PNG_API)

def agro_api_version(self):
return AGRO_API_VERSION
Expand Down Expand Up @@ -279,14 +282,14 @@ def download_satellite_image(self, metaimage, x=None, y=None, zoom=None, palette
# polygon PNG
if isinstance(metaimage, MetaPNGImage):
prepared_url = metaimage.url
status, data = self.http_client.get_png(
status, data = self.png_downloader_http_client.get_png(
prepared_url, params=params)
img = Image(data, metaimage.image_type)
return SatelliteImage(metaimage, img, downloaded_on=timestamps.now(timeformat='unix'), palette=palette)
# GeoTIF
elif isinstance(metaimage, MetaGeoTiffImage):
prepared_url = metaimage.url
status, data = self.http_client.get_geotiff(
status, data = self.geotiff_downloader_http_client.get_geotiff(
prepared_url, params=params)
img = Image(data, metaimage.image_type)
return SatelliteImage(metaimage, img, downloaded_on=timestamps.now(timeformat='unix'), palette=palette)
Expand Down
2 changes: 2 additions & 0 deletions pyowm/agroapi10/uris.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# -*- coding: utf-8 -*-

ROOT_AGRO_API = 'agromonitoring.com/agro/1.0'
ROOT_DOWNLOAD_PNG_API = 'agromonitoring.com/image/1.0'
ROOT_DOWNLOAD_GEOTIFF_API = 'agromonitoring.com/data/1.0'

# Polygons API subset
POLYGONS_URI = 'polygons'
Expand Down
Loading