Preserve native orthophoto detail for training
This commit is contained in:
@@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from .operations import VectorSelectionBBox
|
||||
|
||||
@@ -12,6 +12,7 @@ class OrthophotoAcquireRequest(BaseModel):
|
||||
area_id: UUID | None = None
|
||||
product_key: str = "most_recent"
|
||||
force_refresh: bool = False
|
||||
resolution_m: float | None = Field(default=None, ge=0.1, le=2.0)
|
||||
|
||||
|
||||
class OrthophotoProductRead(BaseModel):
|
||||
|
||||
@@ -262,8 +262,16 @@ class OrthophotoAcquisitionService:
|
||||
status_code=422,
|
||||
)
|
||||
|
||||
width = max(1, math.ceil(width_m / settings.orthophoto_resolution_m))
|
||||
height = max(1, math.ceil(height_m / settings.orthophoto_resolution_m))
|
||||
resolution_m = float(payload.resolution_m or settings.orthophoto_resolution_m)
|
||||
if resolution_m < product.native_resolution_m:
|
||||
raise AppError(
|
||||
code="ORTHOPHOTO_RESOLUTION_EXCEEDS_SOURCE",
|
||||
message="Requested sampling cannot be finer than the governed source resolution",
|
||||
details={"requested_resolution_m": resolution_m, "native_resolution_m": product.native_resolution_m},
|
||||
status_code=422,
|
||||
)
|
||||
width = max(1, math.ceil(width_m / resolution_m))
|
||||
height = max(1, math.ceil(height_m / resolution_m))
|
||||
bbox_4326 = [min_x, min_y, max_x, max_y]
|
||||
bbox_31370 = [float(value) for value in lambert_bounds]
|
||||
request_identity = {
|
||||
@@ -275,14 +283,14 @@ class OrthophotoAcquisitionService:
|
||||
"bbox_epsg31370": [round(value, 3) for value in bbox_31370],
|
||||
"width": width,
|
||||
"height": height,
|
||||
"resolution_m": settings.orthophoto_resolution_m,
|
||||
"resolution_m": resolution_m,
|
||||
}
|
||||
request_hash = hashlib.sha256(json.dumps(request_identity, sort_keys=True).encode("utf-8")).hexdigest()
|
||||
spatial_identity = {
|
||||
"bbox_epsg4326": request_identity["bbox_epsg4326"],
|
||||
"width": width,
|
||||
"height": height,
|
||||
"resolution_m": settings.orthophoto_resolution_m,
|
||||
"resolution_m": resolution_m,
|
||||
}
|
||||
spatial_hash = hashlib.sha256(json.dumps(spatial_identity, sort_keys=True).encode("utf-8")).hexdigest()
|
||||
params = {
|
||||
@@ -522,7 +530,7 @@ class OrthophotoAcquisitionService:
|
||||
layer=product.layer,
|
||||
width=prepared["width"],
|
||||
height=prepared["height"],
|
||||
resolution_m=resolved_settings.orthophoto_resolution_m,
|
||||
resolution_m=float(prepared["resolution_m"]),
|
||||
bbox_epsg4326=prepared["bbox_epsg4326"],
|
||||
bbox_epsg31370=prepared["bbox_epsg31370"],
|
||||
attribution=product.attribution,
|
||||
@@ -561,7 +569,10 @@ class OrthophotoAcquisitionService:
|
||||
"observation_label": product.observation_label,
|
||||
"observation_date_precision": product.temporal_granularity,
|
||||
"native_resolution_m": product.native_resolution_m,
|
||||
"requested_resolution_m": resolved_settings.orthophoto_resolution_m,
|
||||
"requested_resolution_m": float(prepared["resolution_m"]),
|
||||
"observation_time_precision": (
|
||||
"unknown_per_pixel" if product.key == "most_recent" or product.key.endswith("_latest") else "product_period"
|
||||
),
|
||||
"color_mode": product.color_mode,
|
||||
"supports_detection": product.supports_detection,
|
||||
"layer": product.layer,
|
||||
@@ -581,7 +592,7 @@ class OrthophotoAcquisitionService:
|
||||
"bbox_epsg31370": prepared["bbox_epsg31370"],
|
||||
"width": prepared["width"],
|
||||
"height": prepared["height"],
|
||||
"resolution_m": resolved_settings.orthophoto_resolution_m,
|
||||
"resolution_m": float(prepared["resolution_m"]),
|
||||
"limitation_message": product.limitation_message,
|
||||
},
|
||||
)
|
||||
@@ -597,7 +608,7 @@ class OrthophotoAcquisitionService:
|
||||
layer=product.layer,
|
||||
width=prepared["width"],
|
||||
height=prepared["height"],
|
||||
resolution_m=resolved_settings.orthophoto_resolution_m,
|
||||
resolution_m=float(prepared["resolution_m"]),
|
||||
bbox_epsg4326=prepared["bbox_epsg4326"],
|
||||
bbox_epsg31370=prepared["bbox_epsg31370"],
|
||||
attribution=product.attribution,
|
||||
|
||||
Reference in New Issue
Block a user