Skip to content

Commit

Permalink
Made pmtiles and mbtiles support optional
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Oct 10, 2023
1 parent 876d891 commit 3dc9ffc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

```
Expand Down
2 changes: 2 additions & 0 deletions docs/src/installation/configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down
4 changes: 4 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 11 additions & 9 deletions src/validation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 3dc9ffc

Please sign in to comment.