Pattern

Pattern is the reusable container that sits between the flight-pattern generators and campaign/planning workflows.

  • Pattern generators such as racetrack() and spiral() return Pattern instances.

  • Line-based patterns store ordered FlightLine objects.

  • Waypoint-based patterns store ordered Waypoint objects.

  • compute_flight_plan() accepts Pattern objects directly and expands them into their underlying elements.

  • Campaign assigns stable pattern_id and line_id values when a pattern is added to a campaign.

Pattern class

class Pattern[source]

Bases: object

A named, parameterized pattern within a campaign.

Variables:
  • pattern_id – Stable identifier assigned by the owning Campaign. Empty string for patterns not yet added to a campaign.

  • kind – Generator kind (“rosette”, “racetrack”, “polygon”, “sawtooth”, “spiral”).

  • name – Human-readable name.

  • params – Generator parameters as a plain-JSON-compatible dict (lengths/altitudes in meters). Sufficient to regenerate.

  • lines – Ordered mapping of line_id -> FlightLine for line-based patterns. Empty for waypoint-based patterns.

  • waypoints – Ordered list of Waypoints for continuous patterns. Empty for line-based patterns.

kind: str
name: str
params: dict
pattern_id: str = ''
lines: Dict[str, FlightLine]
waypoints: List[Waypoint]
property is_line_based: bool
property is_waypoint_based: bool
property line_ids: List[str]
elements()[source]

Return the ordered flight lines or waypoints for this pattern.

property entry_waypoint: Waypoint

Waypoint where this pattern’s traversal begins.

For line-based patterns, this is the start of the first leg (self.lines[first_line_id].waypoint1). For waypoint-based patterns, this is the first element of self.waypoints.

Used by the flight-line optimizer to compute transit-in cost when scheduling this pattern in a sortie.

Raises:

HyPlanValueError – If the pattern has no elements (empty lines and empty waypoints).

property exit_waypoint: Waypoint

Waypoint where this pattern’s traversal ends.

For line-based patterns, this is the end of the last leg (self.lines[last_line_id].waypoint2). For waypoint-based patterns, this is the last element of self.waypoints.

Used by the flight-line optimizer to compute transit-out cost when scheduling this pattern in a sortie.

Raises:

HyPlanValueError – If the pattern has no elements (empty lines and empty waypoints).

replace_line(line_id, line)[source]

Replace a line in place, preserving its ID and pattern membership.

Return type:

None

Parameters:
to_dict()[source]

Serialize the pattern to a plain JSON-compatible dict.

Return type:

dict

classmethod from_dict(data)[source]

Reconstruct a Pattern from a dict produced by to_dict().

Return type:

Pattern

Parameters:

data (dict)

to_geojson()[source]

Return a GeoJSON FeatureCollection of this pattern’s elements.

Line-based patterns yield one LineString feature per leg (with line_id and pattern_id in properties). Waypoint-based patterns yield one Point feature per waypoint plus one LineString for the connecting track.

Return type:

dict

regenerate(**overrides)[source]

Return a new Pattern by re-invoking the generator with params.

Any keyword overrides are merged into params for the regeneration call. The returned Pattern is not yet added to a campaign; use Campaign.replace_pattern() to swap it in.

Return type:

Pattern

__init__(kind, name, params, pattern_id='', lines=<factory>, waypoints=<factory>)
Parameters:
Return type:

None