Skip to content

Commit

Permalink
Update Python example to use current API
Browse files Browse the repository at this point in the history
  • Loading branch information
brawer committed May 10, 2022
1 parent 64fee30 commit 78a2c09
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ Updated weekly. Aggregated over the past 52 weeks to smoothen seasonal effects.
For any location on the planet, up to ~150m/z18 resolution.


## Roadmap to 1.0
## Code repository

* `cmd/webserver` is the [OSMViews webserver](https://osmviews.toolforge.org).
* `cmd/osmviews-builder` is the pipeline that computes the data.

Client libraries are maintained in separate repositories.
For Python, see [brawer/osmviews-py](https://github.com/brawer/osmviews-py).

* Write a Python function `osmviews.load()` to load and refresh
the local GeoTIFF file. Currently, clients have to download the
the file manually.

## Roadmap to 1.0

* Write documentation for the Python client.

Expand Down
6 changes: 4 additions & 2 deletions cmd/webserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ func (ws *Webserver) HandleMain(w http.ResponseWriter, r *http.Request) {
<head>
<link href='https://tools-static.wmflabs.org/fontcdn/css?family=Roboto+Slab:400,700' rel='stylesheet' type='text/css'/>
<link href='https://tools-static.wmflabs.org/fontcdn/css?family=Source+Code+Pro:400' rel='stylesheet' type='text/css'/>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<style>
* {
box-sizing: border-box;
font-family: 'Roboto Slab', serif;
}
h1 {
color: #ffaed7;
margin-left: 1em;
margin-top: 1em;
}
Expand Down Expand Up @@ -101,7 +102,8 @@ a:visited { color: #ffaed7 }
<p class="code"># pip install osmviews
import osmviews
with osmviews.OSMViews('path/to/osmviews.tiff') as o:
osmviews.download('/tmp/osmviews.tiff')
with osmviews.open('/tmp/osmviews.tiff') as o:
print(f'Tokyo, Shibuya: {o.rank( 35.658514, 139.701330):>9.2f}')
print(f'Tokyo, Sumida: {o.rank( 35.710719, 139.801547):>9.2f}')
print(f'Zürich, Altstetten: {o.rank( 47.391485, 8.488945):>9.2f}')
Expand Down

0 comments on commit 78a2c09

Please sign in to comment.