maplibre-preview 1.1.1 → 1.1.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 +6 -0
- data/lib/maplibre-preview/version.rb +1 -1
- data/lib/maplibre-preview/views/maplibre_map.slim +17 -7
- data/lib/maplibre-preview.rb +1 -25
- data/spec/maplibre_preview_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 880bdf4635bf0ab9f3164d52eaa89b30af2158b92d7f18a66ae3826eb6b038d9
|
4
|
+
data.tar.gz: f83cd22d094dd39d8be2e5eee0e0b8b41e15f7f4456e4d78e21f94016265d957
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28419d7377ec6f75213f617d5fbe33d35ba85392373e0db9eb8b430bb474d636095b4373b3f51ccd3a99d4057ee5a1b8af098700d3540c55d58a2a12987ab00e
|
7
|
+
data.tar.gz: 17418dbe1c8e87bab566c75102435e3cde668ec59345a65eda810b55c844b7bb02c0a85d4aabfd8d57e10c23693344e2a7096ce3fea64abd4e40eb73b0b7152e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [1.1.4] - 2025-10-03
|
4
|
+
|
5
|
+
### Fixed
|
6
|
+
- **Terrain elevation correction** for accurate height display in tooltips and profiles
|
7
|
+
- **Centralized exaggeration compensation** with `getRealTerrainElevation` function
|
8
|
+
|
3
9
|
## [1.1.0] - 2025-10-01
|
4
10
|
|
5
11
|
### Refactored
|
@@ -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);
|
@@ -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
|
|
data/lib/maplibre-preview.rb
CHANGED
@@ -47,31 +47,7 @@ module MapLibrePreview
|
|
47
47
|
class App < Sinatra::Base
|
48
48
|
register Extension
|
49
49
|
|
50
|
-
|
51
|
-
set :views, File.expand_path('maplibre-preview/views', __dir__)
|
52
|
-
set :public_folder, File.expand_path('maplibre-preview/public', __dir__)
|
53
|
-
end
|
54
|
-
|
55
|
-
get '/js/:file' do
|
56
|
-
serve_js_file(params[:file])
|
57
|
-
end
|
58
|
-
|
59
|
-
get '/map' do
|
60
|
-
slim :maplibre_map, layout: :maplibre_layout, locals: { options: {} }
|
61
|
-
end
|
62
|
-
|
63
|
-
private
|
64
|
-
|
65
|
-
def serve_js_file(filename)
|
66
|
-
gem_js_path = File.expand_path("maplibre-preview/public/js/#{filename}", __dir__)
|
67
|
-
if File.exist?(gem_js_path)
|
68
|
-
content_type 'application/javascript'
|
69
|
-
File.read(gem_js_path)
|
70
|
-
else
|
71
|
-
status 404
|
72
|
-
'File not found'
|
73
|
-
end
|
74
|
-
end
|
50
|
+
get '/', &->{ slim :maplibre_map, layout: :maplibre_layout, locals: { options: {} } }
|
75
51
|
end
|
76
52
|
end
|
77
53
|
|
@@ -7,7 +7,7 @@ RSpec.describe MapLibrePreview do
|
|
7
7
|
let(:app) { Class.new(MapLibrePreview::App) { set :environment, :test } }
|
8
8
|
|
9
9
|
it 'provides complete map development interface' do
|
10
|
-
get '/
|
10
|
+
get '/'
|
11
11
|
expect(last_response).to be_ok
|
12
12
|
|
13
13
|
expect(last_response.body).to include('map-container')
|
@@ -30,7 +30,7 @@ RSpec.describe MapLibrePreview do
|
|
30
30
|
let(:app) { Class.new(MapLibrePreview::App) { set :environment, :test } }
|
31
31
|
|
32
32
|
it 'includes proper external dependencies' do
|
33
|
-
get '/
|
33
|
+
get '/'
|
34
34
|
body = last_response.body
|
35
35
|
|
36
36
|
expect(body).to include('unpkg.com/maplibre-gl')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maplibre-preview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Ludov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-10-
|
11
|
+
date: 2025-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|