Intermediate refactoring

This commit is contained in:
Pieter Vander Vennet 2020-07-20 15:59:48 +02:00
parent 93db813cfc
commit 069cddf034
103 changed files with 7950 additions and 0 deletions

View file

@ -0,0 +1,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AllKnownLayouts = void 0;
var Groen_1 = require("./Layouts/Groen");
var GRB_1 = require("./Layouts/GRB");
var Bookcases_1 = require("./Layouts/Bookcases");
var Cyclofix_1 = require("./Layouts/Cyclofix");
var WalkByBrussels_1 = require("./Layouts/WalkByBrussels");
var All_1 = require("./Layouts/All");
var MetaMap_1 = require("./Layouts/MetaMap");
var StreetWidth_1 = require("./Layouts/StreetWidth");
var Natuurpunt_1 = require("./Layouts/Natuurpunt");
var AllKnownLayouts = /** @class */ (function () {
function AllKnownLayouts() {
}
AllKnownLayouts.AllLayouts = function () {
var all = new All_1.All();
var layouts = [
new Groen_1.Groen(),
new GRB_1.GRB(),
new Cyclofix_1.default(),
new Bookcases_1.Bookcases(),
new WalkByBrussels_1.WalkByBrussels(),
new MetaMap_1.MetaMap(),
new StreetWidth_1.StreetWidth(),
new Natuurpunt_1.Natuurpunt(),
all
/*new Toilets(),
new Statues(),
*/
];
var allSets = {};
for (var _i = 0, layouts_1 = layouts; _i < layouts_1.length; _i++) {
var layout = layouts_1[_i];
allSets[layout.name] = layout;
all.layers = all.layers.concat(layout.layers);
}
return allSets;
};
AllKnownLayouts.GetSets = function (layoutNames) {
var all = new All_1.All();
for (var _i = 0, layoutNames_1 = layoutNames; _i < layoutNames_1.length; _i++) {
var name_1 = layoutNames_1[_i];
all.layers = all.layers.concat(AllKnownLayouts.allSets[name_1].layers);
}
return all;
};
AllKnownLayouts.allSets = AllKnownLayouts.AllLayouts();
return AllKnownLayouts;
}());
exports.AllKnownLayouts = AllKnownLayouts;

View file

@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LayerDefinition = void 0;
var FilteredLayer_1 = require("../Logic/FilteredLayer");
var LayerDefinition = /** @class */ (function () {
function LayerDefinition(options) {
if (options === void 0) { options = undefined; }
var _a;
/**
* If an object of the next layer is contained for this many percent in this feature, it is eaten and not shown
*/
this.maxAllowedOverlapPercentage = undefined;
if (options === undefined) {
console.log("No options!");
return;
}
this.name = options.name;
this.maxAllowedOverlapPercentage = (_a = options.maxAllowedOverlapPercentage) !== null && _a !== void 0 ? _a : 0;
this.newElementTags = options.newElementTags;
this.icon = options.icon;
this.minzoom = options.minzoom;
this.overpassFilter = options.overpassFilter;
this.title = options.title;
this.elementsToShow = options.elementsToShow;
this.style = options.style;
console.log(this);
}
LayerDefinition.prototype.asLayer = function (basemap, allElements, changes, userDetails, selectedElement, showOnPopup) {
return new FilteredLayer_1.FilteredLayer(this.name, basemap, allElements, changes, this.overpassFilter, this.maxAllowedOverlapPercentage, this.style, selectedElement, showOnPopup);
};
return LayerDefinition;
}());
exports.LayerDefinition = LayerDefinition;

View file

@ -0,0 +1,87 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Artwork = void 0;
var LayerDefinition_1 = require("../LayerDefinition");
var Question_1 = require("../../Logic/Question");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var leaflet_1 = require("leaflet");
var Artwork = /** @class */ (function (_super) {
__extends(Artwork, _super);
function Artwork() {
var _this = _super.call(this) || this;
_this.name = "artwork";
_this.newElementTags = [new TagsFilter_1.Tag("tourism", "artwork")];
_this.icon = "./assets/statue.svg";
_this.overpassFilter = new TagsFilter_1.Tag("tourism", "artwork");
_this.minzoom = 13;
_this.questions = [
Question_1.QuestionDefinition.radioAndTextQuestion("What kind of artwork is this?", 10, "artwork_type", [
{ text: "A statue", value: "statue" },
{ text: "A bust (thus a statue, but only of the head and shoulders)", value: "bust" },
{ text: "A sculpture", value: "sculpture" },
{ text: "A mural painting", value: "mural" },
{ text: "A painting", value: "painting" },
{ text: "A graffiti", value: "graffiti" },
{ text: "A relief", value: "relief" },
{ text: "An installation", value: "installation" }
]),
Question_1.QuestionDefinition.textQuestion("Whom or what is depicted in this statue?", "subject", 20).addUnrequiredTag("subject:wikidata", "*"),
Question_1.QuestionDefinition.textQuestion("Is there an inscription on this artwork?", "inscription", 16),
Question_1.QuestionDefinition.textQuestion("What is the name of this artwork? If there is no explicit name, skip the question", "name", 15),
];
_this.style = function (tags) {
return {
icon: new leaflet_1.default.icon({
iconUrl: "assets/statue.svg",
iconSize: [40, 40],
text: "hi"
}),
color: "#0000ff"
};
};
_this.elementsToShow = [
new TagMappingOptions({
key: "name",
template: "<h2>Artwork '{name}'</h2>",
missing: "Artwork"
}),
new TagMappingOptions({
key: "artwork_type",
template: "This artwork is a {artwork_type}"
}),
new TagMappingOptions({
key: "artist_name",
template: "This artwork was made by {artist_name}"
}),
new TagMappingOptions({
key: "subject",
template: "This artwork depicts {subject}"
}),
new TagMappingOptions({
key: "subject:wikidata",
template: "<a href='https://www.wikidata.org/wiki/{subject:wikidata}' target='_blank'>See more data about the subject</a>"
}),
new TagMappingOptions({
key: "website",
template: "<a href='{website}' target='_blank'>Website of the statue</a>"
}),
new TagMappingOptions({ key: "image", template: "<img class='popupImg' alt='image' src='{image}' />" })
];
return _this;
}
return Artwork;
}(LayerDefinition_1.LayerDefinition));
exports.Artwork = Artwork;

View file

@ -0,0 +1,58 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var LayerDefinition_1 = require("../LayerDefinition");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var OperatorTag_1 = require("../Questions/OperatorTag");
var L = require("leaflet");
var FixedText_1 = require("../Questions/FixedText");
var ParkingType_1 = require("../Questions/bike/ParkingType");
var ImageCarouselWithUpload_1 = require("../../UI/Image/ImageCarouselWithUpload");
var BikeParkings = /** @class */ (function (_super) {
__extends(BikeParkings, _super);
function BikeParkings() {
var _this = _super.call(this) || this;
_this.name = "bike_parking";
_this.icon = "./assets/bike/parking.svg";
_this.overpassFilter = new TagsFilter_1.Tag("amenity", "bicycle_parking");
_this.newElementTags = [
new TagsFilter_1.Tag("amenity", "bicycle_parking"),
];
_this.maxAllowedOverlapPercentage = 10;
_this.minzoom = 13;
_this.style = _this.generateStyleFunction();
_this.title = new FixedText_1.default("Fietsparking");
_this.elementsToShow = [
new ImageCarouselWithUpload_1.ImageCarouselWithUploadConstructor(),
new OperatorTag_1.OperatorTag(),
new ParkingType_1.default()
];
return _this;
}
BikeParkings.prototype.generateStyleFunction = function () {
var self = this;
return function (properties) {
return {
color: "#00bb00",
icon: L.icon({
iconUrl: self.icon,
iconSize: [50, 50]
})
};
};
};
return BikeParkings;
}(LayerDefinition_1.LayerDefinition));
exports.default = BikeParkings;

View file

@ -0,0 +1,97 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var LayerDefinition_1 = require("../LayerDefinition");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var L = require("leaflet");
var StationChain_1 = require("../Questions/bike/StationChain");
var StationPumpTools_1 = require("../Questions/bike/StationPumpTools");
var StationStand_1 = require("../Questions/bike/StationStand");
var PumpManual_1 = require("../Questions/bike/PumpManual");
var StationOperator_1 = require("../Questions/bike/StationOperator");
var FixedText_1 = require("../Questions/FixedText");
var PumpManometer_1 = require("../Questions/bike/PumpManometer");
var ImageCarouselWithUpload_1 = require("../../UI/Image/ImageCarouselWithUpload");
var PumpOperational_1 = require("../Questions/bike/PumpOperational");
var PumpValves_1 = require("../Questions/bike/PumpValves");
var BikeStations = /** @class */ (function (_super) {
__extends(BikeStations, _super);
function BikeStations() {
var _this = _super.call(this) || this;
_this.pump = new TagsFilter_1.Tag("service:bicycle:pump", "yes");
_this.pumpOperationalAny = new TagsFilter_1.Tag("service:bicycle:pump:operational_status", "yes");
_this.pumpOperationalOk = new TagsFilter_1.Or([new TagsFilter_1.Tag("service:bicycle:pump:operational_status", "yes"), new TagsFilter_1.Tag("service:bicycle:pump:operational_status", "operational"), new TagsFilter_1.Tag("service:bicycle:pump:operational_status", "ok"), new TagsFilter_1.Tag("service:bicycle:pump:operational_status", "")]);
_this.tools = new TagsFilter_1.Tag("service:bicycle:tools", "yes");
_this.name = "bike station or pump";
_this.icon = "./assets/wrench.svg";
_this.overpassFilter = new TagsFilter_1.And([
new TagsFilter_1.Tag("amenity", "bicycle_repair_station")
]);
_this.newElementTags = [
new TagsFilter_1.Tag("amenity", "bicycle_repair_station")
];
_this.maxAllowedOverlapPercentage = 10;
_this.minzoom = 13;
_this.style = _this.generateStyleFunction();
_this.title = new FixedText_1.default("Bike station");
_this.elementsToShow = [
new ImageCarouselWithUpload_1.ImageCarouselWithUploadConstructor(),
new StationPumpTools_1.default(),
new StationChain_1.default().OnlyShowIf(_this.tools),
new StationStand_1.default().OnlyShowIf(_this.tools),
new PumpManual_1.default().OnlyShowIf(_this.pump),
new PumpManometer_1.default().OnlyShowIf(_this.pump),
new PumpValves_1.default().OnlyShowIf(_this.pump),
new PumpOperational_1.default().OnlyShowIf(_this.pump),
new StationOperator_1.default(),
];
return _this;
}
BikeStations.prototype.generateStyleFunction = function () {
var self = this;
return function (properties) {
var hasPump = self.pump.matchesProperties(properties);
var isOperational = self.pumpOperationalOk.matchesProperties(properties);
var hasTools = self.tools.matchesProperties(properties);
var 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";
}
var iconUrl = "./assets/bike/" + iconName;
return {
color: "#00bb00",
icon: L.icon({
iconUrl: iconUrl,
iconSize: [50, 50]
})
};
};
};
return BikeStations;
}(LayerDefinition_1.LayerDefinition));
exports.default = BikeStations;

View file

@ -0,0 +1,145 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Birdhide = void 0;
var LayerDefinition_1 = require("../LayerDefinition");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var TagRendering_1 = require("../TagRendering");
var FixedText_1 = require("../Questions/FixedText");
var ImageCarouselWithUpload_1 = require("../../UI/Image/ImageCarouselWithUpload");
var leaflet_1 = require("leaflet");
var Birdhide = /** @class */ (function (_super) {
__extends(Birdhide, _super);
function Birdhide() {
var _this = _super.call(this, {
name: "vogelkijkplaats",
overpassFilter: Birdhide.birdhide,
elementsToShow: [new FixedText_1.default("hi")],
icon: "assets/nature/birdhide.svg",
minzoom: 12,
newElementTags: [Birdhide.birdhide],
style: function (tags) {
return { color: "", icon: undefined };
},
}) || this;
function rmStart(toRemove, title) {
if (title.toLowerCase().indexOf(toRemove.toLowerCase()) == 0) {
return title.substr(toRemove.length).trim();
}
return title;
}
function rmStarts(toRemove, title) {
for (var _i = 0, toRemove_1 = toRemove; _i < toRemove_1.length; _i++) {
var toRm = toRemove_1[_i];
title = rmStart(toRm, title);
}
return title;
}
_this.title = new TagRendering_1.TagRenderingOptions({
tagsPreprocessor: function (tags) {
if (tags.name) {
var nm = rmStarts(["Vogelkijkhut", "Vogelkijkwand", "Kijkwand", "Kijkhut"], tags.name);
tags.name = " '" + nm + "'";
}
else {
tags.name = "";
}
},
mappings: [
{
k: new TagsFilter_1.And([new TagsFilter_1.Tag("shelter", "no"), new TagsFilter_1.Tag("building", "")]),
txt: "Vogelkijkwand{name}"
},
{
k: new TagsFilter_1.And([new TagsFilter_1.Tag("amenity", "shelter"), new TagsFilter_1.Tag("building", "yes")]),
txt: "Vogelijkhut{name}"
},
{
k: new TagsFilter_1.Tag("amenity", "shelter"),
txt: "Vogelijkhut{name}"
},
{
k: new TagsFilter_1.Tag("building", "yes"),
txt: "Vogelijkhut{name}"
},
{ k: null, txt: "Vogelkijkplaats{name}" }
]
});
_this.style = function (properties) {
var icon = "assets/nature/birdhide.svg";
if (new TagsFilter_1.Or([new TagsFilter_1.Tag("amenity", "shelter"), new TagsFilter_1.Tag("building", "yes"), new TagsFilter_1.Tag("shelter", "yes")]).matchesProperties(properties)) {
icon = "assets/nature/birdshelter.svg";
}
return {
color: "#0000bb",
icon: leaflet_1.default.icon({
iconUrl: icon,
iconSize: [40, 40],
iconAnchor: [20, 20]
})
};
};
_this.elementsToShow = [
new ImageCarouselWithUpload_1.ImageCarouselWithUploadConstructor(),
new TagRendering_1.TagRenderingOptions({
question: "Is dit een kijkwand of kijkhut?",
mappings: [
{
k: new TagsFilter_1.And([new TagsFilter_1.Tag("shelter", "no"), new TagsFilter_1.Tag("building", ""), new TagsFilter_1.Tag("amenity", "")]),
txt: "Vogelkijkwand"
},
{
k: new TagsFilter_1.And([new TagsFilter_1.Tag("amenity", "shelter"), new TagsFilter_1.Tag("building", "yes"), new TagsFilter_1.Tag("shelter", "yes")]),
txt: "Vogelijkhut"
}
]
}),
new TagRendering_1.TagRenderingOptions({
question: "Is ze rolstoeltoegankelijk?",
mappings: [
{
k: new TagsFilter_1.Tag("wheelchair", "no"),
txt: "Niet rolstoeltoegankelijk"
},
{
k: new TagsFilter_1.Tag("wheelchair", "limited"),
txt: "Een rolstoel raakt er, maar het is niet makkelijk"
},
{
k: new TagsFilter_1.Tag("wheelchair", "yes"),
txt: "Een rolstoel raakt er gemakkelijk"
}
]
}),
new TagRendering_1.TagRenderingOptions({
question: "Wie beheert deze?",
freeform: {
key: "operator",
template: "Beheer door $$$",
renderTemplate: "Beheer door {operator}",
placeholder: "organisatie"
},
mappings: [
{ k: new TagsFilter_1.Tag("operator", "Natuurpunt"), txt: "Natuurpunt" },
{ k: new TagsFilter_1.Tag("operator", "Agentschap Natuur en Bos"), txt: "het Agentschap Natuur en Bos (ANB)" },
]
})
];
return _this;
}
Birdhide.birdhide = new TagsFilter_1.Tag("leisure", "bird_hide");
return Birdhide;
}(LayerDefinition_1.LayerDefinition));
exports.Birdhide = Birdhide;

View file

@ -0,0 +1,167 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Bookcases = void 0;
var LayerDefinition_1 = require("../LayerDefinition");
var leaflet_1 = require("leaflet");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var TagRendering_1 = require("../TagRendering");
var NameInline_1 = require("../Questions/NameInline");
var ImageCarouselWithUpload_1 = require("../../UI/Image/ImageCarouselWithUpload");
var Bookcases = /** @class */ (function (_super) {
__extends(Bookcases, _super);
function Bookcases() {
var _this = _super.call(this) || this;
_this.name = "boekenkast";
_this.newElementTags = [new TagsFilter_1.Tag("amenity", "public_bookcase")];
_this.icon = "./assets/bookcase.svg";
_this.overpassFilter = new TagsFilter_1.Tag("amenity", "public_bookcase");
_this.minzoom = 11;
_this.title = new NameInline_1.NameInline("ruilboekenkastje");
_this.elementsToShow = [
new ImageCarouselWithUpload_1.ImageCarouselWithUploadConstructor(),
new TagRendering_1.TagRenderingOptions({
question: "Heeft dit boekenruilkastje een naam?",
freeform: {
key: "name",
template: "De naam is $$$",
renderTemplate: "",
placeholder: "",
extraTags: new TagsFilter_1.Tag("noname", "")
},
mappings: [
{ k: new TagsFilter_1.Tag("noname", "yes"), txt: "Neen, er is geen naam aangeduid op het boekenruilkastje" },
]
}),
new TagRendering_1.TagRenderingOptions({
question: "Hoeveel boeken passen in dit boekenruilkastje?",
freeform: {
renderTemplate: "Er passen {capacity} boeken in dit boekenruilkastje",
template: "Er passen $$$ boeken in dit boekenruilkastje",
key: "capacity",
placeholder: "aantal"
},
}),
new TagRendering_1.TagRenderingOptions({
question: "Wat voor soort boeken heeft dit boekenruilkastje?",
mappings: [
{ k: new TagsFilter_1.Tag("books", "children"), txt: "Voornamelijk kinderboeken" },
{ k: new TagsFilter_1.Tag("books", "adults"), txt: "Voornamelijk boeken voor volwassenen" },
{ k: new TagsFilter_1.Tag("books", "children;adults"), txt: "Zowel kinderboeken als boeken voor volwassenen" }
],
}),
new TagRendering_1.TagRenderingOptions({
question: "Staat dit boekenruilkastje binnen of buiten?",
mappings: [
{ k: new TagsFilter_1.Tag("indoor", "yes"), txt: "Dit boekenruilkastje staat binnen" },
{ k: new TagsFilter_1.Tag("indoor", "no"), txt: "Dit boekenruilkastje staat buiten" },
{ k: new TagsFilter_1.Tag("indoor", ""), txt: "Dit boekenruilkastje staat buiten" }
]
}),
new TagRendering_1.TagRenderingOptions({
question: "Is dit boekenruilkastje vrij toegankelijk?",
mappings: [
{ k: new TagsFilter_1.Tag("access", "yes"), txt: "Ja, vrij toegankelijk" },
{ k: new TagsFilter_1.Tag("access", "customers"), txt: "Enkel voor klanten" },
]
}).OnlyShowIf(new TagsFilter_1.Tag("indoor", "yes")),
new TagRendering_1.TagRenderingOptions({
question: "Wie (welke organisatie) beheert dit boekenruilkastje?",
freeform: {
key: "opeartor",
renderTemplate: "Dit boekenruilkastje wordt beheerd door {operator}",
template: "Dit boekenruilkastje wordt beheerd door $$$"
}
}),
new TagRendering_1.TagRenderingOptions({
question: "Zijn er openingsuren voor dit boekenruilkastje?",
mappings: [
{ k: new TagsFilter_1.Tag("opening_hours", "24/7"), txt: "Dag en nacht toegankelijk" },
{ k: new TagsFilter_1.Tag("opening_hours", ""), txt: "Dag en nacht toegankelijk" },
{ k: new TagsFilter_1.Tag("opening_hours", "sunrise-sunset"), txt: "Van zonsopgang tot zonsondergang" },
],
freeform: {
key: "opening_hours",
renderTemplate: "De openingsuren zijn {opening_hours}",
template: "De openingsuren zijn $$$"
}
}),
new TagRendering_1.TagRenderingOptions({
question: "Is dit boekenruilkastje deel van een netwerk?",
freeform: {
key: "brand",
renderTemplate: "Deel van het netwerk {brand}",
template: "Deel van het netwerk $$$"
},
mappings: [{
k: new TagsFilter_1.And([new TagsFilter_1.Tag("brand", "Little Free Library"), new TagsFilter_1.Tag("nobrand", "")]),
txt: "Little Free Library"
},
{
k: new TagsFilter_1.And([new TagsFilter_1.Tag("brand", ""), new TagsFilter_1.Tag("nobrand", "yes")]),
txt: "Maakt geen deel uit van een groter netwerk"
}]
}).OnlyShowIf(new TagsFilter_1.Or([
new TagsFilter_1.Tag("ref", ""),
new TagsFilter_1.And([new TagsFilter_1.Tag("ref", "*"), new TagsFilter_1.Tag("brand", "")])
])),
new TagRendering_1.TagRenderingOptions({
question: "Wat is het referentienummer van dit boekenruilkastje?",
freeform: {
key: "ref",
template: "Het referentienummer is $$$",
renderTemplate: "Gekend als {brand} <b>{ref}</b>"
}
}).OnlyShowIf(new TagsFilter_1.Tag("brand", "*")),
new TagRendering_1.TagRenderingOptions({
question: "Wanneer werd dit boekenruilkastje geinstalleerd?",
priority: -1,
freeform: {
key: "start_date",
renderTemplate: "Geplaatst op {start_date}",
template: "Geplaatst op $$$"
}
}),
new TagRendering_1.TagRenderingOptions({
question: "Is er een website waar we er meer informatie is over dit boekenruilkastje?",
freeform: {
key: "website",
renderTemplate: "<a href='{website}' target='_blank'>Meer informatie over dit boekenruilkastje</a>",
template: "$$$",
placeholder: "website"
}
}),
new TagRendering_1.TagRenderingOptions({
freeform: {
key: "description",
renderTemplate: "<b>Beschrijving door de uitbater:</b><br>{description}",
template: "$$$",
}
})
];
_this.style = function (tags) {
return {
icon: new leaflet_1.default.icon({
iconUrl: "assets/bookcase.svg",
iconSize: [40, 40]
}),
color: "#0000ff"
};
};
return _this;
}
return Bookcases;
}(LayerDefinition_1.LayerDefinition));
exports.Bookcases = Bookcases;

View file

@ -0,0 +1,85 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Bos = void 0;
var LayerDefinition_1 = require("../LayerDefinition");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var AccessTag_1 = require("../Questions/AccessTag");
var OperatorTag_1 = require("../Questions/OperatorTag");
var NameQuestion_1 = require("../Questions/NameQuestion");
var NameInline_1 = require("../Questions/NameInline");
var DescriptionQuestion_1 = require("../Questions/DescriptionQuestion");
var ImageCarouselWithUpload_1 = require("../../UI/Image/ImageCarouselWithUpload");
var Bos = /** @class */ (function (_super) {
__extends(Bos, _super);
function Bos() {
var _this = _super.call(this) || this;
_this.name = "bos";
_this.icon = "./assets/tree_white_background.svg";
_this.overpassFilter = new TagsFilter_1.Or([
new TagsFilter_1.Tag("natural", "wood"),
new TagsFilter_1.Tag("landuse", "forest"),
new TagsFilter_1.Tag("natural", "scrub")
]);
_this.newElementTags = [
new TagsFilter_1.Tag("landuse", "forest"),
new TagsFilter_1.Tag("fixme", "Toegevoegd met MapComplete, geometry nog uit te tekenen")
];
_this.maxAllowedOverlapPercentage = 10;
_this.minzoom = 13;
_this.style = _this.generateStyleFunction();
_this.title = new NameInline_1.NameInline("bos");
_this.elementsToShow = [
new ImageCarouselWithUpload_1.ImageCarouselWithUploadConstructor(),
new NameQuestion_1.NameQuestion(),
new AccessTag_1.AccessTag(),
new OperatorTag_1.OperatorTag(),
new DescriptionQuestion_1.DescriptionQuestion("bos")
];
return _this;
}
Bos.prototype.generateStyleFunction = function () {
var self = this;
return function (properties) {
var questionSeverity = 0;
for (var _i = 0, _a = self.elementsToShow; _i < _a.length; _i++) {
var qd = _a[_i];
if (qd instanceof DescriptionQuestion_1.DescriptionQuestion) {
continue;
}
if (qd.IsQuestioning(properties)) {
questionSeverity = Math.max(questionSeverity, qd.Priority());
}
}
var colormapping = {
0: "#00bb00",
1: "#00ff00",
10: "#dddd00",
20: "#ff0000"
};
var colour = colormapping[questionSeverity];
while (colour == undefined) {
questionSeverity--;
colour = colormapping[questionSeverity];
}
return {
color: colour,
icon: undefined
};
};
};
return Bos;
}(LayerDefinition_1.LayerDefinition));
exports.Bos = Bos;

View file

@ -0,0 +1,71 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DrinkingWater = void 0;
var LayerDefinition_1 = require("../LayerDefinition");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var OperatorTag_1 = require("../Questions/OperatorTag");
var L = require("leaflet");
var FixedText_1 = require("../Questions/FixedText");
var TagRendering_1 = require("../TagRendering");
var ImageCarouselWithUpload_1 = require("../../UI/Image/ImageCarouselWithUpload");
var DrinkingWater = /** @class */ (function (_super) {
__extends(DrinkingWater, _super);
function DrinkingWater() {
var _this = _super.call(this) || this;
_this.name = "drinking_water";
_this.icon = "./assets/bug.svg";
_this.overpassFilter = new TagsFilter_1.Or([
new TagsFilter_1.And([
new TagsFilter_1.Tag("amenity", "drinking_water")
])
]);
_this.newElementTags = [
new TagsFilter_1.Tag("amenity", "drinking_water"),
];
_this.maxAllowedOverlapPercentage = 10;
_this.minzoom = 13;
_this.style = _this.generateStyleFunction();
_this.title = new FixedText_1.default("Drinking water");
_this.elementsToShow = [
new OperatorTag_1.OperatorTag(),
];
_this.elementsToShow = [
new ImageCarouselWithUpload_1.ImageCarouselWithUploadConstructor(),
new TagRendering_1.TagRenderingOptions({
question: "How easy is it to fill water bottles?",
mappings: [
{ k: new TagsFilter_1.Tag("bottle", "yes"), txt: "It is easy to refill water bottles" },
{ k: new TagsFilter_1.Tag("bottle", "no"), txt: "Water bottles may not fit" }
],
})
];
return _this;
}
DrinkingWater.prototype.generateStyleFunction = function () {
var self = this;
return function (properties) {
return {
color: "#00bb00",
icon: new L.icon({
iconUrl: self.icon,
iconSize: [40, 40]
})
};
};
};
return DrinkingWater;
}(LayerDefinition_1.LayerDefinition));
exports.DrinkingWater = DrinkingWater;

View file

@ -0,0 +1,80 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.GhostBike = void 0;
var LayerDefinition_1 = require("../LayerDefinition");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var TagRendering_1 = require("../TagRendering");
var FixedText_1 = require("../Questions/FixedText");
var ImageCarouselWithUpload_1 = require("../../UI/Image/ImageCarouselWithUpload");
var leaflet_1 = require("leaflet");
var GhostBike = /** @class */ (function (_super) {
__extends(GhostBike, _super);
function GhostBike() {
var _this = _super.call(this) || this;
_this.name = "ghost bike";
_this.overpassFilter = new TagsFilter_1.Tag("memorial", "ghost_bike");
_this.title = new FixedText_1.default("Ghost bike");
_this.elementsToShow = [
new FixedText_1.default("A <b>ghost bike</b> is a memorial for a cyclist who died in a traffic accident," +
" in the form of a white bicycle placed permanently near the accident location."),
new ImageCarouselWithUpload_1.ImageCarouselWithUploadConstructor(),
new TagRendering_1.TagRenderingOptions({
question: "Whom is remembered by this ghost bike?" +
"<span class='question-subtext'>" +
"<br/>" +
"Please respect privacy - only fill out the name if it is widely published or marked on the cycle." +
"</span>",
mappings: [{ k: new TagsFilter_1.Tag("noname", "yes"), txt: "There is no name marked on the bike" },],
freeform: {
key: "name",
extraTags: new TagsFilter_1.Tag("noname", ""),
template: "$$$",
renderTemplate: "In the remembrance of <b>{name}</b>",
}
}),
new TagRendering_1.TagRenderingOptions({
question: "When was the ghost bike installed?",
freeform: {
key: "start_date",
template: "The ghost bike was placed on $$$",
renderTemplate: "The ghost bike was placed on <b>{start_date}</b>",
}
}),
new TagRendering_1.TagRenderingOptions({
question: "On what URL can more information be found?" +
"<span class='question-subtext'>If available, add a link to a news report about the accident or about the placing of the ghost bike</span>",
freeform: {
key: "source",
template: "More information available on $$$",
renderTemplate: "<a href='{source}' target='_blank'>More information</a>",
}
}),
];
_this.style = function (tags) {
return {
color: "#000000",
icon: leaflet_1.default.icon({
iconUrl: 'assets/bike/ghost.svg',
iconSize: [40, 40],
iconAnchor: [20, 20],
})
};
};
return _this;
}
return GhostBike;
}(LayerDefinition_1.LayerDefinition));
exports.GhostBike = GhostBike;

View file

