Small fixes in CustomGenerator; artworkmap is now a json-preset

This commit is contained in:
Pieter Vander Vennet 2020-08-25 02:12:26 +02:00
parent c8b2dab669
commit 1cdf2ee9bc
9 changed files with 224 additions and 150 deletions

View file

@ -6,7 +6,6 @@ import {Groen} from "./Layouts/Groen";
import Cyclofix from "./Layouts/Cyclofix";
import {StreetWidth} from "./Layouts/StreetWidth";
import {GRB} from "./Layouts/GRB";
import {Artworks} from "./Layouts/Artworks";
import {ClimbingTrees} from "./Layouts/ClimbingTrees";
import {Smoothness} from "./Layouts/Smoothness";
import {MetaMap} from "./Layouts/MetaMap";
@ -16,6 +15,7 @@ import {CustomLayoutFromJSON} from "./JSON/CustomLayoutFromJSON";
import * as bookcases from "../assets/themes/bookcases/Bookcases.json";
import * as aed from "../assets/themes/aed/aed.json";
import * as toilets from "../assets/themes/toilets/toilets.json";
import * as artworks from "../assets/themes/artwork/artwork.json";
export class AllKnownLayouts {
@ -30,11 +30,11 @@ export class AllKnownLayouts {
CustomLayoutFromJSON.LayoutFromJSON(bookcases),
CustomLayoutFromJSON.LayoutFromJSON(aed),
CustomLayoutFromJSON.LayoutFromJSON(toilets),
CustomLayoutFromJSON.LayoutFromJSON(artworks),
new MetaMap(),
new StreetWidth(),
new ClimbingTrees(),
new Artworks(),
new Smoothness(),
new Groen(),

View file

@ -1,88 +0,0 @@
import {LayerDefinition} from "../LayerDefinition";
import {Tag} from "../../Logic/TagsFilter";
import L from "leaflet";
import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload";
import Translations from "../../UI/i18n/Translations";
import Website from "../Questions/Website";
import FixedText from "../Questions/FixedText";
import {TagRenderingOptions} from "../TagRenderingOptions";
export class Artwork extends LayerDefinition {
constructor() {
super("artwork");
this.name = "artwork";
const t = Translations.t.artwork;
this.title = t.title;
const tag = new Tag("tourism", "artwork");
this.presets = [
{
title: this.title,
tags: [tag]
}
];
this.icon = "./assets/statue.svg";
this.overpassFilter = tag;
this.minzoom = 13;
const to = Translations.t.artwork.type;
const artworkType = new TagRenderingOptions({
priority: 5,
question: to.question,
freeform: {
key: "artwork_type",
extraTags: new Tag("fixme", "Freeform artwork_type= tag used: possibly a wrong value"),
template: to.template.txt,
renderTemplate: to.render.txt,
placeholder: Translations.t.cyclofix.freeFormPlaceholder,
},
mappings: [
{k: new Tag("artwork_type", "architecture"), txt: to.architecture},
{k: new Tag("artwork_type", "mural"), txt: to.mural},
{k: new Tag("artwork_type", "painting"), txt: to.painting},
{k: new Tag("artwork_type", "sculpture"), txt: to.sculpture},
{k: new Tag("artwork_type", "statue"), txt: to.statue},
{k: new Tag("artwork_type", "bust"), txt: to.bust},
{k: new Tag("artwork_type", "stone"), txt: to.stone},
{k: new Tag("artwork_type", "installation"), txt: to.installation},
{k: new Tag("artwork_type", "graffiti"), txt: to.graffiti},
{k: new Tag("artwork_type", "relief"), txt: to.relief},
{k: new Tag("artwork_type", "azulejo"), txt: to.azulejo},
{k: new Tag("artwork_type", "tilework"), txt: to.tilework}
]
});
const artistQuestion = new TagRenderingOptions({
question: t.artist.question,
freeform: {
key: "artist_name",
template: "$$$",
renderTemplate: "{artist_name}"
}
});
this.elementsToShow = [
new ImageCarouselWithUploadConstructor(),
artworkType,
artistQuestion,
new Website(t.title)
];
this.style = function (tags) {
return {
icon: {
iconUrl: "./assets/statue.svg",
iconSize: [40, 40],
},
color: "#0000ff"
};
}
}
}

View file

@ -1,17 +0,0 @@
import {Layout} from "../Layout";
import {Artwork} from "../Layers/Artwork";
export class Artworks extends Layout{
constructor() {
super( "artworks",
["en","nl","fr"],
"Open Artwork Map",
[new Artwork()],
10,
50.8435,
4.3688,
"<h3>Open Artwork Map</h3>");
this.icon = "./assets/statue.svg"
}
}

View file

@ -24,7 +24,7 @@ export class State {
// The singleton of the global state
public static state: State;
public static vNumber = "0.0.6a";
public static vNumber = "0.0.6b";
// The user journey states thresholds when a new feature gets unlocked
public static userJourney = {

View file

@ -578,17 +578,20 @@ export class ThemeGenerator extends UIElement {
textField = new TextField<string>({
placeholder: "single key",
startValidated: false,
value: new UIEventSource<string>(""),
value:value,
toString: str => str,
fromString: str => {
if(str === undefined){
return "";
}
if (str === "*") {
return str;
}
str = str.trim();
if (str.match("^_*[a-zA-Z]*[a-zA-Z0-9:]*$") == null) {
if (str.match("^_*[a-zA-Z]*[a-zA-Z0-9:_]*$") == null) {
return undefined;
}
return str.trim();
return str;
}
})
@ -619,13 +622,18 @@ export class ThemeGenerator extends UIElement {
});
}
let sendingPing = false;
value.addCallback((v) => {
if (v === undefined || v === "") {
delete root[key];
} else {
root[key] = v;
}
self.themeObject.ping(); // We assume the root is a part of the themeObject
if(!sendingPing){
sendingPing = true;
self.themeObject.ping(); // We assume the root is a part of the themeObject
sendingPing = false;
}
});
self.themeObject.addCallback(() => {

View file

@ -13,6 +13,7 @@ export class ValidatedTextField {
"$": (str) => true,
"string": (str) => true,
"date": (str) => true, // TODO validate and add a date picker
"wikidata": (str) => true, // TODO validate wikidata IDS
"int": (str) => {str = ""+str; return str !== undefined && str.indexOf(".") < 0 && !isNaN(Number(str))},
"nat": (str) => {str = ""+str; return str !== undefined && str.indexOf(".") < 0 && !isNaN(Number(str)) && Number(str) > 0},
"float": (str) => !isNaN(Number(str)),

View file

@ -62,14 +62,19 @@ export class MoreScreen extends UIElement {
}
if (layout.name === CustomLayout.NAME) {
continue;
continue;
}
const currentLocation = State.state.locationControl.data;
const linkText =
`https://pietervdvn.github.io/MapComplete/${layout.name}.html?z=${currentLocation.zoom}&lat=${currentLocation.lat}&lon=${currentLocation.lon}`
let linkText =
`./${layout.name}.html?z=${currentLocation.zoom}&lat=${currentLocation.lat}&lon=${currentLocation.lon}`
if (location.hostname === "localhost" || location.hostname === "127.0.0.1") {
linkText = `./index.html?layout=${layout.name}&z=${currentLocation.zoom}&lat=${currentLocation.lat}&lon=${currentLocation.lon}`
}
let description = Translations.W(layout.description);
if(description !== undefined){
if (description !== undefined) {
description = new Combine(["<br/>", description]);
}
const link =

View file

@ -29,38 +29,7 @@ export default class Translations {
},
artwork: {
name: new T({ en: 'Artwork', nl: 'Kunstwerk', fr: "Oeuvre d'art" }),
title: new T({ en: 'Artwork', nl: 'Kunstwerk', fr: "Oeuvre d'art" }),
type: {
render: new T({
en: 'This is artwork of the type: {artwork_type}',
nl: 'Dit is een kunstwerk van het type: {artwork_type}',
fr: "Ceci est un travail d'art de type: {artwork_type}"
}),
template: new T({ en: 'Some other type: $$$', nl: 'Een ander type: $$$', fr: 'Un autre type: $$$' }),
question: new T({
en: 'What is the type of this artwork?',
nl: 'Wat voor type kunstwerk is dit?',
fr: "Quel est le type de cette oeuvre d'art?"
}),
architecture: new T({ en: "architecture", nl: "architectuur", fr: "architecture" }),
mural: new T({ en: "mural", nl: "muurschildering", fr: "mural" }),
painting: new T({ en: "painting", nl: "schilderij", fr: "peinture" }),
sculpture: new T({ en: "sculpture", nl: "beeldhouwwerk", fr: "sculpture" }),
statue: new T({ en: "statue", nl: "standbeeld", fr: "statue" }),
bust: new T({ en: "bust", nl: "buste", fr: "buste" }),
stone: new T({ en: "stone", nl: "steen", fr: "rocher" }),
installation: new T({ en: "installation", nl: "installatie", fr: "installation" }),
graffiti: new T({ en: "graffiti", nl: "graffiti", fr: "graffiti" }),
relief: new T({ en: "relief", nl: "verlichting", fr: "relief" }),
azulejo: new T({ en: "azulejo", nl: "azulejo", fr: "azulejo" }),
tilework: new T({ en: "tilework", nl: "tegelwerk", fr: "carrelage" })
}, artist: {
question: new T({en:"Which artist created this artwork?"})
}
},
cyclofix: {
title: new T({
en: 'Cyclofix - an open map for cyclists',
@ -754,7 +723,7 @@ export default class Translations {
header: new T({
en: "<h2>Add a point?</h2>You clicked somewhere where no data is known yet.<br/>",
nl: "<h2>Punt toevoegen?</h2>Je klikte ergens waar er nog geen data is.<br/>",
fr: "<h2>Pas de données</h2> vous avez cliqué sur un endroit ou il n'y a pas encore de données. <br/>"
fr: "<h2>Pas de données</h2>Vous avez cliqué sur un endroit ou il n'y a pas encore de données. <br/>"
}),
pleaseLogin: new T({

View file

@ -1,2 +1,198 @@
{
{
"startLat": 0,
"startLon": 0,
"startZoom": 12,
"maintainer": "Not logged in",
"language": [
"en",
"nl"
],
"widenFactor": 0.07,
"name": "artworks",
"title": {
"en": "Open Artwork Map",
"nl": "Kunstwerkenkaart"
},
"icon": "./assets/themes/artwork/artwork.svg",
"description": {
"en": "Welcome to Open Artwork Map, a map of statues, busts, grafittis, ... all over the world",
"nl": "Welkom op de Open Kunstwerken Kaart"
},
"layers": [
{
"id": "Artwork",
"title": {
"key": "*",
"render": {
"en": "Artwork",
"nl": "Kunstwerk",
"fr": "Oeuvre d'art"
}
},
"icon": {
"key": "*",
"render": "./assets/themes/artwork/artwork.svg"
},
"color": {
"key": "*",
"render": "#0000ff"
},
"width": {
"key": "*",
"render": "10"
},
"description": {
"en": "",
"nl": ""
},
"minzoom": 12,
"wayHandling": 2,
"presets": [
{
"tags": "tourism=artwork",
"title": {
"en": "Artwork"
}
}
],
"tagRenderings": [
{
"mappings": [
{
"if": "a=b",
"then": "xyz"
},
{
"if": "artwork_type=architecture",
"then": {
"en": "architecture",
"nl": "architectuur",
"fr": "architecture"
}
},
{
"if": "artwork_type=mural",
"then": {
"en": "mural",
"nl": "muurschildering",
"fr": "mural"
}
},
{
"if": "artwork_type=painting",
"then": {
"en": "painting",
"nl": "schilderij",
"fr": "peinture"
}
},
{
"if": "artwork_type=sculpture",
"then": {
"en": "sculpture",
"nl": "beeldhouwwerk",
"fr": "sculpture"
}
},
{
"if": "artwork_type=statue",
"then": {
"en": "statue",
"nl": "standbeeld",
"fr": "statue"
}
},
{
"if": "artwork_type=bust",
"then": {
"en": "bust",
"nl": "buste",
"fr": "buste"
}
},
{
"if": "artwork_type=stone",
"then": {
"en": "stone",
"nl": "steen",
"fr": "rocher"
}
},
{
"if": "artwork_type=installation",
"then": {
"en": "installation",
"nl": "installatie",
"fr": "installation"
}
},
{
"if": "artwork_type=graffiti",
"then": {
"en": "graffiti",
"nl": "graffiti",
"fr": "graffiti"
}
},
{
"if": "artwork_type=relief",
"then": {
"en": "relief",
"nl": "verlichting",
"fr": "relief"
}
},
{
"if": "artwork_type=azulejo",
"then": {
"en": "azulejo",
"nl": "azulejo",
"fr": "azulejo"
}
},
{
"if": "artwork_type=tilework",
"then": {
"en": "tilework",
"nl": "tegelwerk",
"fr": "carrelage"
}
}
],
"key": "artwork_type",
"render": {
"en": "This is a {artwork_type}",
"nl": "Dit is een {artwork_type}",
"fr": "{artwork_type}"
},
"type": "text",
"question": {
"en": "What is the type of this artwork?",
"nl": "Wat voor soort kunstwerk is dit?",
"fr": "Quel est le type de cette oeuvre d'art?"
},
"addExtraTags": "fixme=Artowrk type was added with the freeform, might need another check"
},
{
"question": "Which wikidata-entry corresponds with <b>this artwork</b>?",
"key": "wikidata",
"type": "wikidata",
"render": "Corresponds with <a href='https://www.wikidata.org/wiki/{wikidata}' target='_blank'>{wikidata}</a>"
},
{
"question": "Which artist created this?",
"key": "artist_name",
"render": "Created by {artist_name}",
"condition": "wikidata="
},
{
"question": "On which website is more information about this artwork?",
"key": "website",
"type": "url",
"render": "More information on {website}"
}
],
"overpassTags": "tourism=artwork"
}
]
}