maplibre-preview 1.1.3 → 1.2.4
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/CHANGELOG.md +24 -0
- data/bin/maplibre-preview +144 -0
- data/lib/maplibre-preview/version.rb +1 -1
- data/lib/maplibre-preview/views/maplibre_map.slim +18 -8
- metadata +27 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c014b48eb6865531f00686bfefe9994d6a3a13c6f1b489db0108b685cb265cb1
|
4
|
+
data.tar.gz: 06acc3ebcb2854e37781a1fc37859e5b114f0a51f2c3123498aa251c7f8a7758
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0019e4a9dcc04d061ac10cb0742b45a1a65da75e6e777b4c98be3f660d135f85add8bbbf8d4f31cf08fb407fc68501742b90ecd681aa4e239b6b27a8367e093f'
|
7
|
+
data.tar.gz: 504f58c1450d8b6e569f48b5bf6ee6df496edd2a87cf61f5d76597cdcf3c54d1bcd86978c7dea3d89769537667201f4acfc48a364629f03982b08839ab01390c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [1.2.4] - 2025-10-05
|
4
|
+
|
5
|
+
### Added
|
6
|
+
- **CLI executable** - completely new `bin/maplibre-preview` command-line interface
|
7
|
+
- **Server management commands** with `--up`, `--down`, `--port` options
|
8
|
+
- **Help system** with `--help` and `--version` commands
|
9
|
+
- **Process management** with PID file tracking and server control
|
10
|
+
- **Puma dependency** for reliable server operation
|
11
|
+
- **Ruby 3.0+ requirement** for modern Ruby features
|
12
|
+
|
13
|
+
### New CLI Features
|
14
|
+
- **`maplibre-preview --up`** - start server with default or custom port
|
15
|
+
- **`maplibre-preview --up --port 9292`** - start server on specific port
|
16
|
+
- **`maplibre-preview --down`** - stop running server
|
17
|
+
- **`maplibre-preview --help`** - show usage information
|
18
|
+
- **`maplibre-preview --version`** - show version information
|
19
|
+
- **Unknown command validation** - proper error messages for invalid arguments
|
20
|
+
|
21
|
+
## [1.1.4] - 2025-10-03
|
22
|
+
|
23
|
+
### Fixed
|
24
|
+
- **Terrain elevation correction** for accurate height display in tooltips and profiles
|
25
|
+
- **Centralized exaggeration compensation** with `getRealTerrainElevation` function
|
26
|
+
|
3
27
|
## [1.1.0] - 2025-10-01
|
4
28
|
|
5
29
|
### Refactored
|
@@ -0,0 +1,144 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'maplibre-preview'
|
5
|
+
require 'optparse'
|
6
|
+
require 'json'
|
7
|
+
require 'fileutils'
|
8
|
+
|
9
|
+
class MapLibrePreviewCLI
|
10
|
+
PID_FILE = File.join(Dir.home, '.maplibre-preview.pid')
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@options = { port: 4567, up: false }
|
14
|
+
setup_parser
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
@parser.parse!
|
19
|
+
|
20
|
+
unless ARGV.empty?
|
21
|
+
puts "Error: Unknown argument(s): #{ARGV.join(', ')}"
|
22
|
+
puts "Use 'maplibre-preview --help' for available options"
|
23
|
+
exit 1
|
24
|
+
end
|
25
|
+
|
26
|
+
return handle_server_stop if @options[:stop]
|
27
|
+
return handle_already_running if server_running?
|
28
|
+
|
29
|
+
if @options[:up]
|
30
|
+
start_server
|
31
|
+
else
|
32
|
+
puts "MapLibre Preview v#{MapLibrePreview::VERSION}"
|
33
|
+
puts "Use 'maplibre-preview --up' to start the server"
|
34
|
+
puts "Use 'maplibre-preview --help' for more options"
|
35
|
+
exit 0
|
36
|
+
end
|
37
|
+
rescue OptionParser::InvalidOption => e
|
38
|
+
puts "Error: #{e.message}"
|
39
|
+
puts "Use 'maplibre-preview --help' for available options"
|
40
|
+
exit 1
|
41
|
+
rescue Interrupt
|
42
|
+
puts "\nShutting down server"
|
43
|
+
cleanup_server_info
|
44
|
+
exit 0
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def setup_parser
|
50
|
+
@parser = OptionParser.new do |opts|
|
51
|
+
opts.banner = "MapLibre Preview v#{MapLibrePreview::VERSION}"
|
52
|
+
opts.separator ""
|
53
|
+
opts.separator "Usage: maplibre-preview [OPTIONS]"
|
54
|
+
opts.separator ""
|
55
|
+
opts.separator "Options:"
|
56
|
+
|
57
|
+
opts.on("--up", "Start the server") { @options[:up] = true }
|
58
|
+
opts.on("-p", "--port PORT", Integer, "Port to run on (default: 4567)") { |port| @options[:port] = port }
|
59
|
+
opts.on("--down", "Stop the running server") { @options[:stop] = true }
|
60
|
+
opts.on("-h", "--help", "Show this help message") { puts opts; exit 0 }
|
61
|
+
opts.on("--version", "Show version information") { puts "MapLibre Preview v#{MapLibrePreview::VERSION}"; exit 0 }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def handle_server_stop
|
66
|
+
return puts("No server is currently running") unless server_running?
|
67
|
+
|
68
|
+
puts "Stopping server on port #{server_info&.dig('port')}"
|
69
|
+
kill_server_process ? puts("Server stopped successfully") : puts("Could not stop server automatically")
|
70
|
+
cleanup_server_info
|
71
|
+
end
|
72
|
+
|
73
|
+
def handle_already_running
|
74
|
+
puts "Server already running on port #{server_info&.dig('port')}"
|
75
|
+
puts "Use 'maplibre-preview --down' to stop it first"
|
76
|
+
exit 1
|
77
|
+
end
|
78
|
+
|
79
|
+
def start_server
|
80
|
+
puts "MapLibre Preview v#{MapLibrePreview::VERSION}"
|
81
|
+
puts "Starting server on port #{@options[:port]}"
|
82
|
+
puts "Open: http://localhost:#{@options[:port]}"
|
83
|
+
puts "Press Ctrl+C to stop"
|
84
|
+
puts ""
|
85
|
+
|
86
|
+
save_server_info(@options[:port])
|
87
|
+
MapLibrePreview::App.run!(port: @options[:port], host: '0.0.0.0')
|
88
|
+
end
|
89
|
+
|
90
|
+
def server_running?
|
91
|
+
return false unless File.exist?(PID_FILE)
|
92
|
+
|
93
|
+
process_exists?(server_info&.dig('pid'))
|
94
|
+
rescue
|
95
|
+
cleanup_server_info
|
96
|
+
false
|
97
|
+
end
|
98
|
+
|
99
|
+
def server_info
|
100
|
+
@server_info ||= begin
|
101
|
+
return nil unless File.exist?(PID_FILE)
|
102
|
+
JSON.parse(File.read(PID_FILE))
|
103
|
+
rescue
|
104
|
+
cleanup_server_info
|
105
|
+
nil
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def save_server_info(port)
|
110
|
+
server_info = { 'port' => port, 'pid' => Process.pid, 'started_at' => Time.now.to_i }
|
111
|
+
File.write(PID_FILE, JSON.pretty_generate(server_info))
|
112
|
+
end
|
113
|
+
|
114
|
+
def cleanup_server_info
|
115
|
+
File.delete(PID_FILE) if File.exist?(PID_FILE)
|
116
|
+
@server_info = nil
|
117
|
+
end
|
118
|
+
|
119
|
+
def kill_server_process
|
120
|
+
return false unless server_info&.dig('pid')
|
121
|
+
|
122
|
+
pid = server_info['pid']
|
123
|
+
return false unless process_exists?(pid)
|
124
|
+
|
125
|
+
Process.kill('TERM', pid)
|
126
|
+
sleep(1)
|
127
|
+
Process.kill('KILL', pid) if process_exists?(pid)
|
128
|
+
true
|
129
|
+
rescue => e
|
130
|
+
puts "Warning: Could not kill process: #{e.message}"
|
131
|
+
false
|
132
|
+
end
|
133
|
+
|
134
|
+
def process_exists?(pid)
|
135
|
+
return false unless pid
|
136
|
+
|
137
|
+
Process.kill(0, pid)
|
138
|
+
true
|
139
|
+
rescue Errno::ESRCH
|
140
|
+
false
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
MapLibrePreviewCLI.new.run
|
@@ -85,6 +85,14 @@ javascript:
|
|
85
85
|
|
86
86
|
const toDomId = (prefix, id) => `${prefix}-${String(id).replace(/[^a-zA-Z0-9_-]/g, '_')}`;
|
87
87
|
|
88
|
+
const getRealTerrainElevation = (lngLat) => {
|
89
|
+
const elevation = map.queryTerrainElevation(lngLat);
|
90
|
+
if (elevation == null) return null;
|
91
|
+
|
92
|
+
const exaggeration = currentStyle?.terrain?.exaggeration || 1.0;
|
93
|
+
return elevation / exaggeration;
|
94
|
+
};
|
95
|
+
|
88
96
|
const showLoading = () => document.getElementById('loading-indicator').style.display = 'block';
|
89
97
|
const hideLoading = () => document.getElementById('loading-indicator').style.display = 'none';
|
90
98
|
|
@@ -322,11 +330,11 @@ javascript:
|
|
322
330
|
features.length > 0 && console.log('Clicked feature:', features[0]);
|
323
331
|
|
324
332
|
if (hoverMode === 'click' && currentStyle?.terrain) {
|
325
|
-
const
|
326
|
-
if (
|
333
|
+
const realElevation = getRealTerrainElevation([e.lngLat.lng, e.lngLat.lat]);
|
334
|
+
if (realElevation != null) {
|
327
335
|
elevationTooltip && elevationTooltip.style.display === 'block'
|
328
336
|
? hideElevationTooltip()
|
329
|
-
: showElevationTooltip(e.originalEvent,
|
337
|
+
: showElevationTooltip(e.originalEvent, realElevation);
|
330
338
|
}
|
331
339
|
}
|
332
340
|
});
|
@@ -352,8 +360,10 @@ javascript:
|
|
352
360
|
hideElevationTooltip();
|
353
361
|
|
354
362
|
if (currentStyle?.terrain) {
|
355
|
-
const
|
356
|
-
|
363
|
+
const realElevation = getRealTerrainElevation([e.lngLat.lng, e.lngLat.lat]);
|
364
|
+
if (realElevation != null) {
|
365
|
+
showElevationTooltip(e.originalEvent, realElevation);
|
366
|
+
}
|
357
367
|
}
|
358
368
|
|
359
369
|
profileMode && profilePoints.length === 1 && updateTemporaryLine(e.lngLat);
|
@@ -419,7 +429,7 @@ javascript:
|
|
419
429
|
document.body.appendChild(elevationTooltip);
|
420
430
|
}
|
421
431
|
|
422
|
-
elevationTooltip.textContent = `${elevation.toFixed(1)}
|
432
|
+
elevationTooltip.textContent = `${elevation.toFixed(1)}m`;
|
423
433
|
elevationTooltip.style.left = `${e.clientX}px`;
|
424
434
|
elevationTooltip.style.top = `${e.clientY}px`;
|
425
435
|
elevationTooltip.style.display = 'block';
|
@@ -489,10 +499,10 @@ javascript:
|
|
489
499
|
const t = i / numPoints;
|
490
500
|
const lng = start.lng + (end.lng - start.lng) * t;
|
491
501
|
const lat = start.lat + (end.lat - start.lat) * t;
|
492
|
-
const
|
502
|
+
const realElevation = getRealTerrainElevation([lng, lat]);
|
493
503
|
const distance = calculateDistance([start.lng, start.lat], [lng, lat]);
|
494
504
|
|
495
|
-
return {distance, elevation:
|
505
|
+
return {distance, elevation: realElevation, coordinates: [lng, lat]};
|
496
506
|
});
|
497
507
|
};
|
498
508
|
|
metadata
CHANGED
@@ -1,15 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maplibre-preview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Ludov
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-10-
|
11
|
+
date: 2025-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: puma
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '6.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '7.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '6.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '7.0'
|
13
33
|
- !ruby/object:Gem::Dependency
|
14
34
|
name: rack
|
15
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,7 +165,8 @@ description: A Ruby gem providing development tools for MapLibre GL JS styles, i
|
|
145
165
|
monitoring.
|
146
166
|
email:
|
147
167
|
- efraam@gmail.com
|
148
|
-
executables:
|
168
|
+
executables:
|
169
|
+
- maplibre-preview
|
149
170
|
extensions: []
|
150
171
|
extra_rdoc_files: []
|
151
172
|
files:
|
@@ -157,6 +178,7 @@ files:
|
|
157
178
|
- LICENSE
|
158
179
|
- README.md
|
159
180
|
- Rakefile
|
181
|
+
- bin/maplibre-preview
|
160
182
|
- docs/README_RU.md
|
161
183
|
- lib/maplibre-preview.rb
|
162
184
|
- lib/maplibre-preview/public/js/contour.js
|
@@ -181,7 +203,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
203
|
requirements:
|
182
204
|
- - ">="
|
183
205
|
- !ruby/object:Gem::Version
|
184
|
-
version:
|
206
|
+
version: 3.0.0
|
185
207
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
208
|
requirements:
|
187
209
|
- - ">="
|