@ -0,0 +1,90 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.GrbToFix = void 0;
var LayerDefinition_1 = require("../LayerDefinition");
var leaflet_1 = require("leaflet");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var TagRendering_1 = require("../TagRendering");
var GrbToFix = /** @class */ (function (_super) {
__extends(GrbToFix, _super);
function GrbToFix() {
var _this = _super.call(this) || this;
_this.name = "grb";
_this.newElementTags = undefined;
_this.icon = "./assets/star.svg";
_this.overpassFilter = new TagsFilter_1.Regex("fixme", "GRB");
_this.minzoom = 13;
_this.style = function (tags) {
return {
icon: new leaflet_1.default.icon({
iconUrl: "assets/star.svg",
iconSize: [40, 40],
text: "hi"
}),
color: "#ff0000"
};
};
_this.title = new TagRendering_1.TagRenderingOptions({
freeform: {
key: "fixme",
renderTemplate: "{fixme}",
template: "Fixme $$$"
}
});
_this.elementsToShow = [
new TagRendering_1.TagRenderingOptions({
freeform: {
key: "addr:street",
renderTemplate: "Het adres is {addr:street} <b>{addr:housenumber}</b>",
template: "Straat? $$$"
}
}),
new TagRendering_1.TagRenderingOptions({
question: "Wat is het huisnummer?",
tagsPreprocessor: function (tags) {
var telltale = "GRB thinks that this has number ";
var index = tags.fixme.indexOf(telltale);
if (index >= 0) {
var housenumber = tags.fixme.slice(index + telltale.length);
tags["grb:housenumber:human"] = housenumber;
tags["grb:housenumber"] = housenumber == "no number" ? "" : housenumber;
}
},
freeform: {
key: "addr:housenumber",
template: "Het huisnummer is $$$",
renderTemplate: "Het huisnummer is <b>{addr:housenumber}</b>, GRB denkt <i>{grb:housenumber:human}</i>",
extraTags: new TagsFilter_1.Tag("fixme", "")
},
mappings: [
{
k: new TagsFilter_1.And([new TagsFilter_1.Tag("addr:housenumber", "{grb:housenumber}"), new TagsFilter_1.Tag("fixme", "")]),
txt: "Volg GRB: <b>{grb:housenumber:human}</b>",
substitute: true
},
{
k: new TagsFilter_1.And([new TagsFilter_1.Tag("addr:housenumber", "{addr:housenumber}"), new TagsFilter_1.Tag("fixme", "")]),
txt: "Volg OSM: <b>{addr:housenumber}</b>",
substitute: true
}
]
})
];
return _this;
}
return GrbToFix;
}(LayerDefinition_1.LayerDefinition));
exports.GrbToFix = GrbToFix;

View file

@ -0,0 +1,122 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.InformationBoard = void 0;
var LayerDefinition_1 = require("../LayerDefinition");
var ImageCarouselWithUpload_1 = require("../../UI/Image/ImageCarouselWithUpload");
var TagRendering_1 = require("../TagRendering");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var leaflet_1 = require("leaflet");
var InformationBoard = /** @class */ (function (_super) {
__extends(InformationBoard, _super);
function InformationBoard() {
var _this = _super.call(this, {
name: "Informatiebord",
minzoom: 12,
overpassFilter: new TagsFilter_1.Tag("tourism", "information"),
newElementTags: [new TagsFilter_1.Tag("tourism", "information")],
maxAllowedOverlapPercentage: 0,
icon: "assets/nature/info.png",
}) || this;
var isMap = new TagsFilter_1.Tag("information", "map");
var isOsmSource = new TagsFilter_1.Tag("map_source", "OpenStreetMap");
_this.title = new TagRendering_1.TagRenderingOptions({
mappings: [
{ k: isMap, txt: "Kaart" },
{ k: null, txt: "Informatiebord" }
]
});
_this.style = function (properties) {
var icon = "assets/nature/info.png";
if (isMap.matchesProperties(properties)) {
icon = "assets/map.svg";
if (isOsmSource.matchesProperties(properties)) {
icon = "assets/osm-logo-white-bg.svg";
var attr = properties["map_source:attribution"];
if (attr == "sticker") {
icon = "assets/map-stickered.svg";
}
else if (attr == "no") {
icon = "assets/osm-logo-buggy-attr.svg";
}
}
}
return {
color: "#000000",
icon: leaflet_1.default.icon({
iconUrl: icon,
iconSize: [50, 50]
})
};
};
_this.elementsToShow = [
new ImageCarouselWithUpload_1.ImageCarouselWithUploadConstructor(),
new TagRendering_1.TagRenderingOptions({
question: "Heeft dit informatiebord een kaart?",
mappings: [
{ k: new TagsFilter_1.Tag("information", "board"), txt: "Dit is een informatiebord" },
{ k: isMap, txt: "Dit is een kaart" }
]
}),
new TagRendering_1.TagRenderingOptions({
question: "Is this map based on OpenStreetMap?",
mappings: [
{
k: isOsmSource,
txt: "This map is based on OpenStreetMap"
},
{
k: new TagsFilter_1.And([new TagsFilter_1.Tag("map_source:attribution", ""), new TagsFilter_1.Tag("map_source", "")]),
txt: "Unknown"
},
],
freeform: {
key: "map_source",
extraTags: new TagsFilter_1.Tag("map_source:attribution", ""),
renderTemplate: "The map data is based on {map_source}",
template: "The map data is based on $$$"
}
}).OnlyShowIf(isMap),
new TagRendering_1.TagRenderingOptions({
question: "Is the attribution present?",
mappings: [
{
k: new TagsFilter_1.Tag("map_source:attribution", "yes"),
txt: "OpenStreetMap is clearly attribute, including the ODBL-license"
},
{
k: new TagsFilter_1.Tag("map_source:attribution", "incomplete"),
txt: "OpenStreetMap is clearly attribute, but the license is not mentioned"
},
{
k: new TagsFilter_1.Tag("map_source:attribution", "sticker"),
txt: "OpenStreetMap wasn't mentioned, but someone put an OpenStreetMap-sticker on it"
},
{
k: new TagsFilter_1.Tag("map_source:attribution", "no"),
txt: "There is no attribution at all"
},
{
k: new TagsFilter_1.Tag("map_source:attribution", "none"),
txt: "There is no attribution at all"
}
]
}).OnlyShowIf(new TagsFilter_1.Tag("map_source", "OpenStreetMap"))
];
return _this;
}
return InformationBoard;
}(LayerDefinition_1.LayerDefinition));
exports.InformationBoard = InformationBoard;

View file

@ -0,0 +1,99 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Map = void 0;
var LayerDefinition_1 = require("../LayerDefinition");
var FixedText_1 = require("../Questions/FixedText");
var ImageCarouselWithUpload_1 = require("../../UI/Image/ImageCarouselWithUpload");
var TagRendering_1 = require("../TagRendering");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var leaflet_1 = require("leaflet");
var Map = /** @class */ (function (_super) {
__extends(Map, _super);
function Map() {
var _this = _super.call(this) || this;
_this.name = "Map";
_this.title = new FixedText_1.default("Map");
_this.minzoom = 12;
_this.overpassFilter = new TagsFilter_1.Tag("information", "map");
_this.newElementTags = [new TagsFilter_1.Tag("tourism", "information"), new TagsFilter_1.Tag("information", "map")];
var isOsmSource = new TagsFilter_1.Tag("map_source", "OpenStreetMap");
_this.style = function (properties) {
var icon = "assets/map.svg";
if (isOsmSource.matchesProperties(properties)) {
icon = "assets/osm-logo-white-bg.svg";
var attr = properties["map_source:attribution"];
if (attr == "sticker") {
icon = "assets/map-stickered.svg";
}
else if (attr == "no") {
icon = "assets/osm-logo-buggy-attr.svg";
}
}
return {
color: "#000000",
icon: leaflet_1.default.icon({
iconUrl: icon,
iconSize: [50, 50]
})
};
};
_this.elementsToShow = [
new ImageCarouselWithUpload_1.ImageCarouselWithUploadConstructor(),
new TagRendering_1.TagRenderingOptions({
question: "Is this map based on OpenStreetMap?",
mappings: [
{
k: isOsmSource,
txt: "This map is based on OpenStreetMap"
},
],
freeform: {
key: "map_source",
renderTemplate: "The map data is based on {map_source}",
template: "The map data is based on $$$"
}
}),
new TagRendering_1.TagRenderingOptions({
question: "Is the attribution present?",
mappings: [
{
k: new TagsFilter_1.Tag("map_source:attribution", "yes"),
txt: "OpenStreetMap is clearly attribute, including the ODBL-license"
},
{
k: new TagsFilter_1.Tag("map_source:attribution", "incomplete"),
txt: "OpenStreetMap is clearly attribute, but the license is not mentioned"
},
{
k: new TagsFilter_1.Tag("map_source:attribution", "sticker"),
txt: "OpenStreetMap wasn't mentioned, but someone put an OpenStreetMap-sticker on it"
},
{
k: new TagsFilter_1.Tag("map_source:attribution", "no"),
txt: "There is no attribution at all"
},
{
k: new TagsFilter_1.Tag("map_source:attribution", "none"),
txt: "There is no attribution at all"
}
]
}).OnlyShowIf(new TagsFilter_1.Tag("map_source", "OpenStreetMap"))
];
return _this;
}
return Map;
}(LayerDefinition_1.LayerDefinition));
exports.Map = Map;

View file

@ -0,0 +1,134 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.NatureReserves = void 0;
var LayerDefinition_1 = require("../LayerDefinition");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var TagRendering_1 = require("../TagRendering");
var AccessTag_1 = require("../Questions/AccessTag");
var OperatorTag_1 = require("../Questions/OperatorTag");
var NameQuestion_1 = require("../Questions/NameQuestion");
var NameInline_1 = require("../Questions/NameInline");
var DescriptionQuestion_1 = require("../Questions/DescriptionQuestion");
var ImageCarouselWithUpload_1 = require("../../UI/Image/ImageCarouselWithUpload");
var NatureReserves = /** @class */ (function (_super) {
__extends(NatureReserves, _super);
function NatureReserves(moreQuests) {
if (moreQuests === void 0) { moreQuests = false; }
var _this = _super.call(this) || this;
_this.name = "natuurgebied";
_this.icon = "./assets/tree_white_background.svg";
_this.overpassFilter =
new TagsFilter_1.Or([new TagsFilter_1.Tag("leisure", "nature_reserve"), new TagsFilter_1.Tag("boundary", "protected_area")]);
_this.maxAllowedOverlapPercentage = 10;
_this.newElementTags = [new TagsFilter_1.Tag("leisure", "nature_reserve"),
new TagsFilter_1.Tag("fixme", "Toegevoegd met MapComplete, geometry nog uit te tekenen")];
_this.minzoom = 13;
_this.title = new NameInline_1.NameInline("natuurreservaat");
_this.style = _this.generateStyleFunction();
_this.elementsToShow = [
new ImageCarouselWithUpload_1.ImageCarouselWithUploadConstructor(),
new NameQuestion_1.NameQuestion(),
new AccessTag_1.AccessTag(),
new OperatorTag_1.OperatorTag(),
new DescriptionQuestion_1.DescriptionQuestion("natuurgebied")
];
var extraRenderings = [
new TagRendering_1.TagRenderingOptions({
question: "Mogen honden in dit natuurgebied?",
mappings: [
{ k: new TagsFilter_1.Tag("dog", "leashed"), txt: "Honden moeten aan de leiband" },
{ k: new TagsFilter_1.Tag("dog", "no"), txt: "Honden zijn niet toegestaan" },
{ k: new TagsFilter_1.Tag("dog", "yes"), txt: "Honden zijn welkom" },
]
}).OnlyShowIf(new TagsFilter_1.Tag("access", "yes")),
new TagRendering_1.TagRenderingOptions({
question: "Op welke website kunnen we meer informatie vinden over dit natuurgebied?",
freeform: {
key: "website",
renderTemplate: "<a href='{website}' target='_blank'>Meer informatie</a>",
template: "$$$"
}
}),
new TagRendering_1.TagRenderingOptions({
question: "Wie is de conservator van dit gebied?<br>" +
"<span class='question-subtext'>Geef de naam van de conservator énkel als die duidelijk online staat gepubliceerd.</span>",
freeform: {
renderTemplate: "De conservator van dit gebied is {curator}",
template: "$$$",
key: "curator"
}
}),
new TagRendering_1.TagRenderingOptions({
question: "Wat is het email-adres van de beheerder?<br>" +
"<span class='question-subtext'>Geef bij voorkeur het emailadres van de Natuurpunt-afdeling; geef enkel een email-adres van de conservator als dit duidelijk is gepubliceerd</span>",
freeform: {
renderTemplate: "Bij problemen of vragen, de conservator kan bereikt worden via " +
"<a href='mailto:{email}'>{email}</a>",
template: "$$$",
key: "email"
}
}),
new TagRendering_1.TagRenderingOptions({
question: "Wat is het telefoonnummer van de beheerder?<br>" +
"<span class='question-subtext'>Geef bij voorkeur het telefoonnummer van de Natuurpunt-afdeling; geef enkel een email-adres van de conservator als dit duidelijk is gepubliceerd</span>",
freeform: {
renderTemplate: "Bij problemen of vragen, de {conservator} kan bereikt worden via " +
"<a href='tel:{phone}'>{phone}</a>",
template: "$$$",
key: "phone"
}
}),
];
if (moreQuests) {
_this.elementsToShow =
_this.elementsToShow.concat(extraRenderings);
}
return _this;
}
NatureReserves.prototype.generateStyleFunction = function () {
var self = this;
return function (properties) {
var _a;
var questionSeverity = 0;
for (var _i = 0, _b = self.elementsToShow; _i < _b.length; _i++) {
var qd = _b[_i];
if (qd instanceof DescriptionQuestion_1.DescriptionQuestion) {
continue;
}
if (qd.IsQuestioning(properties)) {
questionSeverity = Math.max(questionSeverity, (_a = qd.Priority()) !== null && _a !== void 0 ? _a : 0);
}
}
var colormapping = {
0: "#00bb00",
1: "#00ff00",
10: "#dddd00",
20: "#ff0000"
};
var colour = colormapping[questionSeverity];
while (colour == undefined) {
questionSeverity--;
colour = colormapping[questionSeverity];
}
return {
color: colour,
icon: undefined
};
};
};
return NatureReserves;
}(LayerDefinition_1.LayerDefinition));
exports.NatureReserves = NatureReserves;

View file

@ -0,0 +1,108 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Park = void 0;
var LayerDefinition_1 = require("../LayerDefinition");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var TagRendering_1 = require("../TagRendering");
var NameQuestion_1 = require("../Questions/NameQuestion");
var NameInline_1 = require("../Questions/NameInline");
var DescriptionQuestion_1 = require("../Questions/DescriptionQuestion");
var ImageCarouselWithUpload_1 = require("../../UI/Image/ImageCarouselWithUpload");
var Park = /** @class */ (function (_super) {
__extends(Park, _super);
function Park() {
var _this = _super.call(this) || this;
_this.accessByDefault = new TagRendering_1.TagRenderingOptions({
question: "Is dit park publiek toegankelijk?",
mappings: [
{ k: new TagsFilter_1.Tag("access", "yes"), txt: "Publiek toegankelijk" },
{ k: new TagsFilter_1.Tag("access", ""), txt: "Publiek toegankelijk" },
{ k: new TagsFilter_1.Tag("access", "no"), txt: "Niet publiek toegankelijk" },
{ k: new TagsFilter_1.Tag("access", "private"), txt: "Niet publiek toegankelijk, want privaat" },
{ k: new TagsFilter_1.Tag("access", "guided"), txt: "Enkel toegankelijk met een gids of op een activiteit" },
],
freeform: {
key: "access",
renderTemplate: "Dit park is niet toegankelijk: {access}",
template: "De toegankelijkheid van dit park is: $$$"
},
priority: 20
});
_this.operatorByDefault = new TagRendering_1.TagRenderingOptions({
question: "Wie beheert dit park?",
freeform: {
key: "operator",
renderTemplate: "Dit park wordt beheerd door {operator}",
template: "$$$",
},
mappings: [{
k: null, txt: "De gemeente beheert dit park"
}],
priority: 15
});
_this.name = "park";
_this.icon = "./assets/tree_white_background.svg";
_this.overpassFilter =
new TagsFilter_1.Or([new TagsFilter_1.Tag("leisure", "park"), new TagsFilter_1.Tag("landuse", "village_green")]);
_this.newElementTags = [new TagsFilter_1.Tag("leisure", "park"),
new TagsFilter_1.Tag("fixme", "Toegevoegd met MapComplete, geometry nog uit te tekenen")];
_this.maxAllowedOverlapPercentage = 25;
_this.minzoom = 13;
_this.style = _this.generateStyleFunction();
_this.title = new NameInline_1.NameInline("park");
_this.elementsToShow = [
new ImageCarouselWithUpload_1.ImageCarouselWithUploadConstructor(),
new NameQuestion_1.NameQuestion(),
_this.accessByDefault,
_this.operatorByDefault,
new DescriptionQuestion_1.DescriptionQuestion("park"),
];
return _this;
}
Park.prototype.generateStyleFunction = function () {
var self = this;
return function (properties) {
var _a;
var questionSeverity = 0;
for (var _i = 0, _b = self.elementsToShow; _i < _b.length; _i++) {
var qd = _b[_i];
if (qd instanceof DescriptionQuestion_1.DescriptionQuestion) {
continue;
}
if (qd.IsQuestioning(properties)) {
questionSeverity = Math.max(questionSeverity, (_a = qd.Priority()) !== null && _a !== void 0 ? _a : 0);
}
}
var colormapping = {
0: "#00bb00",
1: "#00ff00",
10: "#dddd00",
20: "#ff0000"
};
var colour = colormapping[questionSeverity];
while (colour == undefined) {
questionSeverity--;
colour = colormapping[questionSeverity];
}
return {
color: colour,
icon: undefined
};
};
};
return Park;
}(LayerDefinition_1.LayerDefinition));
exports.Park = Park;

View file

@ -0,0 +1,94 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Toilets = void 0;
var LayerDefinition_1 = require("../LayerDefinition");
var Quests_1 = require("../../Quests");
var FixedUiElement_1 = require("../../UI/Base/FixedUiElement");
var leaflet_1 = require("leaflet");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var Toilets = /** @class */ (function (_super) {
__extends(Toilets, _super);
function Toilets() {
var _a, _b;
var _this = _super.call(this) || this;
_this.name = "toilet";
_this.newElementTags = [new TagsFilter_1.Tag("amenity", "toilets")];
_this.icon = "./assets/toilets.svg";
_this.overpassFilter = new TagsFilter_1.Tag("amenity", "toilets");
_this.minzoom = 13;
_this.questions = [Quests_1.Quests.hasFee,
Quests_1.Quests.toiletsWheelChairs,
Quests_1.Quests.toiletsChangingTable,
Quests_1.Quests.toiletsChangingTableLocation,
Quests_1.Quests.toiletsPosition];
_this.style = function (tags) {
if (tags.wheelchair == "yes") {
return { icon: new leaflet_1.default.icon({
iconUrl: "assets/wheelchair.svg",
iconSize: [40, 40]
}) };
}
return { icon: new leaflet_1.default.icon({
iconUrl: "assets/toilets.svg",
iconSize: [40, 40]
}) };
};
_this.elementsToShow = [
new FixedUiElement_1.FixedUiElement("Toiletten"),
new TagMappingOptions({
key: "access",
mapping: {
yes: "Toegankelijk",
no: "Niet toegankelijk",
private: "Niet toegankelijk",
customers: "Enkel voor klanten",
}
}),
new TagMappingOptions({
key: "fee",
mapping: (_a = {
yes: "Betalend",
no: "Gratis"
},
_a["0"] = "Gratis",
_a),
template: "Betalend, men vraagt {fee}"
}),
new TagMappingOptions({
key: "toilets:position",
mapping: (_b = {
seated: 'Gewone zittoiletten',
urinal: 'Een enkele urinoir',
urinals: 'Urinoirs'
},
_b['urinals;seated'] = "Urinoirs en gewone toiletten",
_b['seated;urinals'] = "Urinoirs en gewone toiletten",
_b)
}),
new TagMappingOptions({
key: "wheelchair",
mapping: {
yes: "Rolstoeltoegankelijk",
no: "Niet Rolstoeltoegankelijk",
limited: "Beperkt rolstoeltoegankelijk",
}
}),
];
return _this;
}
return Toilets;
}(LayerDefinition_1.LayerDefinition));
exports.Toilets = Toilets;

View file

@ -0,0 +1,270 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Widths = void 0;
var LayerDefinition_1 = require("../LayerDefinition");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var TagRendering_1 = require("../TagRendering");
var Widths = /** @class */ (function (_super) {
__extends(Widths, _super);
function Widths(carWidth, cyclistWidth, pedestrianWidth) {
var _this = _super.call(this) || this;
_this._bothSideParking = new TagsFilter_1.Tag("parking:lane:both", "parallel");
_this._noSideParking = new TagsFilter_1.Tag("parking:lane:both", "no_parking");
_this._otherParkingMode = new TagsFilter_1.Or([
new TagsFilter_1.Tag("parking:lane:both", "perpendicular"),
new TagsFilter_1.Tag("parking:lane:left", "perpendicular"),
new TagsFilter_1.Tag("parking:lane:right", "perpendicular"),
new TagsFilter_1.Tag("parking:lane:both", "diagonal"),
new TagsFilter_1.Tag("parking:lane:left", "diagonal"),
new TagsFilter_1.Tag("parking:lane:right", "diagonal"),
]);
_this._leftSideParking = new TagsFilter_1.And([new TagsFilter_1.Tag("parking:lane:left", "parallel"), new TagsFilter_1.Tag("parking:lane:right", "no_parking")]);
_this._rightSideParking = new TagsFilter_1.And([new TagsFilter_1.Tag("parking:lane:right", "parallel"), new TagsFilter_1.Tag("parking:lane:left", "no_parking")]);
_this._sidewalkBoth = new TagsFilter_1.Tag("sidewalk", "both");
_this._sidewalkLeft = new TagsFilter_1.Tag("sidewalk", "left");
_this._sidewalkRight = new TagsFilter_1.Tag("sidewalk", "right");
_this._sidewalkNone = new TagsFilter_1.Tag("sidewalk", "none");
_this._oneSideParking = new TagsFilter_1.Or([_this._leftSideParking, _this._rightSideParking]);
_this._carfree = new TagsFilter_1.Or([new TagsFilter_1.Tag("highway", "pedestrian"), new TagsFilter_1.Tag("highway", "living_street")]);
_this._notCarFree = new TagsFilter_1.Not(_this._carfree);
_this.carWidth = carWidth;
_this.cyclistWidth = cyclistWidth;
_this.pedestrianWidth = pedestrianWidth;
_this.minzoom = 12;
function r(n) {
var pre = Math.floor(n);
var post = Math.floor((n * 10) % 10);
return "" + pre + "." + post;
}
_this.name = "widths";
_this.overpassFilter = new TagsFilter_1.Tag("width:carriageway", "*");
_this.title = new TagRendering_1.TagRenderingOptions({
freeform: {
renderTemplate: "{name}",
template: "$$$",
key: "name"
}
});
var self = _this;
_this.style = function (properties) {
var c = "#f00";
var props = self.calcProps(properties);
if (props.pedestrianFlowNeeded > 0) {
c = "#fa0";
}
if (props.width >= props.targetWidth || !props.cyclingAllowed) {
c = "#0c0";
}
if (!props.parkingStateKnown && properties["note:width:carriageway"] === undefined) {
c = "#f0f";
}
if (_this._carfree.matchesProperties(properties)) {
c = "#aaa";
}
// Mark probably wrong data
if (props.width > 15) {
c = "#f0f";
}
var dashArray = undefined;
if (props.onewayBike) {
dashArray = [20, 8];
}
return {
icon: null,
color: c,
weight: 7,
dashArray: dashArray
};
};
_this.elementsToShow = [
new TagRendering_1.TagRenderingOptions({
question: "Mogen auto's hier parkeren?",
mappings: [
{
k: _this._bothSideParking,
txt: "Auto's kunnen langs beide zijden parkeren.<br+>Dit gebruikt <b>" + r(_this.carWidth * 2) + "m</b><br/>"
},
{
k: _this._oneSideParking,
txt: "Auto's kunnen langs één kant parkeren.<br/>Dit gebruikt <b>" + r(_this.carWidth) + "m</b><br/>"
},
{
k: _this._otherParkingMode,
txt: "Deze straat heeft dwarsparkeren of diagonaalparkeren aan minstens één zijde. Deze parkeerruimte is niet opgenomen in de straatbreedte."
},
{ k: _this._noSideParking, txt: "Auto's mogen hier niet parkeren" },
],
freeform: {
key: "note:width:carriageway",
renderTemplate: "{note:width:carriageway}",
template: "$$$",
}
}).OnlyShowIf(_this._notCarFree),
new TagRendering_1.TagRenderingOptions({
mappings: [
{
k: _this._sidewalkNone,
txt: "Deze straat heeft geen voetpaden. Voetgangers hebben hier <b>" + r(_this.pedestrianWidth * 2) + "m</b> nodig"
},
{
k: new TagsFilter_1.Or([_this._sidewalkLeft, _this._sidewalkRight]),
txt: "Deze straat heeft een voetpad aan één kant. Voetgangers hebben hier <b>" + r(_this.pedestrianWidth) + "m</b> nodig"
},
{ k: _this._sidewalkBoth, txt: "Deze straat heeft voetpad aan beide zijden." },
],
freeform: {
key: "note:width:carriageway",
renderTemplate: "{note:width:carriageway}",
template: "$$$",
}
}).OnlyShowIf(_this._notCarFree),
new TagRendering_1.TagRenderingOptions({
mappings: [
{
k: new TagsFilter_1.Tag("bicycle", "use_sidepath"),
txt: "Er is een afgescheiden, verplicht te gebruiken fietspad. Fietsen op dit wegsegment hoeft dus niet"
},
{
k: new TagsFilter_1.Tag("bicycle", "no"),
txt: "Fietsen is hier niet toegestaan"
},
{
k: new TagsFilter_1.Tag("oneway:bicycle", "yes"),
txt: "Eenrichtingsverkeer, óók voor fietsers. Dit gebruikt <b>" + r(_this.carWidth + _this.cyclistWidth) + "m</b>"
},
{
k: new TagsFilter_1.And([new TagsFilter_1.Tag("oneway", "yes"), new TagsFilter_1.Tag("oneway:bicycle", "no")]),
txt: "Tweerichtingverkeer voor fietsers, eenrichting voor auto's Dit gebruikt <b>" + r(_this.carWidth + 2 * _this.cyclistWidth) + "m</b>"
},
{
k: new TagsFilter_1.Tag("oneway", "yes"),
txt: "Eenrichtingsverkeer voor iedereen. Dit gebruikt <b>" + (_this.carWidth + _this.cyclistWidth) + "m</b>"
},
{
k: null,
txt: "Tweerichtingsverkeer voor iedereen. Dit gebruikt <b>" + r(2 * _this.carWidth + 2 * _this.cyclistWidth) + "m</b>"
}
]
}).OnlyShowIf(_this._notCarFree),
new TagRendering_1.TagRenderingOptions({
tagsPreprocessor: function (tags) {
var props = self.calcProps(tags);
tags.targetWidth = r(props.targetWidth);
tags.short = "";
if (props.width < props.targetWidth) {
tags.short = "Er is dus <b class='alert'>" + r(props.targetWidth - props.width) + "m</b> te weinig";
}
},
freeform: {
key: "width:carriageway",
renderTemplate: "De totale nodige ruimte voor vlot en veilig verkeer is dus <b>{targetWidth}m</b><br>" +
"{short}",
template: "$$$",
}
}).OnlyShowIf(_this._notCarFree),
new TagRendering_1.TagRenderingOptions({
mappings: [
{ k: new TagsFilter_1.Tag("highway", "living_street"), txt: "Dit is een woonerf" },
{ k: new TagsFilter_1.Tag("highway", "pedestrian"), txt: "Deze weg is autovrij" }
]
}),
new TagRendering_1.TagRenderingOptions({
mappings: [
{
k: new TagsFilter_1.Tag("sidewalk", "none"),
txt: "De afstand van huis tot huis is <b>{width:carriageway}m</b>"
},
{
k: new TagsFilter_1.Tag("sidewalk", "left"),
txt: "De afstand van huis tot voetpad is <b>{width:carriageway}m</b>"
},
{
k: new TagsFilter_1.Tag("sidewalk", "right"),
txt: "De afstand van huis tot voetpad is <b>{width:carriageway}m</b>"
},
{
k: new TagsFilter_1.Tag("sidewalk", "both"),
txt: "De afstand van voetpad tot voetpad is <b>{width:carriageway}m</b>"
},
{
k: new TagsFilter_1.Tag("sidewalk", ""),
txt: "De straatbreedte is <b>{width:carriageway}m</b>"
}
]
})
];
return _this;
}
Widths.prototype.calcProps = function (properties) {
var parkingStateKnown = true;
var parallelParkingCount = 0;
if (this._oneSideParking.matchesProperties(properties)) {
parallelParkingCount = 1;
}
else if (this._bothSideParking.matchesProperties(properties)) {
parallelParkingCount = 2;
}
else if (this._noSideParking.matchesProperties(properties)) {
parallelParkingCount = 0;
}
else if (this._otherParkingMode.matchesProperties(properties)) {
parallelParkingCount = 0;
}
else {
parkingStateKnown = false;
console.log("No parking data for ", properties.name, properties.id, properties);
}
var pedestrianFlowNeeded = 0;
if (this._sidewalkBoth.matchesProperties(properties)) {
pedestrianFlowNeeded = 0;
}
else if (this._sidewalkNone.matchesProperties(properties)) {
pedestrianFlowNeeded = 2;
}
else if (this._sidewalkLeft.matchesProperties(properties) || this._sidewalkRight.matches(properties)) {
pedestrianFlowNeeded = 1;
}
else {
pedestrianFlowNeeded = -1;
}
var onewayCar = properties.oneway === "yes";
var onewayBike = properties["oneway:bicycle"] === "yes" ||
(onewayCar && properties["oneway:bicycle"] === undefined);
var cyclingAllowed = !(properties.bicycle === "use_sidepath"
|| properties.bicycle === "no");
var carWidth = (onewayCar ? 1 : 2) * this.carWidth;
var cyclistWidth = 0;
if (cyclingAllowed) {
cyclistWidth = (onewayBike ? 1 : 2) * this.cyclistWidth;
}
var width = parseFloat(properties["width:carriageway"]);
var targetWidth = carWidth +
cyclistWidth +
Math.max(0, pedestrianFlowNeeded) * this.pedestrianWidth +
parallelParkingCount * this.carWidth;
return {
parkingLanes: parallelParkingCount,
parkingStateKnown: parkingStateKnown,
width: width,
targetWidth: targetWidth,
onewayBike: onewayBike,
pedestrianFlowNeeded: pedestrianFlowNeeded,
cyclingAllowed: cyclingAllowed
};
};
return Widths;
}(LayerDefinition_1.LayerDefinition));
exports.Widths = Widths;

38
Customizations/Layout.js Normal file
View file

