Merge branch 'bike-pumps'

This commit is contained in:
Pieter Vander Vennet 2020-07-16 17:24:30 +02:00
commit b24698513d
35 changed files with 850 additions and 282 deletions

View file

@ -3,15 +3,15 @@ import {And, Or, Tag} from "../../Logic/TagsFilter";
import {OperatorTag} from "../Questions/OperatorTag";
import * as L from "leaflet";
import FixedText from "../Questions/FixedText";
import { BikeParkingType } from "../Questions/BikeParkingType";
import ParkingType from "../Questions/bike/ParkingType";
import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload";
export class BikeParkings extends LayerDefinition {
export default class BikeParkings extends LayerDefinition {
constructor() {
super();
this.name = "bike_parking";
this.icon = "./assets/parking.svg";
this.icon = "./assets/bike/parking.svg";
this.overpassFilter = new Tag("amenity", "bicycle_parking");
this.newElementTags = [
new Tag("amenity", "bicycle_parking"),
@ -24,43 +24,21 @@ export class BikeParkings extends LayerDefinition {
this.elementsToShow = [
new ImageCarouselWithUploadConstructor(),
new OperatorTag(),
new BikeParkingType()
new ParkingType()
];
}
private generateStyleFunction() {
const self = this;
return function (properties: any) {
// let questionSeverity = 0;
// for (const qd of self.elementsToShow) {
// if (qd.IsQuestioning(properties)) {
// questionSeverity = Math.max(questionSeverity, qd.options.priority ?? 0);
// }
// }
// let colormapping = {
// 0: "#00bb00",
// 1: "#00ff00",
// 10: "#dddd00",
// 20: "#ff0000"
// };
// let colour = colormapping[questionSeverity];
// while (colour == undefined) {
// questionSeverity--;
// colour = colormapping[questionSeverity];
// }
return {
color: "#00bb00",
icon: new L.icon({
icon: L.icon({
iconUrl: self.icon,
iconSize: [30, 30]
iconSize: [50, 50]
})
};
};
}
}
}

View file

@ -1,77 +0,0 @@
import {LayerDefinition} from "../LayerDefinition";
import {And, Tag, TagsFilter} from "../../Logic/TagsFilter";
import * as L from "leaflet";
import BikeStationChain from "../Questions/BikeStationChain";
import BikeStationPumpTools from "../Questions/BikeStationPumpTools";
import BikeStationStand from "../Questions/BikeStationStand";
import PumpManual from "../Questions/PumpManual";
import BikeStationOperator from "../Questions/BikeStationOperator";
import BikeStationBrand from "../Questions/BikeStationBrand";
import FixedText from "../Questions/FixedText";
import {BikePumpManometer} from "../Questions/BikePumpManometer";
import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload";
import {BikePumpOperationalStatus} from "../Questions/BikePumpOperationalStatus";
import {BikePumpValves} from "../Questions/BikePumpValves";
export default class BikeServices extends LayerDefinition {
private readonly pump: TagsFilter = new Tag("service:bicycle:pump", "yes");
private readonly tools: TagsFilter = new Tag("service:bicycle:tools", "yes");
constructor() {
super();
this.name = "bike station or pump";
this.icon = "./assets/wrench.svg";
this.overpassFilter = new And([
new Tag("amenity", "bicycle_repair_station")
]);
this.newElementTags = [
new Tag("amenity", "bicycle_repair_station")
// new Tag("fixme", "Toegevoegd met MapComplete, geometry nog uit te tekenen")
];
this.maxAllowedOverlapPercentage = 10;
this.minzoom = 13;
this.style = this.generateStyleFunction();
this.title = new FixedText("Bike station");
this.elementsToShow = [
new ImageCarouselWithUploadConstructor(),
new BikeStationPumpTools(),
new BikeStationChain().OnlyShowIf(this.tools),
new BikeStationStand().OnlyShowIf(this.tools),
new PumpManual().OnlyShowIf(this.pump),
new BikePumpManometer().OnlyShowIf(this.pump),
new BikePumpValves().OnlyShowIf(this.pump),
new BikePumpOperationalStatus().OnlyShowIf(this.pump),
new BikeStationOperator(),
new BikeStationBrand()
];
}
private generateStyleFunction() {
const self = this;
return function (properties: any) {
const onlyPump = self.pump.matchesProperties(properties) &&
!self.tools.matchesProperties(properties)
const iconUrl = onlyPump ? "./assets/pump.svg" : "./assets/wrench.svg"
return {
color: "#00bb00",
icon: new L.icon({
iconUrl: iconUrl,
iconSize: [40, 40]
})
};
};
}
}

View file

@ -0,0 +1,89 @@
import {LayerDefinition} from "../LayerDefinition";
import {And, Tag, TagsFilter, Or} from "../../Logic/TagsFilter";
import * as L from "leaflet";
import BikeStationChain from "../Questions/bike/StationChain";
import BikeStationPumpTools from "../Questions/bike/StationPumpTools";
import BikeStationStand from "../Questions/bike/StationStand";
import PumpManual from "../Questions/bike/PumpManual";
import BikeStationOperator from "../Questions/bike/StationOperator";
import BikeStationBrand from "../Questions/bike/StationBrand";
import FixedText from "../Questions/FixedText";
import PumpManometer from "../Questions/bike/PumpManometer";
import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload";
import PumpOperational from "../Questions/bike/PumpOperational";
import PumpValves from "../Questions/bike/PumpValves";
export default class BikeStations extends LayerDefinition {
private readonly pump = new Tag("service:bicycle:pump", "yes");
private readonly pumpOperationalAny = new Tag("service:bicycle:pump:operational_status", "yes");
private readonly pumpOperationalOk = new Or([new Tag("service:bicycle:pump:operational_status", "yes"), new Tag("service:bicycle:pump:operational_status", "operational"), new Tag("service:bicycle:pump:operational_status", "ok")]);
private readonly tools = new Tag("service:bicycle:tools", "yes");
constructor() {
super();
this.name = "bike station or pump";
this.icon = "./assets/wrench.svg";
this.overpassFilter = new And([
new Tag("amenity", "bicycle_repair_station")
]);
this.newElementTags = [
new Tag("amenity", "bicycle_repair_station")
// new Tag("fixme", "Toegevoegd met MapComplete, geometry nog uit te tekenen")
];
this.maxAllowedOverlapPercentage = 10;
this.minzoom = 13;
this.style = this.generateStyleFunction();
this.title = new FixedText("Bike station");
this.elementsToShow = [
new ImageCarouselWithUploadConstructor(),
new BikeStationPumpTools(),
new BikeStationChain().OnlyShowIf(this.tools),
new BikeStationStand().OnlyShowIf(this.tools),
new PumpManual().OnlyShowIf(this.pump),
new PumpManometer().OnlyShowIf(this.pump),
new PumpValves().OnlyShowIf(this.pump),
new PumpOperational().OnlyShowIf(this.pump),
new BikeStationOperator(),
// new BikeStationBrand() DISABLED
];
}
private generateStyleFunction() {
const self = this;
return function (properties: any) {
const hasPump = self.pump.matchesProperties(properties)
const isOperational = !self.pumpOperationalAny.matchesProperties(properties) || self.pumpOperationalOk.matchesProperties(properties)
const hasTools = self.tools.matchesProperties(properties)
let iconName = ""
if (hasPump) {
if (hasTools) {
iconName = "repair_station_pump.svg"
} else {
if (isOperational) {
iconName = "pump.svg"
} else {
iconName = "pump_broken.svg"
}
}
} else {
iconName = "repair_station.svg"
}
const iconUrl = `./assets/bike/${iconName}`
return {
color: "#00bb00",
icon: L.icon({
iconUrl: iconUrl,
iconSize: [50, 50]
})
};
};
}
}

View file

@ -58,7 +58,7 @@ export class GhostBike extends LayerDefinition {
return {
color: "#000000",
icon: L.icon({
iconUrl: 'assets/ghost_bike.svg',
iconUrl: 'assets/bike/ghost.svg',
iconSize: [40, 40],
iconAnchor: [20, 20],
})

View file

@ -1,16 +1,15 @@
import {Layout} from "../Layout";
import {GrbToFix} from "../Layers/GrbToFix";
import { BikeParkings } from "../Layers/BikeParkings";
import BikeServices from "../Layers/BikeServices";
import BikeParkings from "../Layers/BikeParkings";
import BikeServices from "../Layers/BikeStations";
import {GhostBike} from "../Layers/GhostBike";
export default class Cyclofix extends Layout {
constructor() {
super(
"pomp",
"Cyclofix bicycle infrastructure",
// [new BikePumps()],
[new GhostBike(), new BikeParkings(), new BikeServices()],
[new GhostBike(), new BikeServices(), new BikeParkings()],
16,
50.8465573,
4.3516970,
@ -18,7 +17,7 @@ export default class Cyclofix extends Layout {
"<h3>Cyclofix bicycle infrastructure</h3>\n" +
"\n" +
"<p><b>EN&gt;</b> On this map we want to collect data about the whereabouts of bicycle pumps and public racks in Brussels." +
"<p><b>EN&gt;</b> On this map we want to collect data about the whereabouts of bicycle pumps and public racks in Brussels." +
"As a result, cyclists will be able to quickly find the nearest infrastructure for their needs.</p>" +
"<p><b>NL&gt;</b> Op deze kaart willen we gegevens verzamelen over de locatie van fietspompen en openbare stelplaatsen in Brussel." +
"Hierdoor kunnen fietsers snel de dichtstbijzijnde infrastructuur vinden die voldoet aan hun behoeften.</p>" +
@ -27,4 +26,4 @@ export default class Cyclofix extends Layout {
,
"", "");
}
}
}

View file

@ -1,28 +0,0 @@
import {TagRenderingOptions} from "../TagRendering";
import {Tag} from "../../Logic/TagsFilter";
export class BikeParkingType extends TagRenderingOptions {
private static options = {
priority: 5,
question: "Van welk type is deze fietsenparking?",
freeform: {
key: "bicycle_parking",
extraTags: new Tag("fixme", "Freeform bicycle_parking= tag used: possibly a wrong value"),
template: "Iets anders: $$$",
renderTemplate: "Dit is een fietsenparking van het type: {bicycle_parking}",
placeholder: "Specifieer"
},
mappings: [
{k: new Tag("bicycle_parking", "stands"), txt: "<img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dc/Bike_racks_at_north-west_of_Westfield_-_geograph.org.uk_-_1041057.jpg/100px-Bike_racks_at_north-west_of_Westfield_-_geograph.org.uk_-_1041057.jpg\">"},
{k: new Tag("bicycle_parking", "wall_loops"), txt: "<img src=\"https://wiki.openstreetmap.org/w/images/thumb/c/c2/Bike-parking-wheelbender.jpg/100px-Bike-parking-wheelbender.jpg\">"},
{k: new Tag("bicycle_parking", "handlebar_holder"), txt: "<img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Bicycle_parking_handlebar_holder.jpg/100px-Bicycle_parking_handlebar_holder.jpg\">"},
{k: new Tag("bicycle_parking", "shed"), txt: "<img src=\"https://wiki.openstreetmap.org/w/images/thumb/b/b2/Bike-shelter.jpg/100px-Bike-shelter.jpg\">"},
{k: new Tag("bicycle_parking", "two-tier"), txt: "<img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/Bicis_a_l%27estaci%C3%B3_de_Leiden.JPG/100px-Bicis_a_l%27estaci%C3%B3_de_Leiden.JPG\">"}
]
}
constructor() {
super(BikeParkingType.options);
}
}

View file

@ -1,18 +0,0 @@
import {TagRenderingOptions} from "../TagRendering";
import {Tag} from "../../Logic/TagsFilter";
export default class BikeStationChain extends TagRenderingOptions {
private static options = {
priority: 5,
question: "Does this bike station have a special tool to repair your bike chain?",
mappings: [
{k: new Tag("service:bicycle:chain_tool", "yes"), txt: "There is a chain tool."},
{k: new Tag("service:bicycle:chain_tool", "no"), txt: "There is no chain tool."},
]
}
constructor() {
super(BikeStationChain.options);
}
}

View file

@ -1,26 +0,0 @@
import {TagRenderingOptions} from "../TagRendering";
import {Tag} from "../../Logic/TagsFilter";
export default class BikeStationOperator extends TagRenderingOptions {
private static options = {
priority: 15,
question: "Who operates this bike station (name of university, shop, city...)?",
freeform: {
key: "operator",
template: "This bike station is operated by $$$",
renderTemplate: "This bike station is operated by {operator}",
placeholder: "organisatie"
},
mappings: [
{k: new Tag("operator", "KU Leuven"), txt: "KU Leuven"},
{k: new Tag("operator", "Stad Halle"), txt: "Stad Halle"},
{k: new Tag("operator", "Saint Gilles - Sint Gillis"), txt: "Saint Gilles - Sint Gillis"},
{k: new Tag("operator", "Jette"), txt: "Jette"},
{k: new Tag("operator", "private"), txt: "Beheer door een privépersoon"}
]
}
constructor() {
super(BikeStationOperator.options);
}
}

View file

@ -1,19 +0,0 @@
import {TagRenderingOptions} from "../TagRendering";
import {Tag, And} from "../../Logic/TagsFilter";
export default class BikeStationPumpTools extends TagRenderingOptions {
private static options = {
priority: 15,
question: "Which services are available at this bike station?",
mappings: [
{k: new And([new Tag("service:bicycle:tools", "no"), new Tag("service:bicycle:pump", "yes")]), txt: "There is only a pump available."},
{k: new And([new Tag("service:bicycle:tools", "yes"), new Tag("service:bicycle:pump", "no")]), txt: "There are only tools (screwdrivers, pliers...) available."},
{k: new And([new Tag("service:bicycle:tools", "yes"), new Tag("service:bicycle:pump", "yes")]), txt: "There are both tools and a pump available."}
]
}
constructor() {
super(BikeStationPumpTools.options);
}
}

View file

@ -1,18 +0,0 @@
import {TagRenderingOptions} from "../TagRendering";
import {Tag} from "../../Logic/TagsFilter";
export default class BikeStationStand extends TagRenderingOptions {
private static options = {
priority: 10,
question: "Does this bike station have a hook to suspend your bike with or a stand to elevate it?",
mappings: [
{k: new Tag("service:bicycle:stand", "yes"), txt: "There is a hook or stand."},
{k: new Tag("service:bicycle:stand", "no"), txt: "There is no hook or stand"},
]
}
constructor() {
super(BikeStationStand.options);
}
}

View file

@ -1,18 +0,0 @@
import {TagRenderingOptions} from "../TagRendering";
import {Tag} from "../../Logic/TagsFilter";
export default class PumpManual extends TagRenderingOptions {
private static options = {
priority: 5,
question: "Is the pump at this bike station manual or automatic (compressed air)?",
mappings: [
{k: new Tag("manual", "yes"), txt: "Manual"},
{k: new Tag("manual", "no"), txt: "Automatic (with compressed air)"}
]
}
constructor() {
super(PumpManual.options);
}
}

View file

@ -0,0 +1,38 @@
import {TagRenderingOptions} from "../../TagRendering";
import {Tag} from "../../../Logic/TagsFilter";
export default class ParkingType extends TagRenderingOptions {
private static images = {
stands: "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dc/Bike_racks_at_north-west_of_Westfield_-_geograph.org.uk_-_1041057.jpg/100px-Bike_racks_at_north-west_of_Westfield_-_geograph.org.uk_-_1041057.jpg",
wall_loops: "https://wiki.openstreetmap.org/w/images/thumb/c/c2/Bike-parking-wheelbender.jpg/100px-Bike-parking-wheelbender.jpg",
handlebar_holder: "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Bicycle_parking_handlebar_holder.jpg/100px-Bicycle_parking_handlebar_holder.jpg",
shed: "https://wiki.openstreetmap.org/w/images/thumb/b/b2/Bike-shelter.jpg/100px-Bike-shelter.jpg",
"two-tier": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/Bicis_a_l%27estaci%C3%B3_de_Leiden.JPG/100px-Bicis_a_l%27estaci%C3%B3_de_Leiden.JPG"
}
private static toImgTxt(url: string) {
return `<img src=${url}>`
}
constructor() {
super({
priority: 5,
question: "Van welk type is deze fietsenparking?",
freeform: {
key: "bicycle_parking",
extraTags: new Tag("fixme", "Freeform bicycle_parking= tag used: possibly a wrong value"),
template: "Iets anders: $$$",
renderTemplate: "Dit is een fietsenparking van het type: {bicycle_parking}",
placeholder: "Specifieer"
},
mappings: [
{k: new Tag("bicycle_parking", "stands"), txt: ParkingType.toImgTxt(ParkingType.images.stands)},
{k: new Tag("bicycle_parking", "wall_loops"), txt: ParkingType.toImgTxt(ParkingType.images.wall_loops)},
{k: new Tag("bicycle_parking", "handlebar_holder"), txt: ParkingType.toImgTxt(ParkingType.images.handlebar_holder)},
{k: new Tag("bicycle_parking", "shed"), txt: ParkingType.toImgTxt(ParkingType.images.shed)},
{k: new Tag("bicycle_parking", "two-tier"), txt: ParkingType.toImgTxt(ParkingType.images["two-tier"])}
]
});
}
}

View file

@ -1,8 +1,8 @@
import {TagRenderingOptions} from "../TagRendering";
import {Tag} from "../../Logic/TagsFilter";
import {TagRenderingOptions} from "../../TagRendering";
import {Tag} from "../../../Logic/TagsFilter";
export class BikePumpManometer extends TagRenderingOptions{
export default class PumpManometer extends TagRenderingOptions {
constructor() {
super({
question: "Does the pump have a pressure indicator or manometer?",
@ -11,10 +11,6 @@ export class BikePumpManometer extends TagRenderingOptions{
{k: new Tag("manometer","broken"), txt: "Yes, but it is broken"},
{k: new Tag("manometer", "yes"), txt: "No"}
]
});
});
}
}
}

View file

@ -0,0 +1,16 @@
import {TagRenderingOptions} from "../../TagRendering";
import {Tag} from "../../../Logic/TagsFilter";
export default class PumpManual extends TagRenderingOptions {
constructor() {
super({
priority: 5,
question: "Is this an electric bike pump?",
mappings: [
{k: new Tag("manual", "yes"), txt: "Manual pump"},
{k: new Tag("manual", "no"), txt: "Electric pump"}
]
});
}
}

View file

@ -1,8 +1,8 @@
import {TagDependantUIElement} from "../UIElementConstructor";
import {TagRenderingOptions} from "../TagRendering";
import {Tag} from "../../Logic/TagsFilter";
import {TagRenderingOptions} from "../../TagRendering";
import {Tag} from "../../../Logic/TagsFilter";
export class BikePumpOperationalStatus extends TagRenderingOptions{
export default class PumpOperational extends TagRenderingOptions {
constructor() {
super({
question: "Is the bicycle pump still operational?",
@ -12,4 +12,4 @@ export class BikePumpOperationalStatus extends TagRenderingOptions{
]
});
}
}
}

View file

@ -1,7 +1,8 @@
import {TagRenderingOptions} from "../TagRendering";
import {Tag} from "../../Logic/TagsFilter";
import {TagRenderingOptions} from "../../TagRendering";
import {Tag} from "../../../Logic/TagsFilter";
export class BikePumpValves extends TagRenderingOptions{
export default class PumpValves extends TagRenderingOptions{
constructor() {
super({
question: "What valves are supported?",
@ -21,4 +22,4 @@ export class BikePumpValves extends TagRenderingOptions{
}
});
}
}
}

View file

@ -1,6 +1,10 @@
import {TagRenderingOptions} from "../TagRendering";
import {Tag} from "../../Logic/TagsFilter";
import {TagRenderingOptions} from "../../TagRendering";
import {Tag} from "../../../Logic/TagsFilter";
/**
* Currently not used in Cyclofix because it's a little vague
*/
export default class BikeStationBrand extends TagRenderingOptions {
private static options = {
priority: 15,
@ -17,6 +21,7 @@ export default class BikeStationBrand extends TagRenderingOptions {
}
constructor() {
throw Error('BikeStationBrand disabled')
super(BikeStationBrand.options);
}
}

View file

@ -0,0 +1,16 @@
import {TagRenderingOptions} from "../../TagRendering";
import {Tag} from "../../../Logic/TagsFilter";
export default class StationChain extends TagRenderingOptions {
constructor() {
super({
priority: 5,
question: "Does this bike station have a special tool to repair your bike chain?",
mappings: [
{k: new Tag("service:bicycle:chain_tool", "yes"), txt: "There is a chain tool."},
{k: new Tag("service:bicycle:chain_tool", "no"), txt: "There is no chain tool."},
]
});
}
}

View file

@ -0,0 +1,25 @@
import {TagRenderingOptions} from "../../TagRendering";
import {Tag} from "../../../Logic/TagsFilter";
export default class BikeStationOperator extends TagRenderingOptions {
constructor() {
super({
priority: 15,
question: "Who operates this bike station (name of university, shop, city...)?",
freeform: {
key: "operator",
template: "This bike station is operated by $$$",
renderTemplate: "This bike station is operated by {operator}",
placeholder: "organisatie"
},
mappings: [
{k: new Tag("operator", "KU Leuven"), txt: "KU Leuven"},
{k: new Tag("operator", "Stad Halle"), txt: "Stad Halle"},
{k: new Tag("operator", "Saint Gilles - Sint Gillis"), txt: "Saint Gilles - Sint Gillis"},
{k: new Tag("operator", "Jette"), txt: "Jette"},
{k: new Tag("operator", "private"), txt: "Beheer door een privépersoon"}
]
});
}
}

View file

@ -0,0 +1,17 @@
import {TagRenderingOptions} from "../../TagRendering";
import {Tag, And} from "../../../Logic/TagsFilter";
export default class BikeStationPumpTools extends TagRenderingOptions {
constructor() {
super({
priority: 15,
question: "Which services are available at this bike station?",
mappings: [
{k: new And([new Tag("service:bicycle:tools", "no"), new Tag("service:bicycle:pump", "yes")]), txt: "There is only a pump available."},
{k: new And([new Tag("service:bicycle:tools", "yes"), new Tag("service:bicycle:pump", "no")]), txt: "There are only tools (screwdrivers, pliers...) available."},
{k: new And([new Tag("service:bicycle:tools", "yes"), new Tag("service:bicycle:pump", "yes")]), txt: "There are both tools and a pump available."}
]
});
}
}

View file

@ -0,0 +1,16 @@
import {TagRenderingOptions} from "../../TagRendering";
import {Tag} from "../../../Logic/TagsFilter";
export default class BikeStationStand extends TagRenderingOptions {
constructor() {
super({
priority: 10,
question: "Does this bike station have a hook to suspend your bike with or a stand to elevate it?",
mappings: [
{k: new Tag("service:bicycle:stand", "yes"), txt: "There is a hook or stand."},
{k: new Tag("service:bicycle:stand", "no"), txt: "There is no hook or stand"},
]
});
}
}