Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* upstream/master:
  fix swisstopo-landeskarte id (nrenner#464)
  'l' toggles locate state (nrenner#462)
  Update Docker configs
  Highlight route segments for parts with normalized `surface` and `smoothness` values
  Normalize `surface` and `smoothness` variants
  Add OpenStreetMap Notes Layer (nrenner#458)
  don't store empty search queries to search favorites
  Husky fixes for Search/SearchFavorites
  remember and recall last used (non-custom) profile
  Favorite list for search (geocode control) (nrenner#452)
  Bump tmpl from 1.0.4 to 1.0.5 (nrenner#449)
  Bump tar from 4.4.15 to 4.4.19 (nrenner#447)
  Bump path-parse from 1.0.6 to 1.0.7 (nrenner#443)
  Bump tar from 4.4.13 to 4.4.15 (nrenner#441)
  Bump socket.io-parser from 3.3.0 to 3.3.2 (nrenner#435)
  Update browser-sync to fix security issue
  add `amenity=shelter` to Overpass layers (nrenner#433)
  Bump y18n from 3.2.1 to 3.2.2 (nrenner#429)
  Bump locutus from 2.0.14 to 2.0.15 (nrenner#428)
  • Loading branch information
stefankeidel committed Dec 3, 2021
2 parents 31b8554 + 9bcd36b commit 52aa275
Show file tree
Hide file tree
Showing 18 changed files with 591 additions and 116 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:10-buster as build
FROM node:lts as build
RUN mkdir /tmp/brouter-web
WORKDIR /tmp/brouter-web
COPY . .
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,5 @@ Copyright (c) 2018 Norbert Renner and [contributors](https://github.com/nrenner/
[CC0-1.0 License](https://github.com/mapbox/maki/blob/master/LICENSE.txt)
- [temaki](https://github.com/ideditor/temaki)
[CC0-1.0 License](https://github.com/ideditor/temaki/blob/main/LICENSE.md)
- [leaflet-osm-notes](https://github.com/osmlab/leaflet-osm-notes)
[The Unlicense](https://github.com/osmlab/leaflet-osm-notes/blob/gh-pages/LICENSE)
62 changes: 62 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,68 @@ table.dataTable.display tbody tr:hover.selected {
border-radius: 0;
}


/**
* Autocompleter styles
*/
.leaflet-control-geocoder-form.stayvisible { display: inline-block; }
.leaflet-control-geocoder-alternatives{
/* display: block; */
position: absolute;
background-color: white;
left: 2rem;
}

.leaflet-control-geocoder-alternatives{
background-color: rgb(255, 255, 255);
}

.autocomplete-container {
position:absolute;
left: 2rem;
width: calc( 100% - 3rem );
z-index: 100;
}

.autocomplete-select-container {
max-height: 15vh;
overflow-y: auto;
}

.autocomplete-container .autocomplete-select button{
text-align: left;
padding-left: 1rem;
padding-right: 1rem;
width: 100%;
}

#search-fav-menu-toggle {
text-align: right;
padding-right: 2rem;
line-height: 100%;
cursor: pointer;
}

#search-fav-menu-toggle > span {
font-weight: bold;
line-height: 0;
font-size: 1.2rem;
}

.autocomplete-container.filtered .autocomplete-select button{ display: none; }
.autocomplete-container.filtered .autocomplete-select button.match{ display: inherit; }

@media (max-width: 320.98px) {
.leaflet-control-geocoder-form > input[type=text] {
max-width: 50vw;
}

.leaflet-control-geocoder-alternatives {
max-width: 65vw;
}
}


@media (max-width: 575.98px) {
.modal-fullscreen-sm-down {
width: 100vw;
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
command: yarn serve
image: node:lts
ports:
- 3000:3000
- '3000:3000'
user: '1000'
volumes:
- ./:/src
Expand Down
8 changes: 7 additions & 1 deletion js/LayersConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ BR.LayersConfig = L.Class.extend({
_customizeLayers: function () {
var propertyOverrides = BR.confLayers.getPropertyOverrides();

for (id in propertyOverrides) {
for (var id in propertyOverrides) {
var layer = BR.layerIndex[id];

if (layer) {
Expand Down Expand Up @@ -238,6 +238,10 @@ BR.LayersConfig = L.Class.extend({
);
},

createOpenStreetMapNotesLayer: function () {
return new leafletOsmNotes();
},

createLayer: function (layerData) {
var props = layerData.properties;
var url = props.url;
Expand Down Expand Up @@ -322,6 +326,8 @@ BR.LayersConfig = L.Class.extend({
}
} else if (props.dataSource === 'OverpassAPI') {
layer = this.createOverpassLayer(props.query, props.icon);
} else if (props.dataSource === 'OpenStreetMapNotesAPI') {
layer = this.createOpenStreetMapNotesLayer();
} else {
// JOSM
var josmUrl = url;
Expand Down
4 changes: 4 additions & 0 deletions js/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ BR.Map = {
'keydown',
function (e) {
if (BR.Util.keyboardShortcutsAllowed(e) && e.keyCode === this.options.shortcut.locate) {
if (locationControl._active) {
locationControl.stop();
return;
}
locationControl.start();
}
},
Expand Down
2 changes: 2 additions & 0 deletions js/control/Layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ BR.Layers = L.Class.extend({

if (dataSource === 'OverpassAPI') {
layer = this._layersControl.layersConfig.createOverpassLayer(layerUrl);
} else if (dataSource === 'OpenStreetMapNotesAPI') {
layer = this._layersControl.layersConfig.createOpenStreetMapNotesLayer();
} else {
layer = L.tileLayer(layerUrl);
}
Expand Down
34 changes: 32 additions & 2 deletions js/control/RoutingOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,28 @@ BR.RoutingOptions = L.Evented.extend({
initialize: function () {
$('#profile-alternative').on('changed.bs.select', this._getChangeHandler());

var remembered_profile = this.getRememberedProfile();
var remembered_profile_was_selected = false;

// build option list from config
var profiles = BR.conf.profiles;
var profiles_list = L.DomUtil.get('profile');
for (var i = 0; i < profiles.length; i++) {
var option = document.createElement('option');
option.value = profiles[i];
option.text = profiles[i];
if (remembered_profile !== null && remembered_profile === profiles[i]) {
option.selected = true;
remembered_profile_was_selected = true;
}
profiles_list.appendChild(option);
}
// set default value, used as indicator for empty custom profile
profiles_list.children[0].value = 'Custom';
// <custom> profile is empty at start, select next one
profiles_list.children[1].selected = true;
if (!remembered_profile_was_selected) {
// <custom> profile is empty at start, select next one
profiles_list.children[1].selected = true;
}

L.DomEvent.addListener(document, 'keydown', this._keydownListener, this);
},
Expand Down Expand Up @@ -113,8 +122,29 @@ BR.RoutingOptions = L.Evented.extend({
return profile;
},

rememberProfile: function (profile) {
if (!BR.Util.localStorageAvailable()) {
return;
}

if (L.BRouter.isCustomProfile(profile)) {
return;
}

localStorage.setItem('routingprofile', profile);
},

getRememberedProfile: function () {
if (!BR.Util.localStorageAvailable()) {
return null;
}

return localStorage.getItem('routingprofile');
},

_getChangeHandler: function () {
return L.bind(function (evt) {
this.rememberProfile(evt.target.options[evt.target.options.selectedIndex].value);
this.fire('update', { options: this.getOptions() });
}, this);
},
Expand Down
65 changes: 50 additions & 15 deletions js/control/TrackAnalysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ BR.TrackAnalysis = L.Class.extend({
var wayTags = segments[segmentIndex].feature.properties.messages[messageIndex][9].split(' ');
for (var wayTagIndex = 0; wayTagIndex < wayTags.length; wayTagIndex++) {
var wayTagParts = wayTags[wayTagIndex].split('=');
switch (wayTagParts[0]) {
var tagName = this.normalizeTagName(wayTagParts[0]);
switch (tagName) {
case 'highway':
var highwayType = wayTagParts[1];
var trackType = '';
Expand All @@ -167,18 +168,18 @@ BR.TrackAnalysis = L.Class.extend({
break;
case 'surface':
case 'smoothness':
if (typeof analysis[wayTagParts[0]][wayTagParts[1]] === 'undefined') {
analysis[wayTagParts[0]][wayTagParts[1]] = {
if (typeof analysis[tagName][wayTagParts[1]] === 'undefined') {
analysis[tagName][wayTagParts[1]] = {
formatted_name: i18next.t(
'sidebar.analysis.data.' + wayTagParts[0] + '.' + wayTagParts[1],
'sidebar.analysis.data.' + tagName + '.' + wayTagParts[1],
wayTagParts[1]
),
name: wayTagParts[1],
subtype: '',
distance: 0.0,
};
}
analysis[wayTagParts[0]][wayTagParts[1]].distance += parseFloat(
analysis[tagName][wayTagParts[1]].distance += parseFloat(
segments[segmentIndex].feature.properties.messages[messageIndex][3]
);
break;
Expand All @@ -190,6 +191,31 @@ BR.TrackAnalysis = L.Class.extend({
return this.sortAnalysisData(analysis);
},

/**
* Normalize the tag name.
*
* Motivation: The `surface` tag comes in different variations,
* e.g. `surface`, `cycleway:surface` etc. We're only interested
* in the main tag so all other variations are normalized.
*
* @param {string} tagName
* @returns {string}
*/
normalizeTagName: function (tagName) {
// we assume that a tag belongs to the category `surface`,
// if that string is contained anywhere in the tag name:
if (tagName.indexOf('surface') !== -1) {
return 'surface';
}

// the same applies to `smoothness`
if (tagName.indexOf('smoothness') !== -1) {
return 'smoothness';
}

return tagName;
},

/**
* Transform analysis data for each type into an array, sort it
* by distance descending and convert it back to an object.
Expand Down Expand Up @@ -474,22 +500,31 @@ BR.TrackAnalysis = L.Class.extend({

return parsed.highway === dataName;
case 'surface':
if (dataName === 'internal-unknown' && typeof parsed.surface !== 'string') {
return true;
}

return typeof parsed.surface === 'string' && parsed.surface === dataName;
return this.singleWayTagMatchesData('surface', parsed, dataName);
case 'smoothness':
if (dataName === 'internal-unknown' && typeof parsed.smoothness !== 'string') {
return true;
}

return typeof parsed.smoothness === 'string' && parsed.smoothness === dataName;
return this.singleWayTagMatchesData('smoothness', parsed, dataName);
}

return false;
},

singleWayTagMatchesData: function (category, parsedData, lookupValue) {
var foundValue = null;

for (var iterationKey in parsedData) {
if (iterationKey.indexOf(category) !== -1) {
foundValue = parsedData[iterationKey];
break;
}
}

if (lookupValue === 'internal-unknown' && foundValue === null) {
return true;
}

return foundValue === lookupValue;
},

/**
* Transform a way tags string into an object, for example:
*
Expand Down
Loading

0 comments on commit 52aa275

Please sign in to comment.