Skip to content

Commit

Permalink
Merge pull request #173 from wri/update-dist-alerts-dataset
Browse files Browse the repository at this point in the history
update dataset name; allow test datasets
  • Loading branch information
solomon-negusse authored Nov 11, 2024
2 parents bd534de + 4a53264 commit df7b40a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
13 changes: 10 additions & 3 deletions app/routes/titiler/umd_glad_dist_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

router = APIRouter()

# TODO: update to the actual dataset when ready
DATASET = "dan_test"
DATASET = "umd_glad_dist_alerts"

today = date.today()

Expand All @@ -30,8 +29,16 @@
tags=["Raster Tiles"],
response_description="PNG Raster Tile",
)
@router.get(
"/{dataset}/{version}/titiler/{z}/{x}/{y}.png", # for testing datasets - hidden from docs.
response_class=Response,
tags=["Raster Tiles"],
response_description="PNG Raster Tile",
include_in_schema=False,
)
async def glad_dist_alerts_raster_tile(
*,
dataset: str = DATASET,
version,
xyz: Tuple[int, int, int] = Depends(raster_xyz),
start_date: Optional[str] = Query(
Expand Down Expand Up @@ -71,7 +78,7 @@ async def glad_dist_alerts_raster_tile(

tile_x, tile_y, zoom = xyz
bands = ["default", "intensity"]
folder: str = f"s3://{DATA_LAKE_BUCKET}/{DATASET}/{version}/raster/epsg-4326/cog"
folder: str = f"s3://{DATA_LAKE_BUCKET}/{dataset}/{version}/raster/epsg-4326/cog"
with AlertsReader(input=folder) as reader:
# NOTE: the bands in the output `image_data` array will be in the order of
# the input `bands` list
Expand Down
28 changes: 27 additions & 1 deletion terraform/modules/content_delivery_network/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ resource "aws_cloudfront_distribution" "tiles" {
}
}

# send all Titiler requests to tile cache app
# send all generic Titiler requests to tile cache app
ordered_cache_behavior {
allowed_methods = local.methods
cached_methods = local.methods
Expand Down Expand Up @@ -455,6 +455,32 @@ resource "aws_cloudfront_distribution" "tiles" {
}
}

# pass requests for DIST alerts test datasets to tile cache app
ordered_cache_behavior {
allowed_methods = local.methods
cached_methods = local.methods
target_origin_id = "dynamic"
compress = true
path_pattern = "*/titiler/*"
default_ttl = 86400
max_ttl = 86400
min_ttl = 0
smooth_streaming = false
trusted_signers = []
viewer_protocol_policy = "redirect-to-https"

forwarded_values {
headers = local.headers
query_string = true
query_string_cache_keys = []

cookies {
forward = "none"
whitelisted_names = []
}
}
}

# Default static vector tiles are stored on S3
# They won't change and can stay in cache for a year
# We will set response headers for selected tile caches in S3 if required
Expand Down

0 comments on commit df7b40a

Please sign in to comment.