Add Maidenhead grid labels

This commit is contained in:
Thomas Kolb 2021-06-02 22:54:49 +02:00
parent 7af8680e28
commit 1261e682b5

View file

@ -280,6 +280,15 @@ def render(ref_lat, ref_lon, output_stream):
stroke-width: 0.1px;
opacity: 0.5;
}
.maidenhead_label {
font-family: sans-serif;
dominant-baseline: middle;
text-anchor: middle;
fill: red;
opacity: 0.25;
}
"""))
doc.add(doc.circle(center=(R, R), r=R, fill='#ddeeff',
@ -378,6 +387,24 @@ def render(ref_lat, ref_lon, output_stream):
group.add(doc.polyline(points, **{'class': 'maidenhead_line'}))
for x in range(0, N):
for y in range(0, N):
sectorname = chr(ord('A') + (x + N//2) % N) \
+ chr(ord('A') + y)
lon = (x + 0.5) * 2 * np.pi / N
lat = (y + 0.5) * np.pi / N - np.pi/2
tx, ty = map_azimuthal_equidistant(lat, lon, ref_lat, ref_lon, R)
font_size = 10
if y == 0 or y == N-1:
font_size = 3
group.add(doc.text(sectorname, (tx + R, ty + R),
**{'class': 'maidenhead_label',
'font-size': font_size}))
doc.add(group)
"""