@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Layout = void 0;
/**
* A layout is a collection of settings of the global view (thus: welcome text, title, selection of layers).
*/
var Layout = /** @class */ (function () {
/**
*
* @param name: The name used in the query string. If in the query "quests=<name>" is defined, it will select this layout
* @param title: Will be used in the <title> of the page
* @param layers: The layers to show, a list of LayerDefinitions
* @param startzoom: The initial starting zoom of the map
* @param startLat:The initial starting latitude of the map
* @param startLon: the initial starting longitude of the map
* @param welcomeMessage: This message is shown in the collapsable box on the left
* @param gettingStartedPlzLogin: This is shown below the welcomemessage and wrapped in a login link.
* @param welcomeBackMessage: This is shown when the user is logged in
* @param welcomeTail: This text is shown below the login message. It is ideal for extra help
*/
function Layout(name, title, layers, startzoom, startLat, startLon, welcomeMessage, gettingStartedPlzLogin, welcomeBackMessage, welcomeTail) {
if (gettingStartedPlzLogin === void 0) { gettingStartedPlzLogin = "Please login to get started"; }
if (welcomeBackMessage === void 0) { welcomeBackMessage = "You are logged in. Welcome back!"; }
if (welcomeTail === void 0) { welcomeTail = ""; }
this.title = title;
this.startLon = startLon;
this.startLat = startLat;
this.startzoom = startzoom;
this.name = name;
this.layers = layers;
this.welcomeMessage = welcomeMessage;
this.gettingStartedPlzLogin = gettingStartedPlzLogin;
this.welcomeBackMessage = welcomeBackMessage;
this.welcomeTail = welcomeTail;
}
return Layout;
}());
exports.Layout = Layout;

View file

@ -0,0 +1,26 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.All = void 0;
var Layout_1 = require("../Layout");
var All = /** @class */ (function (_super) {
__extends(All, _super);
function All() {
return _super.call(this, "all", "All quest layers", [], 15, 51.2, 3.2, "<h3>All quests of MapComplete</h3>" +
"This is a mixed bag. Some quests might be hard or for experts to answer only", "Please log in", "") || this;
}
return All;
}(Layout_1.Layout));
exports.All = All;

View file

@ -0,0 +1,36 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Bookcases = void 0;
var Layout_1 = require("../Layout");
var Layer = require("../Layers/Bookcases");
var Bookcases = /** @class */ (function (_super) {
__extends(Bookcases, _super);
function Bookcases() {
var _this = _super.call(this, "bookcases", "Open Bookcase Map", [new Layer.Bookcases()], 14, 51.2, 3.2, " <h3>Open BoekenkastjesKaart</h3>\n" +
"\n" +
"<p>" +
"Help mee met het creëeren van een volledige kaart met alle boekenruilkastjes!" +
"Een boekenruilkastje is een vaste plaats in publieke ruimte waar iedereen een boek in kan zetten of uit kan meenemen." +
"Meestal een klein kastje of doosje dat op straat staat, maar ook een oude telefooncellen of een schap in een station valt hieronder." +
"</p>", " <p>Begin met <a href=\"https://www.openstreetmap.org/user/new\" target=\"_blank\">het aanmaken van een account\n" +
" </a> of door je " +
" <span onclick=\"authOsm()\" class=\"activate-osm-authentication\">aan te melden</span>.</p>", "Klik op een boekenruilkastje om vragen te beantwoorden") || this;
_this.locationContains = ["Bookcases.html", "Bookcase.html", "bookcase"];
return _this;
}
return Bookcases;
}(Layout_1.Layout));
exports.Bookcases = Bookcases;

View file

@ -0,0 +1,35 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var Layout_1 = require("../Layout");
var BikeParkings_1 = require("../Layers/BikeParkings");
var BikeStations_1 = require("../Layers/BikeStations");
var GhostBike_1 = require("../Layers/GhostBike");
var DrinkingWater_1 = require("../Layers/DrinkingWater");
var Cyclofix = /** @class */ (function (_super) {
__extends(Cyclofix, _super);
function Cyclofix() {
return _super.call(this, "pomp", "Cyclofix bicycle infrastructure", [new GhostBike_1.GhostBike(), new BikeStations_1.default(), new BikeParkings_1.default(), new DrinkingWater_1.DrinkingWater()], 16, 50.8465573, 4.3516970, "<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." +
"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>" +
"<p><b>FR&gt;</b> Sur cette carte, nous voulons collecter des données sur la localisation des pompes à vélo et des supports publics à Bruxelles." +
"Les cyclistes pourront ainsi trouver rapidement l'infrastructure la plus proche de leurs besoins.</p>", "", "") || this;
}
return Cyclofix;
}(Layout_1.Layout));
exports.default = Cyclofix;

View file

@ -0,0 +1,28 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.GRB = void 0;
var Layout_1 = require("../Layout");
var GrbToFix_1 = require("../Layers/GrbToFix");
var GRB = /** @class */ (function (_super) {
__extends(GRB, _super);
function GRB() {
return _super.call(this, "grb", "Grb import fix tool", [new GrbToFix_1.GrbToFix()], 15, 51.2083, 3.2279, "<h3>GRB Fix tool</h3>\n" +
"\n" +
"Expert use only", "", "") || this;
}
return GRB;
}(Layout_1.Layout));
exports.GRB = GRB;

View file

@ -0,0 +1,56 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Groen = void 0;
var NatureReserves_1 = require("../Layers/NatureReserves");
var Park_1 = require("../Layers/Park");
var Bos_1 = require("../Layers/Bos");
var Layout_1 = require("../Layout");
var Groen = /** @class */ (function (_super) {
__extends(Groen, _super);
function Groen() {
var _this = _super.call(this, "buurtnatuur", "Buurtnatuur", [new NatureReserves_1.NatureReserves(), new Park_1.Park(), new Bos_1.Bos()], 10, 50.8435, 4.3688, "\n" +
"<img src='assets/groen.svg' alt='logo-groen' class='logo'> <br />" +
"<h3>Breng jouw buurtnatuur in kaart</h3>" +
"<b>Natuur maakt gelukkig.</b> Aan de hand van deze website willen we de natuur dicht bij ons beter inventariseren. Met als doel meer mensen te laten genieten van toegankelijke natuur én te strijden voor meer natuur in onze buurten. \n" +
"<ul>" +
"<li>In welke natuurgebieden kan jij terecht? Hoe toegankelijk zijn ze?</li>" +
"<li>In welke bossen kan een gezin in jouw gemeente opnieuw op adem komen?</li>" +
"<li>Op welke onbekende plekjes is het zalig spelen?</li>" +
"</ul>" +
"<p>Samen kleuren we heel Vlaanderen en Brussel groen.</p>" +
"<p>Blijf op de hoogte van de resultaten van buurtnatuur.be: <a href=\"https://www.groen.be/buurtnatuur\" target='_blank'>meld je aan voor e-mailupdates</a>.</p> \n", "<b>Begin meteen door <a href=\"https://www.openstreetmap.org/user/new\" target=\"_blank\">een account te maken\n" +
" te maken</a> of\n" +
" <span onclick=\"authOsm()\" class=\"activate-osm-authentication\">in te loggen</span>.</b>", "", "<h4>Tips</h4>" +
"<ul>" +
"<li>Over groen ingekleurde gebieden weten we alles wat we willen weten.</li>" +
"<li>Bij rood ingekleurde gebieden ontbreekt nog heel wat info: klik een gebied aan en beantwoord de vragen.</li>" +
"<li>Je kan altijd een vraag overslaan als je het antwoord niet weet of niet zeker bent</li>" +
"<li>Je kan altijd een foto toevoegen</li>" +
"<li>Je kan ook zelf een gebied toevoegen door op de kaart te klikken</li>" +
"</ul>" +
"<small>" +
"<p>" +
"De oorspronkelijke data komt van <b>OpenStreetMap</b> en je antwoorden worden daar bewaard.<br/> Omdat iedereen vrij kan meewerken aan dit project, kunnen we niet garanderen dat er geen fouten opduiken." +
"</p>" +
"Je privacy is belangrijk. We tellen wel hoeveel gebruikers deze website bezoeken. We plaatsen een cookie waar geen persoonlijke informatie in bewaard wordt. " +
"Als je inlogt, komt er een tweede cookie bij met je inloggegevens." +
"</small>") || this;
_this.locationContains = ["buurtnatuur.be"];
return _this;
}
return Groen;
}(Layout_1.Layout));
exports.Groen = Groen;

View file

@ -0,0 +1,27 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MetaMap = void 0;
var Layout_1 = require("../Layout");
var Map_1 = require("../Layers/Map");
var MetaMap = /** @class */ (function (_super) {
__extends(MetaMap, _super);
function MetaMap() {
return _super.call(this, "metamap", "Open Map Map", [new Map_1.Map()], 1, 0, 0, " <h3>Open Map Map</h3>\n" +
"This map is a map of physical maps, as known by OpenStreetMap.") || this;
}
return MetaMap;
}(Layout_1.Layout));
exports.MetaMap = MetaMap;

View file

@ -0,0 +1,28 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Natuurpunt = void 0;
var Layout_1 = require("../Layout");
var Birdhide_1 = require("../Layers/Birdhide");
var InformationBoard_1 = require("../Layers/InformationBoard");
var NatureReserves_1 = require("../Layers/NatureReserves");
var Natuurpunt = /** @class */ (function (_super) {
__extends(Natuurpunt, _super);
function Natuurpunt() {
return _super.call(this, "natuurpunt", "De natuur in", [new Birdhide_1.Birdhide(), new InformationBoard_1.InformationBoard(), new NatureReserves_1.NatureReserves(true)], 12, 51.20875, 3.22435, "<h3>Natuurpuntstuff</h3>", "", "") || this;
}
return Natuurpunt;
}(Layout_1.Layout));
exports.Natuurpunt = Natuurpunt;

View file

@ -0,0 +1,31 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Statues = void 0;
var Layout_1 = require("../Layout");
var Artwork_1 = require("../Layers/Artwork");
var Statues = /** @class */ (function (_super) {
__extends(Statues, _super);
function Statues() {
return _super.call(this, "statues", "Open Artwork Map", [new Artwork_1.Artwork()], 10, 50.8435, 4.3688, " <h3>Open Statue Map</h3>\n" +
"\n" +
"<p>" +
"Help with creating a map of all statues all over the world!", " <p>Start by <a href=\"https://www.openstreetmap.org/user/new\" target=\"_blank\">creating an account\n" +
" </a> or by " +
" <span onclick=\"authOsm()\" class=\"activate-osm-authentication\">logging in</span>.</p>", "Start by clicking a pin and answering the questions") || this;
}
return Statues;
}(Layout_1.Layout));
exports.Statues = Statues;

View file

@ -0,0 +1,37 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.StreetWidth = void 0;
var Layout_1 = require("../Layout");
var Widths_1 = require("../Layers/Widths");
var StreetWidth = /** @class */ (function (_super) {
__extends(StreetWidth, _super);
function StreetWidth() {
return _super.call(this, "width", "Straatbreedtes in Brugge", [new Widths_1.Widths(2, 1.5, 0.75)], 15, 51.20875, 3.22435, "<h3>De straat is opgebruikt</h3>" +
"<p>Er is steeds meer druk op de openbare ruimte. Voetgangers, fietsers, steps, auto's, bussen, bestelwagens, buggies, cargobikes, ... willen allemaal hun deel van de openbare ruimte.</p>" +
"" +
"<p>In deze studie nemen we Brugge onder de loep en kijken we hoe breed elke straat is én hoe breed elke straat zou moeten zijn voor een veilig én vlot verkeer.</p>" +
"Verschillende ingrepen kunnen de stad teruggeven aan de inwoners en de stad leefbaarder en levendiger maken.<br/>" +
"Denk aan:" +
"<ul>" +
"<li>De autovrije zone's uitbreiden</li>" +
"<li>De binnenstad fietszone maken</li>" +
"<li>Het aantal woonerven uitbreiden</li>" +
"<li>Grotere auto's meer belasten - ze nemen immers meer parkeerruimte in.</li>" +
"</ul>", "", "") || this;
}
return StreetWidth;
}(Layout_1.Layout));
exports.StreetWidth = StreetWidth;

View file

@ -0,0 +1,31 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Toilets = void 0;
var Layout_1 = require("../Layout");
var Layer = require("../Layers/Toilets");
var Toilets = /** @class */ (function (_super) {
__extends(Toilets, _super);
function Toilets() {
return _super.call(this, "toilets", "Open Toilet Map", [new Layer.Toilets()], 12, 51.2, 3.2, " <h3>Open Toilet Map</h3>\n" +
"\n" +
"<p>Help us to create the most complete map about <i>all</i> the toilets in the world, based on openStreetMap." +
"One can answer questions here, which help users all over the world to find an accessible toilet, close to them.</p>", " <p>Start by <a href=\"https://www.openstreetmap.org/user/new\" target=\"_blank\">creating an account\n" +
" </a> or by " +
" <span onclick=\"authOsm()\" class=\"activate-osm-authentication\">logging in</span>.</p>", "Start by clicking a pin and answering the questions") || this;
}
return Toilets;
}(Layout_1.Layout));
exports.Toilets = Toilets;

View file

@ -0,0 +1,33 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.WalkByBrussels = void 0;
var Layout_1 = require("../Layout");
var DrinkingWater_1 = require("../Layers/DrinkingWater");
var NatureReserves_1 = require("../Layers/NatureReserves");
var Park_1 = require("../Layers/Park");
var WalkByBrussels = /** @class */ (function (_super) {
__extends(WalkByBrussels, _super);
function WalkByBrussels() {
return _super.call(this, "walkbybrussels", "Drinking Water Spots", [new DrinkingWater_1.DrinkingWater(), new Park_1.Park(), new NatureReserves_1.NatureReserves()], 10, 50.8435, 4.3688, " <h3>Drinking water</h3>\n" +
"\n" +
"<p>" +
"Help with creating a map of drinking water points!", " <p>Start by <a href=\"https://www.openstreetmap.org/user/new\" target=\"_blank\">creating an account\n" +
" </a> or by " +
" <span onclick=\"authOsm()\" class=\"activate-osm-authentication\">logging in</span>.</p>", "Start by clicking a pin and answering the questions") || this;
}
return WalkByBrussels;
}(Layout_1.Layout));
exports.WalkByBrussels = WalkByBrussels;

View file

@ -0,0 +1,89 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.OnlyShowIfConstructor = void 0;
var TagsFilter_1 = require("../Logic/TagsFilter");
var UIElement_1 = require("../UI/UIElement");
var OnlyShowIfConstructor = /** @class */ (function () {
function OnlyShowIfConstructor(tagsFilter, embedded) {
this._tagsFilter = tagsFilter;
this._embedded = embedded;
}
OnlyShowIfConstructor.prototype.construct = function (dependencies) {
return new OnlyShowIf(dependencies.tags, this._embedded.construct(dependencies), this._tagsFilter);
};
OnlyShowIfConstructor.prototype.IsKnown = function (properties) {
if (!this.Matches(properties)) {
return true;
}
return this._embedded.IsKnown(properties);
};
OnlyShowIfConstructor.prototype.IsQuestioning = function (properties) {
if (!this.Matches(properties)) {
return false;
}
return this._embedded.IsQuestioning(properties);
};
OnlyShowIfConstructor.prototype.Priority = function () {
return this._embedded.Priority();
};
OnlyShowIfConstructor.prototype.Matches = function (properties) {
return this._tagsFilter.matches(TagsFilter_1.TagUtils.proprtiesToKV(properties));
};
return OnlyShowIfConstructor;
}());
exports.OnlyShowIfConstructor = OnlyShowIfConstructor;
var OnlyShowIf = /** @class */ (function (_super) {
__extends(OnlyShowIf, _super);
function OnlyShowIf(tags, embedded, filter) {
var _this = _super.call(this, tags) || this;
_this._filter = filter;
_this._embedded = embedded;
return _this;
}
OnlyShowIf.prototype.Matches = function () {
return this._filter.matches(TagsFilter_1.TagUtils.proprtiesToKV(this._source.data));
};
OnlyShowIf.prototype.InnerRender = function () {
if (this.Matches()) {
return this._embedded.Render();
}
else {
return "";
}
};
OnlyShowIf.prototype.Priority = function () {
return this._embedded.Priority();
};
OnlyShowIf.prototype.IsKnown = function () {
if (!this.Matches()) {
return false;
}
return this._embedded.IsKnown();
};
OnlyShowIf.prototype.IsQuestioning = function () {
if (!this.Matches()) {
return false;
}
return this._embedded.IsQuestioning();
};
OnlyShowIf.prototype.Activate = function () {
this._embedded.Activate();
};
OnlyShowIf.prototype.Update = function () {
this._embedded.Update();
};
return OnlyShowIf;
}(UIElement_1.UIElement));

View file

@ -0,0 +1,50 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AccessTag = void 0;
var TagRendering_1 = require("../TagRendering");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var AccessTag = /** @class */ (function (_super) {
__extends(AccessTag, _super);
function AccessTag() {
return _super.call(this, AccessTag.options) || this;
}
AccessTag.options = {
priority: 20,
question: "Is dit gebied toegankelijk?",
primer: "Dit gebied is ",
freeform: {
key: "access:description",
template: "Iets anders: $$$",
renderTemplate: "De toegankelijkheid van dit gebied is: {access:description}",
placeholder: "Specifieer"
},
mappings: [
{ k: new TagsFilter_1.And([new TagsFilter_1.Tag("access", "yes"), new TagsFilter_1.Tag("fee", "")]), txt: "publiek toegankelijk" },
{ k: new TagsFilter_1.And([new TagsFilter_1.Tag("access", "no"), new TagsFilter_1.Tag("fee", "")]), txt: "niet toegankelijk" },
{ k: new TagsFilter_1.And([new TagsFilter_1.Tag("access", "private"), new TagsFilter_1.Tag("fee", "")]), txt: "niet toegankelijk, want privegebied" },
{ k: new TagsFilter_1.And([new TagsFilter_1.Tag("access", "permissive"), new TagsFilter_1.Tag("fee", "")]), txt: "toegankelijk, maar het is privegebied" },
{ k: new TagsFilter_1.And([new TagsFilter_1.Tag("access", "guided"), new TagsFilter_1.Tag("fee", "")]), txt: "enkel met gids of op activiteit" },
{
k: new TagsFilter_1.And([new TagsFilter_1.Tag("access", "yes"),
new TagsFilter_1.Tag("fee", "yes")]),
txt: "toegankelijk mits betaling",
priority: 10
},
]
};
return AccessTag;
}(TagRendering_1.TagRenderingOptions));
exports.AccessTag = AccessTag;

View file

@ -0,0 +1,36 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DescriptionQuestion = void 0;
var TagRendering_1 = require("../TagRendering");
var DescriptionQuestion = /** @class */ (function (_super) {
__extends(DescriptionQuestion, _super);
function DescriptionQuestion(category) {
return _super.call(this, {
question: "Zijn er bijzonderheden die we moeten weten over dit " + category + "?<br>" +
"<span class='question-subtext'>Je hoeft niet te herhalen wat je net hebt aangeduid.<br/>" +
"Een <i>naam</i> wordt in de volgende stap gevraagd.<br/>" +
"Voel je vrij om dit veld over te slaan.</span>",
freeform: {
key: "description:0",
renderTemplate: "{description:0}",
template: "$$$"
},
priority: 14
}) || this;
}
return DescriptionQuestion;
}(TagRendering_1.TagRenderingOptions));
exports.DescriptionQuestion = DescriptionQuestion;

View file

@ -0,0 +1,30 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var TagRendering_1 = require("../TagRendering");
var FixedText = /** @class */ (function (_super) {
__extends(FixedText, _super);
function FixedText(category) {
return _super.call(this, {
mappings: [
{
k: null, txt: category
}
]
}) || this;
}
return FixedText;
}(TagRendering_1.TagRenderingOptions));
exports.default = FixedText;

View file

@ -0,0 +1,41 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.NameInline = void 0;
var TagRendering_1 = require("../TagRendering");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var NameInline = /** @class */ (function (_super) {
__extends(NameInline, _super);
function NameInline(category) {
return _super.call(this, {
question: "",
freeform: {
renderTemplate: "{name}",
template: "De naam van dit " + category + " is $$$",
key: "name",
extraTags: new TagsFilter_1.Tag("noname", "") // Remove 'noname=yes'
},
mappings: [
{ k: new TagsFilter_1.Tag("noname", "yes"), txt: NameInline.Upper(category) + " zonder naam" },
{ k: null, txt: NameInline.Upper(category) }
]
}) || this;
}
NameInline.Upper = function (string) {
return string.charAt(0).toUpperCase() + string.slice(1);
};
return NameInline;
}(TagRendering_1.TagRenderingOptions));
exports.NameInline = NameInline;

View file

@ -0,0 +1,48 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.NameQuestion = void 0;
/**
* There are two ways to ask for names:
* One is a big 'name-question', the other is the 'edit name' in the title.
* THis one is the big question
*/
var TagRendering_1 = require("../TagRendering");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var NameQuestion = /** @class */ (function (_super) {
__extends(NameQuestion, _super);
function NameQuestion() {
return _super.call(this, NameQuestion.options) || this;
}
NameQuestion.options = {
priority: 10,
question: "Wat is de <i>officiële</i> naam van dit gebied?<br><span class='question-subtext'>" +
"Zelf een naam bedenken wordt afgeraden.<br/>" +
"Een beschrijving van het gebied geven kan in een volgende stap.<br/>" +
"</span>",
freeform: {
key: "name",
template: "De naam is $$$",
renderTemplate: "",
placeholder: "",
extraTags: new TagsFilter_1.Tag("noname", "")
},
mappings: [
{ k: new TagsFilter_1.Tag("noname", "yes"), txt: "Dit gebied heeft geen naam" },
]
};
return NameQuestion;
}(TagRendering_1.TagRenderingOptions));
exports.NameQuestion = NameQuestion;

View file

@ -0,0 +1,41 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.OperatorTag = void 0;
var TagRendering_1 = require("../TagRendering");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var OperatorTag = /** @class */ (function (_super) {
__extends(OperatorTag, _super);
function OperatorTag() {
return _super.call(this, OperatorTag.options) || this;
}
OperatorTag.options = {
priority: 15,
question: "Wie beheert dit gebied?",
freeform: {
key: "operator",
template: "Dit gebied wordt beheerd door $$$",
renderTemplate: "Dit gebied wordt beheerd door {operator}",
placeholder: "organisatie"
},
mappings: [
{ k: new TagsFilter_1.Tag("operator", "Natuurpunt"), txt: "Natuurpunt" },
{ k: new TagsFilter_1.Tag("operator", "Agentschap Natuur en Bos"), txt: "het Agentschap Natuur en Bos (ANB)" },
{ k: new TagsFilter_1.Tag("operator", "private"), txt: "Beheer door een privépersoon" }
]
};
return OperatorTag;
}(TagRendering_1.TagRenderingOptions));
exports.OperatorTag = OperatorTag;

View file

@ -0,0 +1,40 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.OsmLink = void 0;
var TagRendering_1 = require("../TagRendering");
var Img_1 = require("../../UI/Img");
var TagsFilter_1 = require("../../Logic/TagsFilter");
var OsmLink = /** @class */ (function (_super) {
__extends(OsmLink, _super);
function OsmLink() {
return _super.call(this, OsmLink.options) || this;
}
OsmLink.options = {
freeform: {
key: "id",
template: "$$$",
renderTemplate: "<span class='osmlink'><a href='https://osm.org/{id}' target='_blank'>" +
Img_1.Img.osmAbstractLogo +
"</a></span>",
placeholder: "",
},
mappings: [
{ k: new TagsFilter_1.Tag("id", "node/-1"), txt: "<span class='alert'>Uploading</span>" }
]
};
return OsmLink;
}(TagRendering_1.TagRenderingOptions));
exports.OsmLink = OsmLink;

View file

@ -0,0 +1,59 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.WikipediaLink = void 0;
var TagRendering_1 = require("../TagRendering");
var WikipediaLink = /** @class */ (function (_super) {
__extends(WikipediaLink, _super);
function WikipediaLink() {
return _super.call(this, WikipediaLink.options) || this;
}
WikipediaLink.FixLink = function (value) {
if (value === undefined) {
return undefined;
}
// @ts-ignore
if (value.startsWith("https")) {
return value;
}
else {
var splitted = value.split(":");
var language = splitted[0];
splitted.shift();
var page = splitted.join(":");
return 'https://' + language + '.wikipedia.org/wiki/' + page;
}
};
WikipediaLink.options = {
priority: 10,
// question: "Wat is het overeenstemmende wkipedia-artikel?",
tagsPreprocessor: function (tags) {
if (tags.wikipedia !== undefined) {
tags.wikipedia = WikipediaLink.FixLink(tags.wikipedia);
}
},
freeform: {
key: "wikipedia",
template: "$$$",
renderTemplate: "<span class='wikipedialink'>" +
"<a href='{wikipedia}' target='_blank'>" +
"<img width='64px' src='./assets/wikipedia.svg' alt='wikipedia'>" +
"</a></span>",
placeholder: ""
},
};
return WikipediaLink;
}(TagRendering_1.TagRenderingOptions));
exports.WikipediaLink = WikipediaLink;

View file

@ -0,0 +1,52 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var TagRendering_1 = require("../../TagRendering");
var TagsFilter_1 = require("../../../Logic/TagsFilter");
var ParkingType = /** @class */ (function (_super) {
__extends(ParkingType, _super);
function ParkingType() {
return _super.call(this, {
priority: 5,
question: "Van welk type is deze fietsenparking?",
freeform: {
key: "bicycle_parking",
extraTags: new TagsFilter_1.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 TagsFilter_1.Tag("bicycle_parking", "stands"), txt: ParkingType.toImgTxt(ParkingType.images.stands) },
{ k: new TagsFilter_1.Tag("bicycle_parking", "wall_loops"), txt: ParkingType.toImgTxt(ParkingType.images.wall_loops) },
{ k: new TagsFilter_1.Tag("bicycle_parking", "handlebar_holder"), txt: ParkingType.toImgTxt(ParkingType.images.handlebar_holder) },
{ k: new TagsFilter_1.Tag("bicycle_parking", "shed"), txt: ParkingType.toImgTxt(ParkingType.images.shed) },
{ k: new TagsFilter_1.Tag("bicycle_parking", "two-tier"), txt: ParkingType.toImgTxt(ParkingType.images["two-tier"]) }
]
}) || this;
}
ParkingType.toImgTxt = function (url) {
return "<img src=" + url + ">";
};
ParkingType.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"
};
return ParkingType;
}(TagRendering_1.TagRenderingOptions));
exports.default = ParkingType;

View file

@ -0,0 +1,32 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var TagRendering_1 = require("../../TagRendering");
var TagsFilter_1 = require("../../../Logic/TagsFilter");
var PumpManometer = /** @class */ (function (_super) {
__extends(PumpManometer, _super);
function PumpManometer() {
return _super.call(this, {
question: "Does the pump have a pressure indicator or manometer?",
mappings: [
{ k: new TagsFilter_1.Tag("manometer", "yes"), txt: "Yes, there is a manometer" },
{ k: new TagsFilter_1.Tag("manometer", "broken"), txt: "Yes, but it is broken" },
{ k: new TagsFilter_1.Tag("manometer", "yes"), txt: "No" }
]
}) || this;
}
return PumpManometer;
}(TagRendering_1.TagRenderingOptions));
exports.default = PumpManometer;

View file

@ -0,0 +1,32 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var TagRendering_1 = require("../../TagRendering");
var TagsFilter_1 = require("../../../Logic/TagsFilter");
var PumpManual = /** @class */ (function (_super) {
__extends(PumpManual, _super);
function PumpManual() {
return _super.call(this, {
priority: 5,
question: "Is this an electric bike pump?",
mappings: [
{ k: new TagsFilter_1.Tag("manual", "yes"), txt: "Manual pump" },
{ k: new TagsFilter_1.Tag("manual", "no"), txt: "Electric pump" }
]
}) || this;
}
return PumpManual;
}(TagRendering_1.TagRenderingOptions));
exports.default = PumpManual;

View file

@ -0,0 +1,31 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var TagRendering_1 = require("../../TagRendering");
var TagsFilter_1 = require("../../../Logic/TagsFilter");
var PumpOperational = /** @class */ (function (_super) {
__extends(PumpOperational, _super);
function PumpOperational() {
return _super.call(this, {
question: "Is the bicycle pump still operational?",
mappings: [
{ k: new TagsFilter_1.Tag("service:bicycle:pump:operational_status", "broken"), txt: "This pump is broken" },
{ k: new TagsFilter_1.Tag("service:bicycle:pump:operational_status", ""), txt: "This pump is operational" }
]
}) || this;
}
return PumpOperational;
}(TagRendering_1.TagRenderingOptions));
exports.default = PumpOperational;

View file

@ -0,0 +1,41 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var TagRendering_1 = require("../../TagRendering");
var TagsFilter_1 = require("../../../Logic/TagsFilter");
var PumpValves = /** @class */ (function (_super) {
__extends(PumpValves, _super);
function PumpValves() {
return _super.call(this, {
question: "What valves are supported?",
mappings: [
{
k: new TagsFilter_1.Tag("valves", " sclaverand;schrader;dunlop"),
txt: "There is a default head, so Presta, Dunlop and Auto"
},
{ k: new TagsFilter_1.Tag("valves", "dunlop"), txt: "Only dunlop" },
{ k: new TagsFilter_1.Tag("valves", "sclaverand"), txt: "Only Sclaverand (also known as Dunlop)" },
{ k: new TagsFilter_1.Tag("valves", "auto"), txt: "Only auto" },
],
freeform: {
key: "valves",
template: "Supported valves are $$$",
renderTemplate: "Supported valves are {valves}"
}
}) || this;
}
return PumpValves;
}(TagRendering_1.TagRenderingOptions));
exports.default = PumpValves;

View file

@ -0,0 +1,44 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var TagRendering_1 = require("../../TagRendering");
var TagsFilter_1 = require("../../../Logic/TagsFilter");
/**
* Currently not used in Cyclofix because it's a little vague
*/
var BikeStationBrand = /** @class */ (function (_super) {
__extends(BikeStationBrand, _super);
function BikeStationBrand() {
var _this = this;
throw Error('BikeStationBrand disabled');
_this = _super.call(this, BikeStationBrand.options) || this;
return _this;
}
BikeStationBrand.options = {
priority: 15,
question: "What is the brand of this bike station (name of university, shop, city...)?",
freeform: {
key: "brand",
template: "The brand of this bike station is $$$",
renderTemplate: "The brand of this bike station is {operator}",
placeholder: "brand"
},
mappings: [
{ k: new TagsFilter_1.Tag("brand", "Velo Fix Station"), txt: "Velo Fix Station" }
]
};
return BikeStationBrand;
}(TagRendering_1.TagRenderingOptions));
exports.default = BikeStationBrand;

