Skip to content

Commit 5384272

Browse files
committed
Merge branch 'main' into get_template
2 parents 59ad0e6 + 011ddd1 commit 5384272

File tree

32 files changed

+2988
-2411
lines changed

32 files changed

+2988
-2411
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
- feat(indicator): add as_dict method ([#653])
3333
- refactor(oqt/api): move geojson creation to api ([#653])
3434
- build: bump fastapi and pydantic major version ([#669])
35+
- currentness: overhaul currentness indicator #668
36+
- based on monthly interval instead of yearly ([#668])
37+
- result class determination based on share of three bins instead of median ([#668])
38+
- now uses topic specific thresholds for bin creation ([#668])
39+
- plot now shows relative and absolute contributions ([#668])
40+
- further improvements to description and plot ([#668])
3541

3642
[#589]: https://github.com/GIScience/ohsome-quality-analyst/pull/589
3743
[#600]: https://github.com/GIScience/ohsome-quality-analyst/pull/600
@@ -49,6 +55,7 @@
4955
[#653]: https://github.com/GIScience/ohsome-quality-analyst/pull/653
5056
[#656]: https://github.com/GIScience/ohsome-quality-analyst/pull/656
5157
[#659]: https://github.com/GIScience/ohsome-quality-analyst/pull/659
58+
[#668]: https://github.com/GIScience/ohsome-quality-analyst/pull/668
5259
[#669]: https://github.com/GIScience/ohsome-quality-analyst/pull/669
5360
[#670]: https://github.com/GIScience/ohsome-quality-analyst/pull/670
5461

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ Please provide [tests](/docs/development_setup.md#tests).
7171
## Miscellaneous
7272

7373
- Troubleshooting -> [docs/troubleshooting.md](/docs/troubleshooting.md)
74-
- How to create a new indicator? -> [docs/indicator_creation.md](/docs/indicator_creation.md).
74+
- How are indicators structured? -> [docs/indicator.md](/docs/indicator.md).

docs/api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
Please take a look at the [interactive Swagger UI](https://oqt.ohsome.org/api/docs) to explore the API.
44

55
We also provide a [Jupyter Notebook](https://github.com/GIScience/oqt-examples) with examples on how to use the OQT API with Python.
6+
7+
Have a look at this [blog post](https://heigit.org/de/visualizing-oqt-api-results-in-qgis-2/) to learn how to visualize the OQT API Response in QGIS.

docs/development_setup.md

Lines changed: 24 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,61 @@
11
# Development Setup
22

3-
To run all components (OQT/API, Database, Website) in Docker containers simply run:
3+
To run simply run OQT and the Database the provided Docker setup can be used.
44

55
```bash
66
docker compose up --detach
77
```
88

99
After all services are up they are available under:
1010

11-
- Website: [http://127.0.0.1:8081/](http://127.0.0.1:8081/)
1211
- API: [http://127.0.0.1:8080/](http://127.0.0.1:8080/)
1312
- Database: `host=localhost port=5445 dbname=oqt user=oqt password=oqt`
1413

15-
Please continue reading for more information on each one of those services. If running into issues during the setup please check the [troubleshooting](/docs/troubleshooting.md) document. Also feel free to reach out to us.
14+
For development setup please continue reading.
1615

1716

18-
## Database
19-
20-
A database for development purposes is provided as Dockerfile. This database contains custom regions, regions for running tests and datasets (E.g. SHDI) for those regions. To build and run an already configured image run:
21-
22-
```bash
23-
docker compose up --detach database
24-
```
25-
26-
During building of the database Docker image data for development purposes is downloaded. When the database container is running for the first time it takes a few seconds until the database is initialized and ready to accept connections.
27-
Check the progress with `docker logs database`.
28-
29-
To reinitialize or update the database make sure to delete the volume and rebuild the image. This will delete all data in the database:
30-
31-
```bash
32-
# Make sure that your git is up2date, e.g. git pull
33-
docker compose down --remove-orphans --volumes
34-
docker compose up --detach --force-recreate --build database
35-
```
36-
37-
To avoid using the cache of Docker run:
38-
39-
```bash
40-
docker compose build --no-cache database
41-
docker compose up --detach database
42-
```
43-
44-
> If for development purposes additional datasets are required please have a look at the scripts found in the `database/init_db.production` directory.
45-
46-
47-
### Database for running tests
48-
49-
A minimal database setup for running tests is provided. If the build argument `OQT_TEST_DB` is set to `True` a database is initialized with data only for the regions used by the tests. No (additional) data is downloaded as is the case with the database setup for development.
50-
51-
52-
## Raster Datasets
53-
54-
Please refer to [/docs/raster_datasets.md](/docs/raster_datasets.md).
55-
56-
57-
## OQT Python package
58-
59-
60-
### Requirements
17+
## Requirements
6118

6219
- Python: ≥ 3.10
6320
- Poetry: ≥ 1.5
6421
- R: ≥ 4.0
6522

66-
This project uses [Poetry](https://python-poetry.org/docs/) for packaging and dependencies management. Please make sure it is installed on your system using `pip`.
23+
This project uses [Poetry](https://python-poetry.org/docs/) for packaging and dependencies management. Please make sure it is installed on your system.
6724

25+
For development a database and raster datasets on disk might not be needed. In case the database is needed start the database service defined in the docker compose file. If raster datasets are needed please refer to [/docs/raster_datasets.md](/docs/raster_datasets.md) for setting those up.
6826

69-
### Installation
27+
28+
## Installation
7029

7130
```bash
7231
poetry install
7332
poetry shell # Spawns a shell within the virtual environment.
7433
pre-commit install # Install pre-commit hooks.
7534
# Hack away
35+
pytest # Run all tests
7636
```
7737

7838

79-
### Configuration
39+
## Configuration
8040

8141
For all possible configuration parameter please refer to the [configuration documentation](/docs/configuration.md).
8242

83-
For local development no additional configuration is required. Per default OQT will connect to the database defined in `docker-compose.yml`.
84-
85-
86-
### Usage
87-
43+
For local development no custom configuration is required.
8844

89-
#### API
9045

91-
92-
##### Start the API using Docker:
46+
## Usage
9347

9448
```bash
95-
docker compose up --detach workers
49+
python scripts/start_api.py
9650
```
9751

98-
99-
##### Start the API using a Python script:
100-
101-
```bash
102-
cd scripts
103-
python start_api.py
104-
```
52+
Go to [http://127.0.0.1:8080/docs](http://127.0.0.1:8080/docs) and check out the endpoints.
10553

10654
Default host is 127.0.0.1 and port is 8080. To change this, provide the corresponding parameter:
10755

10856
```bash
109-
python start_api.py --help
57+
$ cd scripts
58+
$ python start_api.py --help
11059
Usage: start_api.py [OPTIONS]
11160

11261
Options:
@@ -116,55 +65,7 @@ Options:
11665
```
11766

11867

119-
##### Endpoints
120-
121-
Go to [http://127.0.0.1:8080/docs](http://127.0.0.1:8080/docs) and check out the endpoints.
122-
123-
Alternative query the API from a terminal using CURL:
124-
125-
```bash
126-
curl -X 'POST' \
127-
'http://127.0.0.1:8080/indicators/mapping-saturation' \
128-
-H 'accept: application/json' \
129-
-H 'Content-Type: application/json' \
130-
-d '{
131-
"topic": "building-count",
132-
"bpolys": {
133-
"type": "Feature",
134-
"geometry": {
135-
"type": "Polygon",
136-
"coordinates": [
137-
[
138-
[
139-
8.674092292785645,
140-
49.40427147224242
141-
],
142-
[
143-
8.695850372314453,
144-
49.40427147224242
145-
],
146-
[
147-
8.695850372314453,
148-
49.415552187316095
149-
],
150-
[
151-
8.674092292785645,
152-
49.415552187316095
153-
],
154-
[
155-
8.674092292785645,
156-
49.40427147224242
157-
]
158-
]
159-
]
160-
}
161-
}
162-
}' \
163-
| python -m json.tool > response.json
164-
```
165-
166-
167-
### Tests
68+
## Tests
16869

16970
All relevant components should be tested. Please write tests for newly integrated
17071
functionality.
@@ -177,9 +78,7 @@ To run all tests just execute `pytest`:
17778
pytest
17879
```
17980

180-
#### Writing tests
181-
182-
##### VCR (videocassette recorder) for tests
81+
### VCR for Tests
18382

18483
All tests that are calling function, which are dependent on external resources (e.g. ohsome API) have to use the [VCR.py](https://vcrpy.readthedocs.io) module: "VCR.py records all HTTP interactions that take place []."
18584
This ensures that the positive test result is not dependent on the external resource. The cassettes are stored in the test directory within [fixtures/vcr_cassettes](/tests/integrationtests/fixtures/vcr_cassettes). These cassettes are supposed to be integrated (committed and pushed) to the repository.
@@ -199,26 +98,26 @@ def test_something(self):
19998

20099
Good examples can be found in [test_oqt.py](/tests/integrationtests/test_oqt.py).
201100

202-
##### Asynchronous functions
101+
### Asynchronous functions
203102

204103
When writing tests for functions which are asynchronous (using the `async/await` pattern) such as the `preprocess` functions of indicator classes, those functions should be called as follows: `asyncio.run(indicator.preprocess())`.
205104

206105

207-
### Logging
106+
## Logging
208107

209108
Logging is enabled by default.
210109

211110
`ohsome_quality_analyst` uses the [logging module](https://docs.python.org/3/library/logging.html).
212111

213-
#### Configuration
112+
### Configuration
214113

215114
The logging module is configured in `config.py`. Both entry-points to
216115
`ohsome_quality_analyst`, the `api.py`, will call the configuration
217116
function defined in `definitions.py`. The default log level is `INFO`. This can be
218117
overwritten by setting the environment variable `OQT_LOG_LEVEL` (See also the
219118
[configuration documentation](docs/configuration.md)).
220119

221-
#### Usage
120+
### Usage
222121

223122
```python
224123
import logging
@@ -227,12 +126,12 @@ logging.info("Logging message")
227126
```
228127

229128

230-
### Database Library
129+
## Database Library
231130

232131
OQT uses [asyncpg](https://magicstack.github.io/asyncpg/current/) as database interface
233132
library.
234133

235-
#### `executemany` Query
134+
### `executemany` Query
236135

237136
In Psycopg one can execute a query for each element of a list with
238137
`executemany(insert_query, vars_list)`.
@@ -248,7 +147,7 @@ await conn.fetch('''
248147
```
249148

250149

251-
### Notes on the integration of R
150+
## Notes on the integration of R
252151

253152
OQT utilizes the package [`rpy2`](https://rpy2.github.io/) to execute R code.
254153

docs/examples/minimal-example.html

Lines changed: 0 additions & 34 deletions
This file was deleted.

docs/faq.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,3 @@ A saturation of 100 % means that the gradient or slope of the last bit (i.e. las
1111
#### Why does the curve of Mapping Saturation decline sometimes?
1212

1313
In case that features or tags are deleted the fitted curve can decline.
14-
15-
### Currentness
16-
17-
#### Can smaller time periods (e.g. monthly) be used for computing the Currentness Indicator?
18-
19-
In term of content there is no reason why a smaller time period could not be used.
20-
21-
#### How does deleted features or time periods without any mapping influence the Currentness result?
22-
23-
TODO

0 commit comments

Comments
 (0)