Engee documentation
Notebook

A postcard with a view of Russia on New Year's Eve

The example is intended to demonstrate a possible scenario for the New Year holidays when observing Russia from space.

We will build a map and apply some themed decorations.

** Are you ready?** Then we'll install some of the libraries we need.:

In [ ]:
Pkg.add("GeoJSON")

Then they must be connected.:

In [ ]:
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");

Let's upload the initial data: maps and a list of Russian cities (we have created our own map, mainly based on the materials of the website <https://data.humdata.org />):

In [ ]:
# Reading a map with subject boundaries
fc = GeoJSON.read( "$(@__DIR__)/Russia_ADM1_0_1_gr.geojson" );

# Reading city data
города = readdlm("$(@__DIR__)/cities.csv", ',', skipstart=1);

When the spatial landmarks are established, we will indicate the time landmarks and our engineering postcard will be ready for publication.:

In [ ]:
# @markdown To build a map based on local time?
Время = "current local time" # @param ["local current time","select time zone"]

# @markdown Or set the desired time zone relative to Moscow
Часовой_пояс = 2 # @param {type:"slider",min:-2,max:10,step:0.25}

if Время == "current local time"
    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
    # The current year change line
    noon_lon = (12 - utc_hours) * 15
    midnight_lon = mod(noon_lon + 180, 360) - 180
end

plot(legend=false, bg_color=:white, bg_inside=:white)

# Subjects of the Federation
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

# Trees and fireworks
for (lon,lat) in zip(Float64.(cities[:, 3]), Float64.(cities[:, 2]))
    if lon < midnight_lon
        draw_tree(lon, lat, 0.3)
    elseif lon < midnight_lon + 15.0 
        # A salute!
        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

# The main difference between an engineering postcard and a regular one is the presence of axes on the graph.
plot!(size=(1200, 700), camera=(-180, 25))
Out[0]:

To download the image, click </ path> in the upper-right corner of the graph.

We hope that this example will allow you to accurately convey your mood during this New Year's time. Happy New Year!