Class JunctionDetector
Detects junction pixels (where 3+ provinces meet) and snaps polyline endpoints to them Extracted from BorderCurveExtractor for single responsibility
Contains logic for:
- Junction pixel detection (3+ provinces meeting at a point)
- Endpoint snapping with spatial grid optimization (O(n) performance)
- Degenerate loop prevention (same polyline endpoints)
public class JunctionDetector
- Inheritance
-
objectJunctionDetector
Constructors
JunctionDetector(int, int, Color32[])
public JunctionDetector(int width, int height, Color32[] idPixels)
Parameters
widthintheightintidPixelsColor32[]
Methods
DetectJunctionPixels()
Detect junction pixels where 3+ provinces meet These are critical connection points for border polylines
public Dictionary<Vector2, HashSet<ushort>> DetectJunctionPixels()
Returns
- Dictionary<Vector2, HashSet<ushort>>
SnapPolylineEndpointsAtJunctions(Dictionary<(ushort, ushort), List<Vector2>>, Dictionary<Vector2, HashSet<ushort>>)
Snap polyline endpoints to nearby junctions using spatial grid optimization Prevents small gaps where borders should meet at junction points
public void SnapPolylineEndpointsAtJunctions(Dictionary<(ushort, ushort), List<Vector2>> allPolylines, Dictionary<Vector2, HashSet<ushort>> junctionPixels)