View file

@ -0,0 +1,32 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var TagRendering_1 = require("../../TagRendering");
var TagsFilter_1 = require("../../../Logic/TagsFilter");
var StationChain = /** @class */ (function (_super) {
__extends(StationChain, _super);
function StationChain() {
return _super.call(this, {
priority: 5,
question: "Does this bike station have a special tool to repair your bike chain?",
mappings: [
{ k: new TagsFilter_1.Tag("service:bicycle:chain_tool", "yes"), txt: "There is a chain tool." },
{ k: new TagsFilter_1.Tag("service:bicycle:chain_tool", "no"), txt: "There is no chain tool." },
]
}) || this;
}
return StationChain;
}(TagRendering_1.TagRenderingOptions));
exports.default = StationChain;

View file

@ -0,0 +1,41 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var TagRendering_1 = require("../../TagRendering");
var TagsFilter_1 = require("../../../Logic/TagsFilter");
var BikeStationOperator = /** @class */ (function (_super) {
__extends(BikeStationOperator, _super);
function BikeStationOperator() {
return _super.call(this, {
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 TagsFilter_1.Tag("operator", "KU Leuven"), txt: "KU Leuven" },
{ k: new TagsFilter_1.Tag("operator", "Stad Halle"), txt: "Stad Halle" },
{ k: new TagsFilter_1.Tag("operator", "Saint Gilles - Sint Gillis"), txt: "Saint Gilles - Sint Gillis" },
{ k: new TagsFilter_1.Tag("operator", "Jette"), txt: "Jette" },
{ k: new TagsFilter_1.Tag("operator", "private"), txt: "Beheer door een privépersoon" }
]
}) || this;
}
return BikeStationOperator;
}(TagRendering_1.TagRenderingOptions));
exports.default = BikeStationOperator;

View file

@ -0,0 +1,33 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var TagRendering_1 = require("../../TagRendering");
var TagsFilter_1 = require("../../../Logic/TagsFilter");
var BikeStationPumpTools = /** @class */ (function (_super) {
__extends(BikeStationPumpTools, _super);
function BikeStationPumpTools() {
return _super.call(this, {
priority: 15,
question: "Which services are available at this bike station?",
mappings: [
{ k: new TagsFilter_1.And([new TagsFilter_1.Tag("service:bicycle:tools", "no"), new TagsFilter_1.Tag("service:bicycle:pump", "yes")]), txt: "There is only a pump available." },
{ k: new TagsFilter_1.And([new TagsFilter_1.Tag("service:bicycle:tools", "yes"), new TagsFilter_1.Tag("service:bicycle:pump", "no")]), txt: "There are only tools (screwdrivers, pliers...) available." },
{ k: new TagsFilter_1.And([new TagsFilter_1.Tag("service:bicycle:tools", "yes"), new TagsFilter_1.Tag("service:bicycle:pump", "yes")]), txt: "There are both tools and a pump available." }
]
}) || this;
}
return BikeStationPumpTools;
}(TagRendering_1.TagRenderingOptions));
exports.default = BikeStationPumpTools;

View file

@ -0,0 +1,32 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var TagRendering_1 = require("../../TagRendering");
var TagsFilter_1 = require("../../../Logic/TagsFilter");
var BikeStationStand = /** @class */ (function (_super) {
__extends(BikeStationStand, _super);
function BikeStationStand() {
return _super.call(this, {
priority: 10,
question: "Does this bike station have a hook to suspend your bike with or a stand to elevate it?",
mappings: [
{ k: new TagsFilter_1.Tag("service:bicycle:stand", "yes"), txt: "There is a hook or stand." },
{ k: new TagsFilter_1.Tag("service:bicycle:stand", "no"), txt: "There is no hook or stand" },
]
}) || this;
}
return BikeStationStand;
}(TagRendering_1.TagRenderingOptions));
exports.default = BikeStationStand;

View file

@ -0,0 +1,321 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.TagRenderingOptions = void 0;
var UIElement_1 = require("../UI/UIElement");
var UIEventSource_1 = require("../UI/UIEventSource");
var TagsFilter_1 = require("../Logic/TagsFilter");
var FixedUiElement_1 = require("../UI/Base/FixedUiElement");
var SaveButton_1 = require("../UI/SaveButton");
var VariableUIElement_1 = require("../UI/Base/VariableUIElement");
var OnlyShowIf_1 = require("./OnlyShowIf");
var TextField_1 = require("../UI/Input/TextField");
var InputElementWrapper_1 = require("../UI/Input/InputElementWrapper");
var FixedInputElement_1 = require("../UI/Input/FixedInputElement");
var RadioButton_1 = require("../UI/Input/RadioButton");
var TagRenderingOptions = /** @class */ (function () {
function TagRenderingOptions(options) {
this.options = options;
}
TagRenderingOptions.prototype.OnlyShowIf = function (tagsFilter) {
return new OnlyShowIf_1.OnlyShowIfConstructor(tagsFilter, this);
};
TagRenderingOptions.prototype.IsQuestioning = function (tags) {
var _a;
var tagsKV = TagsFilter_1.TagUtils.proprtiesToKV(tags);
for (var _i = 0, _b = (_a = this.options.mappings) !== null && _a !== void 0 ? _a : []; _i < _b.length; _i++) {
var oneOnOneElement = _b[_i];
if (oneOnOneElement.k === null || oneOnOneElement.k.matches(tagsKV)) {
return false;
}
}
if (this.options.freeform !== undefined && tags[this.options.freeform.key] !== undefined) {
return false;
}
if (this.options.question === undefined) {
return false;
}
return true;
};
TagRenderingOptions.prototype.construct = function (dependencies) {
return new TagRendering(dependencies.tags, dependencies.changes, this.options);
};
TagRenderingOptions.prototype.IsKnown = function (properties) {
return !this.IsQuestioning(properties);
};
TagRenderingOptions.prototype.Priority = function () {
var _a;
return (_a = this.options.priority) !== null && _a !== void 0 ? _a : 0;
};
return TagRenderingOptions;
}());
exports.TagRenderingOptions = TagRenderingOptions;
var TagRendering = /** @class */ (function (_super) {
__extends(TagRendering, _super);
function TagRendering(tags, changes, options) {
var _a, _b, _c;
var _this = _super.call(this, tags) || this;
_this._questionSkipped = new UIEventSource_1.UIEventSource(false);
_this._editMode = new UIEventSource_1.UIEventSource(false);
var self = _this;
_this.ListenTo(_this._questionSkipped);
_this.ListenTo(_this._editMode);
_this._userDetails = changes.login.userDetails;
_this.ListenTo(_this._userDetails);
_this._question = options.question;
_this._priority = (_a = options.priority) !== null && _a !== void 0 ? _a : 0;
_this._primer = (_b = options.primer) !== null && _b !== void 0 ? _b : "";
_this._tagsPreprocessor = function (properties) {
if (options.tagsPreprocessor === undefined) {
return properties;
}
var newTags = {};
for (var k in properties) {
newTags[k] = properties[k];
}
options.tagsPreprocessor(newTags);
return newTags;
};
_this._mapping = [];
_this._renderMapping = [];
_this._freeform = options.freeform;
// Prepare the choices for the Radio buttons
var choices = [];
var usedChoices = [];
for (var _i = 0, _d = (_c = options.mappings) !== null && _c !== void 0 ? _c : []; _i < _d.length; _i++) {
var choice = _d[_i];
if (choice.k === null) {
_this._mapping.push(choice);
continue;
}
var choiceSubbed = choice;
if (choice.substitute) {
choiceSubbed = {
k: choice.k.substituteValues(options.tagsPreprocessor(_this._source.data)),
txt: _this.ApplyTemplate(choice.txt),
substitute: false,
priority: choice.priority
};
}
var txt = choiceSubbed.txt;
// Choices is what is shown in the radio buttons
if (usedChoices.indexOf(txt) < 0) {
choices.push(new FixedUiElement_1.FixedUiElement(txt));
usedChoices.push(txt);
// This is used to convert the radio button index into tags needed to add
_this._mapping.push(choiceSubbed);
}
else {
_this._renderMapping.push(choiceSubbed); // only used while rendering
}
}
// Prepare the actual input element -> pick an appropriate implementation
_this._questionElement = _this.InputElementFor(options);
var save = function () {
var selection = self._questionElement.GetValue().data;
if (selection) {
changes.addTag(tags.data.id, selection);
}
self._editMode.setData(false);
};
var cancel = function () {
self._questionSkipped.setData(true);
self._editMode.setData(false);
self._source.ping(); // Send a ping upstream to render the next question
};
// Setup the save button and it's action
_this._saveButton = new SaveButton_1.SaveButton(_this._questionElement.GetValue())
.onClick(save);
_this._editButton = new FixedUiElement_1.FixedUiElement("");
if (_this._question !== undefined) {
_this._editButton = new FixedUiElement_1.FixedUiElement("<img class='editbutton' src='./assets/pencil.svg' alt='edit'>")
.onClick(function () {
self._questionElement.GetValue().setData(self.CurrentValue());
self._editMode.setData(true);
});
}
var cancelContents = _this._editMode.map(function (isEditing) {
if (isEditing) {
return "<span class='skip-button'>Annuleren</span>";
}
else {
return "<span class='skip-button'>Overslaan (Ik weet het niet zeker...)</span>";
}
});
// And at last, set up the skip button
_this._skipButton = new VariableUIElement_1.VariableUiElement(cancelContents).onClick(cancel);
return _this;
}
TagRendering.prototype.InputElementFor = function (options) {
var elements = [];
if (options.mappings !== undefined) {
for (var _i = 0, _a = options.mappings; _i < _a.length; _i++) {
var mapping = _a[_i];
elements.push(this.InputElementForMapping(mapping));
}
}
if (options.freeform !== undefined) {
elements.push(this.InputForFreeForm(options.freeform));
}
if (elements.length == 0) {
throw "NO TAGRENDERINGS!";
}
if (elements.length == 1) {
return elements[0];
}
return new RadioButton_1.RadioButton(elements, false);
};
TagRendering.prototype.InputElementForMapping = function (mapping) {
return new FixedInputElement_1.FixedInputElement(mapping.txt, mapping.k);
};
TagRendering.prototype.InputForFreeForm = function (freeform) {
if (freeform === undefined) {
return undefined;
}
var pickString = function (string) {
if (string === "" || string === undefined) {
return undefined;
}
var tag = new TagsFilter_1.Tag(freeform.key, string);
if (freeform.extraTags === undefined) {
return tag;
}
return new TagsFilter_1.And([
freeform.extraTags,
tag
]);
};
var toString = function (tag) {
if (tag instanceof TagsFilter_1.And) {
return toString(tag.and[0]);
}
else if (tag instanceof TagsFilter_1.Tag) {
return tag.value;
}
return undefined;
};
var inputElement;
var textField = new TextField_1.TextField({
placeholder: this._freeform.placeholder,
fromString: pickString,
toString: toString
});
var prepost = freeform.template.split("$$$");
return new InputElementWrapper_1.InputElementWrapper(prepost[0], textField, prepost[1]);
};
TagRendering.prototype.IsKnown = function () {
var tags = TagsFilter_1.TagUtils.proprtiesToKV(this._source.data);
for (var _i = 0, _a = this._mapping.concat(this._renderMapping); _i < _a.length; _i++) {
var oneOnOneElement = _a[_i];
if (oneOnOneElement.k === null || oneOnOneElement.k.matches(tags)) {
return true;
}
}
return this._freeform !== undefined && this._source.data[this._freeform.key] !== undefined;
};
TagRendering.prototype.CurrentValue = function () {
var tags = TagsFilter_1.TagUtils.proprtiesToKV(this._source.data);
for (var _i = 0, _a = this._mapping.concat(this._renderMapping); _i < _a.length; _i++) {
var oneOnOneElement = _a[_i];
if (oneOnOneElement.k === null || oneOnOneElement.k.matches(tags)) {
return oneOnOneElement.k;
}
}
if (this._freeform === undefined) {
return undefined;
}
return new TagsFilter_1.Tag(this._freeform.key, this._source.data[this._freeform.key]);
};
TagRendering.prototype.IsQuestioning = function () {
if (this.IsKnown()) {
return false;
}
if (this._question === undefined) {
// We don't ask this question in the first place
return false;
}
if (this._questionSkipped.data) {
// We don't ask for this question anymore, skipped by user
return false;
}
return true;
};
TagRendering.prototype.RenderAnwser = function () {
var _a;
var tags = TagsFilter_1.TagUtils.proprtiesToKV(this._source.data);
var freeform = "";
var freeformScore = -10;
if (this._freeform !== undefined && this._source.data[this._freeform.key] !== undefined) {
freeform = this.ApplyTemplate(this._freeform.renderTemplate);
freeformScore = 0;
}
var highestScore = -100;
var highestTemplate = undefined;
for (var _i = 0, _b = this._mapping.concat(this._renderMapping); _i < _b.length; _i++) {
var oneOnOneElement = _b[_i];
if (oneOnOneElement.k == null ||
oneOnOneElement.k.matches(tags)) {
// We have found a matching key -> we use the template, but only if it scores better
var score = (_a = oneOnOneElement.priority) !== null && _a !== void 0 ? _a : (oneOnOneElement.k === null ? -1 : 0);
if (score > highestScore) {
highestScore = score;
highestTemplate = oneOnOneElement.txt;
}
}
}
if (freeformScore > highestScore) {
return freeform;
}
if (highestTemplate !== undefined) {
// we render the found template
return this._primer + this.ApplyTemplate(highestTemplate);
}
};
TagRendering.prototype.InnerRender = function () {
if (this.IsQuestioning() || this._editMode.data) {
// Not yet known or questioning, we have to ask a question
return "<div class='question'>" +
"<span class='question-text'>" + this._question + "</span>" +
(this._question !== "" ? "<br/>" : "") +
this._questionElement.Render() +
this._skipButton.Render() +
this._saveButton.Render() +
"</div>";
}
if (this.IsKnown()) {
var html = this.RenderAnwser();
if (html == "") {
return "";
}
var editButton = "";
if (this._userDetails.data.loggedIn) {
editButton = this._editButton.Render();
}
return "<span class='answer'>" +
"<span class='answer-text'>" + html + "</span>" +
editButton +
"</span>";
}
return "";
};
TagRendering.prototype.Priority = function () {
return this._priority;
};
TagRendering.prototype.ApplyTemplate = function (template) {
var tags = this._tagsPreprocessor(this._source.data);
return TagsFilter_1.TagUtils.ApplyTemplate(template, tags);
};
return TagRendering;
}(UIElement_1.UIElement));

View file

@ -0,0 +1,25 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.TagDependantUIElement = void 0;
var UIElement_1 = require("../UI/UIElement");
var TagDependantUIElement = /** @class */ (function (_super) {
__extends(TagDependantUIElement, _super);
function TagDependantUIElement() {
return _super !== null && _super.apply(this, arguments) || this;
}
return TagDependantUIElement;
}(UIElement_1.UIElement));
exports.TagDependantUIElement = TagDependantUIElement;

57
Helpers.js Normal file
View file

@ -0,0 +1,57 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Helpers = void 0;
var Helpers = /** @class */ (function () {
function Helpers() {
}
Helpers.DoEvery = function (millis, f) {
window.setTimeout(function () {
f();
Helpers.DoEvery(millis, f);
}, millis);
};
Helpers.SetupAutoSave = function (changes, millisTillChangesAreSaved, saveAfterXMillis) {
changes.pendingChangesES.addCallback(function () {
var c = changes.pendingChangesES.data;
if (c > 10) {
millisTillChangesAreSaved.setData(0);
changes.uploadAll(undefined);
return;
}
if (c > 0) {
millisTillChangesAreSaved.setData(saveAfterXMillis);
}
});
millisTillChangesAreSaved.addCallback(function (time) {
if (time <= 0 && changes.pendingChangesES.data > 0) {
changes.uploadAll(undefined);
}
});
Helpers.DoEvery(1000, function () {
millisTillChangesAreSaved
.setData(millisTillChangesAreSaved.data - 1000);
});
};
/*
* Registers an action that:
* -> Upload everything to OSM
* -> Asks the user not to close. The 'not to close' dialog should profide enough time to upload
* -> WHen uploading is done, the window is closed anyway
*/
Helpers.LastEffortSave = function (changes) {
window.addEventListener("beforeunload", function (e) {
// Quickly save everyting!
if (changes.pendingChangesES.data == 0) {
return "";
}
changes.uploadAll(function () {
window.close();
});
var confirmationMessage = "Nog even geduld - je laatset wijzigingen worden opgeslaan!";
(e || window.event).returnValue = confirmationMessage; //Gecko + IE
return confirmationMessage; //Webkit, Safari, Chrome
});
};
return Helpers;
}());
exports.Helpers = Helpers;

70
Logic/Basemap.js Normal file
View file

@ -0,0 +1,70 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Basemap = void 0;
var leaflet_1 = require("leaflet");
var UIEventSource_1 = require("../UI/UIEventSource");
// Contains all setup and baselayers for Leaflet stuff
var Basemap = /** @class */ (function () {
function Basemap(leafletElementId, location, extraAttribution) {
this.LastClickLocation = new UIEventSource_1.UIEventSource(undefined);
this.aivLucht2013Layer = leaflet_1.default.tileLayer.wms('https://geoservices.informatievlaanderen.be/raadpleegdiensten/OGW/wms?s', {
layers: "OGWRGB13_15VL",
attribution: "Luchtfoto's van © AIV Vlaanderen (2013-2015) | "
});
this.aivLuchtLatestLayer = leaflet_1.default.tileLayer("https://tile.informatievlaanderen.be/ws/raadpleegdiensten/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&" +
"LAYER=omwrgbmrvl&STYLE=&FORMAT=image/png&tileMatrixSet=GoogleMapsVL&tileMatrix={z}&tileRow={y}&tileCol={x}", {
// omwrgbmrvl
attribution: 'Luchtfoto\'s van © AIV Vlaanderen (Laatste) © AGIV',
maxZoom: 20,
minZoom: 1,
wmts: true
});
this.osmLayer = leaflet_1.default.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution: '',
maxZoom: 19,
minZoom: 1
});
this.osmBeLayer = leaflet_1.default.tileLayer("https://tile.osm.be/osmbe/{z}/{x}/{y}.png", {
attribution: '<a href="https://geo6.be/">Tile hosting courtesy of Geo6</a>',
maxZoom: 18,
minZoom: 1
});
this.grbLayer = leaflet_1.default.tileLayer("https://tile.informatievlaanderen.be/ws/raadpleegdiensten/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=grb_bsk&STYLE=&FORMAT=image/png&tileMatrixSet=GoogleMapsVL&tileMatrix={z}&tileCol={x}&tileRow={y}", {
attribution: 'Achtergrond <i>Grootschalig ReferentieBestand</i>(GRB) © AGIV',
maxZoom: 20,
minZoom: 1,
wmts: true
});
this.baseLayers = {
"Luchtfoto Vlaanderen (recentste door AIV)": this.aivLuchtLatestLayer,
"Luchtfoto Vlaanderen (2013-2015, door AIV)": this.aivLucht2013Layer,
"Kaart van OpenStreetMap": this.osmLayer,
"Kaart Grootschalig ReferentieBestand Vlaanderen (GRB) door AIV": this.grbLayer
};
this.map = leaflet_1.default.map(leafletElementId, {
center: [location.data.lat, location.data.lon],
zoom: location.data.zoom,
layers: [this.osmLayer],
});
this.map.attributionControl.setPrefix(extraAttribution.Render() + " | <a href='https://osm.org'>OpenStreetMap</a>");
this.Location = location;
var layerControl = leaflet_1.default.control.layers(this.baseLayers, null, {
position: 'bottomright',
hideSingleBase: true
});
layerControl.addTo(this.map);
this.map.zoomControl.setPosition("bottomright");
var self = this;
this.map.on("moveend", function () {
location.data.zoom = self.map.getZoom();
location.data.lat = self.map.getCenter().lat;
location.data.lon = self.map.getCenter().lng;
location.ping();
});
this.map.on("click", function (e) {
self.LastClickLocation.setData({ lat: e.latlng.lat, lon: e.latlng.lng });
});
}
return Basemap;
}());
exports.Basemap = Basemap;

222
Logic/Changes.js Normal file
View file

@ -0,0 +1,222 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Changes = void 0;
var OsmObject_1 = require("./OsmObject");
var UIEventSource_1 = require("../UI/UIEventSource");
var TagsFilter_1 = require("./TagsFilter");
var Changes = /** @class */ (function () {
function Changes(changesetComment, login, allElements) {
this._pendingChanges = []; // Gets reset on uploadAll
this.newElements = []; // Gets reset on uploadAll
this.pendingChangesES = new UIEventSource_1.UIEventSource(this._pendingChanges.length);
this.isSaving = new UIEventSource_1.UIEventSource(false);
this._changesetComment = changesetComment;
this.login = login;
this._allElements = allElements;
}
Changes.prototype.addTag = function (elementId, tagsFilter) {
if (tagsFilter instanceof TagsFilter_1.Tag) {
var tag = tagsFilter;
this.addChange(elementId, tag.key, tag.value);
return;
}
if (tagsFilter instanceof TagsFilter_1.And) {
var and = tagsFilter;
for (var _i = 0, _a = and.and; _i < _a.length; _i++) {
var tag = _a[_i];
this.addTag(elementId, tag);
}
return;
}
console.log("Unsupported tagsfilter element to addTag", tagsFilter);
throw "Unsupported tagsFilter element";
};
/**
* Adds a change to the pending changes
* @param elementId
* @param key
* @param value
*/
Changes.prototype.addChange = function (elementId, key, value) {
console.log("Received change", key, value);
if (key === undefined || key === null) {
console.log("Invalid key");
return;
}
if (value === undefined || value === null) {
console.log("Invalid value for ", key);
return;
}
var eventSource = this._allElements.getElement(elementId);
eventSource.data[key] = value;
eventSource.ping();
// We get the id from the event source, as that ID might be rewritten
this._pendingChanges.push({ elementId: eventSource.data.id, key: key, value: value });
this.pendingChangesES.setData(this._pendingChanges.length);
};
/**
* Create a new node element at the given lat/long.
* An internal OsmObject is created to upload later on, a geojson represention is returned.
* Note that the geojson version shares the tags (properties) by pointer, but has _no_ id in properties
*/
Changes.prototype.createElement = function (basicTags, lat, lon) {
var osmNode = new OsmObject_1.OsmNode(Changes._nextId);
this.newElements.push(osmNode);
Changes._nextId--;
var id = "node/" + osmNode.id;
osmNode.lat = lat;
osmNode.lon = lon;
var properties = { id: id };
var geojson = {
"type": "Feature",
"properties": properties,
"id": id,
"geometry": {
"type": "Point",
"coordinates": [
lon,
lat
]
}
};
this._allElements.addOrGetElement(geojson);
// The basictags are COPIED, the id is included in the properties
// The tags are not yet written into the OsmObject, but this is applied onto a
for (var _i = 0, basicTags_1 = basicTags; _i < basicTags_1.length; _i++) {
var kv = basicTags_1[_i];
this.addChange(id, kv.key, kv.value); // We use the call, to trigger all the other machinery (including updating the geojson itsel
properties[kv.key] = kv.value;
}
return geojson;
};
Changes.prototype.uploadAll = function (optionalContinuation) {
if (optionalContinuation === void 0) { optionalContinuation = undefined; }
var self = this;
this.isSaving.setData(true);
var optionalContinuationWrapped = function () {
self.isSaving.setData(false);
if (optionalContinuation) {
optionalContinuation();
}
};
var pending = this._pendingChanges;
this._pendingChanges = [];
this.pendingChangesES.setData(this._pendingChanges.length);
var newElements = this.newElements;
this.newElements = [];
var knownElements = {}; // maps string --> OsmObject
function DownloadAndContinue(neededIds, continuation) {
// local function which downloads all the objects one by one
// this is one big loop, running one download, then rerunning the entire function
if (neededIds.length == 0) {
continuation();
return;
}
var neededId = neededIds.pop();
if (neededId in knownElements) {
DownloadAndContinue(neededIds, continuation);
return;
}
console.log("Downloading ", neededId);
OsmObject_1.OsmObject.DownloadObject(neededId, function (element) {
knownElements[neededId] = element; // assign the element for later, continue downloading the next element
DownloadAndContinue(neededIds, continuation);
});
}
var neededIds = [];
for (var _i = 0, pending_1 = pending; _i < pending_1.length; _i++) {
var change = pending_1[_i];
var id = change.elementId;
if (parseFloat(id.split("/")[1]) < 0) {
console.log("Detected a new element! Exciting!");
}
else {
neededIds.push(id);
}
}
DownloadAndContinue(neededIds, function () {
// Here, inside the continuation, we know that all 'neededIds' are loaded in 'knownElements'
// We apply the changes on them
for (var _i = 0, pending_2 = pending; _i < pending_2.length; _i++) {
var change = pending_2[_i];
if (parseInt(change.elementId.split("/")[1]) < 0) {
// This is a new element - we should apply this on one of the new elements
for (var _a = 0, newElements_1 = newElements; _a < newElements_1.length; _a++) {
var newElement = newElements_1[_a];
if (newElement.type + "/" + newElement.id === change.elementId) {
newElement.addTag(change.key, change.value);
}
}
}
else {
console.log(knownElements, change.elementId);
knownElements[change.elementId].addTag(change.key, change.value);
// note: addTag will flag changes with 'element.changed' internally
}
}
// Small sanity check for duplicate information
var changedElements = [];
for (var elementId in knownElements) {
var element = knownElements[elementId];
if (element.changed) {
changedElements.push(element);
}
}
if (changedElements.length == 0 && newElements.length == 0) {
console.log("No changes in any object");
return;
}
var handleMapping = function (idMapping) {
for (var oldId in idMapping) {
var newId = idMapping[oldId];
var element = self._allElements.getElement(oldId);
element.data.id = newId;
self._allElements.addElementById(newId, element);
element.ping();
}
};
console.log("Beginning upload...");
// At last, we build the changeset and upload
self.login.UploadChangeset(self._changesetComment, function (csId) {
var modifications = "";
for (var _i = 0, changedElements_1 = changedElements; _i < changedElements_1.length; _i++) {
var element = changedElements_1[_i];
if (!element.changed) {
continue;
}
modifications += element.ChangesetXML(csId) + "\n";
}
var creations = "";
for (var _a = 0, newElements_2 = newElements; _a < newElements_2.length; _a++) {
var newElement = newElements_2[_a];
creations += newElement.ChangesetXML(csId);
}
var changes = "<osmChange version='0.6' generator='Mapcomplete 0.0.1'>";
if (creations.length > 0) {
changes +=
"<create>" +
creations +
"</create>";
}
if (modifications.length > 0) {
changes +=
"<modify>" +
modifications +
"</modify>";
}
changes += "</osmChange>";
return changes;
}, handleMapping, optionalContinuationWrapped);
});
};
Changes.prototype.asQuestions = function (qs) {
var ls = [];
for (var i in qs) {
ls.push(new Question(this, qs[i]));
}
return ls;
};
Changes._nextId = -1; // New assined ID's are negative
return Changes;
}());
exports.Changes = Changes;

51
Logic/ElementStorage.js Normal file
View file

@ -0,0 +1,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ElementStorage = void 0;
/**
* Keeps track of a dictionary 'elementID' -> element
*/
var UIEventSource_1 = require("../UI/UIEventSource");
var ElementStorage = /** @class */ (function () {
function ElementStorage() {
this._elements = [];
}
ElementStorage.prototype.addElementById = function (id, eventSource) {
this._elements[id] = eventSource;
};
ElementStorage.prototype.addElement = function (element) {
var eventSource = new UIEventSource_1.UIEventSource(element.properties);
this._elements[element.properties.id] = eventSource;
return eventSource;
};
ElementStorage.prototype.addOrGetElement = function (element) {
var elementId = element.properties.id;
if (elementId in this._elements) {
var es = this._elements[elementId];
var keptKeys = es.data;
// The element already exists
// We add all the new keys to the old keys
for (var k in element.properties) {
var v = element.properties[k];
if (keptKeys[k] !== v) {
keptKeys[k] = v;
es.ping();
}
}
return es;
}
else {
return this.addElement(element);
}
};
ElementStorage.prototype.getElement = function (elementId) {
if (elementId in this._elements) {
return this._elements[elementId];
}
console.log("Can not find eventsource with id ", elementId);
};
ElementStorage.prototype.removeId = function (oldId) {
delete this._elements[oldId];
};
return ElementStorage;
}());
exports.ElementStorage = ElementStorage;

173
Logic/FilteredLayer.js Normal file
View file

