除夕夜俄罗斯的明信片
该示例旨在展示从太空观察俄罗斯时新年假期的可能情景。
我们将建立一个地图,并应用一些主题装饰。
**你准备好了吗?**然后我们将安装一些我们需要的库。:
Pkg.add("GeoJSON")
然后他们必须连接。:
using GeoJSON, Dates, DelimitedFiles, LinearAlgebra
include("$(@__DIR__)/scripts/is_new_year_night.jl");
include("$(@__DIR__)/scripts/lonlat_2_xyz.jl");
include("$(@__DIR__)/scripts/draw_tree.jl");
include("$(@__DIR__)/scripts/draw_firework.jl");
让我们上传初始数据:地图和俄罗斯城市列表(我们创建了自己的地图,主要基于网站的材料<https://data.humdata.org />):
# 阅读具有主题边界的地图
fc = GeoJSON.read( "$(@__DIR__)/Russia_ADM1_0_1_gr.戈伊森" );
# 读取城市数据
города = readdlm("$(@__DIR__)/城市。csv档案源", ',', skipstart=1);
当空间地标建立后,我们会指出时间地标,我们的工程明信片将准备出版。:
# @markdown根据当地时间构建地图?
Время = "现时本地时间" # @param["本地当前时间","选择时区"]
# @markdown或设置相对于莫斯科所需的时区
Часовой_пояс = 2 # @param {type:"slider",min:-2,max:10,step:0.25}
if Время == "现时本地时间"
current_time = now(Dates.UTC)
utc_hours = Dates.hour(current_time) + Dates.minute(current_time) / 60
moscow_hour = utc_hours + 3
midnight_lon = 180.0 - moscow_hour * 15.0
midnight_lon = mod(midnight_lon + 180, 360)
else
utc_hours=9.5-Hour_day
# 本年度变化线
noon_lon = (12 - utc_hours) * 15
midnight_lon = mod(noon_lon + 180, 360) - 180
end
plot(legend=false, bg_color=:white, bg_inside=:white)
# 联邦的主体
for geom in fc.geometry
for subgeom in geom.coordinates
for ring in subgeom
if length(last.(ring)) < 10 continue; end;
x3d, y3d, z3d = lonlat_2_xyz(first.(ring), last.(ring))
plot!(x3d, y3d, z3d, color=rand([:skyblue, :lightseagreen, :darkcyan, :lightslateblue, :indigo]), linewidth=4, label=false)
end
end
end
# if is_new_year_night(current_time) && midnight_lon > 30 && midnight_lon < 190
line_lat_full = range(40, 90, 20)
for (lon_delta, lon_color) = zip([0,0.25,0.5,0.75], [:green3, :lightseagreen, :springgreen, :aquamarine])
line_lon_full = (midnight_lon + lon_delta) .* ones(size(line_lat_full))
x3d_full, y3d_full, z3d_full = lonlat_2_xyz(line_lon_full, line_lat_full)
plot!(x3d_full, y3d_full, z3d_full, color=lon_color, linewidth=8, label=false, alpha=0.6)
end
# end
# 树木及烟花
对于(lon,lat)在zip(Float64.(cities[:,3]),Float64.(城市[:,2]))
if lon < midnight_lon
draw_tree(lon, lat, 0.3)
elseif lon < midnight_lon + 15.0
# 敬礼!
draw_tree(lon+rand()-0.5, lat+rand()-0.5, 0.5)
draw_firework(lon+0.1rand(), lat+0.1rand())
else
draw_tree(lon, lat, 0.5)
end
end
# 工程明信片和普通明信片的主要区别在于图表上存在轴。
plot!(size=(1200, 700), camera=(-180, 25))
要下载图像,请单击<svg viewBox="0 0 1000 1000"class="icon"height="1em"width="1em"><path d="m500 450c-83 0-150-67-150-150 0-83 67-150 150-150 83 0 150 67 150 150 0 83-67 150-150 150z M400 150H-120c-16 0-34 13-39 29l-31 93c-6 15-23 28-40 28h-340c-16 0-34-13-39-28L-31-94c-6-15-23-28-40- 28h-120C-55 0-100-45-100-100v-450c0-55 45-100 100- 100h800c55 0 100 45 100 100v450c0 55-45 100-100 100z m-400-550c-138 0-250 112-250 250 0 138 112 250 250 250 138 0 250-112 250-250 0-138-112-250-250- 250zm365380c-19 0-35 16-35 35 0 19 16 35 35 35 19 0 35-16 35-35 0-19-16-35-35- 35z"变换="矩阵(1 0 0 -1 0 850)"></ 图表右上角的path>。
我们希望这个例子能让你在新的一年里准确地传达你的心情。 新年快乐!