Skip to content

Commit 107baf0

Browse files
authored
Merge pull request #21 from coderdojo-japan/use-minified-geojson
地図表示用に最小化版のGeoJSONファイルを使用
2 parents f6b9322 + f8c3bbe commit 107baf0

File tree

6 files changed

+19
-4
lines changed

6 files changed

+19
-4
lines changed

.github/workflows/scheduler_daily.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ jobs:
5959
- name: 📍 Generate DojoMap from Earth/Japan data
6060
run: |
6161
bundle exec rake upsert_dojos_geojson
62+
bundle exec rake compact_geojson
6263
6364
- name: 🆙 Commit latest data to update DojoMap (if any)
6465
run: |
@@ -79,6 +80,7 @@ jobs:
7980
8081
# Save GeoJSON data to render DojoMap
8182
git add dojos.geojson
83+
git add dojos.min.geojson
8284
8385
# Commit changed files above
8486
git commit -m '🤖 Upsert Earth/Japan data for DojoMap'

Rakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ task(:get_data_from_japan) { ruby 'get_data_from_japan.rb' }
77
task(:cache_dojo_logos) { ruby 'cache_dojo_logos.rb' }
88
task(:cache_data_as_yaml) { ruby 'cache_data_as_yaml.rb' }
99
task(:upsert_dojos_geojson) { ruby 'upsert_dojos_geojson.rb' }
10+
task(:compact_geojson) { ruby 'compact_geojson.rb' }
1011

1112
# GitHub - gjtorikian/html-proofer
1213
# https://github.com/gjtorikian/html-proofer

compact_geojson.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
#!/usr/bin/env ruby
22
require 'json'
33

4-
# Just compact it for better loading by Computer
4+
# Create a minified version of dojos.geojson for production use
55
geojson = JSON.load(File.read("dojos.geojson"))
6-
File.open('dojos.geojson', 'w') do |file|
6+
7+
# Write minified version (no whitespace)
8+
File.open('dojos.min.geojson', 'w') do |file|
79
JSON.dump(geojson, file)
810
end
11+
12+
# Calculate size reduction
13+
original_size = File.size("dojos.geojson")
14+
minified_size = File.size("dojos.min.geojson")
15+
reduction = ((original_size - minified_size) * 100.0 / original_size).round(1)
16+
17+
puts "✅ Created dojos.min.geojson"
18+
puts " Original: #{(original_size / 1024.0).round(1)} KB"
19+
puts " Minified: #{(minified_size / 1024.0).round(1)} KB"
20+
puts " Reduction: #{reduction}%"

dojos.min.geojson

Whitespace-only changes.

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<body>
6464
<div
6565
class="geolonia"
66-
data-geojson="./dojos.geojson"
66+
data-geojson="./dojos.min.geojson"
6767
data-lat="35.6809591"
6868
data-lng="139.7673068"
6969
data-zoom="5"

world.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<body>
6161
<div
6262
class="geolonia"
63-
data-geojson="./dojos.geojson"
63+
data-geojson="./dojos.min.geojson"
6464
data-lat="35.6809591"
6565
data-lng="139.7673068"
6666
data-zoom="0"

0 commit comments

Comments
 (0)