@ -0,0 +1,173 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FilteredLayer = void 0;
var TagsFilter_1 = require("./TagsFilter");
var UIEventSource_1 = require("../UI/UIEventSource");
var leaflet_1 = require("leaflet");
var GeoOperations_1 = require("./GeoOperations");
/***
* A filtered layer is a layer which offers a 'set-data' function
* It is initialized with a tagfilter.
*
* When geojson-data is given to 'setData', all the geojson matching the filter, is rendered on this layer.
* If it is not rendered, it is returned in a 'leftOver'-geojson; which can be consumed by the next layer.
*
* This also makes sure that no objects are rendered twice if they are applicable on two layers
*/
var FilteredLayer = /** @class */ (function () {
function FilteredLayer(name, map, storage, changes, filters, maxAllowedOverlap, style, selectedElement, showOnPopup) {
this.isDisplayed = new UIEventSource_1.UIEventSource(true);
/** List of new elements, geojson features
*/
this._newElements = [];
this._selectedElement = selectedElement;
this._showOnPopup = showOnPopup;
if (style === undefined) {
style = function () {
return {};
};
}
this.name = name;
this._map = map;
this.filters = filters;
this._style = style;
this._storage = storage;
this._maxAllowedOverlap = maxAllowedOverlap;
var self = this;
this.isDisplayed.addCallback(function (isDisplayed) {
if (self._geolayer !== undefined && self._geolayer !== null) {
if (isDisplayed) {
self._geolayer.addTo(self._map.map);
}
else {
self._map.map.removeLayer(self._geolayer);
}
}
});
}
/**
* The main function to load data into this layer.
* The data that is NOT used by this layer, is returned as a geojson object; the other data is rendered
*/
FilteredLayer.prototype.SetApplicableData = function (geojson) {
var leftoverFeatures = [];
var selfFeatures = [];
for (var _i = 0, _a = geojson.features; _i < _a.length; _i++) {
var feature = _a[_i];
// feature.properties contains all the properties
var tags = TagsFilter_1.TagUtils.proprtiesToKV(feature.properties);
if (this.filters.matches(tags)) {
selfFeatures.push(feature);
}
else {
leftoverFeatures.push(feature);
}
}
this.RenderLayer({
type: "FeatureCollection",
features: selfFeatures
});
var notShadowed = [];
for (var _b = 0, leftoverFeatures_1 = leftoverFeatures; _b < leftoverFeatures_1.length; _b++) {
var feature = leftoverFeatures_1[_b];
if (this._maxAllowedOverlap !== undefined && this._maxAllowedOverlap > 0) {
if (GeoOperations_1.GeoOperations.featureIsContainedInAny(feature, selfFeatures, this._maxAllowedOverlap)) {
// This feature is filtered away
continue;
}
}
notShadowed.push(feature);
}
return {
type: "FeatureCollection",
features: notShadowed
};
};
FilteredLayer.prototype.AddNewElement = function (element) {
this._newElements.push(element);
console.log("Element added");
this.RenderLayer(this._dataFromOverpass); // Update the layer
};
FilteredLayer.prototype.RenderLayer = function (data) {
var self = this;
if (this._geolayer !== undefined && this._geolayer !== null) {
this._map.map.removeLayer(this._geolayer);
}
this._dataFromOverpass = data;
var fusedFeatures = [];
var idsFromOverpass = [];
for (var _i = 0, _a = data.features; _i < _a.length; _i++) {
var feature = _a[_i];
idsFromOverpass.push(feature.properties.id);
fusedFeatures.push(feature);
}
for (var _b = 0, _c = this._newElements; _b < _c.length; _b++) {
var feature = _c[_b];
if (idsFromOverpass.indexOf(feature.properties.id) < 0) {
// This element is not yet uploaded or not yet visible in overpass
// We include it in the layer
fusedFeatures.push(feature);
}
}
// We use a new, fused dataset
data = {
type: "FeatureCollection",
features: fusedFeatures
};
// The data is split in two parts: the poinst and the rest
// The points get a special treatment in order to render them properly
// Note that some features might get a point representation as well
this._geolayer = leaflet_1.default.geoJSON(data, {
style: function (feature) {
return self._style(feature.properties);
},
pointToLayer: function (feature, latLng) {
var style = self._style(feature.properties);
var marker;
if (style.icon === undefined) {
marker = leaflet_1.default.circle(latLng, {
radius: 25,
color: style.color
});
}
else {
marker = leaflet_1.default.marker(latLng, {
icon: style.icon
});
}
return marker;
},
onEachFeature: function (feature, layer) {
var eventSource = self._storage.addOrGetElement(feature);
eventSource.addCallback(function () {
if (layer.setIcon) {
layer.setIcon(self._style(feature.properties).icon);
}
else {
console.log("UPdating", layer);
self._geolayer.setStyle(function (feature) {
return self._style(feature.properties);
});
}
});
layer.on("click", function (e) {
console.log("Selected ", feature);
self._selectedElement.setData(feature.properties);
var uiElement = self._showOnPopup(eventSource);
var popup = leaflet_1.default.popup()
.setContent(uiElement.Render())
.setLatLng(e.latlng)
.openOn(self._map.map);
uiElement.Update();
uiElement.Activate();
leaflet_1.default.DomEvent.stop(e); // Marks the event as consumed
});
}
});
if (this.isDisplayed.data) {
this._geolayer.addTo(this._map.map);
}
};
return FilteredLayer;
}());
exports.FilteredLayer = FilteredLayer;

117
Logic/GeoLocationHandler.js Normal file
View file

@ -0,0 +1,117 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.GeoLocationHandler = void 0;
var UIEventSource_1 = require("../UI/UIEventSource");
var UIElement_1 = require("../UI/UIElement");
var leaflet_1 = require("leaflet");
var Helpers_1 = require("../Helpers");
var GeoLocationHandler = /** @class */ (function (_super) {
__extends(GeoLocationHandler, _super);
function GeoLocationHandler(map) {
var _this = _super.call(this, undefined) || this;
_this.currentLocation = new UIEventSource_1.UIEventSource(undefined);
_this._isActive = new UIEventSource_1.UIEventSource(false);
_this._permission = new UIEventSource_1.UIEventSource("");
_this._map = map;
_this.ListenTo(_this.currentLocation);
_this.ListenTo(_this._isActive);
_this.ListenTo(_this._permission);
var self = _this;
function onAccuratePositionProgress(e) {
console.log(e.accuracy);
console.log(e.latlng);
self.currentLocation.setData({ latlng: e.latlng, accuracy: e.accuracy });
}
function onAccuratePositionFound(e) {
console.log(e.accuracy);
console.log(e.latlng);
self.currentLocation.setData({ latlng: e.latlng, accuracy: e.accuracy });
}
function onAccuratePositionError(e) {
console.log("onerror", e.message);
}
map.map.on('accuratepositionprogress', onAccuratePositionProgress);
map.map.on('accuratepositionfound', onAccuratePositionFound);
map.map.on('accuratepositionerror', onAccuratePositionError);
var icon = leaflet_1.default.icon({
iconUrl: './assets/crosshair-blue.svg',
iconSize: [40, 40],
iconAnchor: [20, 20],
});
_this.currentLocation.addCallback(function (location) {
var newMarker = leaflet_1.default.marker(location.latlng, { icon: icon });
newMarker.addTo(map.map);
if (self._marker !== undefined) {
map.map.removeLayer(self._marker);
}
self._marker = newMarker;
});
navigator.permissions.query({ name: 'geolocation' })
.then(function (status) {
console.log("Geolocation is already", status);
if (status.state === "granted") {
self.StartGeolocating();
}
self._permission.setData(status.state);
status.onchange = function () {
self._permission.setData(status.state);
};
});
_this.HideOnEmpty(true);
return _this;
}
GeoLocationHandler.prototype.InnerRender = function () {
if (this.currentLocation.data) {
return "<img src='./assets/crosshair-blue.svg' alt='locate me'>";
}
if (this._isActive.data) {
return "<img src='./assets/crosshair-blue-center.svg' alt='locate me'>";
}
return "<img src='./assets/crosshair.svg' alt='locate me'>";
};
GeoLocationHandler.prototype.StartGeolocating = function () {
var self = this;
if (self._permission.data === "denied") {
return "";
}
if (self.currentLocation.data !== undefined) {
self._map.map.flyTo(self.currentLocation.data.latlng, 18);
}
console.log("Searching location using GPS");
self._map.map.findAccuratePosition({
maxWait: 10000,
desiredAccuracy: 50 // defaults to 20
});
if (!self._isActive.data) {
self._isActive.setData(true);
Helpers_1.Helpers.DoEvery(60000, function () {
self._map.map.findAccuratePosition({
maxWait: 10000,
desiredAccuracy: 50 // defaults to 20
});
});
}
};
GeoLocationHandler.prototype.InnerUpdate = function (htmlElement) {
_super.prototype.InnerUpdate.call(this, htmlElement);
var self = this;
htmlElement.onclick = function () {
self.StartGeolocating();
};
};
return GeoLocationHandler;
}(UIElement_1.UIElement));
exports.GeoLocationHandler = GeoLocationHandler;

185
Logic/GeoOperations.js Normal file
View file

@ -0,0 +1,185 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GeoOperations = void 0;
var turf = require("turf");
var GeoOperations = /** @class */ (function () {
function GeoOperations() {
}
GeoOperations.surfaceAreaInSqMeters = function (feature) {
return turf.area(feature);
};
GeoOperations.featureIsContainedInAny = function (feature, shouldNotContain, maxOverlapPercentage) {
// Returns 'false' if no problematic intersection is found
if (feature.geometry.type === "Point") {
var coor = feature.geometry.coordinates;
for (var _i = 0, shouldNotContain_1 = shouldNotContain; _i < shouldNotContain_1.length; _i++) {
var shouldNotContainElement = shouldNotContain_1[_i];
var shouldNotContainBBox = BBox.get(shouldNotContainElement);
var featureBBox = BBox.get(feature);
if (!featureBBox.overlapsWith(shouldNotContainBBox)) {
continue;
}
if (this.inside(coor, shouldNotContainElement)) {
return true;
}
}
return false;
}
if (feature.geometry.type === "Polygon" || feature.geometry.type === "MultiPolygon") {
var poly = feature;
var featureBBox = BBox.get(feature);
var featureSurface = GeoOperations.surfaceAreaInSqMeters(poly);
for (var _a = 0, shouldNotContain_2 = shouldNotContain; _a < shouldNotContain_2.length; _a++) {
var shouldNotContainElement = shouldNotContain_2[_a];
var shouldNotContainBBox = BBox.get(shouldNotContainElement);
var overlaps = featureBBox.overlapsWith(shouldNotContainBBox);
if (!overlaps) {
continue;
}
// Calculate the surface area of the intersection
// If it is too big, refuse
try {
var intersection = turf.intersect(poly, shouldNotContainElement);
if (intersection == null) {
continue;
}
var intersectionSize = turf.area(intersection);
var ratio = intersectionSize / featureSurface;
if (ratio * 100 >= maxOverlapPercentage) {
console.log("Refused", poly.id, " due to ", shouldNotContainElement.id, "intersection ratio is ", ratio, "which is bigger then the target ratio of ", (maxOverlapPercentage / 100));
return true;
}
}
catch (exception) {
console.log("EXCEPTION CAUGHT WHILE INTERSECTING: ", exception);
// We assume that this failed due to an intersection
return true;
}
}
return false; // No problematic intersections found
}
return false;
};
/**
* Simple check: that every point of the polygon is inside the container
* @param polygon
* @param container
*/
GeoOperations.isPolygonInside = function (polygon, container) {
for (var _i = 0, _a = polygon.geometry.coordinates[0]; _i < _a.length; _i++) {
var coor = _a[_i];
if (!GeoOperations.inside(coor, container)) {
return false;
}
}
return true;
};
/**
* Simple check: one point of the polygon is inside the container
* @param polygon
* @param container
*/
GeoOperations.isPolygonTouching = function (polygon, container) {
for (var _i = 0, _a = polygon.geometry.coordinates[0]; _i < _a.length; _i++) {
var coor = _a[_i];
if (GeoOperations.inside(coor, container)) {
return true;
}
}
return false;
};
GeoOperations.inside = function (pointCoordinate, feature) {
// ray-casting algorithm based on
// http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
if (feature.geometry.type === "Point") {
return false;
}
var x = pointCoordinate[0];
var y = pointCoordinate[1];
var poly = feature.geometry.coordinates[0];
var inside = false;
for (var i = 0, j = poly.length - 1; i < poly.length; j = i++) {
var coori = poly[i];
var coorj = poly[j];
var xi = coori[0];
var yi = coori[1];
var xj = coorj[0];
var yj = coorj[1];
var intersect = ((yi > y) != (yj > y))
&& (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
if (intersect) {
inside = !inside;
}
}
return inside;
};
;
return GeoOperations;
}());
exports.GeoOperations = GeoOperations;
var BBox = /** @class */ (function () {
function BBox(coordinates) {
this.maxLat = Number.MIN_VALUE;
this.maxLon = Number.MIN_VALUE;
this.minLat = Number.MAX_VALUE;
this.minLon = Number.MAX_VALUE;
for (var _i = 0, coordinates_1 = coordinates; _i < coordinates_1.length; _i++) {
var coordinate = coordinates_1[_i];
this.maxLon = Math.max(this.maxLon, coordinate[0]);
this.maxLat = Math.max(this.maxLat, coordinate[1]);
this.minLon = Math.min(this.minLon, coordinate[0]);
this.minLat = Math.min(this.minLat, coordinate[1]);
}
this.check();
}
BBox.prototype.check = function () {
if (isNaN(this.maxLon) || isNaN(this.maxLat) || isNaN(this.minLon) || isNaN(this.minLat)) {
console.log(this);
throw "BBOX has NAN";
}
};
BBox.prototype.overlapsWith = function (other) {
this.check();
other.check();
if (this.maxLon < other.minLon) {
return false;
}
if (this.maxLat < other.minLat) {
return false;
}
if (this.minLon > other.maxLon) {
return false;
}
if (this.minLat > other.maxLat) {
return false;
}
return true;
};
BBox.get = function (feature) {
if (feature.bbox === undefined) {
if (feature.geometry.type === "MultiPolygon") {
var coordinates = [];
for (var _i = 0, _a = feature.geometry.coordinates; _i < _a.length; _i++) {
var coorlist = _a[_i];
coordinates = coordinates.concat(coorlist[0]);
}
feature.bbox = new BBox(coordinates);
}
else if (feature.geometry.type === "Polygon") {
feature.bbox = new BBox(feature.geometry.coordinates[0]);
}
else if (feature.geometry.type === "LineString") {
feature.bbox = new BBox(feature.geometry.coordinates);
}
else if (feature.geometry.type === "Point") {
// Point
feature.bbox = new BBox([feature.geometry.coordinates]);
}
else {
throw "Cannot calculate bbox, unknown type " + feature.geometry.type;
}
}
return feature.bbox;
};
return BBox;
}());

22
Logic/Geocoding.js Normal file
View file

@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Geocoding = void 0;
var $ = require("jquery");
var Geocoding = /** @class */ (function () {
function Geocoding() {
}
Geocoding.Search = function (query, basemap, handleResult, onFail) {
var b = basemap.map.getBounds();
console.log(b);
$.getJSON(Geocoding.host + "format=json&limit=1&viewbox=" +
(b.getEast() + "," + b.getNorth() + "," + b.getWest() + "," + b.getSouth()) +
"&accept-language=nl&q=" + query, function (data) {
handleResult(data);
}).fail(function () {
onFail();
});
};
Geocoding.host = "https://nominatim.openstreetmap.org/search?";
return Geocoding;
}());
exports.Geocoding = Geocoding;

185
Logic/ImageSearcher.js Normal file
View file

@ -0,0 +1,185 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImageSearcher = void 0;
var UIEventSource_1 = require("../UI/UIEventSource");
var Wikimedia_1 = require("./Wikimedia");
var WikimediaImage_1 = require("../UI/Image/WikimediaImage");
var SimpleImageElement_1 = require("../UI/Image/SimpleImageElement");
var ImgurImage_1 = require("../UI/Image/ImgurImage");
/**
* There are multiple way to fetch images for an object
* 1) There is an image tag
* 2) There is an image tag, the image tag contains multiple ';'-seperated URLS
* 3) there are multiple image tags, e.g. 'image', 'image:0', 'image:1', and 'image_0', 'image_1' - however, these are pretty rare so we are gonna ignore them
* 4) There is a wikimedia_commons-tag, which either has a 'File': or a 'category:' containing images
* 5) There is a wikidata-tag, and the wikidata item either has an 'image' attribute or has 'a link to a wikimedia commons category'
* 6) There is a wikipedia article, from which we can deduct the wikidata item
*
* For some images, author and license should be shown
*/
/**
* Class which search for all the possible locations for images and which builds a list of UI-elements for it.
* Note that this list is embedded into an UIEVentSource, ready to put it into a carousel
*/
var ImageSearcher = /** @class */ (function (_super) {
__extends(ImageSearcher, _super);
function ImageSearcher(tags, changes) {
var _this = _super.call(this, []) || this;
_this._wdItem = new UIEventSource_1.UIEventSource("");
_this._commons = new UIEventSource_1.UIEventSource("");
_this._activated = false;
_this._deletedImages = new UIEventSource_1.UIEventSource([]);
_this._tags = tags;
_this._changes = changes;
var self = _this;
_this._wdItem.addCallback(function () {
// Load the wikidata item, then detect usage on 'commons'
var wikidataId = self._wdItem.data;
// @ts-ignore
if (wikidataId.startsWith("Q")) {
wikidataId = wikidataId.substr(1);
}
Wikimedia_1.Wikimedia.GetWikiData(parseInt(wikidataId), function (wd) {
self.AddImage(wd.image);
Wikimedia_1.Wikimedia.GetCategoryFiles(wd.commonsWiki, function (images) {
for (var _i = 0, _a = images.images; _i < _a.length; _i++) {
var image = _a[_i];
// @ts-ignore
if (image.startsWith("File:")) {
self.AddImage(image);
}
}
});
});
});
_this._commons.addCallback(function () {
var commons = self._commons.data;
// @ts-ignore
if (commons.startsWith("Category:")) {
Wikimedia_1.Wikimedia.GetCategoryFiles(commons, function (images) {
for (var _i = 0, _a = images.images; _i < _a.length; _i++) {
var image = _a[_i];
// @ts-ignore
if (image.startsWith("File:")) {
self.AddImage(image);
}
}
});
}
else { // @ts-ignore
if (commons.startsWith("File:")) {
self.AddImage(commons);
}
}
});
return _this;
}
ImageSearcher.prototype.AddImage = function (url) {
if (url === undefined || url === null || url === "") {
return;
}
for (var _i = 0, _a = this.data; _i < _a.length; _i++) {
var el = _a[_i];
if (el === url) {
return;
}
}
this.data.push(url);
this.ping();
};
ImageSearcher.prototype.ImageKey = function (url) {
var tgs = this._tags.data;
for (var key in tgs) {
if (tgs[key] === url) {
return key;
}
}
return undefined;
};
ImageSearcher.prototype.IsDeletable = function (url) {
return this.ImageKey(url) !== undefined;
};
ImageSearcher.prototype.Delete = function (url) {
var key = this.ImageKey(url);
if (key === undefined) {
return;
}
console.log("Deleting image...", key, " --> ", url);
this._changes.addChange(this._tags.data.id, key, "");
this._deletedImages.data.push(url);
this._deletedImages.ping();
};
ImageSearcher.prototype.Activate = function () {
if (this._activated) {
return;
}
this._activated = true;
this.LoadImages();
var self = this;
this._tags.addCallback(function () { return self.LoadImages(); });
};
ImageSearcher.prototype.LoadImages = function () {
if (!this._activated) {
return;
}
var imageTag = this._tags.data.image;
if (imageTag !== undefined) {
var bareImages = imageTag.split(";");
for (var _i = 0, bareImages_1 = bareImages; _i < bareImages_1.length; _i++) {
var bareImage = bareImages_1[_i];
this.AddImage(bareImage);
}
}
for (var key in this._tags.data) {
// @ts-ignore
if (key.startsWith("image:")) {
var url = this._tags.data[key];
this.AddImage(url);
}
}
var wdItem = this._tags.data.wikidata;
if (wdItem !== undefined) {
this._wdItem.setData(wdItem);
}
var commons = this._tags.data.wikimedia_commons;
if (commons !== undefined) {
this._commons.setData(commons);
}
};
/***
* Creates either a 'simpleimage' or a 'wikimediaimage' based on the string
* @param url
* @constructor
*/
ImageSearcher.CreateImageElement = function (url) {
// @ts-ignore
if (url.startsWith("File:")) {
return new WikimediaImage_1.WikimediaImage(url);
}
else if (url.startsWith("https://commons.wikimedia.org/wiki/")) {
var commons = url.substr("https://commons.wikimedia.org/wiki/".length);
return new WikimediaImage_1.WikimediaImage(commons);
}
else if (url.startsWith("https://i.imgur.com/")) {
return new ImgurImage_1.ImgurImage(url);
}
else {
return new SimpleImageElement_1.SimpleImageElement(new UIEventSource_1.UIEventSource(url));
}
};
return ImageSearcher;
}(UIEventSource_1.UIEventSource));
exports.ImageSearcher = ImageSearcher;

90
Logic/Imgur.js Normal file
View file

@ -0,0 +1,90 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Imgur = void 0;
var jquery_1 = require("jquery");
var Wikimedia_1 = require("./Wikimedia");
var Imgur = /** @class */ (function () {
function Imgur() {
}
Imgur.uploadMultiple = function (title, description, blobs, handleSuccessfullUpload, allDone, offset) {
if (offset === void 0) { offset = 0; }
if (blobs.length == offset) {
allDone();
return;
}
var blob = blobs.item(offset);
var self = this;
this.uploadImage(title, description, blob, function (imageUrl) {
handleSuccessfullUpload(imageUrl);
self.uploadMultiple(title, description, blobs, handleSuccessfullUpload, allDone, offset + 1);
});
};
Imgur.getDescriptionOfImage = function (url, handleDescription) {
var hash = url.substr("https://i.imgur.com/".length).split(".jpg")[0];
var apiUrl = 'https://api.imgur.com/3/image/' + hash;
var apiKey = '7070e7167f0a25a';
var settings = {
async: true,
crossDomain: true,
processData: false,
contentType: false,
type: 'GET',
url: apiUrl,
headers: {
Authorization: 'Client-ID ' + apiKey,
Accept: 'application/json',
},
};
jquery_1.default.ajax(settings).done(function (response) {
var descr = response.data.description;
var data = {};
for (var _i = 0, _a = descr.split("\n"); _i < _a.length; _i++) {
var tag = _a[_i];
var kv = tag.split(":");
var k = kv[0];
var v = kv[1].replace("\r", "");
data[k] = v;
}
console.log(data);
var licenseInfo = new Wikimedia_1.LicenseInfo();
licenseInfo.licenseShortName = data.license;
licenseInfo.artist = data.author;
handleDescription(licenseInfo);
}).fail(function (reason) {
console.log("Getting metadata from to IMGUR failed", reason);
});
};
Imgur.uploadImage = function (title, description, blob, handleSuccessfullUpload) {
var apiUrl = 'https://api.imgur.com/3/image';
var apiKey = '7070e7167f0a25a';
var settings = {
async: true,
crossDomain: true,
processData: false,
contentType: false,
type: 'POST',
url: apiUrl,
headers: {
Authorization: 'Client-ID ' + apiKey,
Accept: 'application/json',
},
mimeType: 'multipart/form-data',
};
var formData = new FormData();
formData.append('image', blob);
formData.append("title", title);
formData.append("description", description);
// @ts-ignore
settings.data = formData;
// Response contains stringified JSON
// Image URL available at response.data.link
jquery_1.default.ajax(settings).done(function (response) {
response = JSON.parse(response);
handleSuccessfullUpload(response.data.link);
}).fail(function (reason) {
console.log("Uploading to IMGUR failed", reason);
});
};
return Imgur;
}());
exports.Imgur = Imgur;

99
Logic/LayerUpdater.js Normal file
View file

@ -0,0 +1,99 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LayerUpdater = void 0;
var Overpass_1 = require("./Overpass");
var TagsFilter_1 = require("./TagsFilter");
var UIEventSource_1 = require("../UI/UIEventSource");
var LayerUpdater = /** @class */ (function () {
/**
* The most important layer should go first, as that one gets first pick for the questions
* @param map
* @param minzoom
* @param layers
*/
function LayerUpdater(map, minzoom, layers) {
this.runningQuery = new UIEventSource_1.UIEventSource(false);
this._map = map;
this._layers = layers;
this._minzoom = minzoom;
var filters = [];
for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
var layer = layers_1[_i];
filters.push(layer.filters);
}
this._overpass = new Overpass_1.Overpass(new TagsFilter_1.Or(filters));
var self = this;
map.Location.addCallback(function () {
self.update();
});
}
LayerUpdater.prototype.handleData = function (geojson) {
this.runningQuery.setData(false);
for (var _i = 0, _a = this._layers; _i < _a.length; _i++) {
var layer = _a[_i];
geojson = layer.SetApplicableData(geojson);
}
if (geojson.features.length > 0) {
console.log("Got some leftovers: ", geojson);
}
};
LayerUpdater.prototype.handleFail = function (reason) {
console.log("QUERY FAILED", reason);
console.log("Retrying in 1s");
this.previousBounds = undefined;
var self = this;
window.setTimeout(function () { self.update(); }, 1000);
};
LayerUpdater.prototype.update = function () {
if (this.IsInBounds()) {
return;
}
console.log("Zoom level: ", this._map.map.getZoom(), "Least needed zoom:", this._minzoom);
if (this._map.map.getZoom() < this._minzoom || this._map.Location.data.zoom < this._minzoom) {
console.log("Not running query: zoom not sufficient");
return;
}
if (this.runningQuery.data) {
console.log("Still running a query, skip");
}
var bbox = this.buildBboxFor();
this.runningQuery.setData(true);
var self = this;
this._overpass.queryGeoJson(bbox, function (data) {
self.handleData(data);
}, function (reason) {
self.handleFail(reason);
});
};
LayerUpdater.prototype.buildBboxFor = function () {
var b = this._map.map.getBounds();
var diff = 0.07;
var n = b.getNorth() + diff;
var e = b.getEast() + diff;
var s = b.getSouth() - diff;
var w = b.getWest() - diff;
this.previousBounds = { north: n, east: e, south: s, west: w };
return "[bbox:" + s + "," + w + "," + n + "," + e + "]";
};
LayerUpdater.prototype.IsInBounds = function () {
if (this.previousBounds === undefined) {
return false;
}
var b = this._map.map.getBounds();
if (b.getSouth() < this.previousBounds.south) {
return false;
}
if (b.getNorth() > this.previousBounds.north) {
return false;
}
if (b.getEast() > this.previousBounds.east) {
return false;
}
if (b.getWest() < this.previousBounds.west) {
return false;
}
return true;
};
return LayerUpdater;
}());
exports.LayerUpdater = LayerUpdater;

256
Logic/OsmConnection.js Normal file
View file

@ -0,0 +1,256 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OsmConnection = exports.UserDetails = void 0;
// @ts-ignore
var osm_auth_1 = require("osm-auth");
var UIEventSource_1 = require("../UI/UIEventSource");
var UserDetails = /** @class */ (function () {
function UserDetails() {
this.loggedIn = false;
this.name = "Not logged in";
this.csCount = 0;
this.unreadMessages = 0;
this.totalMessages = 0;
}
return UserDetails;
}());
exports.UserDetails = UserDetails;
var OsmConnection = /** @class */ (function () {
function OsmConnection(dryRun) {
this.auth = new osm_auth_1.default({
oauth_consumer_key: 'hivV7ec2o49Two8g9h8Is1VIiVOgxQ1iYexCbvem',
oauth_secret: 'wDBRTCem0vxD7txrg1y6p5r8nvmz8tAhET7zDASI',
auto: true // show a login form if the user is not authenticated and
// you try to do a call
});
this.preferences = new UIEventSource_1.UIEventSource({});
this.preferenceSources = {};
this.userDetails = new UIEventSource_1.UIEventSource(new UserDetails());
this.userDetails.data.osmConnection = this;
this.userDetails.data.dryRun = dryRun;
this._dryRun = dryRun;
if (this.auth.authenticated()) {
this.AttemptLogin(); // Also updates the user badge
}
else {
console.log("Not authenticated");
}
if (dryRun) {
console.log("DRYRUN ENABLED");
}
}
OsmConnection.prototype.LogOut = function () {
this.auth.logout();
this.userDetails.data.loggedIn = false;
this.userDetails.ping();
console.log("Logged out");
};
OsmConnection.prototype.AttemptLogin = function () {
var self = this;
this.auth.xhr({
method: 'GET',
path: '/api/0.6/user/details'
}, function (err, details) {
var _a;
if (err != null) {
console.log(err);
self.auth.logout();
self.userDetails.data.loggedIn = false;
self.userDetails.ping();
}
if (details == null) {
return;
}
self.UpdatePreferences();
// details is an XML DOM of user details
var userInfo = details.getElementsByTagName("user")[0];
// let moreDetails = new DOMParser().parseFromString(userInfo.innerHTML, "text/xml");
var data = self.userDetails.data;
data.loggedIn = true;
console.log("Login completed, userinfo is ", userInfo);
data.name = userInfo.getAttribute('display_name');
data.csCount = userInfo.getElementsByTagName("changesets")[0].getAttribute("count");
data.img = undefined;
var imgEl = userInfo.getElementsByTagName("img");
if (imgEl !== undefined && imgEl[0] !== undefined) {
data.img = imgEl[0].getAttribute("href");
}
data.img = (_a = data.img) !== null && _a !== void 0 ? _a : "./assets/osm-logo.svg";
var homeEl = userInfo.getElementsByTagName("home");
if (homeEl !== undefined && homeEl[0] !== undefined) {
var lat = parseFloat(homeEl[0].getAttribute("lat"));
var lon = parseFloat(homeEl[0].getAttribute("lon"));
data.home = { lat: lat, lon: lon };
}
var messages = userInfo.getElementsByTagName("messages")[0].getElementsByTagName("received")[0];
data.unreadMessages = parseInt(messages.getAttribute("unread"));
data.totalMessages = parseInt(messages.getAttribute("count"));
self.userDetails.ping();
});
};
/**
* All elements with class 'activate-osm-authentication' are loaded and get an 'onclick' to authenticate
*/
OsmConnection.prototype.registerActivateOsmAUthenticationClass = function () {
var self = this;
var authElements = document.getElementsByClassName("activate-osm-authentication");
for (var i = 0; i < authElements.length; i++) {
var element = authElements.item(i);
// @ts-ignore
element.onclick = function () {
self.AttemptLogin();
};
}
};
OsmConnection.prototype.GetPreference = function (key) {
var _this = this;
if (this.preferenceSources[key] !== undefined) {
return this.preferenceSources[key];
}
if (this.userDetails.data.loggedIn) {
this.UpdatePreferences();
}
var pref = new UIEventSource_1.UIEventSource(this.preferences.data[key]);
pref.addCallback(function (v) {
_this.SetPreference(key, v);
});
this.preferences.addCallback(function (prefs) {
if (prefs[key] !== undefined) {
pref.setData(prefs[key]);
}
});
this.preferenceSources[key] = pref;
return pref;
};
OsmConnection.prototype.UpdatePreferences = function () {
var self = this;
this.auth.xhr({
method: 'GET',
path: '/api/0.6/user/preferences'
}, function (error, value) {
if (error) {
console.log("Could not load preferences", error);
return;
}
var prefs = value.getElementsByTagName("preference");
for (var i = 0; i < prefs.length; i++) {
var pref = prefs[i];
var k = pref.getAttribute("k");
var v = pref.getAttribute("v");
self.preferences.data[k] = v;
}
self.preferences.ping();
});
};
OsmConnection.prototype.SetPreference = function (k, v) {
if (!this.userDetails.data.loggedIn) {
console.log("Not saving preference: user not logged in");
return;
}
if (this.preferences.data[k] === v) {
console.log("Not updating preference", k, " to ", v, "not changed");
return;
}
console.log("Updating preference", k, " to ", v);
this.preferences.data[k] = v;
this.preferences.ping();
this.auth.xhr({
method: 'PUT',
path: '/api/0.6/user/preferences/' + k,
options: { header: { 'Content-Type': 'text/plain' } },
content: v
}, function (error, result) {
if (error) {
console.log("Could not set preference", error);
return;
}
console.log("Preference written!", result == "" ? "OK" : result);
});
};
OsmConnection.parseUploadChangesetResponse = function (response) {
var nodes = response.getElementsByTagName("node");
var mapping = {};
// @ts-ignore
for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
var node = nodes_1[_i];
var oldId = parseInt(node.attributes.old_id.value);
var newId = parseInt(node.attributes.new_id.value);
if (oldId !== undefined && newId !== undefined &&
!isNaN(oldId) && !isNaN(newId)) {
mapping["node/" + oldId] = "node/" + newId;
}
}
return mapping;
};
OsmConnection.prototype.UploadChangeset = function (comment, generateChangeXML, handleMapping, continuation) {
if (this._dryRun) {
console.log("NOT UPLOADING as dryrun is true");
var changesetXML = generateChangeXML("123456");
console.log(changesetXML);
continuation();
return;
}
var self = this;
this.OpenChangeset(comment, function (csId) {
var changesetXML = generateChangeXML(csId);
self.AddChange(csId, changesetXML, function (csId, mapping) {
self.CloseChangeset(csId, continuation);
handleMapping(mapping);
});
});
this.userDetails.data.csCount++;
this.userDetails.ping();
};
OsmConnection.prototype.OpenChangeset = function (comment, continuation) {
this.auth.xhr({
method: 'PUT',
path: '/api/0.6/changeset/create',
options: { header: { 'Content-Type': 'text/xml' } },
content: '<osm><changeset>' +
'<tag k="created_by" v="MapComplete 0.0.0" />' +
'<tag k="comment" v="' + comment + '"/>' +
'</changeset></osm>'
}, function (err, response) {
if (response === undefined) {
console.log("err", err);
return;
}
else {
continuation(response);
}
});
};
OsmConnection.prototype.AddChange = function (changesetId, changesetXML, continuation) {
this.auth.xhr({
method: 'POST',
options: { header: { 'Content-Type': 'text/xml' } },
path: '/api/0.6/changeset/' + changesetId + '/upload',
content: changesetXML
}, function (err, response) {
if (response == null) {
console.log("err", err);
return;
}
var mapping = OsmConnection.parseUploadChangesetResponse(response);
console.log("Uplaoded changeset ", changesetId);
continuation(changesetId, mapping);
});
};
OsmConnection.prototype.CloseChangeset = function (changesetId, continuation) {
console.log("closing");
this.auth.xhr({
method: 'PUT',
path: '/api/0.6/changeset/' + changesetId + '/close',
}, function (err, response) {
if (response == null) {
console.log("err", err);
}
console.log("Closed changeset ", changesetId);
if (continuation !== undefined) {
continuation();
}
});
};
return OsmConnection;
}());
exports.OsmConnection = OsmConnection;

