Skip to content

Commit 351ffdd

Browse files
committed
feat: Add TopSky ECL drawer
1 parent 8e1d769 commit 351ffdd

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

mapbuilder/handlers/jinja.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from mapbuilder.utils.geo import brg, fix
1616
from mapbuilder.utils.jinja_fragment_cache import FragmentCacheExtension
1717
from mapbuilder.utils.sidstar import render_sid
18+
from mapbuilder.utils.topsky import ecl
1819

1920

2021
class JinjaHandler:
@@ -44,6 +45,7 @@ def handle(self, item: Path) -> str:
4445
render_sectorlines=render_sectorlines,
4546
sector_sub=sector_sub,
4647
sector_and=sector_and,
48+
ecl=ecl,
4749
)
4850
jinja_env.filters.update(
4951
geoms=geoms,

mapbuilder/utils/topsky.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
def ecl(start: str, bearing: float, count: int, dist: float = 1, start_blank: bool = True):
2+
"""
3+
Generates an extended center line (ECL) based on a starting point, bearing, number of segments,
4+
distance between points, and whether the sequence begins with a blank segment.
5+
6+
Parameters:
7+
start (str): The starting coordinate identifier.
8+
bearing (float): The initial bearing in degrees, used to determine the direction of the line.
9+
count (int): The total number of segments in the resultant line.
10+
dist (float, optional): The distance between consecutive points in the line. Default is 1.
11+
start_blank (bool, optional): Indicates whether to start the sequence with a blank segment. Default is True.
12+
13+
Returns:
14+
str: A concatenated series of coordinate line segments formatted as strings.
15+
"""
16+
lines = []
17+
draw = not start_blank
18+
for idx in range(0, count):
19+
if draw and idx + 1 <= count:
20+
lines.append(f"COORD_PBD:{start}:{bearing}:{dist * idx}")
21+
lines.append(f"COORD_PBD:{start}:{bearing}:{dist * (idx + 1)}")
22+
lines.append("COORDLINE")
23+
24+
draw = not draw
25+
26+
return "\n".join(lines)

0 commit comments

Comments
 (0)