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": "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": {
"en": "What is the smoothness of this cycleway?",

View file

@ -53,6 +53,8 @@
"favouritePoi": {
"button": {
"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",
"markDescription": "Add this location to a personal list of your favourites",
"unmark": "Remove from your personal list of favourites",
@ -172,12 +174,14 @@
"openIssueTracker": "File a bug",
"openMapillary": "Open Mapillary here",
"openOsmcha": "See latest edits made with {theme}",
"seeOnMapillary": "See this image on Mapillary",
"themeBy": "Theme maintained by {author}",
"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>"
},
"back": "Back",
"backToIndex": "Go back to the overview with all thematic maps",
"backToMap": "Back to the map",
"backgroundMap": "Select a background layer",
"backgroundSwitch": "Switch background",
"cancel": "Cancel",
@ -224,6 +228,14 @@
"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": {
"title": "Select layers",
"zoomInToSeeThisLayer": "Zoom in to see this layer"
@ -324,6 +336,7 @@
"searchShort": "Search…",
"searching": "Searching…"
},
"share": "Share",
"sharescreen": {
"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>",
@ -679,6 +692,10 @@
"description": "a positive, whole number",
"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": {
"description": "a piece of text"
},

View file

@ -1,19 +1,12 @@
import { ValidatorType } from "./Validators"
import { UIEventSource } from "../../Logic/UIEventSource"
import { MapProperties } from "../../Models/MapProperties"
import BaseUIElement from "../BaseUIElement"
import WikidataSearchBox from "../Wikipedia/WikidataSearchBox"
import Wikidata from "../../Logic/Web/Wikidata"
import { Utils } from "../../Utils"
import Locale from "../i18n/Locale"
import { Feature } from "geojson"
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 {
/**

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)
}
}