Add more data and allow the script to process items with several lights

pull/16/head
Pierre Mesure 2022-01-27 11:04:00 +01:00
rodzic d09e2ff089
commit c0df72a63c
4 zmienionych plików z 279260 dodań i 24 usunięć

Wyświetl plik

@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- run: |
wget -O data-full.json https://lz4.overpass-api.de/api/interpreter\?data\=%0A%09%09%09%5Bout%3Ajson%5D%5Btimeout%3A200%5D%3B%0A%09%09%09%2F%2F%20gather%20results%0A%09%09%09\(%0A%09%09%09%20%20%2F%2F%20query%20part%20for%3A%20%E2%80%9C%22seamark%3Alight%3Asequence%22%3D\*%E2%80%9D%0A%09%09%09%20%20node%5B%22seamark%3Alight%3Asequence%22%5D\(-90%2C-180%2C90%2C180\)%3B%0A%09%09%09%20%20way%5B%22seamark%3Alight%3Asequence%22%5D\(-90%2C-180%2C90%2C180\)%3B%0A%09%09%09\)%3B%0A%09%09%09%2F%2F%20print%20results%0A%09%09%09out%20body%3B%0A%09%09%09%3E%3B%0A%09%09%09out%20skel%20qt%3B%0A%09%09
wget -O data-full.json https://www.overpass-api.de/api/interpreter?data=%0A%09%09%09%5Bout%3Ajson%5D%5Btimeout%3A300%5D%3B%0A%09%09%09(%0A%09%09%09%20%20node%5B%22seamark%3Alight%3Asequence%22%5D(-90%2C-180%2C90%2C180)%3B%0A%09%09%09%20%20node%5B%22seamark%3Alight%3A1%3Asequence%22%5D(-90%2C-180%2C90%2C180)%3B%0A%09%09%09%20%20way%5B%22seamark%3Alight%3Asequence%22%5D(-90%2C-180%2C90%2C180)%3B%0A%09%09%09%20%20way%5B%22seamark%3Alight%3A1%3Asequence%22%5D(-90%2C-180%2C90%2C180)%3B%0A%09%09%09)%3B%0A%09%09%09out%20body%3B%0A%09%09%09%3E%3B%0A%09%09%09out%20skel%20qt%3B%0A%09%09
- name: Commit the data
uses: nick-invision/retry@v2
with:

Plik diff jest za duży Load Diff

Wyświetl plik

@ -19,14 +19,14 @@
width: 100%;
height: 100%;
}
#controls {
position: fixed;
bottom: 0;
left: 0;
z-index: 1000;
}
#seamap .leaflet-control-attribution,
#controls {
margin: 10px;
@ -35,7 +35,7 @@
background: none;
text-shadow: 0px 0px 2px black;
}
#seamap .leaflet-control-attribution a {
color: inherit;
text-decoration: underline;
@ -52,13 +52,15 @@
</div>
<a href="https://github.com/geodienst/lighthousemap"><img style="position: absolute; top: 0; right: 0; border: 0; z-index: 1000" src="https://camo.githubusercontent.com/52760788cde945287fbb584134c4cbc2bc36f904/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f77686974655f6666666666662e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png"></a>
<script id="seamap-query" type="text/x-overpass">
[out:json][timeout:25];
[out:json][timeout:300];
// gather results
(
// query part for: “"seamark:light:sequence"=*”
node["seamark:light:sequence"]({{bbox}});
node["seamark:light:1:sequence"]({{bbox}});
way["seamark:light:sequence"]({{bbox}});
relation["seamark:light:sequence"]({{bbox}});
way["seamark:light:1:sequence"]({{bbox}});
// relation["seamark:light:sequence"]({{bbox}});
);
// print results
out body;
@ -67,7 +69,7 @@
</script>
<script id="seamap-wikidata-query" type="text/x-sparql">
SELECT ?item ?itemLabel ?location ?height ?focalHeight ?sequence
WHERE
WHERE
{
?item wdt:P31 wd:Q39715.
?item wdt:P625 ?location.
@ -95,7 +97,7 @@
position: 'bottomright',
prefix: 'Made by <a href="https://www.geodienst.xyz/">Geodienst</a>'
}));
L.tileLayer('https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png', {
detectRetina: true,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, &copy; <a href="http://cartodb.com/attributions">CartoDB</a>'
@ -118,7 +120,6 @@
// let query = document.getElementById('seamap-query').textContent
// .replace(/\{\{bbox\}\}/g, bounds.join(','));
let url = 'https://www.overpass-api.de/api/interpreter?data=' + encodeURIComponent(query);
@ -165,11 +166,11 @@
}
}).addTo(map).addData(geojson);
});
let useRealColors = true;
document.querySelector('input[name=real-colors]').checked = useRealColors;
document.querySelector('input[name=real-colors]').addEventListener('change', function(e) {
useRealColors = this.checked;
});
@ -184,7 +185,7 @@
} catch(e){
// console.error(e)
}
});
};

Wyświetl plik

@ -8,12 +8,36 @@ L.Light = L.Circle.extend({
});
L.Light.sequence = function(tags, fallbackColor = '#FF0') {
renameProperty = function(tags, property) {
console.log('test')
old_key = 'seamark:light:1:' + property
new_key = 'seamark:light:' + property
if (!(new_key in tags) && old_key in tags) {
tags[new_key] = tags[old_key]
}
return tags
}
tags = renameProperty(tags, 'character')
tags = renameProperty(tags, 'colour')
tags = renameProperty(tags, 'group')
tags = renameProperty(tags, 'height')
tags = renameProperty(tags, 'period')
tags = renameProperty(tags, 'range')
tags = renameProperty(tags, 'sector_end')
tags = renameProperty(tags, 'sector_start')
tags = renameProperty(tags, 'sequence')
let character = tags['seamark:light:character'] || 'Fl';
let colors = (tags['seamark:light:colour'] || fallbackColor).split(';');
let sequence = tags['seamark:light:sequence'];
if (character.match(/^Al\./)) {// Alternating color!
character = tags['seamark:light:character'].substring(3);
@ -49,7 +73,7 @@ L.Light.sequence = function(tags, fallbackColor = '#FF0') {
const flash = 0.2;
const longflash = 1.0;
const remainder = period - (short * 2 * flash + longflash)
if (remainder < 0)
throw 'Could not convert Q+LFL to Fl: negative remainder';
@ -103,7 +127,7 @@ L.Light.sequence = function(tags, fallbackColor = '#FF0') {
console.warn('There are fewer sequences than colors', {character, sequence, colors}, tags);
return new L.Light.CombinedSequence(sequences);
default:
throw 'Unknown character: ' + character
}
@ -180,4 +204,4 @@ L.Light.Sequence = class {
}
throw new Error('Ran out of steps while still inside duration?');
}
}
}