Various fixes

This commit is contained in:
Andras Schmelczer 2026-02-04 22:29:42 +00:00
parent 34a4d0ba86
commit 55598aaaa0
14 changed files with 1250 additions and 130 deletions

View file

@ -33,24 +33,19 @@ impl GridIndex {
};
}
// Single pass: compute min/max bounds and count items per cell
let mut min_lat = f32::INFINITY;
let mut max_lat = f32::NEG_INFINITY;
let mut min_lon = f32::INFINITY;
let mut max_lon = f32::NEG_INFINITY;
for index in 0..lat.len() {
if lat[index] < min_lat {
min_lat = lat[index];
}
if lat[index] > max_lat {
max_lat = lat[index];
}
if lon[index] < min_lon {
min_lon = lon[index];
}
if lon[index] > max_lon {
max_lon = lon[index];
}
let la = lat[index];
let lo = lon[index];
if la < min_lat { min_lat = la; }
if la > max_lat { max_lat = la; }
if lo < min_lon { min_lon = lo; }
if lo > max_lon { max_lon = lo; }
}
min_lat -= cell_size;
@ -70,7 +65,7 @@ impl GridIndex {
"Building grid index (CSR)"
);
// First pass: count items per cell
// Count items per cell (now we know the bounds)
let mut counts = vec![0u32; num_cells];
for index in 0..lat.len() {
let grid_row = ((lat[index] - min_lat) / cell_size) as usize;