fix: 加快竞对信号和采样点生成
This commit is contained in:
@@ -8,6 +8,7 @@ from .metrics import grid_metrics_headers
|
||||
from .gpkg import iter_geometry_batches
|
||||
from .raster_math import market_raster_layout
|
||||
from .metrics import metric_row
|
||||
from .raster_math import pixel_center_mask_for_bounds
|
||||
from .raster_math import pixel_center_mask_for_geometry
|
||||
from .raster_math import pixel_window_for_bounds
|
||||
from .raster_math import pixel_window_from_point
|
||||
@@ -191,6 +192,14 @@ def export_market_grid_outputs(
|
||||
candidates += len(batch_rows)
|
||||
intersects_mask = valid_mask & shapely.intersects(market.geometry, geometries)
|
||||
geometry_bounds = shapely.bounds(geometries)
|
||||
widths = geometry_bounds[:, 2] - geometry_bounds[:, 0]
|
||||
heights = geometry_bounds[:, 3] - geometry_bounds[:, 1]
|
||||
bbox_area = widths * heights
|
||||
rectangular = (
|
||||
valid_mask
|
||||
& (shapely.get_num_coordinates(geometries) == 5)
|
||||
& (np.abs(shapely.area(geometries) - bbox_area) <= np.maximum(bbox_area * 1e-6, 1e-18))
|
||||
)
|
||||
for index, row in enumerate(batch_rows):
|
||||
values = dict(zip(fields, row[2:]))
|
||||
numeric_values = {field: to_float(values.get(field)) for field in raster_fields}
|
||||
@@ -255,7 +264,7 @@ def export_market_grid_outputs(
|
||||
exclusion_counts["invalid_rsrp"] += 1
|
||||
continue
|
||||
|
||||
signal_window = pixel_window_for_bounds(
|
||||
signal_window = window if config.CLIP_MODE == "intersects" else pixel_window_for_bounds(
|
||||
geometry_bounds[index],
|
||||
minx,
|
||||
maxy,
|
||||
@@ -267,14 +276,11 @@ def export_market_grid_outputs(
|
||||
if signal_window is None:
|
||||
exclusion_counts["no_center_pixels"] += 1
|
||||
continue
|
||||
geometry_mask = pixel_center_mask_for_geometry(
|
||||
geometries[index],
|
||||
signal_window,
|
||||
minx,
|
||||
maxy,
|
||||
pixel_width,
|
||||
pixel_height,
|
||||
)
|
||||
mask_args = (signal_window, minx, maxy, pixel_width, pixel_height)
|
||||
if rectangular[index]:
|
||||
geometry_mask = pixel_center_mask_for_bounds(geometry_bounds[index], *mask_args)
|
||||
else:
|
||||
geometry_mask = pixel_center_mask_for_geometry(geometries[index], *mask_args)
|
||||
geometry_pixel_count = int(np.count_nonzero(geometry_mask))
|
||||
if geometry_pixel_count == 0:
|
||||
exclusion_counts["no_center_pixels"] += 1
|
||||
|
||||
Reference in New Issue
Block a user