Skip to content

Commit 6aeb6d6

Browse files
update docs (#1140)
1 parent 9c86278 commit 6aeb6d6

File tree

8 files changed

+116
-145
lines changed

8 files changed

+116
-145
lines changed

docs/mkdocs.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,19 @@ extra:
3737
nav:
3838
- TiTiler: "index.md"
3939
- User Guide:
40-
- Intro: "intro.md"
41-
- Dynamic Tiling: "dynamic_tiling.md"
42-
- TileMatrixSets: "tile_matrix_sets.md"
43-
- Output data format: "output_format.md"
44-
- Getting Started with TiTiler: "getting_started_with_titiler.md"
40+
- Getting Started: "user_guide/getting_started.md"
41+
- Dynamic Tiling: "user_guide/dynamic_tiling.md"
42+
- TileMatrixSets: "user_guide/tile_matrix_sets.md"
43+
- Output data format: "user_guide/output_format.md"
44+
- Algorithm: "user_guide/algorithms.md"
45+
- Rendering: "user_guide/rendering.md"
4546

4647
- Advanced User Guide:
4748
- Endpoints Factories: "advanced/endpoints_factories.md"
4849
- Dependencies: "advanced/dependencies.md"
4950
- Customization: "advanced/customization.md"
5051
- Performance Tuning: "advanced/performance_tuning.md"
51-
- Custom Algorithm: "advanced/Algorithms.md"
5252
- Extensions: "advanced/Extensions.md"
53-
- Rendering: "advanced/rendering.md"
5453
# - APIRoute and environment variables: "advanced/APIRoute_and_environment_variables.md"
5554

5655
- Packages:

docs/src/intro.md

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

docs/src/advanced/Algorithms.md renamed to docs/src/user_guide/algorithms.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,22 @@ We added a set of custom algorithms:
88

99
- `hillshade`: Create hillshade from elevation dataset (parameters: azimuth (45), angle_altitude(45))
1010
- `contours`: Create contours lines (raster) from elevation dataset (parameters: increment (35), thickness (1))
11-
- `slope`: Create degrees of slope from elevation dataset
11+
- `slope`: Create degrees of slope from elevation dataset
1212
- `terrarium`: [Mapzen's format]((https://github.com/tilezen/joerd/blob/master/docs/formats.md#terrarium)) to encode elevation value in RGB values `elevation = (red * 256 + green + blue / 256) - 32768`
1313
- `terrainrgb`: [Mapbox](https://docs.mapbox.com/data/tilesets/guides/access-elevation-data/)/[Maptiler](https://docs.maptiler.com/guides/map-tilling-hosting/data-hosting/rgb-terrain-by-maptiler/)'s format to encode elevation value in RGB values `elevation = -10000 + ((red * 256 * 256 + green * 256 + blue) * 0.1)`
1414
- `normalizedIndex`: Normalized Difference Index (e.g NDVI)
1515
- `cast`: Cast data to integer
1616
- `floor`: Round data to the smallest integer
1717
- `ceil`: Round data to the largest integer
1818

19+
- `min`: Return **Min** values along the `bands` axis.
20+
- `max`: Return **Max** values along the `bands` axis.
21+
- `median`: Return **Median** values along the `bands` axis.
22+
- `mean`: Return **Mean** values along the `bands` axis.
23+
- `std`: Return the **Standard Deviation** along the `bands` axis.
24+
- `var`: Return **Variance** along the `bands` axis.
25+
26+
1927
### Usage
2028

2129
```python
File renamed without changes.

docs/src/getting_started_with_titiler.md renamed to docs/src/user_guide/getting_started.md

Lines changed: 101 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Static tiles are like pre-printed map pieces stored in folders. Once created, th
1010

1111
TiTiler's dynamic tiles work like a chef cooking to order. When someone views your map, TiTiler grabs just the data needed and creates tiles on the spot. This lets you instantly change colors, adjust contrast, or highlight different features. Your map becomes flexible and responsive, adapting to what users need right now rather than being stuck with choices made earlier.
1212

13+
More on [Dynamic Tiling](dynamic_tiling.md)
14+
1315
## Let's Get TiTiler Up and Running!
1416

1517
Now that we understand the advantage of TiTiler's dynamic approach, let's get it running on your local machine. Follow these steps:
@@ -102,7 +104,7 @@ uvicorn main:app --reload
102104
```
103105
You should see output similar to this:
104106
105-
![server logs](img/server_logs.png)
107+
![server logs](../img/server_logs.png)
106108
107109
> 💡 **The `--reload` flag** automatically restarts the server whenever you change your code - perfect for development!
108110
@@ -112,11 +114,11 @@ Open your browser and go to:
112114
113115
``` http://127.0.0.1:8000/ ``` - See your welcome message
114116
115-
![browser](img/browser.png)
117+
![browser](../img/browser.png)
116118
117119
``` http://127.0.0.1:8000/docs ``` - Explore the interactive API documentation. The `/docs` page is your mission control center. It shows all the endpoints TiTiler created for you and lets you test them directly in your browser:
118120
119-
![api docs](img/api_docs.png)
121+
![api docs](../img/api_docs.png)
120122
121123
## Visualizing Your Geospatial Data
122124
@@ -182,6 +184,8 @@ URL components explained:
182184
- **`.png`**: Output format (alternatives: `.jpg`, `.webp`, `.tif`)
183185
- **`?url=raster.tif`**: Source raster file
184186

187+
More on [Tiling Schemes](tile_matrix_sets.md)
188+
185189
### **Creating a Web Map with Leaflet**
186190

187191
[Leaflet](https://leafletjs.com/) is a lightweight, open-source JavaScript library for interactive maps. It lets you combine base maps (like OpenStreetMap) with overlays from custom tile servers such as TiTiler.
@@ -280,3 +284,97 @@ If your map loads but your tiles don't appear:
280284
281285
---
282286
*Created by [Dimple Jain](https://jaiindimple.github.io)*
287+
288+
289+
## Default Application
290+
291+
`TiTiler` comes with a default (complete) application with support for COG, STAC, and MosaicJSON. You can install and start the application locally by doing:
292+
293+
```bash
294+
# Update pip
295+
python -m pip install -U pip
296+
297+
# Install titiler packages
298+
python -m pip install uvicorn titiler.application
299+
300+
# Start application using uvicorn
301+
uvicorn titiler.application.main:app
302+
303+
> INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
304+
```
305+
306+
See default endpoints documentation pages:
307+
308+
* [`/cog` - Cloud Optimized GeoTIFF](../endpoints/cog.md)
309+
* [`/mosaicjson` - MosaicJSON](../endpoints/mosaic.md)
310+
* [`/stac` - Spatio Temporal Asset Catalog](../endpoints/stac.md)
311+
* [`/tileMatrixSets` - Tiling Schemes](../endpoints/tms.md)
312+
* [`/algorithms` - Algorithms](../endpoints/algorithms.md)
313+
* [`/colorMaps` - ColorMaps](../endpoints/colormaps.md)
314+
315+
#### Settings
316+
317+
The default application can be customized using environment variables defined in `titiler.application.settings.ApiSettings` class. Each variable needs to be prefixed with `TITILER_API_`.
318+
319+
- `NAME` (str): name of the application. Defaults to `titiler`.
320+
- `CORS_ORIGINS` (str, `,` delimited origins): allowed CORS origin. Defaults to `*`.
321+
- `CORS_ALLOW_METHODS` (str, `,` delimited methods): allowed CORS methods. Defaults to `GET`.
322+
- `CACHECONTROL` (str): Cache control header to add to responses. Defaults to `"public, max-age=3600"`.
323+
- `ROOT_PATH` (str): path behind proxy.
324+
- `DEBUG` (str): adds `LoggerMiddleware` and `TotalTimeMiddleware` in the middleware stack.
325+
- `DISABLE_COG` (bool): disable `/cog` endpoints.
326+
- `DISABLE_STAC` (bool): disable `/stac` endpoints.
327+
- `DISABLE_MOSAIC` (bool): disable `/mosaic` endpoints.
328+
- `LOWER_CASE_QUERY_PARAMETERS` (bool): transform all query-parameters to lower case (see https://github.com/developmentseed/titiler/pull/321).
329+
- `GLOBAL_ACCESS_TOKEN` (str | None): a string which is required in the `?access_token=` query param with every request.
330+
331+
332+
#### Extending TiTiler's app
333+
334+
If you want to include all of Titiler's built-in endpoints, but also include
335+
customized endpoints, you can import and extend the app directly.
336+
337+
```bash
338+
python -m pip install titiler.application uvicorn # also installs titiler.core and titiler.mosaic
339+
```
340+
341+
These can then be used like:
342+
343+
344+
```py
345+
# Add private COG endpoints requiring token validation
346+
from fastapi import APIRouter, Depends, HTTPException, Security
347+
from fastapi.security.api_key import APIKeyQuery
348+
349+
from titiler.application.main import app
350+
from titiler.core.factory import TilerFactory
351+
352+
import uvicorn
353+
354+
api_key_query = APIKeyQuery(name="access_token", auto_error=False)
355+
356+
357+
def token_validation(access_token: str = Security(api_key_query)):
358+
"""stupid token validation."""
359+
if not access_token:
360+
raise HTTPException(status_code=401, detail="Missing `access_token`")
361+
362+
# if access_token == `token` then OK
363+
if not access_token == "token":
364+
raise HTTPException(status_code=401, detail="Invalid `access_token`")
365+
366+
return True
367+
368+
369+
# Custom router with token dependency
370+
router = APIRouter(dependencies=[Depends(token_validation)])
371+
tiler = TilerFactory(router_prefix="private/cog", router=router)
372+
373+
app.include_router(tiler.router, prefix="/private/cog", tags=["Private"])
374+
375+
376+
if __name__ == '__main__':
377+
uvicorn.run(app=app, host="127.0.0.1", port=8080, log_level="info")
378+
```
379+
380+
More on [customization](../advanced/customization.md)
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)