Code formatting; minor fixes
This commit is contained in:
parent
a9f987c079
commit
85b3742c43
38
qsomap.py
38
qsomap.py
|
@ -140,17 +140,6 @@ def svg_make_inverse_country_path(doc, map_radius, polygon, **kwargs):
|
|||
def render(ref_lat, ref_lon, output_stream):
|
||||
random.seed(0)
|
||||
|
||||
""" Test code
|
||||
test_lat = [np.pi/2, np.pi/4, 0, -np.pi/4, -np.pi/2]
|
||||
test_lon = np.arange(-np.pi, np.pi, np.pi/4)
|
||||
|
||||
for lat in test_lat:
|
||||
for lon in test_lon:
|
||||
x, y = map_azimuthal_equidistant(np.array([lat]), np.array([lon]), np.pi/2, 0)
|
||||
|
||||
print(f"{lat*180/np.pi:6.3f}, {lon*180/np.pi:6.3f} => {x[0]:6.3f}, {y[0]:6.3f}", file=sys.stderr)
|
||||
"""
|
||||
|
||||
print("Loading Geodata…", file=sys.stderr)
|
||||
|
||||
with open('geo-countries/data/countries.geojson', 'r') as jfile:
|
||||
|
@ -159,11 +148,13 @@ def render(ref_lat, ref_lon, output_stream):
|
|||
print("Finding boundaries…", file=sys.stderr)
|
||||
|
||||
# key: 3-letter country identifier
|
||||
# data: {full_name, numpy.array(coordinates), numpy.array(proj_coordinates)}.
|
||||
# coordinates is a list of 2xN arrays, where N is the number of points. Row 0
|
||||
# contains the longitude, Row 1 the latitude.
|
||||
# proj_coordinates is a list of 2xN arrays, where N is the number of points.
|
||||
# Row 0 contains the projected x, Row 1 the projected y.
|
||||
# data: {full_name,
|
||||
# numpy.array(coordinates),
|
||||
# numpy.array(proj_coordinates)}.
|
||||
# coordinates is a list of 2xN arrays, where N is the number of points.
|
||||
# Row 0 contains the longitude, Row 1 the latitude.
|
||||
# proj_coordinates is a list of 2xN arrays, where N is the number of
|
||||
# points. Row 0 contains the projected x, Row 1 the projected y.
|
||||
simplegeodata = {}
|
||||
|
||||
features = geojson['features']
|
||||
|
@ -311,10 +302,11 @@ def render(ref_lat, ref_lon, output_stream):
|
|||
|
||||
if is_point_in_polygon((antipodal_lon, antipodal_lat),
|
||||
v['coordinates'][i].T):
|
||||
print("!!! Found polygon containing the antipodal point!")
|
||||
obj = svg_make_inverse_country_path(doc, R, np.flipud(points), **{
|
||||
'class': 'country',
|
||||
'fill': color})
|
||||
print("!!! Found polygon containing the antipodal point!",
|
||||
file=sys.stderr)
|
||||
obj = svg_make_inverse_country_path(doc, R, np.flipud(points),
|
||||
**{'class': 'country',
|
||||
'fill': color})
|
||||
else:
|
||||
obj = doc.polygon(points, **{
|
||||
'class': 'country',
|
||||
|
@ -328,8 +320,8 @@ def render(ref_lat, ref_lon, output_stream):
|
|||
# generate equidistant circles
|
||||
|
||||
d_max = 40075/2
|
||||
for distance in [500, 1000, 2000, 3000, 4000, 5000, 6000, 8000, 10000, 12000,
|
||||
14000, 16000, 18000, 20000]:
|
||||
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'}))
|
||||
|
@ -394,7 +386,7 @@ def render(ref_lat, ref_lon, output_stream):
|
|||
sectorname = chr(ord('A')+x) + chr(ord('A')+y)
|
||||
"""
|
||||
|
||||
print(f"Writing output…", file=sys.stderr)
|
||||
print("Writing output…", file=sys.stderr)
|
||||
doc.write(output_stream, pretty=True)
|
||||
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue