Skip to content

Commit 899b11e

Browse files
committed
Merge branch 'master' of github.com:developmentseed/tifeatures into geom_return_options
2 parents ee76362 + 34bd0c6 commit 899b11e

File tree

19 files changed

+759
-17
lines changed

19 files changed

+759
-17
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
2+
TIFEATURES_NAME="OGC Feature API"
13
DATABASE_URL=postgresql://username:[email protected]:5439/postgis

.github/workflows/ci.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,87 @@ jobs:
6262
flags: unittests
6363
name: ${{ matrix.python-version }}
6464
fail_ci_if_error: false
65+
66+
publish:
67+
needs: [tests]
68+
runs-on: ubuntu-latest
69+
if: contains(github.ref, 'tags') && github.event_name == 'push'
70+
steps:
71+
- uses: actions/checkout@v2
72+
- name: Set up Python
73+
uses: actions/setup-python@v1
74+
with:
75+
python-version: ${{ env.LATEST_PY_VERSION }}
76+
77+
- name: Install dependencies
78+
run: |
79+
python -m pip install --upgrade pip
80+
python -m pip install flit
81+
python -m pip install .
82+
83+
- name: Set tag version
84+
id: tag
85+
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
86+
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
87+
88+
- name: Set module version
89+
id: module
90+
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
91+
run: echo ::set-output name=version::$(python -c 'from importlib.metadata import version; print(version("tifeatures"))')
92+
93+
- name: Build and publish
94+
if: steps.tag.outputs.tag == steps.module.outputs.version
95+
env:
96+
FLIT_USERNAME: ${{ secrets.PYPI_USERNAME }}
97+
FLIT_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
98+
run: flit publish
99+
100+
publish-docker:
101+
needs: [tests]
102+
if: github.ref == 'refs/heads/master' || startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
103+
runs-on: ubuntu-latest
104+
steps:
105+
- name: Checkout
106+
uses: actions/checkout@v2
107+
108+
- name: Set up QEMU
109+
uses: docker/setup-qemu-action@v1
110+
111+
- name: Set up Docker Buildx
112+
uses: docker/setup-buildx-action@v1
113+
114+
- name: Login to Github
115+
uses: docker/login-action@v1
116+
with:
117+
registry: ghcr.io
118+
username: ${{ github.actor }}
119+
password: ${{ secrets.GITHUB_TOKEN }}
120+
121+
- name: Set tag version
122+
id: tag
123+
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
124+
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
125+
126+
# Push `latest` when commiting to master
127+
- name: Build and push
128+
if: github.ref == 'refs/heads/master'
129+
uses: docker/build-push-action@v2
130+
with:
131+
platforms: linux/amd64,linux/arm64
132+
context: .
133+
file: dockerfiles/Dockerfile
134+
push: true
135+
tags: |
136+
ghcr.io/${{ github.repository }}:latest
137+
138+
# Push `{VERSION}` when pushing a new tag
139+
- name: Build and push
140+
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
141+
uses: docker/build-push-action@v2
142+
with:
143+
platforms: linux/amd64,linux/arm64
144+
context: .
145+
file: dockerfiles/Dockerfile
146+
push: true
147+
tags: |
148+
ghcr.io/${{ github.repository }}:${{ steps.tag.outputs.tag }}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Publish docs via GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
# Only rebuild website when docs have changed
9+
- 'README.md'
10+
- 'CHANGES.md'
11+
- 'CONTRIBUTING.md'
12+
- 'docs/**'
13+
14+
jobs:
15+
build:
16+
name: Deploy docs
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout master
20+
uses: actions/checkout@v2
21+
22+
- name: Set up Python 3.8
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: 3.8
26+
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
python -m pip install -e .["docs"]
31+
32+
- name: Create API docs
33+
env:
34+
# we need to set a fake PG url or import will fail
35+
DATABASE_URL: postgresql://username:[email protected]:5439/postgis
36+
run: |
37+
pdocs as_markdown \
38+
--output_dir docs/src/api \
39+
--exclude_source \
40+
--overwrite \
41+
tifeatures.filter.evaluate \
42+
tifeatures.filter.filters \
43+
tifeatures.resources.enums \
44+
tifeatures.resources.response \
45+
tifeatures.db \
46+
tifeatures.dbmodel \
47+
tifeatures.dependencies \
48+
tifeatures.errors \
49+
tifeatures.factory \
50+
tifeatures.layer \
51+
tifeatures.middleware \
52+
tifeatures.model \
53+
tifeatures.settings
54+
55+
- name: Deploy docs
56+
run: mkdocs gh-deploy --force -f docs/mkdocs.yml

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,4 @@ cdk.out/
108108
benchmark/
109109

