From 3dc9ffc29cab9a7a574c04c7a9b6aace21c5d8fa Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Tue, 10 Oct 2023 13:43:52 +0545 Subject: [PATCH] Made pmtiles and mbtiles support optional --- README.md | 5 +++++ docs/src/installation/configurations.md | 2 ++ src/config.py | 4 ++++ src/validation/models.py | 20 +++++++++++--------- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e08a1296..69dd9bfa 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ | GeoPackage | :heavy_check_mark: | | PGDUMP | :heavy_check_mark: | | GeoJSON | :heavy_check_mark: | + | Pmtiles | :heavy_check_mark: | + | Mbtiles | :heavy_check_mark: | ## Installation @@ -90,6 +92,9 @@ Setup the necessary configurations for Raw Data API from [configurations](./docs Setup config.txt in project root. +## Optional : For Tiles Output +If you opt for tiles output and have ```ENABLE_TILES : True``` in env variable . Make sure you install [Tippecanoe] (https://github.com/mapbox/tippecanoe) + ### Start the Server ``` diff --git a/docs/src/installation/configurations.md b/docs/src/installation/configurations.md index ebb39782..20a05ac4 100644 --- a/docs/src/installation/configurations.md +++ b/docs/src/installation/configurations.md @@ -41,6 +41,7 @@ The following are the different configuration options that are accepted. | `EXPORT_MAX_AREA_SQKM` | `EXPORT_MAX_AREA_SQKM` | `[API_CONFIG]` | `100000` | max area in sq. km. to support for rawdata input | OPTIONAL | | `USE_CONNECTION_POOLING` | `USE_CONNECTION_POOLING` | `[API_CONFIG]` | `false` | Enable psycopg2 connection pooling | OPTIONAL | | `ALLOW_BIND_ZIP_FILTER` | `ALLOW_BIND_ZIP_FILTER` | `[API_CONFIG]` | `true` | Enable zip compression for exports | OPTIONAL | +| `ENABLE_TILES` | `ENABLE_TILES` | `[API_CONFIG]` | `false` | Enable Tile Output (Pmtiles and Mbtiles) | OPTIONAL | | `INDEX_THRESHOLD` | `INDEX_THRESHOLD` | `[API_CONFIG]` | `5000` | Area in sqkm to apply grid/country index filter | OPTIONAL | | `CELERY_BROKER_URL` | `CELERY_BROKER_URL` | `[CELERY]` | `redis://localhost:6379/0` | Redis connection string for the broker | OPTIONAL | | `CELERY_RESULT_BACKEND` | `CELERY_RESULT_BACKEND` | `[CELERY]` | `redis://localhost:6379/0` | Redis connection string for the the result backend | OPTIONAL | @@ -72,6 +73,7 @@ The following are the different configuration options that are accepted. | `EXPORT_PATH` | `[API_CONFIG]` | Yes | Yes | | `EXPORT_MAX_AREA_SQKM` | `[API_CONFIG]` | Yes | No | | `USE_CONNECTION_POOLING` | `[API_CONFIG]` | Yes | Yes | +| `ENABLE_TILES` | `[API_CONFIG]` | Yes | No | | `ALLOW_BIND_ZIP_FILTER` | `[API_CONFIG]` | Yes | Yes | | `INDEX_THRESHOLD` | `[API_CONFIG]` | No | Yes | | `CELERY_BROKER_URL` | TBD | Yes | Yes | diff --git a/src/config.py b/src/config.py index 58b67081..a7b4b621 100644 --- a/src/config.py +++ b/src/config.py @@ -72,6 +72,10 @@ "API_CONFIG", "ALLOW_BIND_ZIP_FILTER", fallback=None ) +ENABLE_TILES = os.environ.get("ENABLE_TILES") or config.get( + "API_CONFIG", "ENABLE_TILES", fallback=None +) + #################### ### EXPORT_UPLOAD CONFIG BLOCK diff --git a/src/validation/models.py b/src/validation/models.py index 2c140937..842f4f02 100644 --- a/src/validation/models.py +++ b/src/validation/models.py @@ -28,7 +28,7 @@ from pydantic import Field, validator from typing_extensions import TypedDict -from src.config import ALLOW_BIND_ZIP_FILTER, EXPORT_MAX_AREA_SQKM +from src.config import ALLOW_BIND_ZIP_FILTER, ENABLE_TILES, EXPORT_MAX_AREA_SQKM def to_camel(string: str) -> str: @@ -50,11 +50,12 @@ class RawDataOutputType(Enum): KML = "kml" SHAPEFILE = "shp" FLATGEOBUF = "fgb" - MBTILES = "mbtiles" # fully experimental for now GEOPACKAGE = "gpkg" PGDUMP = "sql" CSV = "csv" - PMTILES = "pmtiles" ## EXPERIMENTAL + if ENABLE_TILES: + MBTILES = "mbtiles" + PMTILES = "pmtiles" ## EXPERIMENTAL class SupportedFilters(Enum): @@ -181,12 +182,13 @@ class RawDataCurrentParams(RawDataCurrentParamsBase): output_type: Optional[RawDataOutputType] = Field( default=RawDataOutputType.GEOJSON.value, example="geojson" ) - min_zoom: Optional[int] = Field( - default=None, description="Only for mbtiles" - ) # only for if mbtiles is output - max_zoom: Optional[int] = Field( - default=None, description="Only for mbtiles" - ) # only for if mbtiles is output + if ENABLE_TILES: + min_zoom: Optional[int] = Field( + default=None, description="Only for mbtiles" + ) # only for if mbtiles is output + max_zoom: Optional[int] = Field( + default=None, description="Only for mbtiles" + ) # only for if mbtiles is output file_name: Optional[str] = Field(default=None, example="My test export") uuid: Optional[bool] = Field( default=True,