feat: 采样点透明度范围可在图层行设置
This commit is contained in:
@@ -16,8 +16,6 @@ TABLE = "采样点图层"
|
||||
GEOM = "geom"
|
||||
SRS_ID = 4326
|
||||
FIELDS = ("电联采样点", "广电采样点", "移动采样点", "总采样点数", "rank")
|
||||
OPACITY_MIN = 10.0
|
||||
OPACITY_MAX = 70.0
|
||||
STYLES = Path(__file__).with_name("styles")
|
||||
WGS84 = (
|
||||
'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,'
|
||||
@@ -51,16 +49,18 @@ def export_sample_grid(grid_5g_conn, grid_5g_layer, grid_5g_rtree, grid_4g_conn,
|
||||
}
|
||||
|
||||
|
||||
def opacity_by_total(totals):
|
||||
"""总采样点数的名次映射到 10–70。越多越高,最多为 70;相同数量同一档。"""
|
||||
def opacity_by_total(totals, low=None, high=None):
|
||||
"""总采样点数的名次映射到 low–high。越多越高,最多为 high;相同数量同一档。"""
|
||||
low = config.SAMPLE_OPACITY_MIN if low is None else float(low)
|
||||
high = config.SAMPLE_OPACITY_MAX if high is None else float(high)
|
||||
levels = sorted(set(totals))
|
||||
if not levels:
|
||||
return {}
|
||||
if len(levels) == 1:
|
||||
return {levels[0]: OPACITY_MAX}
|
||||
if len(levels) == 1 or low == high:
|
||||
return {value: high for value in levels}
|
||||
span = len(levels) - 1
|
||||
return {
|
||||
value: OPACITY_MIN + index / span * (OPACITY_MAX - OPACITY_MIN)
|
||||
value: low + index / span * (high - low)
|
||||
for index, value in enumerate(levels)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user