Persist raster tile CRS metadata
This commit is contained in:
@@ -939,8 +939,13 @@ class RasterOperationsService:
|
||||
|
||||
manifest_tiles: list[dict[str, Any]] = []
|
||||
tile_paths: list[str] = []
|
||||
source_crs: str | None = None
|
||||
|
||||
with rasterio.open(dataset.storage_path) as source:
|
||||
raw_source_crs = getattr(source, "crs", None)
|
||||
source_crs = raw_source_crs.to_string() if hasattr(raw_source_crs, "to_string") else (
|
||||
str(raw_source_crs) if raw_source_crs else dataset.crs
|
||||
)
|
||||
source_count = getattr(source, "count", 0)
|
||||
if not source_count:
|
||||
source_count = 1
|
||||
@@ -981,6 +986,7 @@ class RasterOperationsService:
|
||||
"pixel_window": [int(xoff), int(yoff), int(tile_width), int(tile_height)],
|
||||
"bounds": RasterOperationsService._window_bounds_to_list(bounds),
|
||||
"transform": [float(item) for item in transform.to_gdal()],
|
||||
"crs": source_crs,
|
||||
"index": tile_index,
|
||||
},
|
||||
)
|
||||
@@ -994,10 +1000,14 @@ class RasterOperationsService:
|
||||
except AppError:
|
||||
source_metadata = {"bounds": [0.0, 0.0, 0.0, 0.0]}
|
||||
bounds = source_metadata.get("bounds", [0.0, 0.0, 0.0, 0.0])
|
||||
manifest_crs = source_crs or source_metadata.get("crs") or dataset.crs
|
||||
manifest_payload = {
|
||||
"tile_set_id": tile_set_id,
|
||||
"source_dataset_id": str(dataset.id),
|
||||
"source_raster_id": str(dataset.id),
|
||||
"crs": manifest_crs,
|
||||
"source_crs": manifest_crs,
|
||||
"dataset_crs": dataset.crs,
|
||||
"bounds": [float(value) for value in bounds],
|
||||
"tile_size": int(tile_size),
|
||||
"overlap": int(overlap),
|
||||
|
||||
Reference in New Issue
Block a user