Feature: add slope measurement input

This commit is contained in:
Pieter Vander Vennet 2023-12-14 15:41:34 +01:00
parent 48ac539272
commit fdf38daf5e
5 changed files with 65 additions and 7 deletions

View file

@ -837,6 +837,41 @@
}, },
"id": "Cycleway:surface" "id": "Cycleway:surface"
}, },
{
"id": "incline",
"question": {
"en": "Does {title()} have an incline?"
},
"render": {
"en": "This road has an slope of {incline}"
},
"freeform": {
"key": "incline",
"type": "slope"
},
"mappings": [
{
"if": "incline=",
"then": {
"en": "There is (probably) no incline here"
},
"hideInAnswer": true
},
{
"if": {
"or": [
"incline=up",
"incline=down",
"incline=yes"
]
},
"then": {
"en": "This road has a slope"
},
"hideInAnswer": true
}
]
},
{ {
"question": { "question": {
"en": "What is the smoothness of this cycleway?", "en": "What is the smoothness of this cycleway?",

View file

@ -53,6 +53,8 @@
"favouritePoi": { "favouritePoi": {
"button": { "button": {
"isFavourite": "This location is currently marked as favourite and will show up on all thematic maps of MapComplete you visit.", "isFavourite": "This location is currently marked as favourite and will show up on all thematic maps of MapComplete you visit.",
"isMarkedShort": "Marked as favourite location",
"isNotMarkedShort": "Not marked as favourite",
"markAsFavouriteTitle": "Mark this location as favourite location", "markAsFavouriteTitle": "Mark this location as favourite location",
"markDescription": "Add this location to a personal list of your favourites", "markDescription": "Add this location to a personal list of your favourites",
"unmark": "Remove from your personal list of favourites", "unmark": "Remove from your personal list of favourites",
@ -172,12 +174,14 @@
"openIssueTracker": "File a bug", "openIssueTracker": "File a bug",
"openMapillary": "Open Mapillary here", "openMapillary": "Open Mapillary here",
"openOsmcha": "See latest edits made with {theme}", "openOsmcha": "See latest edits made with {theme}",
"seeOnMapillary": "See this image on Mapillary",
"themeBy": "Theme maintained by {author}", "themeBy": "Theme maintained by {author}",
"title": "Copyright and attribution", "title": "Copyright and attribution",
"translatedBy": "MapComplete has been translated by {contributors} and <a href='https://github.com/pietervdvn/MapComplete/graphs/contributors' target='_blank'>{hiddenCount} more contributors</a>" "translatedBy": "MapComplete has been translated by {contributors} and <a href='https://github.com/pietervdvn/MapComplete/graphs/contributors' target='_blank'>{hiddenCount} more contributors</a>"
}, },
"back": "Back", "back": "Back",
"backToIndex": "Go back to the overview with all thematic maps", "backToIndex": "Go back to the overview with all thematic maps",
"backToMap": "Back to the map",
"backgroundMap": "Select a background layer", "backgroundMap": "Select a background layer",
"backgroundSwitch": "Switch background", "backgroundSwitch": "Switch background",
"cancel": "Cancel", "cancel": "Cancel",
@ -224,6 +228,14 @@
"histogram": { "histogram": {
"error_loading": "Could not load the histogram" "error_loading": "Could not load the histogram"
}, },
"labels": {
"background": "Change background",
"filter": "Filter data",
"jumpToLocation": "Go to your current location",
"menu": "Menu",
"zoomIn": "Zoom in",
"zoomOut": "Zoom out"
},
"layerSelection": { "layerSelection": {
"title": "Select layers", "title": "Select layers",
"zoomInToSeeThisLayer": "Zoom in to see this layer" "zoomInToSeeThisLayer": "Zoom in to see this layer"
@ -324,6 +336,7 @@
"searchShort": "Search…", "searchShort": "Search…",
"searching": "Searching…" "searching": "Searching…"
}, },
"share": "Share",
"sharescreen": { "sharescreen": {
"copiedToClipboard": "Link copied to clipboard", "copiedToClipboard": "Link copied to clipboard",
"documentation": "For more information on available URL-parameters, <a href='https://github.com/pietervdvn/MapComplete/blob/develop/Docs/URL_Parameters.md' target='_blank'>consult the documentation</a>", "documentation": "For more information on available URL-parameters, <a href='https://github.com/pietervdvn/MapComplete/blob/develop/Docs/URL_Parameters.md' target='_blank'>consult the documentation</a>",
@ -679,6 +692,10 @@
"description": "a positive, whole number", "description": "a positive, whole number",
"noZero": "Zero is not allowed" "noZero": "Zero is not allowed"
}, },
"slope": {
"inputExplanation": "Place your phone on the ground with the top side of your phone pointing towards the top of the slope.",
"inputIncorrect": "For correct measurements, make sure the arrow is within the green area."
},
"string": { "string": {
"description": "a piece of text" "description": "a piece of text"
}, },

View file

@ -1,19 +1,12 @@
import { ValidatorType } from "./Validators"
import { UIEventSource } from "../../Logic/UIEventSource" import { UIEventSource } from "../../Logic/UIEventSource"
import { MapProperties } from "../../Models/MapProperties" import { MapProperties } from "../../Models/MapProperties"
import BaseUIElement from "../BaseUIElement"
import WikidataSearchBox from "../Wikipedia/WikidataSearchBox" import WikidataSearchBox from "../Wikipedia/WikidataSearchBox"
import Wikidata from "../../Logic/Web/Wikidata" import Wikidata from "../../Logic/Web/Wikidata"
import { Utils } from "../../Utils" import { Utils } from "../../Utils"
import Locale from "../i18n/Locale" import Locale from "../i18n/Locale"
import { Feature } from "geojson" import { Feature } from "geojson"
import { GeoOperations } from "../../Logic/GeoOperations" import { GeoOperations } from "../../Logic/GeoOperations"
import OpeningHoursInput from "./Helpers/OpeningHoursInput.svelte"
import SvelteUIElement from "../Base/SvelteUIElement"
import DirectionInput from "./Helpers/DirectionInput.svelte"
import DateInput from "./Helpers/DateInput.svelte"
import ColorInput from "./Helpers/ColorInput.svelte"
export interface InputHelperProperties { export interface InputHelperProperties {
/** /**

View file

@ -0,0 +1,13 @@
import NatValidator from "./NatValidator"
export default class SlopeValidator extends NatValidator {
constructor() {
super("slope", "Validates that the slope is a valid number")
}
isValid(str: string): boolean {
if (str.endsWith("%") || str.endsWith("°")) {
str = str.substring(0, str.length - 1)
}
return super.isValid(str)
}
}