1
0
Fork 0
mirror of https://github.com/Findus23/RainbowRoad.git synced 2024-09-19 16:03:52 +02:00

add data from rest of Austria

This commit is contained in:
Lukas Winkler 2022-08-27 17:51:07 +02:00
parent 012ea9390c
commit 08d4c8d9b4
Signed by: lukas
GPG key ID: 54DE4D798D244853
12 changed files with 352 additions and 35 deletions

View file

@ -50,13 +50,12 @@ async function runfetch(filename: string) {
}
for (const d of data) {
if (d.id < 100) {
const max = 2 ** 32
d.id = Math.floor(Math.random() * max);
}
if (typeof d.geo !== "undefined") {
d.geo.length = lineLengthInM(d.geo.coords[0], d.geo.coords[1])
if (d.id < 100) {
const max = 2 ** 32
d.id = Math.floor(Math.random() * max);
}
continue
}
const geosource = d.geosource

41
data/Burgenland.json Normal file
View file

@ -0,0 +1,41 @@
[
{
"id": 1548557755,
"name": "Frauenkirchen",
"type": "prideFlag",
"comment": "Ö3-Wecker-Regenbogen-Zebrastreifen Nummer 3",
"sources": [
{
"type": "official",
"url": "https://www.burgenland.at/news-detail/regenbogenzebrastreifen-fuer-frauenkirchen/",
"date": "2022-07-05"
},
{
"type": "news",
"url": "https://www.meinbezirk.at/neusiedl-am-see/c-lokales/regenbogen-zebrastreifen-vor-der-basilika-in-frauenkirchen_a5454469",
"date": "2022-07-06"
}
],
"geosource": {
"type": "OSMnodes",
"nodes": [
9129447381,
284143552,
8853967843
]
},
"geo": {
"coords": [
[
16.9281382,
47.8357072
],
[
16.9279725,
47.835674
]
],
"length": 12.91
}
}
]

View file

@ -0,0 +1,94 @@
[
{
"id": 2338291641,
"name": "Strasshof an der Nordbahn",
"type": "prideFlag",
"sources": [
{
"type": "news",
"url": "https://www.noen.at/niederoesterreich/politik/strasshof-hat-jetzt-einen-regenbogen-zebrastreifen-niederoesterreich-strasshof-an-der-nordbahn-redaktionsfeed-toleranz-regenbogen-zebrastreifen-oe3-robert-kratky-redaktion-327639717",
"date": "2022-06-30"
},
{
"type": "news",
"url": "https://www.meinbezirk.at/gaenserndorf/c-lokales/regenbogen-zebrastreifen-fuer-strasshof_a5445571",
"date": "2022-06-30"
},
{
"type": "news",
"url": "https://oe3.orf.at/stories/3025611/",
"date": "2022-07-22"
}
],
"comment": "Ö3-Wecker-Regenbogen-Zebrastreifen Nummer 1",
"geosource": {
"type": "RawCoords",
"coords": [
[
16.65308,
48.32012
],
[
16.65314,
48.32014
]
]
},
"geo": {
"coords": [
[
16.65308,
48.32012
],
[
16.65314,
48.32014
]
],
"length": 4.96
}
},
{
"id": 3232915964,
"name": "Schwechat",
"type": "prideFlag",
"sources": [
{
"type": "news",
"url": "https://www.meinbezirk.at/schwechat/c-lokales/erster-regenbogenschutzweg-in-schwechat_a4806267",
"date": "2021-08-05"
},
{
"type": "news",
"url": "https://www.noen.at/schwechat/schwechat-solidaritaet-ein-regenbogen-fuer-die-strasse-schwechat-solidaritaet-regenbogen-gemeinderat-zebrastreifen-minderheiten-aufklaerungsprojekt-print-279632939",
"date": "2021-08-05"
}
],
"geosource": {
"type": "RawCoords",
"coords": [
[
16.4744,
48.13618
],
[
16.47435,
48.13611
]
]
},
"geo": {
"coords": [
[
16.4744,
48.13618
],
[
16.47435,
48.13611
]
],
"length": 8.62
}
}
]

51
data/Salzburg.json Normal file
View file

@ -0,0 +1,51 @@
[
{
"id": 1122716132,
"name": "Bad Hofgastein",
"type": "prideFlag",
"comment": "Ö3-Wecker-Regenbogen-Zebrastreifen Nummer 5",
"sources": [
{
"type": "news",
"url": "https://oe3.orf.at/stories/3025611/",
"date": "2022-07-22"
},
{
"type": "news",
"url": "https://www.salzburg24.at/news/salzburg/pongau/bad-hofgastein-bekommt-regenbogen-zebrastreifen-124464529",
"date": "2022-07-19"
},
{
"type": "news",
"url": "https://www.fmt-pictures.at/bericht.php?bericht_id=10322",
"date": "2022-07-22"
}
],
"geosource": {
"type": "RawCoords",
"coords": [
[
13.09882,
47.16986
],
[
13.09888,
47.16978
]
]
},
"geo": {
"coords": [
[
13.09882,
47.16986
],
[
13.09888,
47.16978
]
],
"length": 9.99
}
}
]

51
data/Steiermark.json Normal file
View file

@ -0,0 +1,51 @@
[
{
"id": 3394477153,
"name": "Leoben",
"type": "prideFlag",
"comment": "Ö3-Wecker-Regenbogen-Zebrastreifen Nummer 2, nach 5 Tagen zerstört",
"sources": [
{
"type": "news",
"url": "https://oe3.orf.at/stories/3025611/",
"date": "2022-07-22"
},
{
"type": "news",
"url": "https://www.meinbezirk.at/leoben/c-lokales/leoben-hat-seinen-regenbogen-zebrastreifen_a5451571",
"date": "2022-07-04"
},
{
"type": "news",
"url": "https://www.meinbezirk.at/leoben/c-lokales/regenbogen-zebrastreifen-nach-nur-fuenf-tagen-zerstoert_a5464429",
"date": "2022-07-09"
},
{
"type": "news",
"url": "https://www.ggg.at/2022/07/11/regenbogen-zebrastreifen-in-leoben-nach-fuenf-tagen-zerstoert/",
"date": "2022-07-11"
}
],
"geosource": {
"type": "OSMnodes",
"nodes": [
2463426113,
846964786,
3760068692
]
},
"geo": {
"coords": [
[
15.0901884,
47.3863884
],
[
15.0903186,
47.3862693
]
],
"length": 16.48
}
}
]

51
data/Tirol.json Normal file
View file

@ -0,0 +1,51 @@
[
{
"id": 134088388,
"name": "Telfs",
"type": "prideFlag",
"comment": "Ö3-Wecker-Regenbogen-Zebrastreifen Nummer 4",
"sources": [
{
"type": "news",
"url": "https://oe3.orf.at/stories/3025611/",
"date": "2022-07-22"
},
{
"type": "news",
"url": "https://www.tt.com/artikel/30826546/bunte-regenbogen-zebrastreifen-fuer-telfs",
"date": "2022-07-22"
},
{
"type": "news",
"url": "https://www.meinbezirk.at/telfs/c-lokales/regenbogen-zebrastreifen-nun-auch-fuer-telfs_a5486716",
"date": "2022-07-21"
}
],
"geosource": {
"type": "RawCoords",
"coords": [
[
11.07489,
47.30752
],
[
11.07492,
47.30748
]
]
},
"geo": {
"coords": [
[
11.07489,
47.30752
],
[
11.07492,
47.30748
]
],
"length": 4.99
}
}
]

View file

@ -1,11 +1,11 @@
import {Coordinate} from "ol/coordinate";
import {Extent} from "ol/extent";
import {View} from "ol";
import {fromLonLat, transformExtent} from "ol/proj";
import {fromLonLat} from "ol/proj";
interface Area {
name: string
center: Coordinate
center?: Coordinate
extent: Extent
zoom: number
}
@ -26,14 +26,27 @@ export const areas: { [name: string]: Area } = {
center: [13.964417, 48.136583],
// https://www.deine-berge.de/Region/Oesterreich/8/Bundesland-Oberoesterreich.html
extent: [12.749244, 47.461112, 14.9921682, 48.7725637]
},
NOE: {
name: "Niederösterreich",
zoom: 9,
// https://www.deine-berge.de/Region/Oesterreich/7/Bundesland-Nieder%C3%B6sterreich.html
extent: [14.4526384, 47.4222062, 17.068839, 49.0205306]
}
}
export const Wien = areas.Wien
export function viewFromArea(area: Area): View {
let center;
const extent = area.extent
if (area.center) {
center = area.center
} else {
center = [(extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2]
}
return new View({
center: fromLonLat(area.center),
center: fromLonLat(center),
zoom: area.zoom,
// extent: transformExtent(area.extent, 'EPSG:4326', 'EPSG:3857'),
constrainOnlyCenter: true

View file

@ -42,8 +42,7 @@ export function loadData(data: Crossing[], vectorSource: VectorSource): void {
featureLine.setProperties({"crossing": c, "type": "line"} as FeatureProperties)
featureDot.setProperties({"crossing": c, "type": "dot"} as FeatureProperties)
featureLine.setId(c.id)
featureDot.setId(c.id + 10000)
featureDot.setId(c.id)
vectorSource.addFeature(featureLine);
vectorSource.addFeature(featureDot);
})

View file

@ -1,23 +1,27 @@
import {Crossing} from "../interfaces";
import {loadData} from "./features";
import VectorSource from "ol/source/Vector";
import {loadData} from "./features";
import {Crossing} from "../interfaces";
export function loadAllData(vectorSource: VectorSource): void {
// @ts-ignore
import("../data/Wien.json?inline").then((data) => {
loadData(data.default as unknown as Crossing[], vectorSource)
const imports = [
import("../data/Wien.json?inline"),
import("../data/Oberösterreich.json?inline"),
import("../data/Niederösterreich.json?inline"),
import("../data/Steiermark.json?inline"),
import("../data/Tirol.json?inline"),
import("../data/Burgenland.json?inline"),
import("../data/Salzburg.json?inline")
]
imports.forEach(imp => {
imp.then(data => {
loadData(data.default as unknown as Crossing[], vectorSource)
})
})
}
// import("../data/Wien.json?url").then(importdata => {
// vectorSource.setAttributions(buildAttribution(importdata.default))
// })
// @ts-ignore
import("../data/Oberösterreich.json?inline").then((data) => {
loadData(data.default as unknown as Crossing[], vectorSource)
})
// import("../data/Oberösterreich.json?url").then(importdata => {
// vectorSource.setAttributions(buildAttribution(importdata.default))
// })
}

View file

@ -15,6 +15,7 @@ import {Crossing} from "../interfaces";
import {loadAllData} from "./loadData";
import "./router"
import {router} from "./router";
import {transformExtent} from "ol/proj";
const map = new Map({
// controls: defaultControls().extend([new AreaControl({router: router})]),
@ -109,7 +110,12 @@ map.addLayer(vectorLineLayer);
Object.entries(areas).forEach(([name, area]) => {
router.on("/" + encodeURIComponent(area.name), () => {
map.setView(viewFromArea(area))
const extent = transformExtent(area.extent, 'EPSG:4326', 'EPSG:3857')
map.getView().fit(extent, {
size: map.getSize(),
// duration:1000
})
// map.setView(viewFromArea(area))
})
})

View file

@ -26,17 +26,17 @@ export function initPopups(map: Map, vectorSource: VectorSource) {
map.addOverlay(overlay);
closer.onclick = function () {
router.navigate("/")
router.navigateReplace("/")
return false;
};
map.on('singleclick', event => {
map.forEachFeatureAtPixel(event.pixel, feature => {
const coordinate = event.coordinate;
const crossing: Crossing = feature.getProperties().crossing
router.navigate("/flag/" + feature.getId())
router.navigateReplace("/flag/" + crossing.id)
}, {hitTolerance: 5})
if (!map.hasFeatureAtPixel(event.pixel, {hitTolerance: 5})) {
router.navigate("/")
router.navigateReplace("/")
}
});

View file

@ -1,6 +1,16 @@
import Navigo, {Route} from "navigo";
import {areas, viewFromArea, Wien} from "./areaData";
export const router = new Navigo("/")
import Navigo, {NavigateOptions} from "navigo";
class CustomNavigo extends Navigo {
navigateReplace(to: string, options?: NavigateOptions) {
if (typeof options === "undefined") {
options = {}
}
options.historyAPIMethod = "replaceState"
this.navigate(to, options);
}
}
export const router = new CustomNavigo("/")
// router.on("/Wien", () => {
// map.setView(viewFromArea(Wien))
@ -15,11 +25,9 @@ export const router = new Navigo("/")
// redirect(router, "/", "/Wien")
export function redirect(router:Navigo,from:string,to:string){
export function redirect(router: CustomNavigo, from: string, to: string) {
router.on(from, () => {
router.navigate(to, {
historyAPIMethod: 'replaceState'
})
router.navigateReplace(to)
})
}