110110
.pgdata/
111+
docs/src/api/*

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<p align="center">
22
<img width="500" src="https://user-images.githubusercontent.com/10407788/172736520-18da1910-87ac-41a9-b6f0-6c6ae503bd5e.png"/>
3-
<p align="center">Simple and Fast Geospatial Feature Server for PostGIS.</p>
3+
<p align="center">Simple and Fast Geospatial Features API for PostGIS.</p>
44
</p>
5-
65
<p align="center">
76
<a href="https://github.com/developmentseed/tifeatures/actions?query=workflow%3ACI" target="_blank">
87
<img src="https://github.com/developmentseed/tifeatures/workflows/CI/badge.svg" alt="Test">
@@ -18,10 +17,13 @@
1817

1918
---
2019

20+
**Documentation**: <a href="https://developmentseed.org/tifeatures/" target="_blank">https://developmentseed.org/tifeatures/</a>
21+
2122
**Source Code**: <a href="https://github.com/developmentseed/tifeatures" target="_blank">https://github.com/developmentseed/tifeatures</a>
2223

2324
---
2425

26+
`TiFeatures`, pronounced **tee-Features**, is a python package which helps creating lightweight **Features** server for PostGIS Database. The API has been designed with respect to [OGC Features API specification](https://github.com/opengeospatial/ogcapi-features).
2527

2628
## Install
2729

@@ -36,6 +38,8 @@ $ python -m pip install -e . # or .["all"] to install optional dependencies
3638
```bash
3739
$ pip install uvicorn
3840

41+
# Set you postgis database instance URL in the environment
42+
$ export DATABASE_URL=postgresql://username:[email protected]:5432/postgis
3943
$ uvicorn tifeatures.main:app
4044
```
4145

@@ -52,6 +56,20 @@ Example of `.env` file can be found in [.env.example](https://github.com/develop
5256
DATABASE_URL=postgresql://username:[email protected]:5432/postgis
5357
```
5458

59+
## OGC Specification
60+
61+
Specification | Status | link |
62+
| -- | -- | -- |
63+
Part 1: Core | ✅ | https://docs.ogc.org/is/17-069r4/17-069r4.html
64+
Part 2: CRS by Reference | ❌ | https://docs.ogc.org/is/18-058r1/18-058r1.html
65+
Part 3: Filtering / CQL2 | ✅ | https://docs.ogc.org/DRAFTS/19-079r1.html
66+
67+
Notes:
68+
69+
The project authors choose not to implement the Part 2 of the specification to avoid the introduction of CRS based GeoJSON. This might change in the future.
70+
71+
While the authors tried to follow the specification (part 1 and 3) to the letter, some API endpoints might have more capacities (e.g geometry column selection).
72+
5573
## Contribution & Development
5674

5775
See [CONTRIBUTING.md](https://github.com/developmentseed/tifeatures/blob/master/CONTRIBUTING.md)

dockerfiles/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG PYTHON_VERSION=3.8
1+
ARG PYTHON_VERSION=3.9
22

33
FROM ghcr.io/vincentsarago/uvicorn-gunicorn:${PYTHON_VERSION}
44

docs/mkdocs.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
site_name: tifeatures
2+
site_description: Simple and Fast Geospatial OGC Features API for PostGIS.
3+
4+
docs_dir: 'src'
5+
site_dir: 'build'
6+
7+
repo_name: "developmentseed/tifeatures"
8+
repo_url: "https://github.com/developmentseed/tifeatures"
9+
10+
extra:
11+
social:
12+
- icon: "fontawesome/brands/github"
13+
link: "https://github.com/developmentseed"
14+
- icon: "fontawesome/brands/twitter"
15+
link: "https://twitter.com/developmentseed"
16+
- icon: "fontawesome/brands/medium"
17+
link: "https://medium.com/devseed"
18+
19+
nav:
20+
- TiFeatures: "index.md"
21+
- Tutorial - User Guide:
22+
- "Endpoints": endpoints.md
23+
- Advanced User Guide:
24+
- "Combine MVT and Features": advanced/timvt_and_tifeatures.md
25+
- API:
26+
- db: api/tifeatures/db.md
27+
- dbmodel: api/tifeatures/dbmodel.md
28+
- dependencies: api/tifeatures/dependencies.md
29+
- errors: api/tifeatures/errors.md
30+
- factory: api/tifeatures/factory.md
31+
- layer: api/tifeatures/layer.md
32+
- middleware: api/tifeatures/middleware.md
33+
- model: api/tifeatures/model.md
34+
- settings: api/tifeatures/settings.md
35+
- resources:
36+
- enums: api/tifeatures/resources/enums.md
37+
- response: api/tifeatures/resources/response.md
38+
- filters:
39+
- evaluate: api/tifeatures/filter/evaluate.md
40+
- filters: api/tifeatures/filter/filters.md
41+
- Development - Contributing: "contributing.md"
42+
- Release Notes: "release-notes.md"
43+
44+
plugins:
45+
- search
46+
47+
theme:
48+
name: material
49+
palette:
50+
primary: indigo
51+
scheme: default
52+
favicon: img/favicon.ico
53+
54+
markdown_extensions:
55+
- admonition
56+
- attr_list
57+
- codehilite:
58+
guess_lang: false
59+
- def_list
60+
- footnotes
61+
- pymdownx.arithmatex
62+
- pymdownx.betterem
63+
- pymdownx.caret:
64+
insert: false
65+
- pymdownx.details
66+
- pymdownx.emoji
67+
- pymdownx.escapeall:
68+
hardbreak: true
69+
nbsp: true
70+
- pymdownx.magiclink:
71+
hide_protocol: true
72+
repo_url_shortener: true
73+
- pymdownx.smartsymbols
74+
- pymdownx.superfences
75+
- pymdownx.tasklist:
76+
custom_checkbox: true
77+
- pymdownx.tilde
78+
- toc:
79+
permalink: true
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
3+
`TiFeatures` and [`TiMVT`](https://github.com/developmentseed/timvt) share a lot of in common and it's possible to create a unique FastAPI application with both **Features** and **MVT** endpoints:
4+
5+
```python
6+
"""Features and MVT app."""
7+
8+
from tifeatures.db import close_db_connection, connect_to_db, register_table_catalog
9+
from tifeatures.factory import Endpoints
10+
from timvt.factory import VectorTilerFactory
11+
from fastapi import FastAPI
12+
from starlette_cramjam.middleware import CompressionMiddleware
13+
14+
app = FastAPI(
15+
title="Features and MVT",
16+
openapi_url="/api",
17+
docs_url="/api.html",
18+
)
19+
20+
# Register endpoints.
21+
endpoints = Endpoints()
22+
app.include_router(endpoints.router, tags=["Features"])
23+
24+
# By default the VectorTilerFactory will only create tiles/ and tilejson.json endpoints
25+
mvt_endpoints = VectorTilerFactory()
26+
app.include_router(mvt_endpoints.router)
27+
28+
app.add_middleware(CompressionMiddleware)
29+
30+
31+
@app.on_event("startup")
32+
async def startup_event() -> None:
33+
"""Connect to database on startup."""
34+
await connect_to_db(app)
35+
# TiMVT and TiFeatures share the same `Table_catalog` format
36+
# see https://github.com/developmentseed/timvt/pull/83
37+
await register_table_catalog(app)
38+
39+
40+
@app.on_event("shutdown")
41+
async def shutdown_event() -> None:
42+
"""Close database connection."""
43+
await close_db_connection(app)
44+
```
45+
46+
!!! Note
47+
To run the example, copy the code to a file main.py, and start uvicorn with:
48+
49+
`uvicorn main:app --reload`
50+
51+
52+
![](https://user-images.githubusercontent.com/10407788/175392407-d8cf4fec-497c-42a7-ae8f-d754962bf1e7.png)

docs/src/contributing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../CONTRIBUTING.md

0 commit comments

Comments
 (0)