Draw azimuth/distance lines above Maidenhead grid

Also, the azimuth/distance lines and their labels are now put in their
own group.
This commit is contained in:
Thomas Kolb 2021-06-02 23:06:29 +02:00
parent 1261e682b5
commit 67caf16b14

View file

@ -326,42 +326,6 @@ def render(ref_lat, ref_lon, output_stream):
group.set_desc(title=v['name']) group.set_desc(title=v['name'])
doc.add(group) doc.add(group)
# generate equidistant circles
d_max = 40075/2
for distance in [500, 1000, 2000, 3000, 4000, 5000, 6000, 8000, 10000,
12000, 14000, 16000, 18000, 20000]:
r = R * distance / d_max
doc.add(doc.circle(center=(R, R), r=r,
**{'class': 'dist_circle'}))
doc.add(doc.text(f"{distance} km", (R, R-r+5),
**{'class': 'dist_circle_label'}))
# generate azimuth lines in 30° steps
for azimuth in np.arange(0, np.pi, np.pi/6):
start_x = R + R * np.cos(azimuth-np.pi/2)
start_y = R + R * np.sin(azimuth-np.pi/2)
end_x = R - R * np.cos(azimuth-np.pi/2)
end_y = R - R * np.sin(azimuth-np.pi/2)
doc.add(doc.line((start_x, start_y), (end_x, end_y),
**{'class': 'azimuth_line'}))
azimuth_deg = int(np.round(azimuth * 180 / np.pi))
textpos = (2*R - 10, R - 2)
txt = doc.text(f"{azimuth_deg:d} °", textpos,
**{'class': 'azimuth_line_label'})
txt.rotate(azimuth_deg - 90, center=(R, R))
doc.add(txt)
txt = doc.text(f"{azimuth_deg+180:d} °", textpos,
**{'class': 'azimuth_line_label'})
txt.rotate(azimuth_deg - 90 + 180, center=(R, R))
doc.add(txt)
# generate Maidenhead locator grid (first two letters only) # generate Maidenhead locator grid (first two letters only)
group = doc.g() group = doc.g()
@ -405,7 +369,47 @@ def render(ref_lat, ref_lon, output_stream):
**{'class': 'maidenhead_label', **{'class': 'maidenhead_label',
'font-size': font_size})) 'font-size': font_size}))
doc.add(group) doc.add(group) # Maidenhead grid
group = doc.g()
# generate equidistant circles
d_max = 40075/2
for distance in [500, 1000, 2000, 3000, 4000, 5000, 6000, 8000, 10000,
12000, 14000, 16000, 18000, 20000]:
r = R * distance / d_max
group.add(doc.circle(center=(R, R), r=r,
**{'class': 'dist_circle'}))
group.add(doc.text(f"{distance} km", (R, R-r+5),
**{'class': 'dist_circle_label'}))
# generate azimuth lines in 30° steps
for azimuth in np.arange(0, np.pi, np.pi/6):
start_x = R + R * np.cos(azimuth-np.pi/2)
start_y = R + R * np.sin(azimuth-np.pi/2)
end_x = R - R * np.cos(azimuth-np.pi/2)
end_y = R - R * np.sin(azimuth-np.pi/2)
group.add(doc.line((start_x, start_y), (end_x, end_y),
**{'class': 'azimuth_line'}))
azimuth_deg = int(np.round(azimuth * 180 / np.pi))
textpos = (2*R - 10, R - 2)
txt = doc.text(f"{azimuth_deg:d} °", textpos,
**{'class': 'azimuth_line_label'})
txt.rotate(azimuth_deg - 90, center=(R, R))
group.add(txt)
txt = doc.text(f"{azimuth_deg+180:d} °", textpos,
**{'class': 'azimuth_line_label'})
txt.rotate(azimuth_deg - 90 + 180, center=(R, R))
group.add(txt)
doc.add(group) # Circles, azimuth lines and labels
""" """
for x in range(0, 26): for x in range(0, 26):