-
Notifications
You must be signed in to change notification settings - Fork 0
BCRS
BCRS (Boundary-Coordinate Raster Solve) implements the full contained-plus-expansion solve—the only family in LIRiAP that combines containment certification with explicit boundary expansion (CABF).
| Variant | Description | Optimization |
|---|---|---|
| Standard | Full BCRS workflow | Standard |
| Fast | Prioritized, limited expensive runs | Trial ranking |
flowchart TD
A[Stage 1: Geometry preparation] --> B[Stage 2: Heuristic candidates]
B --> C[Stage 3: Angle refinement]
C --> D[Stage 4: BCRS boundary-coordinate solve]
D --> E[Stage 5: CABF expansion]
E --> F[Stage 6: Containment certification]
F --> G{Strict certification passes?}
G -- Yes --> H[Stage 7: Select best + output]
G -- No --> I{Fallback enabled?}
I -- Yes --> J[Best-effort certified fallback]
I -- No --> K[No rectangle for feature]
J --> H
BCRS introduces several novel techniques:
Uses polygon vertex coordinates as grid lines rather than uniform spacing. This creates a variable-pitch histogram solver that adapts to the polygon boundary distribution.
After initial BCRS solve, expands each side via coordinate-ascent binary search, clamping to nearest boundary coordinates to avoid floating-point overreach.
The largest-rectangle-in-histogram solver adapts bin spacing based on boundary coordinate distribution rather than uniform grid.
- Trial ranking: orders Stage 3 angles by likelihood
- Limited expensive Stage 4-5 runs: only top candidates proceed to boundary-coordinate solve
- Reuses Stage 3 area cache to reduce repeated computation
- Validate geometry
- Normalize multipart inputs (use largest part)
- Optional precision snapping
- Edge-orientation histogram proposes angles
- Convex-hull upper bound prunes weak directions
- Coarse grid search keeps top-K candidates
- Bounded Brent optimization around each Stage 2 angle
- Finds local optimum near initial candidate
- Rotate polygon to test angle
- Create boundary-coordinate grid from vertex x/y values
- Run variable-pitch histogram solver
- Returns best axis-aligned rectangle at that angle
- Expand each side by coordinate-ascent binary search
- Clamp to nearest boundary coordinates
- Avoids floating-point overreach
- Verify full containment in original polygon frame
- Apply controlled shrink when needed
- Best-effort fallback if strict fails and fallback enabled
- Keep best certified candidate
- Compute ratio/gain/best-effort metadata
- Return rectangle geometry
BCRS is the only algorithm family that combines:
- Containment certification
- Explicit boundary expansion (CABF)
This implements the full target formulation in LIRiAP.
| Parameter | Purpose |
|---|---|
| GRID_COARSE | Initial grid resolution |
| GRID_FINE | Fine grid resolution |
| TOP_K | Candidates for refinement |
| ANGLE_STEP | Fallback sweep step |
| MAX_RATIO | Aspect ratio limit |
| ALWAYS_RETURN | Enable best-effort fallback |
| USE_BUFFER | Apply containment buffer |
| BUFFER_VALUE | Buffer distance |
| Variant | Time @290 | Time @5406 | Scaling |
|---|---|---|---|
| Standard (strict) | 42.91s | 772.05s | 17.99x |
| Standard (fallback) | 42.35s | 788.03s | 18.61x |
| Fast (fallback) | 23.61s | 445.01s | 18.85x |
Best execution mode: Single worker (1w) — parallelization overhead exceeds benefit for this algorithm.
-
area: Rectangle area in CRS map units -
angle: Rotation angle in degrees -
ratio: Aspect ratio (long:short) -
cand_rank: Rank of selected candidate -
s2_gain: Area gain from Stage 2 -
s4_gain: Area gain from Stage 4 (BCRS) -
s5_gain: Area gain from Stage 5 (CABF expansion) -
best_effort: 1 if fallback used, 0 otherwise
- Daniels, K., Milenkovic, V., Roth, D. (1997). Finding the largest axis-aligned rectangle in a polygon. Proc. 13th CCCG.
- Bentley, J.L. (1977). Programming Pearls: Fast Algorithms for Polygon Containment.
- Preparata, F.P., Shamos, M.I. (1985). Computational Geometry: An Introduction.