Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an overlay that highlights curves. #171

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
'Google Map': 'Google Térkép',
'Google Terrain': 'Google Domborzat',
'Google Satellite': 'Google Műhold',
'Elevation Shading': 'Domborzat Kiemelés'
'Elevation Shading': 'Domborzat Kiemelés',
'Curvature': 'Kanyarívek'
},
'themes': {
'System Theme': 'Rendszer megjelenése',
Expand Down
895 changes: 895 additions & 0 deletions map/curves.geojson

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions map/curves.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Data source

Data source is from: https://roadcurvature.com/.

Direct download of data is from: https://kml.roadcurvature.com/europe/hungary.c_1000.kmz.

This data has been converted to geoJson with the tool: https://mygeodata.cloud/converter/kml-to-gpx.

# License

RoadCurvature.com is © Adam Franco.

The Curvature program is © Adam Franco and is open-source software licensed under the Gnu General Public License (GPL) Version 3 or later.

Curvature output data is © OpenStreetMap Contributors and are open-data provided under the terms of the Open Data Commons Open Database License (ODBL).
39 changes: 37 additions & 2 deletions res/huroutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,19 @@ const huroutes = {
},
// Choosable overlay sources supported in the layer selector. All are off by default.
'overlays': {
'Elevation Shading': L.tileLayer('https://map.turistautak.hu/tiles/shading/{z}/{x}/{y}.png', {attribution:'© turistautak.hu',minZoom:5,maxZoom: 18,zIndex:5,className: 'overlay-dem'})
'Elevation Shading': L.tileLayer('https://map.turistautak.hu/tiles/shading/{z}/{x}/{y}.png', {attribution:'© turistautak.hu',minZoom:5,maxZoom: 18,zIndex:5,className: 'overlay-dem'}),
'Curvature': L.layerGroup(null, {attribution:'Curves: &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'})
},
// Overlay sources that are always shown and hidden along with specific map tile sources.
// The name of the overlay must be the same as the tile layer to which it is bound.
'tileOverlays': {}
'tileOverlays': {},
// Lazy-content overlay data, which is downloaded only when the user first shows it.
// Usage: Create an overlay under 'overlays' with an empty L.layerGroup. Create an
// item in 'lazyOverlays' with the same ID as the layergroup overlay. The value is
// a function that returns the layer that contains the data.
'lazyOverlays': {
'Curvature': (layer) => omnivore.geojson('map/curves.geojson', null, layer)
}
},
// A list of navigation service providers that can be chosen for the "navigate to" links'.
// The default provider used is the first one.
Expand Down Expand Up @@ -181,7 +189,10 @@ $(document).ready(function() {
(localStorage.overlays || '').split('|').forEach(item => {
const overlay = overlays[item];
if (overlay)
{
overlay.addTo(map);
initLazyOverlay(item, overlay);
}
});
const tileOverlay = huroutes.opt.map.tileOverlays[localStorage.mapstyle];
if (tileOverlay)
Expand Down Expand Up @@ -256,6 +267,8 @@ function initCtrls(tiles, overlays)
overlays = overlays ? overlays.split('|') : [];
overlays.push(overlay.layer.id);
localStorage.overlays = overlays.join('|');

initLazyOverlay(overlay.layer.id, overlay.layer);
});
map.on('overlayremove', (overlay) => {
var overlays = (localStorage.overlays || '').split('|');
Expand Down Expand Up @@ -304,6 +317,28 @@ function initCtrls(tiles, overlays)
}, true);
}

/**
* Initializes data inside of a layer group on demand.
* @param {string} id The overlay identifier.
* @param {object} layerGroup A Leaflet layerGroup object to which the data is added.
*/
function initLazyOverlay(id, layerGroup)
{
try {
if (layerGroup.getLayers().length == 0)
{
var layer = L.geoJson(null, {
style: {
color: '#BB0',
opacity: 0.9,
weight: 1.5
}
});
layerGroup.addLayer(huroutes.opt.map.lazyOverlays[id](layer));
}
} catch { }
}

/**
* Loads route data into the web application.
* @param {object} data The huroutes database.
Expand Down