Table of Contents

Class JunctionDetector

Namespace
Map.Rendering.Border
Assembly
MapAssembly.dll

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
object
JunctionDetector

Constructors

JunctionDetector(int, int, Color32[])

public JunctionDetector(int width, int height, Color32[] idPixels)

Parameters

width int
height int
idPixels Color32[]

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)

Parameters

allPolylines Dictionary<(ushort, ushort), List<Vector2>>

All border polylines (will be modified in-place)

junctionPixels Dictionary<Vector2, HashSet<ushort>>

Junction pixels from DetectJunctionPixels()