fix: increase sampling density for tiny region detection and show all detected regions

Two critical fixes:

1. **Increase sampling density from 5×5 to 11×11 grid**
   - Previous: 25 sample points across 50px box = ~12.5px spacing
   - New: 121 sample points across 50px box = ~5px spacing
   - Problem: Tiny regions like San Marino (1-2px) were falling between sample
     points and not being detected unless cursor was directly on them
   - Solution: Denser sampling ensures we don't miss sub-5px regions

2. **Show all detected regions in debug panel, not just first 5**
   - Removed .slice(0, 5) limit
   - Added region count to header
   - Needed to see full detection list to diagnose sampling issues

The geometry-based detection introduced this regression because bounding box
detection was catching everything (including empty space), while precise
geometry detection with sparse sampling was missing tiny regions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock 2025-11-25 05:46:04 -06:00
parent 791c7de0d8
commit 2c9f760ae9
2 changed files with 6 additions and 9 deletions

View File

@ -2310,19 +2310,14 @@ export function MapRenderer({
)}
<div style={{ marginTop: '8px', paddingTop: '8px', borderTop: '1px solid #444' }}>
<strong>Detected Regions:</strong>
<strong>Detected Regions ({detectedRegions.length}):</strong>
</div>
{detectedRegions.slice(0, 5).map((region) => (
{detectedRegions.map((region) => (
<div key={region.id} style={{ fontSize: '10px', marginLeft: '8px' }}>
{region.id}: {region.pixelWidth.toFixed(1)}×{region.pixelHeight.toFixed(1)}px
{region.isVerySmall ? ' (SMALL)' : ''}
</div>
))}
{detectedRegions.length > 5 && (
<div style={{ fontSize: '10px', marginLeft: '8px', color: '#888' }}>
...and {detectedRegions.length - 5} more
</div>
)}
<div style={{ marginTop: '8px' }}>
<strong>Current Zoom:</strong> {getCurrentZoom().toFixed(1)}×
</div>

View File

@ -173,8 +173,10 @@ export function useRegionDetection(options: UseRegionDetectionOptions): UseRegio
}
// Bounding box overlaps - now check actual path geometry
// Sample a grid of points within the detection box
const samplesPerSide = 5 // 5×5 = 25 sample points
// Sample a dense grid of points within the detection box
// For 50px box: 11×11 = 121 sample points (every ~5px)
// This ensures we don't miss tiny regions like San Marino (1-2px)
const samplesPerSide = 11
const sampleStep = detectionBoxSize / (samplesPerSide - 1)
let overlaps = false