Skip to content

Commit d397205

Browse files
committed
encode shapes
1 parent 7e9eda6 commit d397205

File tree

15 files changed

+407
-194
lines changed

15 files changed

+407
-194
lines changed

.circleci/config.yml

-85
This file was deleted.

.github/workflows/ci.yml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: CI
2+
3+
# On every pull request, but only on push to master
4+
on:
5+
push:
6+
branches:
7+
- master
8+
tags:
9+
- '*'
10+
pull_request:
11+
12+
jobs:
13+
tests:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
python-version: [3.6, 3.7, 3.8]
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
python -m pip install tox codecov pre-commit
29+
30+
# Run tox using the version of Python in `PATH`
31+
- name: Run Tox
32+
run: tox -e py
33+
34+
# Run pre-commit (only for python-3.7)
35+
- name: run pre-commit
36+
if: matrix.python-version == 3.7
37+
run: pre-commit run --all-files
38+
39+
- name: Upload Results
40+
if: success()
41+
uses: codecov/codecov-action@v1
42+
with:
43+
file: ./coverage.xml
44+
flags: unittests
45+
name: ${{ matrix.platform }}-${{ matrix.tox-env }}
46+
fail_ci_if_error: false
47+
48+
publish:
49+
needs: [tests]
50+
runs-on: ubuntu-latest
51+
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
52+
steps:
53+
- uses: actions/checkout@v2
54+
- name: Set up Python
55+
uses: actions/setup-python@v1
56+
with:
57+
python-version: "3.x"
58+
59+
- name: Install dependencies
60+
run: |
61+
python -m pip install --upgrade pip
62+
python -m pip install tox
63+
64+
- name: Set tag version
65+
id: tag
66+
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
67+
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
68+
69+
- name: Set module version
70+
id: module
71+
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
72+
run: echo ::set-output name=version::$(python setup.py --version)
73+
74+
- name: Build and publish
75+
if: steps.tag.outputs.tag == steps.module.outputs.version
76+
env:
77+
TOXENV: release
78+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
79+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
80+
run: tox

.pre-commit-config.yaml

+43-33
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,44 @@
1-
21
repos:
3-
-
4-
repo: 'https://github.com/ambv/black'
5-
# 18.6b1
6-
rev: ed50737290662f6ef4016a7ea44da78ee1eff1e2
7-
hooks:
8-
- id: black
9-
args: ['--safe']
10-
language_version: python3.6
11-
-
12-
repo: 'https://github.com/pre-commit/pre-commit-hooks'
13-
# v1.3.0
14-
rev: a6209d8d4f97a09b61855ea3f1fb250f55147b8b
15-
hooks:
16-
- id: flake8
17-
language_version: python3.6
18-
args: [
19-
# E501 let black handle all line length decisions
20-
# W503 black conflicts with "line break before operator" rule
21-
# E203 black conflicts with "whitespace before ':'" rule
22-
'--ignore=E501,W503,E203']
23-
-
24-
repo: 'https://github.com/chewse/pre-commit-mirrors-pydocstyle'
25-
# 2.1.1
26-
rev: 22d3ccf6cf91ffce3b16caa946c155778f0cb20f
27-
hooks:
28-
- id: pydocstyle
29-
language_version: python3.6
30-
args: [
31-
# Check for docstring presence only
32-
'--select=D1',
33-
# Don't require docstrings for tests
34-
'--match=(?!test).*\.py']
2+
- repo: https://github.com/psf/black
3+
rev: 19.10b0
4+
hooks:
5+
- id: black
6+
language_version: python3.7
7+
args: ["--safe"]
8+
9+
- repo: https://github.com/PyCQA/isort
10+
rev: 5.4.2
11+
hooks:
12+
- id: isort
13+
language_version: python3.7
14+
15+
- repo: https://github.com/PyCQA/flake8
16+
rev: 3.8.3
17+
hooks:
18+
- id: flake8
19+
language_version: python3.7
20+
args: [
21+
# E501 let black handle all line length decisions
22+
# W503 black conflicts with "line break before operator" rule
23+
# E203 black conflicts with "whitespace before ':'" rule
24+
"--ignore=E501,W503,E203",
25+
]
26+
27+
- repo: https://github.com/PyCQA/pydocstyle
28+
rev: 5.1.1
29+
hooks:
30+
- id: pydocstyle
31+
language_version: python3.7
32+
args: [
33+
# Check for docstring presence only
34+
"--select=D1",
35+
# Don't require docstrings for tests
36+
'--match=(?!test).*\.py',
37+
]
38+
39+
- repo: https://github.com/pre-commit/mirrors-mypy
40+
rev: v0.770
41+
hooks:
42+
- id: mypy
43+
language_version: python3.7
44+
args: ["--no-strict-optional", "--ignore-missing-imports"]

CHANGES.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Next (TBD)
2+
3+
* update tests for new vector-tile-base version
4+
* add `shapes` encoding (add shapely and rasterio in requirements).
5+
6+
**breaking changes**
7+
8+
* renamed `mvt.encoder` to `mvt.pixels_encoder`
9+
10+
## 0.0.1dev1 (2019-06-25)
11+
12+
* Fix missing files in package
13+
14+
## 0.0.1dev0 (2019-06-24)
15+
16+
* Initial release.

CHANGES.txt

-11
This file was deleted.

README.md

+69-21
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
# rio-tiler-mvt
22