View file

@ -0,0 +1,56 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OsmImageUploadHandler = void 0;
var ImageUploadFlow_1 = require("../UI/ImageUploadFlow");
var OsmImageUploadHandler = /** @class */ (function () {
function OsmImageUploadHandler(tags, userdetails, preferedLicense, changeHandler, slideShow) {
this._slideShow = slideShow; // To move the slideshow (if any) to the last, just added element
if (tags === undefined || userdetails === undefined || changeHandler === undefined) {
throw "Something is undefined";
}
this._tags = tags;
this._changeHandler = changeHandler;
this._userdetails = userdetails;
this._preferedLicense = preferedLicense;
}
OsmImageUploadHandler.prototype.generateOptions = function (license) {
var _a;
var tags = this._tags.data;
var self = this;
var title = (_a = tags.name) !== null && _a !== void 0 ? _a : "Unknown area";
var description = [
"author:" + this._userdetails.data.name,
"license:" + license,
"wikidata:" + tags.wikidata,
"osmid:" + tags.id,
"name:" + tags.name
].join("\n");
var changes = this._changeHandler;
return {
title: title,
description: description,
handleURL: function (url) {
var freeIndex = 0;
while (tags["image:" + freeIndex] !== undefined) {
freeIndex++;
}
console.log("Adding image:" + freeIndex, url);
changes.addChange(tags.id, "image:" + freeIndex, url);
self._slideShow.MoveTo(-1); // set the last (thus newly added) image) to view
},
allDone: function () {
changes.uploadAll(function () {
console.log("Writing changes...");
});
}
};
};
OsmImageUploadHandler.prototype.getUI = function () {
var self = this;
return new ImageUploadFlow_1.ImageUploadFlow(this._userdetails, this._preferedLicense, function (license) {
return self.generateOptions(license);
});
};
return OsmImageUploadHandler;
}());
exports.OsmImageUploadHandler = OsmImageUploadHandler;

160
Logic/OsmObject.js Normal file
View file

@ -0,0 +1,160 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.OsmRelation = exports.OsmWay = exports.OsmNode = exports.OsmObject = void 0;
var $ = require("jquery");
var OsmObject = /** @class */ (function () {
function OsmObject(type, id) {
this.tags = {};
this.changed = false;
this.id = id;
this.type = type;
}
OsmObject.DownloadObject = function (id, continuation) {
var splitted = id.split("/");
var type = splitted[0];
var idN = splitted[1];
switch (type) {
case ("node"):
return new OsmNode(idN).Download(continuation);
case ("way"):
return new OsmWay(idN).Download(continuation);
case ("relation"):
return new OsmRelation(idN).Download(continuation);
}
};
/**
* Replaces all '"' (double quotes) by '&quot;'
* Bugfix where names containing '"' were not uploaded, such as '"Het Zwin" nature reserve'
* @param string
* @constructor
*/
OsmObject.prototype.Escape = function (string) {
while (string.indexOf('"') >= 0) {
string = string.replace('"', '&quot;');
}
return string;
};
/**
* Generates the changeset-XML for tags
* @constructor
*/
OsmObject.prototype.TagsXML = function () {
var tags = "";
for (var key in this.tags) {
var v = this.tags[key];
if (v !== "") {
tags += ' <tag k="' + this.Escape(key) + '" v="' + this.Escape(this.tags[key]) + '"/>\n';
}
}
return tags;
};
OsmObject.prototype.Download = function (continuation) {
var self = this;
$.getJSON("https://www.openstreetmap.org/api/0.6/" + this.type + "/" + this.id, function (data) {
var element = data.elements[0];
self.tags = element.tags;
self.version = element.version;
self.SaveExtraData(element);
continuation(self);
});
return this;
};
OsmObject.prototype.addTag = function (k, v) {
if (k in this.tags) {
var oldV = this.tags[k];
if (oldV == v) {
return;
}
console.log("WARNING: overwriting ", oldV, " with ", v, " for key ", k);
}
this.tags[k] = v;
this.changed = true;
};
OsmObject.prototype.VersionXML = function () {
if (this.version === undefined) {
return "";
}
return 'version="' + this.version + '"';
};
return OsmObject;
}());
exports.OsmObject = OsmObject;
var OsmNode = /** @class */ (function (_super) {
__extends(OsmNode, _super);
function OsmNode(id) {
return _super.call(this, "node", id) || this;
}
OsmNode.prototype.ChangesetXML = function (changesetId) {
var tags = this.TagsXML();
var change = ' <node id="' + this.id + '" changeset="' + changesetId + '" ' + this.VersionXML() + ' lat="' + this.lat + '" lon="' + this.lon + '">\n' +
tags +
' </node>\n';
return change;
};
OsmNode.prototype.SaveExtraData = function (element) {
this.lat = element.lat;
this.lon = element.lon;
};
return OsmNode;
}(OsmObject));
exports.OsmNode = OsmNode;
var OsmWay = /** @class */ (function (_super) {
__extends(OsmWay, _super);
function OsmWay(id) {
return _super.call(this, "way", id) || this;
}
OsmWay.prototype.ChangesetXML = function (changesetId) {
var tags = this.TagsXML();
var nds = "";
for (var node in this.nodes) {
nds += ' <nd ref="' + this.nodes[node] + '"/>\n';
}
var change = ' <way id="' + this.id + '" changeset="' + changesetId + '" ' + this.VersionXML() + '>\n' +
nds +
tags +
' </way>\n';
return change;
};
OsmWay.prototype.SaveExtraData = function (element) {
this.nodes = element.nodes;
};
return OsmWay;
}(OsmObject));
exports.OsmWay = OsmWay;
var OsmRelation = /** @class */ (function (_super) {
__extends(OsmRelation, _super);
function OsmRelation(id) {
return _super.call(this, "relation", id) || this;
}
OsmRelation.prototype.ChangesetXML = function (changesetId) {
var members = "";
for (var memberI in this.members) {
var member = this.members[memberI];
members += ' <member type="' + member.type + '" ref="' + member.ref + '" role="' + member.role + '"/>\n';
}
var tags = this.TagsXML();
var change = ' <relation id="' + this.id + '" changeset="' + changesetId + '" ' + this.VersionXML() + '>\n' +
members +
tags +
' </relation>\n';
return change;
};
OsmRelation.prototype.SaveExtraData = function (element) {
this.members = element.members;
};
return OsmRelation;
}(OsmObject));
exports.OsmRelation = OsmRelation;

47
Logic/Overpass.js Normal file
View file

@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Overpass = void 0;
var OsmToGeoJson = require("osmtogeojson");
var $ = require("jquery");
/**
* Interfaces overpass to get all the latest data
*/
var Overpass = /** @class */ (function () {
function Overpass(filter) {
this._filter = filter;
}
Overpass.prototype.buildQuery = function (bbox) {
var filters = this._filter.asOverpass();
var filter = "";
for (var _i = 0, filters_1 = filters; _i < filters_1.length; _i++) {
var filterOr = filters_1[_i];
filter += 'nwr' + filterOr + ';';
}
var query = '[out:json][timeout:25]' + bbox + ';(' + filter + ');out body;>;out skel qt;';
console.log(query);
return "https://overpass-api.de/api/interpreter?data=" + encodeURIComponent(query);
};
Overpass.prototype.queryGeoJson = function (bbox, continuation, onFail) {
var query = this.buildQuery(bbox);
if (Overpass.testUrl !== null) {
console.log("Using testing URL");
query = Overpass.testUrl;
}
$.getJSON(query, function (json, status) {
if (status !== "success") {
console.log("Query failed");
onFail(status);
}
if (json.elements === [] && json.remarks.indexOf("runtime error") > 0) {
console.log("Timeout or other runtime error");
return;
}
// @ts-ignore
var geojson = OsmToGeoJson.default(json);
continuation(geojson);
}).fail(onFail);
};
Overpass.testUrl = null;
return Overpass;
}());
exports.Overpass = Overpass;

View file

@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StrayClickHandler = void 0;
var leaflet_1 = require("leaflet");
/**
* The stray-click-hanlders adds a marker to the map if no feature was clicked.
* Shows the given uiToShow-element in the messagebox
*/
var StrayClickHandler = /** @class */ (function () {
function StrayClickHandler(basemap, selectElement, leftMessage, uiToShow) {
var _this = this;
this._basemap = basemap;
this._leftMessage = leftMessage;
this._uiToShow = uiToShow;
var self = this;
var map = basemap.map;
basemap.LastClickLocation.addCallback(function (lastClick) {
selectElement.setData(undefined);
if (self._lastMarker !== undefined) {
map.removeLayer(self._lastMarker);
}
self._lastMarker = leaflet_1.default.marker([lastClick.lat, lastClick.lon]);
var uiElement = uiToShow();
var popup = leaflet_1.default.popup().setContent(uiElement.Render());
uiElement.Activate();
uiElement.Update();
self._lastMarker.addTo(map);
self._lastMarker.bindPopup(popup).openPopup();
self._lastMarker.on("click", function () {
leftMessage.setData(self._uiToShow);
});
});
selectElement.addCallback(function () {
if (self._lastMarker !== undefined) {
map.removeLayer(self._lastMarker);
_this._lastMarker = undefined;
}
});
}
return StrayClickHandler;
}());
exports.StrayClickHandler = StrayClickHandler;

240
Logic/TagsFilter.js Normal file
View file

@ -0,0 +1,240 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.TagUtils = exports.Not = exports.And = exports.Or = exports.Tag = exports.Regex = exports.TagsFilter = void 0;
var TagsFilter = /** @class */ (function () {
function TagsFilter() {
}
TagsFilter.prototype.matchesProperties = function (properties) {
return this.matches(TagUtils.proprtiesToKV(properties));
};
return TagsFilter;
}());
exports.TagsFilter = TagsFilter;
var Regex = /** @class */ (function (_super) {
__extends(Regex, _super);
function Regex(k, r) {
var _this = _super.call(this) || this;
_this._k = k;
_this._r = r;
return _this;
}
Regex.prototype.asOverpass = function () {
return ["['" + this._k + "'~'" + this._r + "']"];
};
Regex.prototype.matches = function (tags) {
var _a;
if (!(tags instanceof Array)) {
throw "You used 'matches' on something that is not a list. Did you mean to use 'matchesProperties'?";
}
for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
var tag = tags_1[_i];
if (tag.k === this._k) {
if (tag.v === "") {
// This tag has been removed
return false;
}
if (this._r === "*") {
// Any is allowed
return true;
}
var matchCount = (_a = tag.v.match(this._r)) === null || _a === void 0 ? void 0 : _a.length;
return (matchCount !== null && matchCount !== void 0 ? matchCount : 0) > 0;
}
}
return false;
};
Regex.prototype.substituteValues = function (tags) {
throw "Substituting values is not supported on regex tags";
};
return Regex;
}(TagsFilter));
exports.Regex = Regex;
var Tag = /** @class */ (function (_super) {
__extends(Tag, _super);
function Tag(key, value) {
var _this = _super.call(this) || this;
_this.key = key;
_this.value = value;
return _this;
}
Tag.prototype.matches = function (tags) {
for (var _i = 0, tags_2 = tags; _i < tags_2.length; _i++) {
var tag = tags_2[_i];
if (tag.k === this.key) {
if (tag.v === "") {
// This tag has been removed
return this.value === "";
}
if (this.value === "*") {
// Any is allowed
return true;
}
return this.value === tag.v;
}
}
if (this.value === "") {
return true;
}
return false;
};
Tag.prototype.asOverpass = function () {
if (this.value === "*") {
return ['["' + this.key + '"]'];
}
if (this.value === "") {
// NOT having this key
return ['[!"' + this.key + '"]'];
}
return ['["' + this.key + '"="' + this.value + '"]'];
};
Tag.prototype.substituteValues = function (tags) {
return new Tag(this.key, TagUtils.ApplyTemplate(this.value, tags));
};
return Tag;
}(TagsFilter));
exports.Tag = Tag;
var Or = /** @class */ (function (_super) {
__extends(Or, _super);
function Or(or) {
var _this = _super.call(this) || this;
_this.or = or;
return _this;
}
Or.prototype.matches = function (tags) {
for (var _i = 0, _a = this.or; _i < _a.length; _i++) {
var tagsFilter = _a[_i];
if (tagsFilter.matches(tags)) {
return true;
}
}
return false;
};
Or.prototype.asOverpass = function () {
var choices = [];
for (var _i = 0, _a = this.or; _i < _a.length; _i++) {
var tagsFilter = _a[_i];
var subChoices = tagsFilter.asOverpass();
for (var _b = 0, subChoices_1 = subChoices; _b < subChoices_1.length; _b++) {
var subChoice = subChoices_1[_b];
choices.push(subChoice);
}
}
return choices;
};
Or.prototype.substituteValues = function (tags) {
var newChoices = [];
for (var _i = 0, _a = this.or; _i < _a.length; _i++) {
var c = _a[_i];
newChoices.push(c.substituteValues(tags));
}
return new Or(newChoices);
};
return Or;
}(TagsFilter));
exports.Or = Or;
var And = /** @class */ (function (_super) {
__extends(And, _super);
function And(and) {
var _this = _super.call(this) || this;
_this.and = and;
return _this;
}
And.prototype.matches = function (tags) {
for (var _i = 0, _a = this.and; _i < _a.length; _i++) {
var tagsFilter = _a[_i];
if (!tagsFilter.matches(tags)) {
return false;
}
}
return true;
};
And.prototype.combine = function (filter, choices) {
var values = [];
for (var _i = 0, choices_1 = choices; _i < choices_1.length; _i++) {
var or = choices_1[_i];
values.push(filter + or);
}
return values;
};
And.prototype.asOverpass = function () {
var allChoices = null;
for (var _i = 0, _a = this.and; _i < _a.length; _i++) {
var andElement = _a[_i];
var andElementFilter = andElement.asOverpass();
if (allChoices === null) {
allChoices = andElementFilter;
continue;
}
var newChoices = [];
for (var _b = 0, allChoices_1 = allChoices; _b < allChoices_1.length; _b++) {
var choice = allChoices_1[_b];
newChoices.push(this.combine(choice, andElementFilter));
}
allChoices = newChoices;
}
return allChoices;
};
And.prototype.substituteValues = function (tags) {
var newChoices = [];
for (var _i = 0, _a = this.and; _i < _a.length; _i++) {
var c = _a[_i];
newChoices.push(c.substituteValues(tags));
}
return new And(newChoices);
};
return And;
}(TagsFilter));
exports.And = And;
var Not = /** @class */ (function (_super) {
__extends(Not, _super);
function Not(not) {
var _this = _super.call(this) || this;
_this.not = not;
return _this;
}
Not.prototype.asOverpass = function () {
throw "Not supported yet";
};
Not.prototype.matches = function (tags) {
return !this.not.matches(tags);
};
Not.prototype.substituteValues = function (tags) {
return new Not(this.not.substituteValues(tags));
};
return Not;
}(TagsFilter));
exports.Not = Not;
var TagUtils = /** @class */ (function () {
function TagUtils() {
}
TagUtils.proprtiesToKV = function (properties) {
var result = [];
for (var k in properties) {
result.push({ k: k, v: properties[k] });
}
return result;
};
TagUtils.ApplyTemplate = function (template, tags) {
for (var k in tags) {
while (template.indexOf("{" + k + "}") >= 0) {
template = template.replace("{" + k + "}", tags[k]);
}
}
return template;
};
return TagUtils;
}());
exports.TagUtils = TagUtils;

135
Logic/Wikimedia.js Normal file
View file

@ -0,0 +1,135 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LicenseInfo = exports.ImagesInCategory = exports.Wikidata = exports.Wikimedia = void 0;
var $ = require("jquery");
/**
* This module provides endpoints for wikipedia/wikimedia and others
*/
var Wikimedia = /** @class */ (function () {
function Wikimedia() {
}
Wikimedia.ImageNameToUrl = function (filename, width, height) {
if (width === void 0) { width = 500; }
if (height === void 0) { height = 200; }
filename = encodeURIComponent(filename);
return "https://commons.wikimedia.org/wiki/Special:FilePath/" + filename + "?width=" + width + "&height=" + height;
};
Wikimedia.LicenseData = function (filename, handle) {
if (filename in this.knownLicenses) {
return this.knownLicenses[filename];
}
if (filename === "") {
return;
}
var url = "https://en.wikipedia.org/w/" +
"api.php?action=query&prop=imageinfo&iiprop=extmetadata&" +
"titles=" + filename +
"&format=json&origin=*";
$.getJSON(url, function (data, status) {
var _a, _b, _c, _d, _e, _f, _g, _h;
var licenseInfo = new LicenseInfo();
var license = data.query.pages[-1].imageinfo[0].extmetadata;
licenseInfo.artist = (_a = license.Artist) === null || _a === void 0 ? void 0 : _a.value;
licenseInfo.license = (_b = license.License) === null || _b === void 0 ? void 0 : _b.value;
licenseInfo.copyrighted = (_c = license.Copyrighted) === null || _c === void 0 ? void 0 : _c.value;
licenseInfo.attributionRequired = (_d = license.AttributionRequired) === null || _d === void 0 ? void 0 : _d.value;
licenseInfo.usageTerms = (_e = license.UsageTerms) === null || _e === void 0 ? void 0 : _e.value;
licenseInfo.licenseShortName = (_f = license.LicenseShortName) === null || _f === void 0 ? void 0 : _f.value;
licenseInfo.credit = (_g = license.Credit) === null || _g === void 0 ? void 0 : _g.value;
licenseInfo.description = (_h = license.ImageDescription) === null || _h === void 0 ? void 0 : _h.value;
Wikimedia.knownLicenses[filename] = licenseInfo;
handle(licenseInfo);
});
};
Wikimedia.GetCategoryFiles = function (categoryName, handleCategory, alreadyLoaded, continueParameter) {
var _this = this;
if (alreadyLoaded === void 0) { alreadyLoaded = 0; }
if (continueParameter === void 0) { continueParameter = undefined; }
if (categoryName === undefined || categoryName === null || categoryName === "") {
return;
}
// @ts-ignore
if (!categoryName.startsWith("Category:")) {
categoryName = "Category:" + categoryName;
}
var url = "https://commons.wikimedia.org/w/api.php?" +
"action=query&list=categorymembers&format=json&" +
"&origin=*" +
"&cmtitle=" + encodeURIComponent(categoryName);
if (continueParameter !== undefined) {
url = url + "&" + continueParameter.k + "=" + continueParameter.param;
}
$.getJSON(url, function (response) {
var _a;
var imageOverview = new ImagesInCategory();
var members = (_a = response.query) === null || _a === void 0 ? void 0 : _a.categorymembers;
if (members === undefined) {
members = [];
}
for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
var member = members_1[_i];
imageOverview.images.push(member.title);
}
if (response.continue === undefined || alreadyLoaded > 30) {
handleCategory(imageOverview);
}
else {
console.log("Recursive load for ", categoryName);
_this.GetCategoryFiles(categoryName, function (recursiveImages) {
for (var _i = 0, _a = imageOverview.images; _i < _a.length; _i++) {
var image = _a[_i];
recursiveImages.images.push(image);
}
handleCategory(recursiveImages);
}, alreadyLoaded + 10, { k: "cmcontinue", param: response.continue.cmcontinue });
}
});
};
Wikimedia.GetWikiData = function (id, handleWikidata) {
var url = "https://www.wikidata.org/wiki/Special:EntityData/Q" + id + ".json";
$.getJSON(url, function (response) {
var _a, _b, _c, _d;
var entity = response.entities["Q" + id];
var commons = entity.sitelinks.commonswiki;
var wd = new Wikidata();
wd.commonsWiki = commons === null || commons === void 0 ? void 0 : commons.title;
// P18 is the claim 'depicted in this image'
var image = (_d = (_c = (_b = (_a = entity.claims.P18) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.mainsnak) === null || _c === void 0 ? void 0 : _c.datavalue) === null || _d === void 0 ? void 0 : _d.value;
if (image) {
wd.image = "File:" + image;
}
handleWikidata(wd);
});
};
Wikimedia.knownLicenses = {};
return Wikimedia;
}());
exports.Wikimedia = Wikimedia;
var Wikidata = /** @class */ (function () {
function Wikidata() {
}
return Wikidata;
}());
exports.Wikidata = Wikidata;
var ImagesInCategory = /** @class */ (function () {
function ImagesInCategory() {
// Filenames of relevant images
this.images = [];
}
return ImagesInCategory;
}());
exports.ImagesInCategory = ImagesInCategory;
var LicenseInfo = /** @class */ (function () {
function LicenseInfo() {
this.artist = "";
this.license = "";
this.licenseShortName = "";
this.usageTerms = "";
this.attributionRequired = false;
this.copyrighted = false;
this.credit = "";
this.description = "";
}
return LicenseInfo;
}());
exports.LicenseInfo = LicenseInfo;

40
Quests.js Normal file
View file

@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Quests = void 0;
var Question_1 = require("./Logic/Question");
var Quests = /** @class */ (function () {
function Quests() {
}
Quests.nameOf = function (name) {
return Question_1.QuestionDefinition.noNameOrNameQuestion("<b>Wat is de <i>officiële</i> naam van dit " + name + "?</b><br />" +
"Veel gebieden hebben geen naam. Duid dit dan ook zo aan.", "Dit " + name + " heeft geen naam", 20);
};
Quests.hasFee = Question_1.QuestionDefinition.radioQuestionSimple("Moet men betalen om deze toiletten te gebruiken?", 10, "fee", [{ text: "ja", value: "yes" }, { text: "nee", value: "no" }]);
Quests.toiletsWheelChairs = Question_1.QuestionDefinition.radioQuestionSimple("Zijn deze toiletten rolstoeltoegankelijk?", 20, "wheelchair", [{ text: "ja", value: "yes" }, { text: "nee", value: "no" }]).addUnrequiredTag("toilets:position", "urinals");
Quests.toiletsChangingTable = Question_1.QuestionDefinition.radioQuestionSimple("Is er een luiertafel beschikbaar?", 20, "changing_table", [{ text: "ja", value: "yes" }, { text: "nee", value: "no" }])
// Urinals are often a pitlatrine/something very poor where no changing table is
.addUnrequiredTag("toilets:position", "urinals").addUnrequiredTag("toilets:position", "urinal");
Quests.toiletsChangingTableLocation = Question_1.QuestionDefinition.radioAndTextQuestion("Waar bevindt de luiertafel zich?", 5, "changing_table", [{ text: "In de vrouwentoiletten", value: "female_toilet" },
{ text: "In de mannentoiletten", value: "male_toilet" },
{ text: "In de rolstoeltoegangkelijke toiletten", value: "wheelchair_toilet" },
{ text: "In de aparte, speciaal voorziene ruimte", value: "dedicated_room" },
{ text: "In de genderneutrale toiletten", value: "unisex_toilet" }])
.addRequiredTag("changing_table", "yes");
Quests.toiletsPosition = Question_1.QuestionDefinition.radioQuestionSimple("Wat voor toiletten zijn dit?", 1, "toilets:position", [{ text: "Enkel urinoirs", value: "urinals" },
{ text: "Enkel 'gewone' toiletten waar men op gaat zitten", value: "seated" },
{ text: "Er zijn zowel urinoirs als zittoiletten", value: "seated;urinals" }]);
Quests.accessNatureReserve = Question_1.QuestionDefinition.radioQuestionSimple("Is dit gebied toegankelijk voor het publiek?", 10, "access", [
{ text: "Nee, dit is afgesloten", value: "no" },
{ text: "Nee, dit is een privaat terrein", value: "no" },
{ text: "Hoewel het een privebos is, kan men er toch in", value: "permissive" },
{ text: "Enkel tijdens activiteiten of met een gids", value: "guided" },
{ text: "Ja, het is gewoon toegankelijk", value: "yes" }
]).addUnrequiredTag("seamark:type", "restricted_area");
Quests.operator = Question_1.QuestionDefinition.radioAndTextQuestion("Wie is de beheerder van dit gebied?", 1, "operator", [{ text: "Natuurpunt", value: "Natuurpunt" },
{ text: "Het Agenschap voor Natuur en Bos", value: "Agentschap Natuur en Bos" },
{ text: "Een prive-eigenaar", value: "private" }
]).addUnrequiredTag("access", "private")
.addUnrequiredTag("access", "no");
return Quests;
}());
exports.Quests = Quests;

129
UI/AddButton.js Normal file
View file

@ -0,0 +1,129 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AddButton = void 0;
var UIEventSource_1 = require("./UIEventSource");
var UIElement_1 = require("./UIElement");
var AddButton = /** @class */ (function (_super) {
__extends(AddButton, _super);
function AddButton(basemap, changes, options) {
var _this = _super.call(this, undefined) || this;
_this.curentAddSelection = new UIEventSource_1.UIEventSource("");
_this.SELECTING_POI = "selecting_POI";
_this.PLACING_POI = "placing_POI";
/*State is one of:
* "": the default stated
* "select_POI": show a 'select which POI to add' query (skipped if only one option exists)
* "placing_point": shown while adding a point
* ""
*/
_this.state = new UIEventSource_1.UIEventSource("");
_this.zoomlevel = basemap.Location;
_this.ListenTo(_this.zoomlevel);
_this._options = options;
_this.ListenTo(_this.curentAddSelection);
_this.ListenTo(_this.state);
_this.state.setData(_this.SELECTING_POI);
_this.changes = changes;
var self = _this;
basemap.map.on("click", function (e) {
var location = e.latlng;
console.log("Clicked at ", location);
self.HandleClick(location.lat, location.lng);
});
basemap.map.on("mousemove", function () {
if (self.state.data === self.PLACING_POI) {
var icon = "crosshair";
for (var _i = 0, _a = self._options; _i < _a.length; _i++) {
var option = _a[_i];
if (option.name === self.curentAddSelection.data && option.icon !== undefined) {
icon = 'url("' + option.icon + '") 32 32 ,crosshair';
console.log("Cursor icon: ", icon);
}
}
document.getElementById('leafletDiv').style.cursor = icon;
}
else {
// @ts-ignore
document.getElementById('leafletDiv').style.cursor = '';
}
});
return _this;
}
AddButton.prototype.HandleClick = function (lat, lon) {
this.state.setData(this.SELECTING_POI);
console.log("Handling click", lat, lon, this.curentAddSelection.data);
for (var _i = 0, _a = this._options; _i < _a.length; _i++) {
var option = _a[_i];
if (this.curentAddSelection.data === option.name) {
console.log("PLACING a ", option);
var feature = this.changes.createElement(option.tags, lat, lon);
option.layerToAddTo.AddNewElement(feature);
return;
}
}
};
AddButton.prototype.InnerRender = function () {
if (this.zoomlevel.data.zoom < 19) {
return "Zoom in om een punt toe te voegen";
}
if (this.state.data === this.SELECTING_POI) {
var html = "<form>";
for (var _i = 0, _a = this._options; _i < _a.length; _i++) {
var option = _a[_i];
// <button type='button'> looks SO retarded
// the default type of button is 'submit', which performs a POST and page reload
html += "<button type='button' class='addPOIoption' value='" + option.name + "'>Voeg een " + option.name + " toe</button><br/>";
}
html += "</form>";
return html;
}
if (this.state.data === this.PLACING_POI) {
return "<div id='clickOnMapInstruction'>Klik op de kaart om een nieuw punt toe te voegen<div>" +
"<div id='cancelInstruction'>Klik hier om toevoegen te annuleren</div>";
}
if (this.curentAddSelection.data === "") {
return "<span onclick>Voeg een punt toe...</span>";
}
return "Annuleer";
};
AddButton.prototype.InnerUpdate = function (htmlElement) {
var self = this;
htmlElement.onclick = function (event) {
// @ts-ignore
if (event.consumed) {
return;
}
if (self.state.data === self.PLACING_POI) {
self.state.setData(self.SELECTING_POI);
}
};
var buttons = htmlElement.getElementsByClassName('addPOIoption');
var _loop_1 = function (button) {
button.onclick = function (event) {
self.curentAddSelection.setData(button.value);
self.state.setData(self.PLACING_POI);
event.consumed = true;
};
};
// @ts-ignore
for (var _i = 0, buttons_1 = buttons; _i < buttons_1.length; _i++) {
var button = buttons_1[_i];
_loop_1(button);
}
};
return AddButton;
}(UIElement_1.UIElement));
exports.AddButton = AddButton;

