Generate azimuth lines and basic Maidenhead locator grid

No text in the grid „squares“ yet.
This commit is contained in:
Thomas Kolb 2021-05-29 21:26:59 +02:00
parent f676af2fde
commit af794b0598
1 changed files with 83 additions and 6 deletions

View File

@ -180,10 +180,7 @@ for k, v in simplegeodata.items():
v['proj_coordinates'] = proj_polys
#print(simplegeodata['AW']['proj_coordinates'])
###print(simplegeodata['DE']['proj_coordinates'])
#debug plot
# generate the SVG
doc = svgwrite.Drawing("/tmp/test.svg", size=(2*R, 2*R))
@ -191,7 +188,26 @@ doc = svgwrite.Drawing("/tmp/test.svg", size=(2*R, 2*R))
doc.defs.add(doc.style("""
.country {
stroke: black;
stroke-width: 0.01;
stroke-width: 0.01px;
}
.dist_circle_label, .azimuth_line_label {
font-size: 3px;
font: sans-serif;
text-anchor: middle;
}
.dist_circle, .azimuth_line {
fill: none;
stroke: black;
stroke-width: 0.1px;
}
.maidenhead_line {
fill: none;
stroke: red;
stroke-width: 0.1px;
opacity: 0.5;
}
"""))
@ -223,8 +239,69 @@ 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, fill='none',
stroke_width=0.1, stroke='black'))
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()
N = 18 # subdivisions of Earth
resolution = 4096
for x in range(0, N):
lon = x * 2 * np.pi / N
lat = np.linspace(-np.pi/2, np.pi/2, resolution)
x, y = map_azimuthal_equidistant(lat, lon, ref_lat, ref_lon, R)
points = np.array([x, y]).T + R
group.add(doc.polyline(points, **{'class': 'maidenhead_line'}))
for y in range(0, N):
lon = np.linspace(-np.pi, np.pi, resolution)
lat = y * np.pi / N - np.pi/2
x, y = map_azimuthal_equidistant(lat, lon, ref_lat, ref_lon, R)
points = np.array([x, y]).T + R
group.add(doc.polyline(points, **{'class': 'maidenhead_line'}))
doc.add(group)
"""
for x in range(0, 26):
for y in range(0, 26):
sectorname = chr(ord('A')+x) + chr(ord('A')+y)
"""
print(f"Saving {doc.filename}")
doc.save(pretty=True)