3-
[![Packaging status](https://badge.fury.io/py/rio-tiler-mvt.svg)](https://badge.fury.io/py/rio-tiler-mvt)
4-
[![CircleCI](https://circleci.com/gh/cogeotiff/rio-tiler-mvt.svg?style=svg)](https://codecov.io/gh/cogeotiff/rio-tiler-mvt)
5-
[![codecov](https://codecov.io/gh/cogeotiff/rio-tiler-mvt/branch/master/graph/badge.svg)](https://circleci.com/gh/cogeotiff/rio-tiler-mvt)
3+
<p align="center">
4+
<img src="https://user-images.githubusercontent.com/10407788/57476379-72cf6000-7264-11e9-979d-bf9f486518c2.png" style="max-width: 800px;" alt="rio-tiler"></a>
5+
</p>
6+
<p align="center">
7+
<em>A rio-tiler plugin to translate tile array to MVT (using python-vtzero).</em>
8+
</p>
9+
<p align="center">
10+
<a href="https://github.com/cogeotiff/rio-tiler-mvt/actions?query=workflow%3ACI" target="_blank">
11+
<img src="https://github.com/cogeotiff/rio-tiler-mvt/workflows/CI/badge.svg" alt="Test">
12+
</a>
13+
<a href="https://codecov.io/gh/cogeotiff/rio-tiler-mvt" target="_blank">
14+
<img src="https://codecov.io/gh/cogeotiff/rio-tiler-mvt/branch/master/graph/badge.svg" alt="Coverage">
15+
</a>
16+
<a href="https://pypi.org/project/rio-tiler-mvt" target="_blank">
17+
<img src="https://img.shields.io/pypi/v/rio-tiler-mvt?color=%2334D058&label=pypi%20package" alt="Package version">
18+
</a>
19+
<a href="https://github.com/cogeotiff/rio-tiler-mvt/blob/master/LICENSE" target="_blank">
20+
<img src="https://img.shields.io/github/license/cogeotiff/rio-tiler-mvt.svg" alt="Downloads">
21+
</a>
22+
</p>
623

724

8-
A rio-tiler plugin to translate tile array to MVT (using python-vtzero)
9-
10-
![](https://user-images.githubusercontent.com/10407788/57476379-72cf6000-7264-11e9-979d-bf9f486518c2.png)
11-
1225
More on [COG Talk](https://medium.com/devseed/search?q=cog%20talk) blog posts
1326

1427
## Install
@@ -22,7 +35,7 @@ $ pip install cython~=0.28 # see https://github.com/tilery/python-vtzero#require
2235

2336
$ pip install rio-tiler-mvt
2437
```
25-
Or
38+
Or
2639
```bash
2740
$ git clone https://github.com/cogeotiff/rio-tiler-mvt
2841
$ cd rio-tiler-mvt
@@ -33,14 +46,53 @@ $ pip install -e .
3346

3447
### API
3548

36-
`mvt.encoder(data, mask, band_names=[], layer_name="my_layer", feature_type="point")`
49+
#### **pixel_encoder**
50+
51+
pixels_encoder(
52+
data: numpy.ndarray,
53+
mask: numpy.ndarray,
54+
band_names: list = [],
55+
layer_name: str = "my_layer",
56+
feature_type: str = "point"
57+
)
58+
59+
Inputs:
60+
- data: raster tile data to encode
61+
- mask: mask data
62+
- band_names: Raster band's names
63+
- layer_name: Layer name
64+
- feature_type: Feature type (point or polygon)
65+
66+
Returns:
67+
- mvt : Mapbox Vector Tile encoded data.
68+
69+
Examples:
70+
71+
```python
72+
from rio_tiler.io import COGReader
73+
from rio_tiler_mvt import pixels_encoder
74+
75+
with COGReader("fixtures/test.tif") as cog
76+
img = cog.tile(72, 63, 7, resampling_method="nearest")
77+
mvt = pixels_encoder(img.data, img.mask, layer_name="test", feature_type="point")
78+
```
79+
80+
#### **shapes_encoder**
81+
82+
shapes_encoder(
83+
data: numpy.ndarray, # 1D array (height, width)
84+
mask: numpy.ndarray,
85+
layer_name: str = "my_layer",
86+
colormap: dict = {},
87+
class_names: dict = {}
88+
)
3789

3890
Inputs:
39-
- data : raster tile data to encode
40-
- mask : mask data
41-
- band_names : Raster band's names
42-
- layer_name : Layer name
43-
- feature_type : Feature type (point or polygon)
91+
- data: raster tile data to encode
92+
- mask: mask data
93+
- layer_name: Layer name
94+
- colormap: GDAL colormap. If provided a `color` value will be added to the feature properties
95+
- class_names: Dictionary mapping pixel value with class names. If provided a `name` value will be added to the feature properties.
4496

4597
Returns:
4698
- mvt : Mapbox Vector Tile encoded data.
@@ -58,16 +110,12 @@ $ cd rio-tiler-mvt
58110
$ pip install -e .[dev]
59111
```
60112

61-
**Python3.6 only**
113+
**Python3.7 only**
62114

63-
This repo is set to use `pre-commit` to run *flake8*, *pydocstring* and *black* ("uncompromising Python code formatter") when commiting new code.
115+
This repo is set to use `pre-commit` to run *isort*, *flake8*, *pydocstring*, *black* ("uncompromising Python code formatter") and mypy when committing new code.
64116

65117
```bash
66118
$ pre-commit install
67119
```
68120

69-
70-
## Implementations
71-
[cogeo-mosaic](https://github.com/developmentseed/cogeo-mosaic.git)
72-
73-
[satellite-3d](https://github.com/developmentseed/satellite-3d.git)
121+
[satellite-3d](https://github.com/developmentseed/satellite-3d.git)

0 commit comments

Comments
 (0)