diff --git a/docker-compose.yml b/docker-compose.yml index dd94776..4cb0267 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,9 +5,9 @@ services: # See https://github.com/developmentseed/titiler/discussions/387 #platform: linux/amd64 # enable `image` if you would like to use Docker image from Github package - # image: ghcr.io/undp-data/titiler-aks:v0.0.2 + image: ghcr.io/undp-data/cogserver:latest # enable `build` if you would like to build Docker image from source code - image: undpgeohub.azurecr.io/cogserver-debug +# image: undpgeohub.azurecr.io/cogserver-debug build: context: . @@ -19,11 +19,11 @@ services: # env_file: # - gdal_rio.env ports: - - 8000:80 -# environment: + - "8000:8000" + environment: # # Application -# - HOST=0.0.0.0 -# - PORT=8000 + - HOST=0.0.0.0 + - PORT=8000 diff --git a/src/cogserver/extensions/vrt.py b/src/cogserver/extensions/vrt.py index a920370..336ee17 100644 --- a/src/cogserver/extensions/vrt.py +++ b/src/cogserver/extensions/vrt.py @@ -41,7 +41,6 @@ async def create_vrt_from_urls( srcNoData = " ".join(srcNoData) options = gdal.BuildVRTOptions( separate=True, - bandList=list(range(1, len(urls) + 1)), xRes=xRes, yRes=yRes, resampleAlg=resamplingAlg, @@ -51,7 +50,8 @@ async def create_vrt_from_urls( ) with tempfile.NamedTemporaryFile() as temp: - gdal.BuildVRT(temp.name, urls, options=options) + ds = gdal.BuildVRT(temp.name, urls, options=options) + ds = None with open(temp.name, "r") as file: file_text = ET.fromstring(file.read()) available_bands = file_text.findall("VRTRasterBand") @@ -70,6 +70,12 @@ async def create_vrt_from_urls( metadata_dict = {} pattern = r"(.*?)=(.*)" + # non-case sensitive description pattern + description_pattern = r"(?i)description=(.*)" + + description_matches = re.findall(description_pattern, dataset_metadata) + if description_matches: + ET.SubElement(source_band, "Description").text = description_matches[0] matches = re.findall(pattern, dataset_metadata) for match in matches: metadata_dict[match[0].strip()] = match[1].strip() @@ -124,21 +130,6 @@ async def create_vrt( yRes: Optional[float] = Query(None, description="Y resolution. Applicable only when `resolution` is `user`") ): - """ - Create a VRT from multiple COGs supplied as URLs - - Args: - urls (List[str]): List of URLs - srcNoData (List[str], optional): Set nodata values for input bands (different values can be supplied for each band). If the option is not specified, the intrinsic nodata settings on the source datasets will be used (if they exist). The value set by this option is written in the NODATA element of each ComplexSource element. Use a value of None to ignore intrinsic nodata settings on the source datasets. Defaults to None. - vrtNoData (List[str], optional): Set nodata values at the VRT band level (different values can be supplied for each band). If the option is not specified, intrinsic nodata settings on the first dataset will be used (if they exist). The value set by this option is written in the NoDataValue element of each VRTRasterBand element. Use a value of None to ignore intrinsic nodata settings on the source datasets. Defaults to None. - resamplingAlg (Literal["nearest", "bilinear", "cubic", "cubicspline", "lanczos", "average", "mode"], optional): Resampling algorithm. Defaults to "nearest". - resolution (Literal["highest", "lowest", "average", "user"], optional): Resolution to use for the resulting VRT. Defaults to "average". - xRes (Optional[float], optional): X resolution. Defaults to None. - yRes (Optional[float], optional): Y resolution. Defaults to None. - - Returns: - Response: VRT XML - """ if len(urls) < 1: return Response("Please provide at least two URLs", status_code=400)