feat: 采样点透明度范围可在图层行设置
This commit is contained in:
+15
@@ -78,6 +78,15 @@ def require_int(params, key, low, high, label):
|
||||
return value
|
||||
|
||||
|
||||
def opacity_percent(value, label):
|
||||
if isinstance(value, bool) or not isinstance(value, (int, float)):
|
||||
raise ValueError(f"{label}必须为数字。")
|
||||
number = float(value)
|
||||
if not 0 <= number <= 100:
|
||||
raise ValueError(f"{label}需在 0 到 100 之间。")
|
||||
return number
|
||||
|
||||
|
||||
def require_float(params, key, low, high, label):
|
||||
value = params.get(key)
|
||||
if isinstance(value, bool) or not isinstance(value, (int, float)):
|
||||
@@ -211,6 +220,12 @@ def prepare_market(raw):
|
||||
params = dict(raw or {})
|
||||
plan = normalize(params.get("OUTPUT_LAYERS"))
|
||||
params["OUTPUT_LAYERS"] = plan
|
||||
low = opacity_percent(params.get("SAMPLE_OPACITY_MIN", 10), "透明度下限")
|
||||
high = opacity_percent(params.get("SAMPLE_OPACITY_MAX", 70), "透明度上限")
|
||||
if low > high:
|
||||
raise ValueError("透明度下限不能大于上限。")
|
||||
params["SAMPLE_OPACITY_MIN"] = low
|
||||
params["SAMPLE_OPACITY_MAX"] = high
|
||||
needed = needed_sources(plan)
|
||||
for key in SOURCES:
|
||||
if key not in needed:
|
||||
|
||||
Reference in New Issue
Block a user