Fix associations
This commit is contained in:
parent
c2a2306d18
commit
cc48d34804
3 changed files with 40 additions and 41 deletions
|
@ -6,10 +6,9 @@ import {Utils} from "../Utils";
|
||||||
import CountryCoder from "latlon2country"
|
import CountryCoder from "latlon2country"
|
||||||
|
|
||||||
class SimpleMetaTagger {
|
class SimpleMetaTagger {
|
||||||
private _f: (feature: any, index: number) => void;
|
|
||||||
public readonly keys: string[];
|
public readonly keys: string[];
|
||||||
public readonly doc: string;
|
public readonly doc: string;
|
||||||
|
private _f: (feature: any, index: number) => void;
|
||||||
|
|
||||||
constructor(keys: string[], doc: string, f: ((feature: any, index: number) => void)) {
|
constructor(keys: string[], doc: string, f: ((feature: any, index: number) => void)) {
|
||||||
this.keys = keys;
|
this.keys = keys;
|
||||||
|
@ -89,39 +88,39 @@ export default class MetaTagging {
|
||||||
if (tags.opening_hours === undefined || tags._country === undefined) {
|
if (tags.opening_hours === undefined || tags._country === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try{
|
try {
|
||||||
|
|
||||||
const oh = new opening_hours(tags["opening_hours"], {
|
const oh = new opening_hours(tags["opening_hours"], {
|
||||||
lat: tags._lat,
|
lat: tags._lat,
|
||||||
lon: tags._lon,
|
lon: tags._lon,
|
||||||
address: {
|
address: {
|
||||||
country_code: tags._country.toLowerCase()
|
country_code: tags._country.toLowerCase()
|
||||||
}
|
}
|
||||||
}, {tag_key: "opening_hours"});
|
}, {tag_key: "opening_hours"});
|
||||||
// AUtomatically triggered on the next change
|
// AUtomatically triggered on the next change
|
||||||
const updateTags = () => {
|
const updateTags = () => {
|
||||||
const oldValueIsOpen = tags["_isOpen"];
|
const oldValueIsOpen = tags["_isOpen"];
|
||||||
tags["_isOpen"] = oh.getState() ? "yes" : "no";
|
tags["_isOpen"] = oh.getState() ? "yes" : "no";
|
||||||
const comment = oh.getComment();
|
const comment = oh.getComment();
|
||||||
if (comment) {
|
if (comment) {
|
||||||
tags["_isOpen:description"] = comment;
|
tags["_isOpen:description"] = comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldValueIsOpen !== tags._isOpen) {
|
if (oldValueIsOpen !== tags._isOpen) {
|
||||||
tagsSource.ping();
|
tagsSource.ping();
|
||||||
}
|
}
|
||||||
|
|
||||||
const nextChange = oh.getNextChange();
|
const nextChange = oh.getNextChange();
|
||||||
if (nextChange !== undefined) {
|
if (nextChange !== undefined) {
|
||||||
window.setTimeout(
|
window.setTimeout(
|
||||||
updateTags,
|
updateTags,
|
||||||
(nextChange.getTime() - (new Date()).getTime())
|
(nextChange.getTime() - (new Date()).getTime())
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
updateTags();
|
||||||
updateTags();
|
} catch (e) {
|
||||||
}catch(e){
|
console.error("Error while parsing opening hours of ", tags.id, e);
|
||||||
console.error(e);
|
|
||||||
tags["_isOpen"] = "parse_error";
|
tags["_isOpen"] = "parse_error";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,8 +233,8 @@ export default class MetaTagging {
|
||||||
let carWidthUsed = (onewayCar ? 1 : 2) * carWidth;
|
let carWidthUsed = (onewayCar ? 1 : 2) * carWidth;
|
||||||
properties["_width:needed:cars"] = Utils.Round(carWidthUsed);
|
properties["_width:needed:cars"] = Utils.Round(carWidthUsed);
|
||||||
properties["_width:needed:parking"] = Utils.Round(parallelParkingCount * carWidth)
|
properties["_width:needed:parking"] = Utils.Round(parallelParkingCount * carWidth)
|
||||||
|
|
||||||
|
|
||||||
let cyclistWidthUsed = 0;
|
let cyclistWidthUsed = 0;
|
||||||
if (cyclingAllowed) {
|
if (cyclingAllowed) {
|
||||||
cyclistWidthUsed = (onewayBike ? 1 : 2) * cyclistWidth;
|
cyclistWidthUsed = (onewayBike ? 1 : 2) * cyclistWidth;
|
||||||
|
@ -250,16 +249,16 @@ export default class MetaTagging {
|
||||||
carWidthUsed +
|
carWidthUsed +
|
||||||
cyclistWidthUsed +
|
cyclistWidthUsed +
|
||||||
parallelParkingCount * carWidthUsed;
|
parallelParkingCount * carWidthUsed;
|
||||||
properties["_width:needed:no_pedestrians"] =Utils.Round(targetWidthIgnoringPedestrians);
|
properties["_width:needed:no_pedestrians"] = Utils.Round(targetWidthIgnoringPedestrians);
|
||||||
|
|
||||||
const pedestriansNeed = Math.max(0, pedestrianFlowNeeded) * pedestrianWidth;
|
const pedestriansNeed = Math.max(0, pedestrianFlowNeeded) * pedestrianWidth;
|
||||||
const targetWidth = targetWidthIgnoringPedestrians + pedestriansNeed ;
|
const targetWidth = targetWidthIgnoringPedestrians + pedestriansNeed;
|
||||||
properties["_width:needed"] = Utils.Round(targetWidth);
|
properties["_width:needed"] = Utils.Round(targetWidth);
|
||||||
properties["_width:needed:pedestrians"] = Utils.Round(pedestriansNeed)
|
properties["_width:needed:pedestrians"] = Utils.Round(pedestriansNeed)
|
||||||
|
|
||||||
|
|
||||||
properties["_width:difference"] = Utils.Round(targetWidth - width );
|
properties["_width:difference"] = Utils.Round(targetWidth - width);
|
||||||
properties["_width:difference:no_pedestrians"] = Utils.Round(targetWidthIgnoringPedestrians - width) ;
|
properties["_width:difference:no_pedestrians"] = Utils.Round(targetWidthIgnoringPedestrians - width);
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
2
State.ts
2
State.ts
|
@ -25,7 +25,7 @@ export default class State {
|
||||||
// The singleton of the global state
|
// The singleton of the global state
|
||||||
public static state: State;
|
public static state: State;
|
||||||
|
|
||||||
public static vNumber = "0.2.6b";
|
public static vNumber = "0.2.6c";
|
||||||
|
|
||||||
// The user journey states thresholds when a new feature gets unlocked
|
// The user journey states thresholds when a new feature gets unlocked
|
||||||
public static userJourney = {
|
public static userJourney = {
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
"or": [
|
"or": [
|
||||||
"theme~cycling|bicycle",
|
"theme~cycling|bicycle",
|
||||||
"sport=cycling",
|
"sport=cycling",
|
||||||
"association=cycling|bicycle",
|
"association~cycling|bicycle",
|
||||||
"ngo=cycling|bicycle",
|
"ngo~cycling|bicycle",
|
||||||
"club=bicycle|cycling"
|
"club~bicycle|cycling"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"title": {
|
"title": {
|
||||||
|
|
Loading…
Reference in a new issue