jekyll-gis-blogger 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +0 -0
- data/README.md +43 -3
- data/lib/jekyll-gis-blogger/assets.rb +0 -0
- data/lib/jekyll-gis-blogger/hooks/table_wrapper.rb +0 -0
- data/lib/jekyll-gis-blogger/photo_journey.rb +168 -0
- data/lib/jekyll-gis-blogger/tags/datatable.rb +0 -0
- data/lib/jekyll-gis-blogger/tags/gpx_track.rb +0 -0
- data/lib/jekyll-gis-blogger/tags/lungkui.rb +112 -33
- data/lib/jekyll-gis-blogger/tags/map.rb +0 -0
- data/lib/jekyll-gis-blogger/tags/storymap.rb +0 -0
- data/lib/jekyll-gis-blogger/utils.rb +0 -0
- data/lib/jekyll-gis-blogger/vendor/assets/gis-blogger/css/icons/vco-icons.eot +0 -0
- data/lib/jekyll-gis-blogger/vendor/assets/gis-blogger/css/icons/vco-icons.svg +0 -0
- data/lib/jekyll-gis-blogger/vendor/assets/gis-blogger/css/icons/vco-icons.ttf +0 -0
- data/lib/jekyll-gis-blogger/vendor/assets/gis-blogger/css/icons/vco-icons.woff +0 -0
- data/lib/jekyll-gis-blogger/vendor/assets/gis-blogger/css/icons/vco-icons.woff2 +0 -0
- data/lib/jekyll-gis-blogger/vendor/assets/gis-blogger/css/lungkui.css +283 -115
- data/lib/jekyll-gis-blogger/vendor/assets/gis-blogger/css/storymap.css +0 -0
- data/lib/jekyll-gis-blogger/vendor/assets/gis-blogger/js/lungkui.js +1100 -139
- data/lib/jekyll-gis-blogger/vendor/assets/gis-blogger/js/storymap-min.js +0 -0
- data/lib/jekyll-gis-blogger.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 681ba2bed3ec01254cd1838b0155873ae4549abd224db4b28b37ea482f524b68
|
|
4
|
+
data.tar.gz: 9543106f1cc60e6b06fa562c78d21db067b8f697d718de0baaa2f0ef30168d09
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cb8c27e97503c74bacb082d25c3aaf604b918a989c0ba30a2c8fb98b4894471a7b85a02fa7b81e68b544a8f8605e9c8b549aeef36eff1d42ecd489d0c84f6cef
|
|
7
|
+
data.tar.gz: d160fc30c70d554277b093649410c1bf6896b9d0c2d972d1bcc75a183709e0cd82e608d62f39ce858ebee508d13522bbd34699f7cc595782a32cdd80c52723b9
|
data/LICENSE
CHANGED
|
File without changes
|
data/README.md
CHANGED
|
@@ -105,9 +105,49 @@ Nothing to copy by hand.
|
|
|
105
105
|
{% lungkui config="/assets/datasets/my_story.lungkui.json" %}
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
-
Options
|
|
108
|
+
Options (all optional):
|
|
109
|
+
|
|
110
|
+
| Option | Default | Meaning |
|
|
111
|
+
|---|---|---|
|
|
112
|
+
| `mode` | `deck` | `deck`: one slide at a time (pager, arrow keys when focused, swipe). `scroll`: the reader scrolls through the panels |
|
|
113
|
+
| `fullpage` | off | `true`: a full-screen story in the page flow (sticky map) instead of a fixed-height box |
|
|
114
|
+
| `height`, `width` | `600px`, `100%` | size of the box (ignored with `fullpage`) |
|
|
115
|
+
| `basemap` | follows the page theme (OpenFreeMap positron/dark) | a lungkui preset (`positron`, `dark`, `liberty`, `bright`, `fiord`, `osm`, `opentopo`) or an XYZ tile URL |
|
|
116
|
+
| `theme` | page CSS | `light`, `dark` or `paper` |
|
|
117
|
+
| `accent` | theme | accent colour |
|
|
118
|
+
| `panel` | `left` | side the panel docks to on wide screens |
|
|
119
|
+
| `route` | `true` | dashed line joining the stops in order |
|
|
120
|
+
| `markers` | `numbered` | `numbered`, `dot` or `none` |
|
|
121
|
+
| `pitch` | `0` | camera tilt for the stops |
|
|
122
|
+
| `center`, `zoom` | first slide | initial view |
|
|
123
|
+
|
|
124
|
+
Narrower than 720px, the panel becomes a bottom sheet under the map. The overview
|
|
125
|
+
slide (`overview: 1`) frames every stop. For areas, legends and data layers, write a
|
|
126
|
+
lungkui config JSON and use `config=`. A site can theme stories with CSS variables
|
|
127
|
+
on `.lk-root` (`--lk-accent`, `--lk-panel-bg`, `--lk-text`, `--lk-font`, ...).
|
|
128
|
+
|
|
129
|
+
Data layers in a `config=` JSON can use lungkui thematic styles (choropleth,
|
|
130
|
+
proportional symbols, categories, heatmap, flows, 3D extrusion, track) with
|
|
131
|
+
auto-legends; see the lungkui README.
|
|
132
|
+
|
|
133
|
+
**Photo story (GPX + geotagged photos):**
|
|
109
134
|
|
|
110
|
-
|
|
135
|
+
```liquid
|
|
136
|
+
{% lungkui gpx="/assets/trip/route.gpx" photos="/assets/trip/photos/" title="Down the river" %}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Each JPEG in `photos=` becomes a slide, in the order it was taken. Its position comes
|
|
140
|
+
from the photo's EXIF GPS; without GPS, its EXIF time is matched to the GPX track's
|
|
141
|
+
timestamps (`time_offset="-3600"` corrects a camera clock that was an hour fast). The
|
|
142
|
+
caption is the EXIF image description, else the file name. The map shows thumbnail
|
|
143
|
+
markers and colours the track up to each photo. Options: `title`, `text` (cover HTML),
|
|
144
|
+
`photo_zoom`, `time_offset`, plus `panel`, `theme`, `basemap`, `accent`, `height`.
|
|
145
|
+
|
|
146
|
+
Privacy: published JPEGs keep their EXIF, GPS included. Strip it from photos of
|
|
147
|
+
sensitive places (homes, nests, rare species) before publishing; the story only needs
|
|
148
|
+
the GPX and the time.
|
|
149
|
+
|
|
150
|
+
Try every variant in the bundled test site (12 example stories): see `example/README.md`.
|
|
111
151
|
|
|
112
152
|
#### Authoring schema
|
|
113
153
|
|
|
@@ -115,7 +155,7 @@ Same GeoJSON field names as storymap (`headline`, `text`, `media`, `caption`, `c
|
|
|
115
155
|
|
|
116
156
|
#### Bundled assets
|
|
117
157
|
|
|
118
|
-
`assets/gis-blogger/js/lungkui.js` and `assets/gis-blogger/css/lungkui.css` ship
|
|
158
|
+
Bundled lungkui.js: **0.2.0** (BSD-3-Clause). `assets/gis-blogger/js/lungkui.js` and `assets/gis-blogger/css/lungkui.css` ship
|
|
119
159
|
with the gem and are copied into your build automatically. MapLibre GL JS is
|
|
120
160
|
loaded from CDN. Nothing to copy by hand.
|
|
121
161
|
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rexml/document"
|
|
4
|
+
require "time"
|
|
5
|
+
|
|
6
|
+
module Jekyll
|
|
7
|
+
module GisBlogger
|
|
8
|
+
# Photo stories: a GPX track plus geotagged photos, read at build time with the
|
|
9
|
+
# standard library only (a small EXIF reader; no gem dependency).
|
|
10
|
+
#
|
|
11
|
+
# A photo is placed by its EXIF GPS position when it has one; otherwise its EXIF
|
|
12
|
+
# time (plus time_offset, for a camera clock that was off) is matched against the
|
|
13
|
+
# track's timestamps and the position interpolated. `progress` (0..1) is how far
|
|
14
|
+
# along the track, by distance, the photo was taken.
|
|
15
|
+
module PhotoJourney
|
|
16
|
+
module_function
|
|
17
|
+
|
|
18
|
+
# ---------------------------------------------------------------- EXIF
|
|
19
|
+
|
|
20
|
+
TAG_DESCRIPTION = 0x010E
|
|
21
|
+
TAG_EXIF_IFD = 0x8769
|
|
22
|
+
TAG_GPS_IFD = 0x8825
|
|
23
|
+
TAG_DATETIME = 0x9003
|
|
24
|
+
TAG_OFFSET = 0x9011
|
|
25
|
+
TYPE_SIZES = { 1 => 1, 2 => 1, 3 => 2, 4 => 4, 5 => 8, 7 => 1, 9 => 4, 10 => 8 }.freeze
|
|
26
|
+
|
|
27
|
+
# { lat:, lon:, time: (UTC Time), caption: } from a JPEG; {} if it has no EXIF.
|
|
28
|
+
def read_exif(path)
|
|
29
|
+
tiff = app1_tiff(File.binread(path))
|
|
30
|
+
return {} unless tiff
|
|
31
|
+
|
|
32
|
+
le = tiff[0, 2] == "II"
|
|
33
|
+
u16 = ->(o) { tiff[o, 2].unpack1(le ? "v" : "n") }
|
|
34
|
+
u32 = ->(o) { tiff[o, 4].unpack1(le ? "V" : "N") }
|
|
35
|
+
ifd0 = read_ifd(tiff, u32.call(4), u16, u32, le)
|
|
36
|
+
exif = ifd0[TAG_EXIF_IFD] ? read_ifd(tiff, ifd0[TAG_EXIF_IFD], u16, u32, le) : {}
|
|
37
|
+
gps = ifd0[TAG_GPS_IFD] ? read_ifd(tiff, ifd0[TAG_GPS_IFD], u16, u32, le) : {}
|
|
38
|
+
|
|
39
|
+
out = {}
|
|
40
|
+
out[:caption] = ifd0[TAG_DESCRIPTION].to_s.strip if ifd0[TAG_DESCRIPTION]
|
|
41
|
+
if gps[2] && gps[4]
|
|
42
|
+
out[:lat] = dms(gps[2]) * (gps[1].to_s.start_with?("S") ? -1 : 1)
|
|
43
|
+
out[:lon] = dms(gps[4]) * (gps[3].to_s.start_with?("W") ? -1 : 1)
|
|
44
|
+
end
|
|
45
|
+
if exif[TAG_DATETIME]
|
|
46
|
+
offset = exif[TAG_OFFSET].to_s[/[+-]\d\d:\d\d/] || "+00:00"
|
|
47
|
+
stamp = exif[TAG_DATETIME].to_s.sub(/\A(\d{4}):(\d\d):(\d\d)/, '\1-\2-\3')
|
|
48
|
+
out[:time] = Time.parse("#{stamp} #{offset}").utc
|
|
49
|
+
end
|
|
50
|
+
out
|
|
51
|
+
rescue StandardError
|
|
52
|
+
{}
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def app1_tiff(bytes)
|
|
56
|
+
return nil unless bytes.byteslice(0, 2) == "\xFF\xD8".b
|
|
57
|
+
|
|
58
|
+
pos = 2
|
|
59
|
+
while pos + 4 <= bytes.bytesize
|
|
60
|
+
marker, len = bytes.byteslice(pos, 4).unpack("nn")
|
|
61
|
+
return nil if (marker & 0xFF00) != 0xFF00 || marker == 0xFFDA
|
|
62
|
+
|
|
63
|
+
seg = bytes.byteslice(pos + 4, len - 2)
|
|
64
|
+
return seg.byteslice(6..) if marker == 0xFFE1 && seg.start_with?("Exif\0\0".b)
|
|
65
|
+
|
|
66
|
+
pos += 2 + len
|
|
67
|
+
end
|
|
68
|
+
nil
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Tag => value for one IFD (ASCII as String, rationals as Float arrays, ints as Integer).
|
|
72
|
+
def read_ifd(tiff, off, u16, u32, little)
|
|
73
|
+
n = u16.call(off)
|
|
74
|
+
(0...n).each_with_object({}) do |i, h|
|
|
75
|
+
e = off + 2 + i * 12
|
|
76
|
+
tag, type = u16.call(e), u16.call(e + 2)
|
|
77
|
+
count = u32.call(e + 4)
|
|
78
|
+
size = TYPE_SIZES.fetch(type, 1) * count
|
|
79
|
+
data = size <= 4 ? e + 8 : u32.call(e + 8)
|
|
80
|
+
h[tag] = case type
|
|
81
|
+
when 2 then tiff[data, count].delete("\0")
|
|
82
|
+
when 3 then count == 1 ? u16.call(data) : (0...count).map { |k| u16.call(data + 2 * k) }
|
|
83
|
+
when 4 then count == 1 ? u32.call(data) : (0...count).map { |k| u32.call(data + 4 * k) }
|
|
84
|
+
when 5, 10
|
|
85
|
+
(0...count).map do |k|
|
|
86
|
+
num, den = tiff[data + 8 * k, 8].unpack(little ? "VV" : "NN")
|
|
87
|
+
den.zero? ? 0.0 : num.to_f / den
|
|
88
|
+
end
|
|
89
|
+
else tiff[data, size]
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def dms(parts)
|
|
95
|
+
d, m, s = Array(parts) + [0, 0, 0]
|
|
96
|
+
d + m / 60.0 + s / 3600.0
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# ----------------------------------------------------------------- GPX
|
|
100
|
+
|
|
101
|
+
# [{ lonlat: [lon, lat], time: Time|nil, dist: metres from start }]
|
|
102
|
+
def read_gpx(text)
|
|
103
|
+
doc = REXML::Document.new(text)
|
|
104
|
+
pts = []
|
|
105
|
+
REXML::XPath.each(doc, "//*[local-name()='trkpt' or local-name()='rtept']") do |p|
|
|
106
|
+
t = p.elements.to_a.find { |c| c.name == "time" }&.text
|
|
107
|
+
pts << { lonlat: [p.attributes["lon"].to_f, p.attributes["lat"].to_f], time: t && Time.parse(t).utc }
|
|
108
|
+
end
|
|
109
|
+
total = 0.0
|
|
110
|
+
pts.each_with_index do |p, i|
|
|
111
|
+
total += haversine(pts[i - 1][:lonlat], p[:lonlat]) if i.positive?
|
|
112
|
+
p[:dist] = total
|
|
113
|
+
end
|
|
114
|
+
pts
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def haversine((lon1, lat1), (lon2, lat2))
|
|
118
|
+
rad = Math::PI / 180
|
|
119
|
+
dlat = (lat2 - lat1) * rad
|
|
120
|
+
dlon = (lon2 - lon1) * rad
|
|
121
|
+
a = Math.sin(dlat / 2)**2 + Math.cos(lat1 * rad) * Math.cos(lat2 * rad) * Math.sin(dlon / 2)**2
|
|
122
|
+
2 * 6_371_000 * Math.asin(Math.sqrt(a))
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# ----------------------------------------------------------- placement
|
|
126
|
+
|
|
127
|
+
# { lonlat:, progress:, source: :gps|:time } or nil when the photo cannot be placed.
|
|
128
|
+
def place(exif, track, time_offset: 0)
|
|
129
|
+
return nil if track.size < 2
|
|
130
|
+
|
|
131
|
+
total = track.last[:dist].to_f
|
|
132
|
+
if exif[:lat] && exif[:lon]
|
|
133
|
+
lonlat = [exif[:lon], exif[:lat]]
|
|
134
|
+
dist = project(lonlat, track)
|
|
135
|
+
return { lonlat: lonlat, progress: total.positive? ? dist / total : 0, source: :gps }
|
|
136
|
+
end
|
|
137
|
+
return nil unless exif[:time] && track.first[:time] && track.last[:time]
|
|
138
|
+
|
|
139
|
+
t = exif[:time] + time_offset
|
|
140
|
+
return nil if t < track.first[:time] || t > track.last[:time]
|
|
141
|
+
|
|
142
|
+
a, b = track.each_cons(2).find { |p, q| t >= p[:time] && t <= q[:time] }
|
|
143
|
+
f = b[:time] == a[:time] ? 0 : (t - a[:time]) / (b[:time] - a[:time])
|
|
144
|
+
lonlat = [0, 1].map { |k| a[:lonlat][k] + (b[:lonlat][k] - a[:lonlat][k]) * f }
|
|
145
|
+
dist = a[:dist] + (b[:dist] - a[:dist]) * f
|
|
146
|
+
{ lonlat: lonlat, progress: total.positive? ? dist / total : 0, source: :time }
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Distance along the track (m) of the point on it closest to lonlat.
|
|
150
|
+
# Planar projection per segment: fine at photo-to-river distances.
|
|
151
|
+
def project(lonlat, track)
|
|
152
|
+
best = [Float::INFINITY, 0.0]
|
|
153
|
+
track.each_cons(2) do |a, b|
|
|
154
|
+
ax, ay = a[:lonlat]
|
|
155
|
+
bx, by = b[:lonlat]
|
|
156
|
+
dx, dy = bx - ax, by - ay
|
|
157
|
+
len2 = dx * dx + dy * dy
|
|
158
|
+
f = len2.zero? ? 0 : ((lonlat[0] - ax) * dx + (lonlat[1] - ay) * dy) / len2
|
|
159
|
+
f = f.clamp(0, 1)
|
|
160
|
+
px, py = ax + dx * f, ay + dy * f
|
|
161
|
+
d2 = (lonlat[0] - px)**2 + (lonlat[1] - py)**2
|
|
162
|
+
best = [d2, a[:dist] + (b[:dist] - a[:dist]) * f] if d2 < best[0]
|
|
163
|
+
end
|
|
164
|
+
best[1]
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
end
|
|
File without changes
|
|
File without changes
|
|
@@ -9,14 +9,16 @@ module Jekyll
|
|
|
9
9
|
include Jekyll::GisBlogger::Utils
|
|
10
10
|
|
|
11
11
|
DEFAULTS = {
|
|
12
|
-
"height"
|
|
13
|
-
"width"
|
|
14
|
-
"mode"
|
|
15
|
-
"zoom"
|
|
16
|
-
"
|
|
17
|
-
"basemap" => "https://tile.openstreetmap.org/{z}/{x}/{y}.png"
|
|
12
|
+
"height" => "600px",
|
|
13
|
+
"width" => "100%",
|
|
14
|
+
"mode" => "deck",
|
|
15
|
+
"zoom" => "6",
|
|
16
|
+
"panel" => "left"
|
|
18
17
|
}.freeze
|
|
19
18
|
|
|
19
|
+
# lungkui.js basemap presets; anything else is treated as an XYZ tile URL.
|
|
20
|
+
BASEMAP_PRESETS = %w[positron dark liberty bright fiord osm opentopo].freeze
|
|
21
|
+
|
|
20
22
|
MAPLIBRE_CSS = "https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.css"
|
|
21
23
|
MAPLIBRE_JS = "https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.js"
|
|
22
24
|
|
|
@@ -42,14 +44,20 @@ module Jekyll
|
|
|
42
44
|
div_id = "lungkui-map-#{count}"
|
|
43
45
|
|
|
44
46
|
config_js = build_config_arg(site, baseurl)
|
|
45
|
-
return warn_html("needs one of: geojson= | config=") unless config_js
|
|
47
|
+
return warn_html("needs one of: geojson= | config= | gpx= with photos=") unless config_js
|
|
46
48
|
|
|
47
49
|
assets = inject_assets_once(page, baseurl)
|
|
48
50
|
|
|
49
51
|
[
|
|
50
52
|
assets,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
# fullpage: a full-screen story in the page flow (sticky map, page scrolls);
|
|
54
|
+
# otherwise a fixed-height box inside the post.
|
|
55
|
+
if truthy(@attrs["fullpage"])
|
|
56
|
+
%(<div id="#{div_id}" class="lk-root"></div>)
|
|
57
|
+
else
|
|
58
|
+
%(<div id="#{div_id}" class="lk-root lk-embed" ) +
|
|
59
|
+
%(style="position:relative;width:#{width};height:#{height};"></div>)
|
|
60
|
+
end,
|
|
53
61
|
%(<script type="module">),
|
|
54
62
|
%(import { Lungkui } from '#{baseurl}/assets/gis-blogger/js/lungkui.js';),
|
|
55
63
|
%(new Lungkui('##{div_id}', #{config_js});),
|
|
@@ -62,40 +70,112 @@ module Jekyll
|
|
|
62
70
|
def build_config_arg(site, baseurl)
|
|
63
71
|
if @attrs["config"]
|
|
64
72
|
inline(parse_config(site, @attrs["config"]))
|
|
73
|
+
elsif @attrs["gpx"] && @attrs["photos"]
|
|
74
|
+
inline(build_photo_config(site, baseurl))
|
|
65
75
|
elsif @attrs["geojson"]
|
|
66
76
|
inline(build_config(site, baseurl))
|
|
67
77
|
end
|
|
68
78
|
end
|
|
69
79
|
|
|
80
|
+
PHOTO_EXT = /\.jpe?g\z/i
|
|
81
|
+
|
|
82
|
+
# Photo story: the GPX track, then one slide per placeable photo in time
|
|
83
|
+
# order. Options: title, text (cover HTML), photo_zoom, time_offset (seconds
|
|
84
|
+
# added to camera times), plus the usual panel/theme/basemap/accent.
|
|
85
|
+
def build_photo_config(site, baseurl)
|
|
86
|
+
pj = Jekyll::GisBlogger::PhotoJourney
|
|
87
|
+
track = pj.read_gpx(read_source(site, @attrs["gpx"]))
|
|
88
|
+
return {} if track.size < 2
|
|
89
|
+
|
|
90
|
+
dir = @attrs["photos"].sub(%r{/*\z}, "/")
|
|
91
|
+
files = Dir.glob(File.join(site.in_source_dir(dir), "*")).select { |f| f.match?(PHOTO_EXT) }
|
|
92
|
+
offset = @attrs["time_offset"].to_i
|
|
93
|
+
shots = files.filter_map do |f|
|
|
94
|
+
exif = pj.read_exif(f)
|
|
95
|
+
placed = pj.place(exif, track, time_offset: offset)
|
|
96
|
+
unless placed
|
|
97
|
+
Jekyll.logger.warn "lungkui:", "#{File.basename(f)}: no GPS and no time on the track, skipped"
|
|
98
|
+
next
|
|
99
|
+
end
|
|
100
|
+
{ file: File.basename(f), exif: exif, placed: placed }
|
|
101
|
+
end
|
|
102
|
+
# Time order when known (that is the journey), else along-track order.
|
|
103
|
+
shots.sort_by! { |s| [s[:exif][:time] ? 0 : 1, s[:exif][:time] || Time.at(0), s[:placed][:progress]] }
|
|
104
|
+
|
|
105
|
+
line = { "type" => "FeatureCollection", "features" => [{
|
|
106
|
+
"type" => "Feature", "properties" => {},
|
|
107
|
+
"geometry" => { "type" => "LineString", "coordinates" => track.map { |p| p[:lonlat].map { |v| v.round(5) } } }
|
|
108
|
+
}] }
|
|
109
|
+
zoom = (@attrs["photo_zoom"] || 10).to_f
|
|
110
|
+
panel = @attrs["panel"] || DEFAULTS["panel"]
|
|
111
|
+
url_dir = absolute?(dir) ? dir : "#{baseurl}#{dir}"
|
|
112
|
+
|
|
113
|
+
slides = [{
|
|
114
|
+
"id" => "cover", "position" => "full", "title" => @attrs["title"].to_s,
|
|
115
|
+
"html" => @attrs["text"].to_s, "camera" => { "fit" => { "layer" => "track" } },
|
|
116
|
+
"progress" => { "layer" => "track", "value" => 0 }, "legend" => ["track"]
|
|
117
|
+
}]
|
|
118
|
+
shots.each_with_index do |s, i|
|
|
119
|
+
caption = s[:exif][:caption].to_s
|
|
120
|
+
title = caption.empty? ? File.basename(s[:file], ".*").tr("_-", " ") : caption
|
|
121
|
+
slides << {
|
|
122
|
+
"id" => "photo-#{i + 1}", "position" => panel, "title" => title,
|
|
123
|
+
"kicker" => s[:exif][:time] ? s[:exif][:time].strftime("%-d %b %Y, %H:%M UTC") : "Photo #{i + 1}",
|
|
124
|
+
"media" => { "url" => "#{url_dir}#{s[:file]}", "caption" => caption },
|
|
125
|
+
"camera" => { "center" => s[:placed][:lonlat].map { |v| v.round(5) }, "zoom" => zoom },
|
|
126
|
+
"progress" => { "layer" => "track", "value" => s[:placed][:progress].round(4) }
|
|
127
|
+
}
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
cfg = {
|
|
131
|
+
"mode" => @attrs["mode"] || DEFAULTS["mode"], "markers" => "photo", "panelSide" => panel,
|
|
132
|
+
"map" => { "center" => track.first[:lonlat], "zoom" => (@attrs["zoom"] || DEFAULTS["zoom"]).to_f },
|
|
133
|
+
"layers" => [{ "id" => "track", "type" => "line",
|
|
134
|
+
"source" => { "geojson" => line, "lineMetrics" => true },
|
|
135
|
+
"style" => { "kind" => "track", "width" => 3.5, "legendLabel" => "Route travelled" } }],
|
|
136
|
+
"slides" => slides
|
|
137
|
+
}
|
|
138
|
+
cfg["map"]["basemap"] = basemap_config(@attrs["basemap"]) if present?(@attrs["basemap"])
|
|
139
|
+
theme = {}
|
|
140
|
+
theme["preset"] = @attrs["theme"] if present?(@attrs["theme"])
|
|
141
|
+
theme["accent"] = @attrs["accent"] if present?(@attrs["accent"])
|
|
142
|
+
cfg["theme"] = theme unless theme.empty?
|
|
143
|
+
cfg
|
|
144
|
+
end
|
|
145
|
+
|
|
70
146
|
def warn_html(reason)
|
|
71
147
|
Jekyll.logger.warn "lungkui:", reason
|
|
72
148
|
"<!-- lungkui: #{reason} -->"
|
|
73
149
|
end
|
|
74
150
|
|
|
75
151
|
def build_config(site, baseurl)
|
|
76
|
-
|
|
77
|
-
slides = slides_from_geojson(read_source(site, geojson_path))
|
|
78
|
-
|
|
79
|
-
geojson_url = absolute?(geojson_path) ? geojson_path : "#{baseurl}#{geojson_path}"
|
|
152
|
+
slides = slides_from_geojson(read_source(site, @attrs["geojson"]))
|
|
80
153
|
center = @attrs["center"] ? @attrs["center"].split(",").map(&:to_f) : default_center(slides)
|
|
81
|
-
|
|
82
|
-
{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"id" => "trail", "type" => "circle",
|
|
93
|
-
"source" => { "geojson" => geojson_url },
|
|
94
|
-
"paint" => { "circle-radius" => 7, "circle-color" => "@accent",
|
|
95
|
-
"circle-stroke-color" => "#fff", "circle-stroke-width" => 2 }
|
|
96
|
-
}],
|
|
97
|
-
"slides" => slides
|
|
154
|
+
|
|
155
|
+
map = { "center" => center, "zoom" => (@attrs["zoom"] || DEFAULTS["zoom"]).to_f }
|
|
156
|
+
map["basemap"] = basemap_config(@attrs["basemap"]) if present?(@attrs["basemap"])
|
|
157
|
+
|
|
158
|
+
config = {
|
|
159
|
+
"mode" => @attrs["mode"] || DEFAULTS["mode"],
|
|
160
|
+
"map" => map,
|
|
161
|
+
"layers" => [], # lungkui draws the numbered stops and the route itself
|
|
162
|
+
"route" => @attrs.key?("route") ? truthy(@attrs["route"]) : true,
|
|
163
|
+
"panelSide" => @attrs["panel"] || DEFAULTS["panel"],
|
|
164
|
+
"slides" => slides
|
|
98
165
|
}
|
|
166
|
+
config["markers"] = @attrs["markers"] if present?(@attrs["markers"])
|
|
167
|
+
theme = {}
|
|
168
|
+
theme["preset"] = @attrs["theme"] if present?(@attrs["theme"])
|
|
169
|
+
theme["accent"] = @attrs["accent"] if present?(@attrs["accent"])
|
|
170
|
+
config["theme"] = theme unless theme.empty?
|
|
171
|
+
config
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# A lungkui preset name passes through; anything else is an XYZ tile URL.
|
|
175
|
+
def basemap_config(value)
|
|
176
|
+
return value if BASEMAP_PRESETS.include?(value)
|
|
177
|
+
|
|
178
|
+
{ "type" => "xyz", "url" => value, "attribution" => "© OpenStreetMap contributors" }
|
|
99
179
|
end
|
|
100
180
|
|
|
101
181
|
def slides_from_geojson(text)
|
|
@@ -133,11 +213,10 @@ module Jekyll
|
|
|
133
213
|
|
|
134
214
|
slide = {
|
|
135
215
|
"id" => "s#{pos}",
|
|
136
|
-
"position" => overview ? "full" : (
|
|
216
|
+
"position" => overview ? "full" : (@attrs["panel"] || DEFAULTS["panel"]),
|
|
137
217
|
"title" => props["headline"].to_s,
|
|
138
218
|
"html" => html,
|
|
139
|
-
"camera" => { "center" => [lon, lat], "zoom" => zoom, "pitch" =>
|
|
140
|
-
"show" => ["trail"]
|
|
219
|
+
"camera" => overview ? { "center" => [lon, lat], "fit" => true } : { "center" => [lon, lat], "zoom" => zoom, "pitch" => (@attrs["pitch"] || 0).to_f }
|
|
141
220
|
}
|
|
142
221
|
slide["media"] = media_block if media_block
|
|
143
222
|
slide
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|