From 67caf16b14df03537c134e0afca671eb59f1c416 Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Wed, 2 Jun 2021 23:06:29 +0200 Subject: [PATCH] Draw azimuth/distance lines above Maidenhead grid Also, the azimuth/distance lines and their labels are now put in their own group. --- qsomap.py | 78 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/qsomap.py b/qsomap.py index ff3c374..a2ce520 100755 --- a/qsomap.py +++ b/qsomap.py @@ -326,42 +326,6 @@ def render(ref_lat, ref_lon, output_stream): group.set_desc(title=v['name']) 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) group = doc.g() @@ -405,7 +369,47 @@ def render(ref_lat, ref_lon, output_stream): **{'class': 'maidenhead_label', '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):