49
UI/Base/Button.js Normal file
View file

@ -0,0 +1,49 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Button = void 0;
var UIElement_1 = require("../UIElement");
var Button = /** @class */ (function (_super) {
__extends(Button, _super);
function Button(text, onclick, clss) {
if (clss === void 0) { clss = ""; }
var _this = _super.call(this, undefined) || this;
_this._text = text;
_this._onclick = onclick;
if (clss !== "") {
_this._clss = "class='" + clss + "'";
}
else {
_this._clss = "";
}
return _this;
}
Button.prototype.InnerRender = function () {
return "<form>" +
"<button id='button-" + this.id + "' type='button' " + this._clss + ">" + this._text.Render() + "</button>" +
"</form>";
};
Button.prototype.InnerUpdate = function (htmlElement) {
_super.prototype.InnerUpdate.call(this, htmlElement);
var self = this;
console.log("Update for ", htmlElement);
document.getElementById("button-" + this.id).onclick = function () {
console.log("Clicked");
self._onclick();
};
};
return Button;
}(UIElement_1.UIElement));
exports.Button = Button;

57
UI/Base/CollapseButton.js Normal file
View file

@ -0,0 +1,57 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CollapseButton = void 0;
var UIElement_1 = require("../UIElement");
var UIEventSource_1 = require("../UIEventSource");
var CollapseButton = /** @class */ (function (_super) {
__extends(CollapseButton, _super);
function CollapseButton(idToCollapse) {
var _this = _super.call(this, undefined) || this;
_this.isCollapsed = new UIEventSource_1.UIEventSource(false);
_this.ListenTo(_this.isCollapsed);
_this.isCollapsed.addCallback(function (collapse) {
var el = document.getElementById(idToCollapse);
if (el === undefined || el === null) {
console.log("Element not found");
return;
}
if (collapse) {
el.style.height = "3.5em";
el.style.width = "15em";
}
else {
el.style.height = "auto";
el.style.width = "auto";
}
});
var self = _this;
_this.onClick(function () {
self.isCollapsed.setData(!self.isCollapsed.data);
});
return _this;
}
CollapseButton.prototype.InnerRender = function () {
var up = './assets/arrow-up.svg';
var down = './assets/arrow-down.svg';
var arrow = up;
if (this.isCollapsed.data) {
arrow = down;
}
return "<img class='collapse-button' src='" + arrow + "' alt='collapse'>";
};
return CollapseButton;
}(UIElement_1.UIElement));
exports.CollapseButton = CollapseButton;

30
UI/Base/FixedUiElement.js Normal file
View file

@ -0,0 +1,30 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.FixedUiElement = void 0;
var UIElement_1 = require("../UIElement");
var FixedUiElement = /** @class */ (function (_super) {
__extends(FixedUiElement, _super);
function FixedUiElement(html) {
var _this = _super.call(this, undefined) || this;
_this._html = html !== null && html !== void 0 ? html : "";
return _this;
}
FixedUiElement.prototype.InnerRender = function () {
return this._html;
};
return FixedUiElement;
}(UIElement_1.UIElement));
exports.FixedUiElement = FixedUiElement;

View file

@ -0,0 +1,38 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.VariableUiElement = void 0;
var UIElement_1 = require("../UIElement");
var VariableUiElement = /** @class */ (function (_super) {
__extends(VariableUiElement, _super);
function VariableUiElement(html, innerUpdate) {
if (innerUpdate === void 0) { innerUpdate = undefined; }
var _this = _super.call(this, html) || this;
_this._html = html;
_this._innerUpdate = innerUpdate;
return _this;
}
VariableUiElement.prototype.InnerRender = function () {
return this._html.data;
};
VariableUiElement.prototype.InnerUpdate = function (htmlElement) {
_super.prototype.InnerUpdate.call(this, htmlElement);
if (this._innerUpdate !== undefined) {
this._innerUpdate(htmlElement);
}
};
return VariableUiElement;
}(UIElement_1.UIElement));
exports.VariableUiElement = VariableUiElement;

View file

@ -0,0 +1,45 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.VerticalCombine = void 0;
var UIElement_1 = require("../UIElement");
var VerticalCombine = /** @class */ (function (_super) {
__extends(VerticalCombine, _super);
function VerticalCombine(elements, className) {
if (className === void 0) { className = undefined; }
var _this = _super.call(this, undefined) || this;
_this._elements = elements;
_this._className = className;
return _this;
}
VerticalCombine.prototype.InnerRender = function () {
var html = "";
for (var _i = 0, _a = this._elements; _i < _a.length; _i++) {
var element = _a[_i];
if (!element.IsEmpty()) {
html += "<div>" + element.Render() + "</div>";
}
}
if (html === "") {
return "";
}
if (this._className === undefined) {
return html;
}
return "<div class='" + this._className + "'>" + html + "</div>";
};
return VerticalCombine;
}(UIElement_1.UIElement));
exports.VerticalCombine = VerticalCombine;

72
UI/CenterMessageBox.js Normal file
View file

@ -0,0 +1,72 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CenterMessageBox = void 0;
var UIElement_1 = require("./UIElement");
var UIEventSource_1 = require("./UIEventSource");
var CenterMessageBox = /** @class */ (function (_super) {
__extends(CenterMessageBox, _super);
function CenterMessageBox(startZoom, centermessage, osmConnection, location, queryRunning) {
var _this = _super.call(this, centermessage) || this;
_this._zoomInMore = new UIEventSource_1.UIEventSource(true);
_this._centermessage = centermessage;
_this._location = location;
_this._osmConnection = osmConnection;
_this._queryRunning = queryRunning;
_this.ListenTo(queryRunning);
var self = _this;
location.addCallback(function () {
self._zoomInMore.setData(location.data.zoom < startZoom);
});
_this.ListenTo(_this._zoomInMore);
return _this;
}
CenterMessageBox.prototype.InnerRender = function () {
if (this._centermessage.data != "") {
return this._centermessage.data;
}
if (this._queryRunning.data) {
return "Data wordt geladen...";
}
else if (this._zoomInMore.data) {
return "Zoom in om de data te zien en te bewerken";
}
return "Klaar!";
};
CenterMessageBox.prototype.ShouldShowSomething = function () {
if (this._queryRunning.data) {
return true;
}
return this._zoomInMore.data;
};
CenterMessageBox.prototype.InnerUpdate = function (htmlElement) {
var pstyle = htmlElement.parentElement.style;
if (this._centermessage.data != "") {
pstyle.opacity = "1";
pstyle.pointerEvents = "all";
this._osmConnection.registerActivateOsmAUthenticationClass();
return;
}
pstyle.pointerEvents = "none";
if (this.ShouldShowSomething()) {
pstyle.opacity = "0.5";
}
else {
pstyle.opacity = "0";
}
};
return CenterMessageBox;
}(UIElement_1.UIElement));
exports.CenterMessageBox = CenterMessageBox;

67
UI/ConfirmDialog.js Normal file
View file

@ -0,0 +1,67 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfirmDialog = void 0;
var UIElement_1 = require("./UIElement");
var UIEventSource_1 = require("./UIEventSource");
var FixedUiElement_1 = require("./Base/FixedUiElement");
var VariableUIElement_1 = require("./Base/VariableUIElement");
var ConfirmDialog = /** @class */ (function (_super) {
__extends(ConfirmDialog, _super);
function ConfirmDialog(show, question, optionA, optionB, executeA, executeB, classA, classB) {
if (classA === void 0) { classA = ""; }
if (classB === void 0) { classB = ""; }
var _this = _super.call(this, show) || this;
_this._showOptions = new UIEventSource_1.UIEventSource(false);
_this.ListenTo(_this._showOptions);
var self = _this;
show.addCallback(function () {
self._showOptions.setData(false);
});
_this._question = new FixedUiElement_1.FixedUiElement("<span class='ui-question'>" + question + "</span>")
.onClick(function () {
self._showOptions.setData(!self._showOptions.data);
});
_this._optionA = new VariableUIElement_1.VariableUiElement(_this._showOptions.map(function (show) { return show ? "<div class='" + classA + "'>" + optionA + "</div>" : ""; }))
.onClick(function () {
self._showOptions.setData(false);
executeA();
});
_this._optionB = new VariableUIElement_1.VariableUiElement(_this._showOptions.map(function (show) {
return show ? "<div class='" + classB + "'>" + optionB + "</div>" : "";
}))
.onClick(function () {
self._showOptions.setData(false);
executeB();
});
return _this;
}
ConfirmDialog.prototype.InnerRender = function () {
if (!this._source.data) {
return "";
}
return this._question.Render() +
this._optionA.Render() +
this._optionB.Render();
};
ConfirmDialog.prototype.Update = function () {
_super.prototype.Update.call(this);
this._question.Update();
this._optionA.Update();
this._optionB.Update();
};
return ConfirmDialog;
}(UIElement_1.UIElement));
exports.ConfirmDialog = ConfirmDialog;

89
UI/FeatureInfoBox.js Normal file
View file

@ -0,0 +1,89 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.FeatureInfoBox = void 0;
var UIElement_1 = require("./UIElement");
var VerticalCombine_1 = require("./Base/VerticalCombine");
var TagRendering_1 = require("../Customizations/TagRendering");
var OsmLink_1 = require("../Customizations/Questions/OsmLink");
var WikipediaLink_1 = require("../Customizations/Questions/WikipediaLink");
var TagsFilter_1 = require("../Logic/TagsFilter");
var FeatureInfoBox = /** @class */ (function (_super) {
__extends(FeatureInfoBox, _super);
function FeatureInfoBox(tagsES, title, elementsToShow, changes, userDetails) {
var _this = _super.call(this, tagsES) || this;
_this._tagsES = tagsES;
_this._changes = changes;
_this._userDetails = userDetails;
_this.ListenTo(userDetails);
var deps = { tags: _this._tagsES, changes: _this._changes };
_this._infoboxes = [];
elementsToShow = elementsToShow !== null && elementsToShow !== void 0 ? elementsToShow : [];
for (var _i = 0, elementsToShow_1 = elementsToShow; _i < elementsToShow_1.length; _i++) {
var tagRenderingOption = elementsToShow_1[_i];
_this._infoboxes.push(tagRenderingOption.construct(deps));
}
title = title !== null && title !== void 0 ? title : new TagRendering_1.TagRenderingOptions({
mappings: [{ k: new TagsFilter_1.And([]), txt: "" }]
});
_this._title = new TagRendering_1.TagRenderingOptions(title.options).construct(deps);
_this._osmLink = new OsmLink_1.OsmLink().construct(deps);
_this._wikipedialink = new WikipediaLink_1.WikipediaLink().construct(deps);
return _this;
}
FeatureInfoBox.prototype.InnerRender = function () {
var info = [];
var questions = [];
for (var _i = 0, _a = this._infoboxes; _i < _a.length; _i++) {
var infobox = _a[_i];
if (infobox.IsKnown()) {
info.push(infobox);
}
else if (infobox.IsQuestioning()) {
questions.push(infobox);
}
}
var questionsHtml = "";
if (this._userDetails.data.loggedIn && questions.length > 0) {
// We select the most important question and render that one
var mostImportantQuestion = void 0;
var score = -1000;
for (var _b = 0, questions_1 = questions; _b < questions_1.length; _b++) {
var question = questions_1[_b];
if (mostImportantQuestion === undefined || question.Priority() > score) {
mostImportantQuestion = question;
score = question.Priority();
}
}
questionsHtml = mostImportantQuestion.Render();
}
return "<div class='featureinfobox'>" +
"<div class='featureinfoboxtitle'>" +
"<span>" +
this._title.Render() +
"</span>" +
this._wikipedialink.Render() +
this._osmLink.Render() +
"</div>" +
"<div class='infoboxcontents'>" +
new VerticalCombine_1.VerticalCombine(info, "infobox-information ").Render() +
questionsHtml +
"</div>" +
"" +
"</div>";
};
return FeatureInfoBox;
}(UIElement_1.UIElement));
exports.FeatureInfoBox = FeatureInfoBox;

112
UI/Image/ImageCarousel.js Normal file
View file

@ -0,0 +1,112 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImageCarousel = exports.ImageCarouselConstructor = void 0;
var ImageSearcher_1 = require("../../Logic/ImageSearcher");
var SlideShow_1 = require("../SlideShow");
var FixedUiElement_1 = require("../Base/FixedUiElement");
var VariableUIElement_1 = require("../Base/VariableUIElement");
var ConfirmDialog_1 = require("../ConfirmDialog");
var UIElementConstructor_1 = require("../../Customizations/UIElementConstructor");
var ImageCarouselConstructor = /** @class */ (function () {
function ImageCarouselConstructor() {
}
ImageCarouselConstructor.prototype.IsKnown = function (properties) {
return true;
};
ImageCarouselConstructor.prototype.IsQuestioning = function (properties) {
return false;
};
ImageCarouselConstructor.prototype.Priority = function () {
return 0;
};
ImageCarouselConstructor.prototype.construct = function (tags, changes) {
return new ImageCarousel(tags, changes);
};
return ImageCarouselConstructor;
}());
exports.ImageCarouselConstructor = ImageCarouselConstructor;
var ImageCarousel = /** @class */ (function (_super) {
__extends(ImageCarousel, _super);
function ImageCarousel(tags, changes) {
var _this = _super.call(this, tags) || this;
_this._userDetails = changes.login.userDetails;
var self = _this;
_this.searcher = new ImageSearcher_1.ImageSearcher(tags, changes);
_this._uiElements = _this.searcher.map(function (imageURLS) {
var uiElements = [];
for (var _i = 0, imageURLS_1 = imageURLS; _i < imageURLS_1.length; _i++) {
var url = imageURLS_1[_i];
var image = ImageSearcher_1.ImageSearcher.CreateImageElement(url);
uiElements.push(image);
}
return uiElements;
});
_this.slideshow = new SlideShow_1.SlideShow(_this._uiElements, new FixedUiElement_1.FixedUiElement("")).HideOnEmpty(true);
var showDeleteButton = _this.slideshow._currentSlide.map(function (i) {
if (!self._userDetails.data.loggedIn) {
return false;
}
return self.searcher.IsDeletable(self.searcher.data[i]);
}, [_this.searcher, _this._userDetails]);
_this.slideshow._currentSlide.addCallback(function () {
showDeleteButton.ping(); // This pings the showDeleteButton, which indicates that it has to hide it's subbuttons
});
var deleteCurrent = function () {
self.searcher.Delete(self.searcher.data[self.slideshow._currentSlide.data]);
};
_this._deleteButton = new ConfirmDialog_1.ConfirmDialog(showDeleteButton, "<img src='assets/delete.svg' alt='Afbeelding verwijderen' class='delete-image'>", "<span>Afbeelding verwijderen</span>", "<span>Terug</span>", deleteCurrent, function () { }, 'delete-image-confirm', 'delete-image-cancel');
var mapping = _this.slideshow._currentSlide.map(function (i) {
if (_this.searcher._deletedImages.data.indexOf(_this.searcher.data[i]) >= 0) {
return "<div class='image-is-removed'>Deze afbeelding is verwijderd</div>";
}
return "";
});
_this._isDeleted = new VariableUIElement_1.VariableUiElement(mapping);
_this.searcher._deletedImages.addCallback(function () {
_this.slideshow._currentSlide.ping();
});
return _this;
}
ImageCarousel.prototype.InnerRender = function () {
return "<span class='image-carousel-container'>" +
"<div class='image-delete-container'>" +
this._deleteButton.Render() +
this._isDeleted.Render() +
"</div>" +
this.slideshow.Render() +
"</span>";
};
ImageCarousel.prototype.IsKnown = function () {
return true;
};
ImageCarousel.prototype.IsQuestioning = function () {
return false;
};
ImageCarousel.prototype.Priority = function () {
return 0;
};
ImageCarousel.prototype.InnerUpdate = function (htmlElement) {
_super.prototype.InnerUpdate.call(this, htmlElement);
this._deleteButton.Update();
this._isDeleted.Update();
};
ImageCarousel.prototype.Activate = function () {
_super.prototype.Activate.call(this);
this.searcher.Activate();
};
return ImageCarousel;
}(UIElementConstructor_1.TagDependantUIElement));
exports.ImageCarousel = ImageCarousel;

View file

@ -0,0 +1,74 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImageCarouselWithUploadConstructor = void 0;
var UIElementConstructor_1 = require("../../Customizations/UIElementConstructor");
var ImageCarousel_1 = require("./ImageCarousel");
var OsmImageUploadHandler_1 = require("../../Logic/OsmImageUploadHandler");
var ImageCarouselWithUploadConstructor = /** @class */ (function () {
function ImageCarouselWithUploadConstructor() {
}
ImageCarouselWithUploadConstructor.prototype.IsKnown = function (properties) {
return true;
};
ImageCarouselWithUploadConstructor.prototype.IsQuestioning = function (properties) {
return false;
};
ImageCarouselWithUploadConstructor.prototype.Priority = function () {
return 0;
};
ImageCarouselWithUploadConstructor.prototype.construct = function (dependencies) {
return new ImageCarouselWithUpload(dependencies);
};
return ImageCarouselWithUploadConstructor;
}());
exports.ImageCarouselWithUploadConstructor = ImageCarouselWithUploadConstructor;
var ImageCarouselWithUpload = /** @class */ (function (_super) {
__extends(ImageCarouselWithUpload, _super);
function ImageCarouselWithUpload(dependencies) {
var _this = _super.call(this, dependencies.tags) || this;
var tags = dependencies.tags;
var changes = dependencies.changes;
_this._imageElement = new ImageCarousel_1.ImageCarousel(tags, changes);
var userDetails = changes.login.userDetails;
var license = changes.login.GetPreference("mapcomplete-pictures-license");
_this._pictureUploader = new OsmImageUploadHandler_1.OsmImageUploadHandler(tags, userDetails, license, changes, _this._imageElement.slideshow).getUI();
return _this;
}
ImageCarouselWithUpload.prototype.InnerRender = function () {
return this._imageElement.Render() +
this._pictureUploader.Render();
};
ImageCarouselWithUpload.prototype.Activate = function () {
_super.prototype.Activate.call(this);
this._imageElement.Activate();
this._pictureUploader.Activate();
};
ImageCarouselWithUpload.prototype.Update = function () {
_super.prototype.Update.call(this);
this._imageElement.Update();
this._pictureUploader.Update();
};
ImageCarouselWithUpload.prototype.IsKnown = function () {
return true;
};
ImageCarouselWithUpload.prototype.IsQuestioning = function () {
return false;
};
ImageCarouselWithUpload.prototype.Priority = function () {
return 0;
};
return ImageCarouselWithUpload;
}(UIElementConstructor_1.TagDependantUIElement));

59
UI/Image/ImgurImage.js Normal file
View file

@ -0,0 +1,59 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImgurImage = void 0;
var UIEventSource_1 = require("../UIEventSource");
var UIElement_1 = require("../UIElement");
var Imgur_1 = require("../../Logic/Imgur");
var ImgurImage = /** @class */ (function (_super) {
__extends(ImgurImage, _super);
function ImgurImage(source) {
var _this = _super.call(this, undefined) || this;
_this._imageLocation = source;
if (ImgurImage.allLicenseInfos[source] !== undefined) {
_this._imageMeta = ImgurImage.allLicenseInfos[source];
}
else {
_this._imageMeta = new UIEventSource_1.UIEventSource(null);
ImgurImage.allLicenseInfos[source] = _this._imageMeta;
var self_1 = _this;
Imgur_1.Imgur.getDescriptionOfImage(source, function (license) {
self_1._imageMeta.setData(license);
});
}
_this.ListenTo(_this._imageMeta);
return _this;
}
ImgurImage.prototype.InnerRender = function () {
var _a, _b;
var image = "<img src='" + this._imageLocation + "' " + "alt='' >";
if (this._imageMeta.data === null) {
return image;
}
var attribution = "<span class='attribution-author'><b>" + ((_a = this._imageMeta.data.artist) !== null && _a !== void 0 ? _a : "") + "</b></span>" + " <span class='license'>" + ((_b = this._imageMeta.data.licenseShortName) !== null && _b !== void 0 ? _b : "") + "</span>";
return "<div class='imgWithAttr'>" +
image +
"<div class='attribution'>" +
attribution +
"</div>" +
"</div>";
};
/***
* Dictionary from url to alreayd known license info
*/
ImgurImage.allLicenseInfos = {};
return ImgurImage;
}(UIElement_1.UIElement));
exports.ImgurImage = ImgurImage;

View file

@ -0,0 +1,28 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SimpleImageElement = void 0;
var UIElement_1 = require("../UIElement");
var SimpleImageElement = /** @class */ (function (_super) {
__extends(SimpleImageElement, _super);
function SimpleImageElement(source) {
return _super.call(this, source) || this;
}
SimpleImageElement.prototype.InnerRender = function () {
return "<img src='" + this._source.data + "' alt='img'>";
};
return SimpleImageElement;
}(UIElement_1.UIElement));
exports.SimpleImageElement = SimpleImageElement;

View file

@ -0,0 +1,59 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.WikimediaImage = void 0;
var UIEventSource_1 = require("../UIEventSource");
var UIElement_1 = require("../UIElement");
var Wikimedia_1 = require("../../Logic/Wikimedia");
var WikimediaImage = /** @class */ (function (_super) {
__extends(WikimediaImage, _super);
function WikimediaImage(source) {
var _this = _super.call(this, undefined) || this;
_this._imageLocation = source;
if (WikimediaImage.allLicenseInfos[source] !== undefined) {
_this._imageMeta = WikimediaImage.allLicenseInfos[source];
}
else {
_this._imageMeta = new UIEventSource_1.UIEventSource(new Wikimedia_1.LicenseInfo());
WikimediaImage.allLicenseInfos[source] = _this._imageMeta;
var self_1 = _this;
Wikimedia_1.Wikimedia.LicenseData(source, function (info) {
self_1._imageMeta.setData(info);
});
}
_this.ListenTo(_this._imageMeta);
return _this;
}
WikimediaImage.prototype.InnerRender = function () {
var _a, _b;
var url = Wikimedia_1.Wikimedia.ImageNameToUrl(this._imageLocation, 500, 400);
url = url.replace(/'/g, '%27');
var wikimediaLink = "<a href='https://commons.wikimedia.org/wiki/" + this._imageLocation + "' target='_blank'>" +
"<img class='wikimedia-link' src='./assets/wikimedia-commons-white.svg' alt='Wikimedia Commons Logo'/>" +
"</a> ";
var attribution = "<span class='attribution-author'>" + ((_a = this._imageMeta.data.artist) !== null && _a !== void 0 ? _a : "") + "</span>" + " <span class='license'>" + ((_b = this._imageMeta.data.licenseShortName) !== null && _b !== void 0 ? _b : "") + "</span>";
var image = "<img src='" + url + "' " + "alt='" + this._imageMeta.data.description + "' >";
return "<div class='imgWithAttr'>" +
image +
"<div class='attribution'>" +
wikimediaLink +
attribution +
"</div>" +
"</div>";
};
WikimediaImage.allLicenseInfos = {};
return WikimediaImage;
}(UIElement_1.UIElement));
exports.WikimediaImage = WikimediaImage;

107
UI/ImageUploadFlow.js Normal file
View file

@ -0,0 +1,107 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImageUploadFlow = void 0;
var UIElement_1 = require("./UIElement");
var UIEventSource_1 = require("./UIEventSource");
var jquery_1 = require("jquery");
var Imgur_1 = require("../Logic/Imgur");
var DropDown_1 = require("./Input/DropDown");
var VariableUIElement_1 = require("./Base/VariableUIElement");
var ImageUploadFlow = /** @class */ (function (_super) {
__extends(ImageUploadFlow, _super);
function ImageUploadFlow(userInfo, preferedLicense, uploadOptions) {
var _this = _super.call(this, undefined) || this;
_this._isUploading = new UIEventSource_1.UIEventSource(0);
_this._userdetails = userInfo;
_this.ListenTo(userInfo);
_this._uploadOptions = uploadOptions;
_this.ListenTo(_this._isUploading);
var licensePicker = new DropDown_1.DropDown("Jouw foto wordt gepubliceerd ", [
{ value: "CC0", shown: "in het publiek domein" },
{ value: "CC-BY-SA 4.0", shown: "onder een CC-BY-SA-licentie" },
{ value: "CC-BY 4.0", shown: "onder een CC-BY-licentie" }
], preferedLicense);
_this._licensePicker = licensePicker;
_this._selectedLicence = licensePicker.selectedElement;
var licenseExplanations = {
"CC-BY-SA 4.0": "<b>Creative Commonse met naamsvermelding en gelijk delen</b><br/>" +
"Je foto mag door iedereen gratis gebruikt worden, als ze je naam vermelden én ze afgeleide werken met deze licentie en attributie delen.",
"CC-BY 4.0": "<b>Creative Commonse met naamsvermelding</b> <br/>" +
"Je foto mag door iedereen gratis gebruikt worden, als ze je naam vermelden",
"CC0": "<b>Geen copyright</b><br/> Je foto mag door iedereen voor alles gebruikt worden"
};
_this._licenseExplanation = new VariableUIElement_1.VariableUiElement(_this._selectedLicence.map(function (license) {
return licenseExplanations[license];
}));
return _this;
}
ImageUploadFlow.prototype.InnerRender = function () {
if (!this._userdetails.data.loggedIn) {
return "<div class='activate-osm-authentication'>Gelieve je aan te melden om een foto toe te voegen of vragen te beantwoorden</div>";
}
if (this._isUploading.data == 1) {
return "<b>Bezig met een foto te uploaden...</b>";
}
if (this._isUploading.data > 0) {
return "<b>Bezig met uploaden, nog " + this._isUploading.data + " foto's te gaan...</b>";
}
return "" +
"<div class='imageflow'>" +
"<label for='fileselector-" + this.id + "'>" +
"<div class='imageflow-file-input-wrapper'>" +
"<img src='./assets/camera-plus.svg' alt='upload image'/> " +
"<span class='imageflow-add-picture'>Voeg foto toe</span>" +
"<div class='break'></div>" +
"</div>" +
this._licensePicker.Render() +
"</label>" +
"<input id='fileselector-" + this.id + "' " +
"type='file' " +
"class='imageflow-file-input' " +
"accept='image/*' name='picField' size='24' multiple='multiple' alt=''" +
"/>" +
"</div>";
};
ImageUploadFlow.prototype.InnerUpdate = function (htmlElement) {
_super.prototype.InnerUpdate.call(this, htmlElement);
var user = this._userdetails.data;
htmlElement.onclick = function () {
if (!user.loggedIn) {
user.osmConnection.AttemptLogin();
}
};
this._licensePicker.Update();
var selector = document.getElementById('fileselector-' + this.id);
var self = this;
if (selector != null) {
selector.onchange = function () {
var files = jquery_1.default(this).get(0).files;
self._isUploading.setData(files.length);
var opts = self._uploadOptions(self._selectedLicence.data);
Imgur_1.Imgur.uploadMultiple(opts.title, opts.description, files, function (url) {
console.log("File saved at", url);
self._isUploading.setData(self._isUploading.data - 1);
opts.handleURL(url);
}, function () {
console.log("All uploads completed");
opts.allDone();
});
};
}
};
return ImageUploadFlow;
}(UIElement_1.UIElement));
exports.ImageUploadFlow = ImageUploadFlow;

16
UI/Img.js Normal file
View file

@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Img = void 0;
var Img = /** @class */ (function () {
function Img() {
}
Img.osmAbstractLogo = "<svg class='osm-logo' xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" width=\"24px\" version=\"1.1\" viewBox=\"0 0 66 64\">" +
" <g transform=\"translate(-0.849, -61)\">\n" +
" <path d=\"M0.849,61 L6.414,75.609 L0.849,90.217 L6.414,104.826 L0.849,119.435 L4.266,120.739 L22.831,102.183 L26.162,102.696 L30.205,98.652 C27.819,95.888 26.033,92.59 25.057,88.948 L26.953,87.391 C26.627,85.879 26.449,84.313 26.449,82.704 C26.449,74.67 30.734,67.611 37.136,63.696 L30.066,61 L15.457,66.565 L0.849,61 z\"></path>" +
" <path d=\"M48.71,64.617 C48.406,64.617 48.105,64.629 47.805,64.643 C47.52,64.657 47.234,64.677 46.953,64.704 C46.726,64.726 46.499,64.753 46.275,64.783 C46.039,64.814 45.811,64.847 45.579,64.887 C45.506,64.9 45.434,64.917 45.362,64.93 C45.216,64.958 45.072,64.987 44.927,65.017 C44.812,65.042 44.694,65.06 44.579,65.087 C44.442,65.119 44.307,65.156 44.17,65.191 C43.943,65.25 43.716,65.315 43.492,65.383 C43.323,65.433 43.155,65.484 42.988,65.539 C42.819,65.595 42.65,65.652 42.483,65.713 C42.475,65.716 42.466,65.719 42.457,65.722 C35.819,68.158 31.022,74.369 30.649,81.774 C30.633,82.083 30.622,82.391 30.622,82.704 C30.622,83.014 30.631,83.321 30.649,83.626 C30.649,83.629 30.648,83.632 30.649,83.635 C30.662,83.862 30.681,84.088 30.701,84.313 C31.466,93.037 38.377,99.948 47.101,100.713 C47.326,100.733 47.552,100.754 47.779,100.765 C47.782,100.765 47.785,100.765 47.788,100.765 C48.093,100.783 48.399,100.791 48.709,100.791 C53.639,100.791 58.096,98.833 61.353,95.652 C61.532,95.477 61.712,95.304 61.883,95.122 C61.913,95.09 61.941,95.058 61.97,95.026 C61.98,95.015 61.987,95.002 61.996,94.991 C62.132,94.845 62.266,94.698 62.396,94.548 C62.449,94.487 62.501,94.426 62.553,94.365 C62.594,94.316 62.634,94.267 62.675,94.217 C62.821,94.04 62.961,93.861 63.101,93.678 C63.279,93.444 63.456,93.199 63.622,92.956 C63.956,92.471 64.267,91.97 64.553,91.452 C64.661,91.257 64.757,91.06 64.857,90.861 C64.89,90.796 64.93,90.735 64.962,90.67 C64.98,90.633 64.996,90.594 65.014,90.556 C65.125,90.324 65.234,90.09 65.336,89.852 C65.349,89.82 65.365,89.789 65.379,89.756 C65.48,89.517 65.575,89.271 65.666,89.026 C65.678,88.994 65.689,88.962 65.701,88.93 C65.792,88.679 65.881,88.43 65.962,88.174 C65.97,88.148 65.98,88.122 65.988,88.096 C66.069,87.832 66.144,87.564 66.214,87.296 C66.219,87.275 66.226,87.255 66.231,87.235 C66.301,86.962 66.365,86.686 66.423,86.409 C66.426,86.391 66.428,86.374 66.431,86.356 C66.445,86.291 66.453,86.223 66.466,86.156 C66.511,85.925 66.552,85.695 66.588,85.461 C66.632,85.169 66.671,84.878 66.701,84.583 C66.701,84.574 66.701,84.565 66.701,84.556 C66.731,84.258 66.755,83.955 66.77,83.652 C66.77,83.646 66.77,83.641 66.77,83.635 C66.786,83.326 66.797,83.017 66.797,82.704 C66.797,72.69 58.723,64.617 48.71,64.617 z\"></path>" +
" <path d=\"M62.936,99.809 C59.074,103.028 54.115,104.965 48.71,104.965 C47.101,104.965 45.535,104.787 44.023,104.461 L42.466,106.357 C39.007,105.43 35.855,103.781 33.179,101.574 L28.996,105.765 L29.51,108.861 L13.953,124.426 L15.457,125 L30.066,119.435 L44.675,125 L59.283,119.435 L64.849,104.826 L62.936,99.809 z\"></path>" +
" </g>" +
"</svg>";
return Img;
}());
exports.Img = Img;

69
UI/Input/DropDown.js Normal file
View file

@ -0,0 +1,69 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DropDown = void 0;
var UIEventSource_1 = require("../UIEventSource");
var UIElement_1 = require("../UIElement");
var DropDown = /** @class */ (function (_super) {
__extends(DropDown, _super);
function DropDown(label, values, selectedElement) {
if (selectedElement === void 0) { selectedElement = undefined; }
var _this = _super.call(this, undefined) || this;
_this._label = label;
_this._values = values;
_this.selectedElement = selectedElement !== null && selectedElement !== void 0 ? selectedElement : new UIEventSource_1.UIEventSource(values[0].value);
if (selectedElement.data === undefined) {
_this.selectedElement.setData(values[0].value);
}
var self = _this;
_this.selectedElement.addCallback(function () {
self.InnerUpdate();
});
return _this;
}
DropDown.prototype.InnerRender = function () {
var options = "";
for (var _i = 0, _a = this._values; _i < _a.length; _i++) {
var value = _a[_i];
options += "<option value='" + value.value + "'>" + value.shown + "</option>";
}
return "<form>" +
"<label for='dropdown-" + this.id + "'>" + this._label + "</label>" +
"<select name='dropdown-" + this.id + "' id='dropdown-" + this.id + "'>" +
options +
"</select>" +
"</form>";
};
DropDown.prototype.InnerUpdate = function () {
var self = this;
var e = document.getElementById("dropdown-" + this.id);
if (e === null) {
return;
}
// @ts-ignore
if (this.selectedElement.data !== e.value) {
// @ts-ignore
e.value = this.selectedElement.data;
}
e.onchange = function () {
// @ts-ignore
var selectedValue = e.options[e.selectedIndex].value;
console.log("Putting data", selectedValue);
self.selectedElement.setData(selectedValue);
};
};
return DropDown;
}(UIElement_1.UIElement));
exports.DropDown = DropDown;

View file

@ -0,0 +1,39 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.FixedInputElement = void 0;
var InputElement_1 = require("./InputElement");
var UIEventSource_1 = require("../UIEventSource");
var FixedUiElement_1 = require("../Base/FixedUiElement");
var FixedInputElement = /** @class */ (function (_super) {
__extends(FixedInputElement, _super);
function FixedInputElement(rendering, value) {
var _this = _super.call(this, undefined) || this;
_this.value = new UIEventSource_1.UIEventSource(value);
_this.rendering = typeof (rendering) === 'string' ? new FixedUiElement_1.FixedUiElement(rendering) : rendering;
return _this;
}
FixedInputElement.prototype.GetValue = function () {
return this.value;
};
FixedInputElement.prototype.InnerRender = function () {
return this.rendering.Render();
};
FixedInputElement.prototype.IsValid = function (t) {
return t === this.value.data;
};
return FixedInputElement;
}(InputElement_1.InputElement));
exports.FixedInputElement = FixedInputElement;

25
UI/Input/InputElement.js Normal file
View file

@ -0,0 +1,25 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.InputElement = void 0;
var UIElement_1 = require("../UIElement");
var InputElement = /** @class */ (function (_super) {
__extends(InputElement, _super);
function InputElement() {
return _super !== null && _super.apply(this, arguments) || this;
}
return InputElement;
}(UIElement_1.UIElement));
exports.InputElement = InputElement;

View file

@ -0,0 +1,39 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.InputElementWrapper = void 0;
var InputElement_1 = require("./InputElement");
var UIElement_1 = require("../UIElement");
var InputElementWrapper = /** @class */ (function (_super) {
__extends(InputElementWrapper, _super);
function InputElementWrapper(pre, input, post) {
var _this = _super.call(this, undefined) || this;
_this.post = UIElement_1.UIElement.Fix(post);
_this.input = input;
_this.pre = UIElement_1.UIElement.Fix(pre);
return _this;
}
InputElementWrapper.prototype.GetValue = function () {
return this.input.GetValue();
};
InputElementWrapper.prototype.InnerRender = function () {
return this.pre.Render() + this.input.Render() + this.post.Render();
};
InputElementWrapper.prototype.IsValid = function (t) {
return this.input.IsValid(t);
};
return InputElementWrapper;
}(InputElement_1.InputElement));
exports.InputElementWrapper = InputElementWrapper;

122
UI/Input/RadioButton.js Normal file
View file

@ -0,0 +1,122 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.RadioButton = void 0;
var UIEventSource_1 = require("../UIEventSource");
var InputElement_1 = require("./InputElement");
var RadioButton = /** @class */ (function (_super) {
__extends(RadioButton, _super);
function RadioButton(elements, selectFirstAsDefault) {
if (selectFirstAsDefault === void 0) { selectFirstAsDefault = true; }
var _this = _super.call(this, undefined) || this;
_this._selectedElementIndex = new UIEventSource_1.UIEventSource(null);
_this._elements = elements;
_this._selectFirstAsDefault = selectFirstAsDefault;
var self = _this;
_this.value =
UIEventSource_1.UIEventSource.flatten(_this._selectedElementIndex.map(function (selectedIndex) {
if (selectedIndex !== undefined && selectedIndex !== null) {
return elements[selectedIndex].GetValue();
}
}), elements.map(function (e) { return e.GetValue(); }));
_this.value.addCallback(function (t) {
self.SetCorrectValue(t);
});
var _loop_1 = function (i) {
// If an element is clicked, the radio button corresponding with it should be selected as well
elements[i].onClick(function () {
self._selectedElementIndex.setData(i);
});
};
for (var i = 0; i < elements.length; i++) {
_loop_1(i);
}
return _this;
}
RadioButton.prototype.IsValid = function (t) {
for (var _i = 0, _a = this._elements; _i < _a.length; _i++) {
var inputElement = _a[_i];
if (inputElement.IsValid(t)) {
return true;
}
}
return false;
};
RadioButton.prototype.GetValue = function () {
return this.value;
};
RadioButton.prototype.IdFor = function (i) {
return 'radio-' + this.id + '-' + i;
};
RadioButton.prototype.InnerRender = function () {
var body = "";
var i = 0;
for (var _i = 0, _a = this._elements; _i < _a.length; _i++) {
var el = _a[_i];
var htmlElement = '<input type="radio" id="' + this.IdFor(i) + '" name="radiogroup-' + this.id + '">' +
'<label for="' + this.IdFor(i) + '">' + el.Render() + '</label>' +
'<br>';
body += htmlElement;
i++;
}
return "<form id='" + this.id + "-form'>" + body + "</form>";
};
RadioButton.prototype.SetCorrectValue = function (t) {
if (t === undefined) {
return;
}
// We check that what is selected matches the previous rendering
for (var i = 0; i < this._elements.length; i++) {
var e = this._elements[i];
if (e.IsValid(t)) {
this._selectedElementIndex.setData(i);
e.GetValue().setData(t);
// @ts-ignore
document.getElementById(this.IdFor(i)).checked = true;
return;
}
}
};
RadioButton.prototype.InnerUpdate = function (htmlElement) {
var self = this;
function checkButtons() {
for (var i = 0; i < self._elements.length; i++) {
var el_1 = document.getElementById(self.IdFor(i));
// @ts-ignore
if (el_1.checked) {
self._selectedElementIndex.setData(i);
}
}
}
var el = document.getElementById(this.id);
el.addEventListener("change", function () {
checkButtons();
});
if (this._selectFirstAsDefault) {
this.SetCorrectValue(this.value.data);
if (this._selectedElementIndex.data === null || this._selectedElementIndex.data === undefined) {
var el_2 = document.getElementById(this.IdFor(0));
if (el_2) {
// @ts-ignore
el_2.checked = true;
checkButtons();
}
}
}
};
;
return RadioButton;
}(InputElement_1.InputElement));
exports.RadioButton = RadioButton;

94
UI/Input/TextField.js Normal file
View file

@ -0,0 +1,94 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextField = void 0;
var UIEventSource_1 = require("../UIEventSource");
var InputElement_1 = require("./InputElement");
var FixedUiElement_1 = require("../Base/FixedUiElement");
var TextField = /** @class */ (function (_super) {
__extends(TextField, _super);
function TextField(options) {
var _a, _b, _c, _d;
var _this = _super.call(this, undefined) || this;
/**
* Pings and has the value data
*/
_this.enterPressed = new UIEventSource_1.UIEventSource(undefined);
_this.value = new UIEventSource_1.UIEventSource("");
_this.mappedValue = (_a = options === null || options === void 0 ? void 0 : options.value) !== null && _a !== void 0 ? _a : new UIEventSource_1.UIEventSource(undefined);
// @ts-ignore
_this._fromString = (_b = options.fromString) !== null && _b !== void 0 ? _b : (function (str) { return (str); });
_this.value.addCallback(function (str) { return _this.mappedValue.setData(options.fromString(str)); });
_this.mappedValue.addCallback(function (t) { return _this.value.setData(options.toString(t)); });
_this._placeholder =
typeof (options.placeholder) === "string" ? new FixedUiElement_1.FixedUiElement(options.placeholder) :
((_c = options.placeholder) !== null && _c !== void 0 ? _c : new FixedUiElement_1.FixedUiElement(""));
_this._toString = (_d = options.toString) !== null && _d !== void 0 ? _d : (function (t) { return ("" + t); });
var self = _this;
_this.mappedValue.addCallback(function (t) {
if (t === undefined && t === null) {
return;
}
var field = document.getElementById('text-' + _this.id);
if (field === undefined || field === null) {
return;
}
// @ts-ignore
field.value = options.toString(t);
});
return _this;
}
TextField.prototype.GetValue = function () {
return this.mappedValue;
};
TextField.prototype.InnerRender = function () {
return "<form onSubmit='return false' class='form-text-field'>" +
"<input type='text' placeholder='" + this._placeholder.InnerRender() + "' id='text-" + this.id + "'>" +
"</form>";
};
TextField.prototype.InnerUpdate = function (htmlElement) {
var field = document.getElementById('text-' + this.id);
if (field === null) {
return;
}
var self = this;
field.oninput = function () {
// @ts-ignore
self.value.setData(field.value);
};
field.addEventListener("keyup", function (event) {
if (event.key === "Enter") {
// @ts-ignore
self.enterPressed.setData(field.value);
}
});
};
TextField.prototype.IsValid = function (t) {
if (t === undefined || t === null) {
return false;
}
var result = this._toString(t);
return result !== undefined && result !== null;
};
TextField.prototype.Clear = function () {
var field = document.getElementById('text-' + this.id);
if (field !== undefined) {
// @ts-ignore
field.value = "";
}
};
return TextField;
}(InputElement_1.InputElement));
exports.TextField = TextField;

56
UI/MessageBoxHandler.js Normal file
View file

@ -0,0 +1,56 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MessageBoxHandler = void 0;
/**
* Keeps 'messagebox' and 'messageboxmobile' in sync, shows a 'close' button on the latter one
*/
var UIEventSource_1 = require("./UIEventSource");
var VariableUIElement_1 = require("./Base/VariableUIElement");
var MessageBoxHandler = /** @class */ (function () {
function MessageBoxHandler(uielement, onClear) {
this._uielement = uielement;
this.listenTo(uielement);
this.update();
window.onhashchange = function () {
if (location.hash === "") {
// No more element: back to the map!
uielement.setData(undefined);
onClear();
}
};
new VariableUIElement_1.VariableUiElement(new UIEventSource_1.UIEventSource("<h2>Naar de kaart</h2>"), function () {
document.getElementById("to-the-map").onclick = function () {
uielement.setData(undefined);
onClear();
};
}).AttachTo("to-the-map");
}
MessageBoxHandler.prototype.listenTo = function (uiEventSource) {
var self = this;
uiEventSource.addCallback(function () {
self.update();
});
};
MessageBoxHandler.prototype.update = function () {
var _a, _b, _c;
var wrapper = document.getElementById("messagesboxmobilewrapper");
var gen = this._uielement.data;
console.log("Generator: ", gen);
if (gen === undefined) {
wrapper.classList.add("hidden");
if (location.hash !== "") {
location.hash = "";
}
return;
}
location.hash = "#element";
wrapper.classList.remove("hidden");
/* gen()
?.HideOnEmpty(true)
?.AttachTo("messagesbox")
?.Activate();*/
(_c = (_b = (_a = gen()) === null || _a === void 0 ? void 0 : _a.HideOnEmpty(true)) === null || _b === void 0 ? void 0 : _b.AttachTo("messagesboxmobile")) === null || _c === void 0 ? void 0 : _c.Activate();
};
return MessageBoxHandler;
}());
exports.MessageBoxHandler = MessageBoxHandler;

49
UI/PendingChanges.js Normal file
View file

@ -0,0 +1,49 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.PendingChanges = void 0;
var UIElement_1 = require("./UIElement");
var PendingChanges = /** @class */ (function (_super) {
__extends(PendingChanges, _super);
function PendingChanges(changes, countdown) {
var _this = _super.call(this, changes.pendingChangesES) || this;
_this.ListenTo(changes.isSaving);
_this.ListenTo(countdown);
_this._pendingChangesCount = changes.pendingChangesES;
_this._countdown = countdown;
_this._isSaving = changes.isSaving;
_this.onClick(function () {
changes.uploadAll();
});
return _this;
}
PendingChanges.prototype.InnerRender = function () {
if (this._isSaving.data) {
return "<span class='alert'>Saving</span>";
}
if (this._pendingChangesCount.data == 0) {
return "";
}
var restingSeconds = this._countdown.data / 1000;
var dots = "";
while (restingSeconds > 0) {
dots += ".";
restingSeconds = restingSeconds - 1;
}
return "Saving " + this._pendingChangesCount.data;
};
return PendingChanges;
}(UIElement_1.UIElement));
exports.PendingChanges = PendingChanges;

51
UI/QuestionPicker.js Normal file
View file

@ -0,0 +1,51 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.QuestionPicker = void 0;
var UIElement_1 = require("./UIElement");
var QuestionPicker = /** @class */ (function (_super) {
__extends(QuestionPicker, _super);
function QuestionPicker(questions, tags) {
var _this = _super.call(this, tags) || this;
_this._questions = questions;
_this.tags = tags.data;
_this.source = tags;
return _this;
}
QuestionPicker.prototype.InnerRender = function () {
var t = this.tags;
var highestPriority = Number.MIN_VALUE;
var highestQ;
for (var _i = 0, _a = this._questions; _i < _a.length; _i++) {
var q = _a[_i];
if (!q.Applicable(t)) {
continue;
}
var priority = q.question.severity;
if (priority > highestPriority) {
highestPriority = priority;
highestQ = q;
}
}
if (highestQ === undefined) {
return "Er zijn geen vragen meer!";
}
return "<div class='question'>" +
highestQ.CreateHtml(this.source).Render() +
"</div>";
};
return QuestionPicker;
}(UIElement_1.UIElement));
exports.QuestionPicker = QuestionPicker;

38
UI/SaveButton.js Normal file
View file

@ -0,0 +1,38 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SaveButton = void 0;
var UIElement_1 = require("./UIElement");
var SaveButton = /** @class */ (function (_super) {
__extends(SaveButton, _super);
function SaveButton(value) {
var _this = _super.call(this, value) || this;
if (value === undefined) {
throw "No event source for savebutton, something is wrong";
}
_this._value = value;
return _this;
}
SaveButton.prototype.InnerRender = function () {
if (this._value.data === undefined ||
this._value.data === null
|| this._value.data === "") {
return "<span class='save-non-active'>Opslaan</span>";
}
return "<span class='save'>Opslaan</span>";
};
return SaveButton;
}(UIElement_1.UIElement));
exports.SaveButton = SaveButton;

83
UI/SearchAndGo.js Normal file
View file

@ -0,0 +1,83 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SearchAndGo = void 0;
var UIElement_1 = require("./UIElement");
var TextField_1 = require("./Input/TextField");
var UIEventSource_1 = require("./UIEventSource");
var FixedUiElement_1 = require("./Base/FixedUiElement");
var Geocoding_1 = require("../Logic/Geocoding");
var SearchAndGo = /** @class */ (function (_super) {
__extends(SearchAndGo, _super);
function SearchAndGo(map) {
var _this = _super.call(this, undefined) || this;
_this._placeholder = new UIEventSource_1.UIEventSource("Zoek naar een locatie...");
_this._searchField = new TextField_1.TextField({
placeholder: _this._placeholder
});
_this._foundEntries = new UIEventSource_1.UIEventSource([]);
_this._goButton = new FixedUiElement_1.FixedUiElement("<img class='search-go' src='./assets/search.svg' alt='GO'>");
_this._map = map;
_this.ListenTo(_this._foundEntries);
var self = _this;
_this._searchField.enterPressed.addCallback(function () {
self.RunSearch();
});
_this._goButton.onClick(function () {
self.RunSearch();
});
return _this;
}
// Triggered by 'enter' or onclick
SearchAndGo.prototype.RunSearch = function () {
var _this = this;
var searchString = this._searchField.GetValue().data;
this._searchField.Clear();
this._placeholder.setData("Bezig met zoeken...");
var self = this;
Geocoding_1.Geocoding.Search(searchString, this._map, function (result) {
if (result.length == 0) {
_this._placeholder.setData("Niets gevonden");
return;
}
var bb = result[0].boundingbox;
var bounds = [
[bb[0], bb[2]],
[bb[1], bb[3]]
];
self._map.map.fitBounds(bounds);
_this._placeholder.setData("Zoek naar een locatie...");
}, function () {
_this._placeholder.setData("Niets gevonden: er ging iets mis");
});
};
SearchAndGo.prototype.InnerRender = function () {
// "<img class='search' src='./assets/search.svg' alt='Search'> " +
return this._searchField.Render() +
this._goButton.Render();
};
SearchAndGo.prototype.Update = function () {
_super.prototype.Update.call(this);
this._searchField.Update();
this._goButton.Update();
};
SearchAndGo.prototype.Activate = function () {
_super.prototype.Activate.call(this);
this._searchField.Activate();
this._goButton.Activate();
};
return SearchAndGo;
}(UIElement_1.UIElement));
exports.SearchAndGo = SearchAndGo;

84
UI/SimpleAddUI.js Normal file
View file

@ -0,0 +1,84 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SimpleAddUI = void 0;
var UIElement_1 = require("./UIElement");
var FixedUiElement_1 = require("./Base/FixedUiElement");
var Button_1 = require("./Base/Button");
/**
* Asks to add a feature at the last clicked location, at least if zoom is sufficient
*/
var SimpleAddUI = /** @class */ (function (_super) {
__extends(SimpleAddUI, _super);
function SimpleAddUI(zoomlevel, lastClickLocation, changes, selectedElement, dataIsLoading, userDetails, addButtons) {
var _this = _super.call(this, zoomlevel) || this;
_this._zoomlevel = zoomlevel;
_this._lastClickLocation = lastClickLocation;
_this._changes = changes;
_this._selectedElement = selectedElement;
_this._dataIsLoading = dataIsLoading;
_this._userDetails = userDetails;
_this.ListenTo(userDetails);
_this.ListenTo(dataIsLoading);
_this._addButtons = [];
for (var _i = 0, addButtons_1 = addButtons; _i < addButtons_1.length; _i++) {
var option = addButtons_1[_i];
// <button type='button'> looks SO retarded
// the default type of button is 'submit', which performs a POST and page reload
var button = new Button_1.Button(new FixedUiElement_1.FixedUiElement("Voeg hier een " + option.name + " toe"), _this.CreatePoint(option));
_this._addButtons.push(button);
}
return _this;
}
SimpleAddUI.prototype.CreatePoint = function (option) {
var self = this;
return function () {
console.log("Creating a new ", option.name, " at last click location");
var loc = self._lastClickLocation.data;
var feature = self._changes.createElement(option.tags, loc.lat, loc.lon);
option.layerToAddTo.AddNewElement(feature);
self._selectedElement.setData(feature.properties);
};
};
SimpleAddUI.prototype.InnerRender = function () {
var header = "<h2>Geen selectie</h2>" +
"Je klikte ergens waar er nog geen gezochte data is.<br/>";
if (!this._userDetails.data.loggedIn) {
return header + "<a class='activate-osm-authentication'>Gelieve je aan te melden om een nieuw punt toe te voegen</a>";
}
if (this._zoomlevel.data.zoom < 19) {
return header + "Zoom verder in om een element toe te voegen.";
}
if (this._dataIsLoading.data) {
return header + "De data is nog aan het laden. Nog even geduld, dan kan je een punt toevoegen";
}
var html = "";
for (var _i = 0, _a = this._addButtons; _i < _a.length; _i++) {
var button = _a[_i];
html += button.Render();
}
return header + html;
};
SimpleAddUI.prototype.InnerUpdate = function (htmlElement) {
_super.prototype.InnerUpdate.call(this, htmlElement);
for (var _i = 0, _a = this._addButtons; _i < _a.length; _i++) {
var button = _a[_i];
button.Update();
}
this._userDetails.data.osmConnection.registerActivateOsmAUthenticationClass();
};
return SimpleAddUI;
}(UIElement_1.UIElement));
exports.SimpleAddUI = SimpleAddUI;

92
UI/SlideShow.js Normal file
View file

@ -0,0 +1,92 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SlideShow = void 0;
var UIElement_1 = require("./UIElement");
var UIEventSource_1 = require("./UIEventSource");
var FixedUiElement_1 = require("./Base/FixedUiElement");
var SlideShow = /** @class */ (function (_super) {
__extends(SlideShow, _super);
function SlideShow(embeddedElements, noImages) {
var _this = _super.call(this, embeddedElements) || this;
_this._currentSlide = new UIEventSource_1.UIEventSource(0);
_this._embeddedElements = embeddedElements;
_this.ListenTo(_this._currentSlide);
_this._noimages = noImages;
var self = _this;
_this._prev = new FixedUiElement_1.FixedUiElement("<div class='prev-button'>" +
"<div class='vspan'></div>" +
"<img src='assets/arrow-left-smooth.svg' alt='Prev'/>" +
"</div>")
.onClick(function () {
var current = self._currentSlide.data;
self.MoveTo(current - 1);
});
_this._next = new FixedUiElement_1.FixedUiElement("<div class='next-button'>" +
"<div class='vspan'></div>" +
"<img src='assets/arrow-right-smooth.svg' alt='Next'/>" +
"</div>")
.onClick(function () {
var current = self._currentSlide.data;
self.MoveTo(current + 1);
});
return _this;
}
SlideShow.prototype.InnerRender = function () {
if (this._embeddedElements.data.length == 0) {
return this._noimages.Render();
}
if (this._embeddedElements.data.length == 1) {
return "<div class='image-slideshow'><div class='slides'><div class='slide'>" +
this._embeddedElements.data[0].Render() +
"</div></div></div>";
}
var slides = "";
for (var i = 0; i < this._embeddedElements.data.length; i++) {
var embeddedElement = this._embeddedElements.data[i];
var state = "hidden";
if (this._currentSlide.data === i) {
state = "active-slide";
}
slides += " <div class=\"slide " + state + "\">" + embeddedElement.Render() + "</div>\n";
}
return "<div class='image-slideshow'>"
+ this._prev.Render()
+ "<div class='slides'>" + slides + "</div>"
+ this._next.Render()
+ "</div>";
};
SlideShow.prototype.MoveTo = function (index) {
if (index < 0) {
index = this._embeddedElements.data.length - 1;
}
index = index % this._embeddedElements.data.length;
this._currentSlide.setData(index);
};
SlideShow.prototype.InnerUpdate = function (htmlElement) {
this._next.Update();
this._prev.Update();
};
SlideShow.prototype.Activate = function () {
for (var _i = 0, _a = this._embeddedElements.data; _i < _a.length; _i++) {
var embeddedElement = _a[_i];
embeddedElement.Activate();
}
this._next.Update();
this._prev.Update();
};
return SlideShow;
}(UIElement_1.UIElement));
exports.SlideShow = SlideShow;

115
UI/UIElement.js Normal file
View file

@ -0,0 +1,115 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UIElement = void 0;
var FixedUiElement_1 = require("./Base/FixedUiElement");
var UIElement = /** @class */ (function () {
function UIElement(source) {
this._hideIfEmpty = false;
this.id = "ui-element-" + UIElement.nextId;
this._source = source;
UIElement.nextId++;
this.ListenTo(source);
}
UIElement.prototype.ListenTo = function (source) {
if (source === undefined) {
return;
}
var self = this;
source.addCallback(function () {
self.Update();
});
};
UIElement.prototype.onClick = function (f) {
this._onClick = f;
this.Update();
return this;
};
UIElement.Fix = function (element) {
if (typeof (element) === 'string') {
return new FixedUiElement_1.FixedUiElement(element);
}
return element;
};
UIElement.prototype.Update = function () {
var element = document.getElementById(this.id);
if (element === null || element === undefined) {
// The element is not painted
return;
}
element.innerHTML = this.InnerRender();
if (this._hideIfEmpty) {
if (element.innerHTML === "") {
element.parentElement.style.display = "none";
}
else {
element.parentElement.style.display = undefined;
}
}
if (this._onClick !== undefined) {
var self_1 = this;
element.onclick = function () {
self_1._onClick();
};
element.style.pointerEvents = "all";
element.style.cursor = "pointer";
}
this.InnerUpdate(element);
for (var i in this) {
var child = this[i];
if (child instanceof UIElement) {
child.Update();
}
else if (child instanceof Array) {
for (var _i = 0, child_1 = child; _i < child_1.length; _i++) {
var ch = child_1[_i];
if (ch instanceof UIElement) {
ch.Update();
}
}
}
}
};
UIElement.prototype.HideOnEmpty = function (hide) {
this._hideIfEmpty = hide;
this.Update();
return this;
};
// Called after the HTML has been replaced. Can be used for css tricks
UIElement.prototype.InnerUpdate = function (htmlElement) { };
UIElement.prototype.Render = function () {
return "<span class='uielement' id='" + this.id + "'>" + this.InnerRender() + "</span>";
};
UIElement.prototype.AttachTo = function (divId) {
var element = document.getElementById(divId);
if (element === null) {
console.log("SEVERE: could not attach UIElement to ", divId);
return;
}
element.innerHTML = this.Render();
this.Update();
return this;
};
UIElement.prototype.Activate = function () {
for (var i in this) {
var child = this[i];
if (child instanceof UIElement) {
child.Activate();
}
else if (child instanceof Array) {
for (var _i = 0, child_2 = child; _i < child_2.length; _i++) {
var ch = child_2[_i];
if (ch instanceof UIElement) {
ch.Activate();
}
}
}
}
};
;
UIElement.prototype.IsEmpty = function () {
return this.InnerRender() === "";
};
UIElement.nextId = 0;
return UIElement;
}());
exports.UIElement = UIElement;

58
UI/UIEventSource.js Normal file
View file

@ -0,0 +1,58 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UIEventSource = void 0;
var UIEventSource = /** @class */ (function () {
function UIEventSource(data) {
this._callbacks = [];
this.data = data;
}
UIEventSource.prototype.addCallback = function (callback) {
this._callbacks.push(callback);
return this;
};
UIEventSource.prototype.setData = function (t) {
if (this.data === t) {
return;
}
this.data = t;
this.ping();
};
UIEventSource.prototype.ping = function () {
for (var _i = 0, _a = this._callbacks; _i < _a.length; _i++) {
var callback = _a[_i];
callback(this.data);
}
};
UIEventSource.flatten = function (source, possibleSources) {
var _a;
var sink = new UIEventSource((_a = source.data) === null || _a === void 0 ? void 0 : _a.data);
source.addCallback(function (latestData) {
sink.setData(latestData === null || latestData === void 0 ? void 0 : latestData.data);
});
for (var _i = 0, possibleSources_1 = possibleSources; _i < possibleSources_1.length; _i++) {
var possibleSource = possibleSources_1[_i];
possibleSource.addCallback(function () {
var _a;
sink.setData((_a = source.data) === null || _a === void 0 ? void 0 : _a.data);
});
}
return sink;
};
UIEventSource.prototype.map = function (f, extraSources) {
if (extraSources === void 0) { extraSources = []; }
var self = this;
var update = function () {
newSource.setData(f(self.data));
newSource.ping();
};
this.addCallback(update);
for (var _i = 0, extraSources_1 = extraSources; _i < extraSources_1.length; _i++) {
var extraSource = extraSources_1[_i];
extraSource.addCallback(update);
}
var newSource = new UIEventSource(f(this.data));
return newSource;
};
return UIEventSource;
}());
exports.UIEventSource = UIEventSource;

Some files were not shown because too many files have changed in this diff Show more