Merge develop

This commit is contained in:
Pieter Vander Vennet 2024-09-17 02:36:38 +02:00
commit 5a9f8f0a0a
62 changed files with 4448 additions and 710 deletions

View file

@ -26,7 +26,8 @@ export default class Constants {
"last_click",
"favourite",
"summary",
"search"
"search",
"geocoded_image"
] as const
/**
* Special layers which are not included in a theme by default

View file

@ -22,6 +22,7 @@ export interface MapProperties {
readonly lastClickLocation: Store<{ lon: number; lat: number }>
readonly allowZooming: UIEventSource<true | boolean>
readonly useTerrain: Store<boolean>
readonly showScale: UIEventSource<boolean>
/**
* Triggered when the user navigated by using the keyboard.

View file

@ -722,7 +722,7 @@ export class ValidatePointRendering extends DesugaringStep<PointRenderingConfigJ
if (json.marker && !Array.isArray(json.marker)) {
context.enter("marker").err("The marker in a pointRendering should be an array")
}
if (json.location.length == 0) {
if (!(json.location?.length > 0)) {
context
.enter("location")
.err(

View file

@ -9,6 +9,7 @@ import { QueryParameters } from "../../Logic/Web/QueryParameters"
import { Utils } from "../../Utils"
import { RegexTag } from "../../Logic/Tags/RegexTag"
import MarkdownUtils from "../../Utils/MarkdownUtils"
import Validators, { ValidatorType } from "../../UI/InputElement/Validators"
export type FilterConfigOption = {
question: Translation
@ -18,7 +19,7 @@ export type FilterConfigOption = {
osmTags: TagsFilter | undefined
/* Only set if fields are present. Used to create `osmTags` (which are used to _actually_ filter) when the field is written*/
readonly originalTagsSpec: TagConfigJson
fields: { name: string; type: string }[]
fields: { name: string; type: ValidatorType }[]
}
export default class FilterConfig {
public readonly id: string
@ -58,8 +59,11 @@ export default class FilterConfig {
throw `Invalid filter: no question given at ${ctx}`
}
const fields: { name: string; type: string }[] = (option.fields ?? []).map((f, i) => {
const type = f.type ?? "string"
const fields: { name: string; type: ValidatorType }[] = (option.fields ?? []).map((f, i) => {
const type = <ValidatorType> f.type ?? "string"
if(Validators.availableTypes.indexOf(type) < 0){
throw `Invalid filter: type is not a valid validator. Did you mean one of ${Utils.sortedByLevenshteinDistance(type, <any>Validators.availableTypes, x => x).slice(0, 3)}`
}
// Type is validated against 'ValidatedTextField' in Validation.ts, in ValidateFilterConfig
if (f.name === undefined || f.name === "" || f.name.match(/[a-z0-9_-]+/) == null) {
throw `Invalid filter: a variable name should match [a-z0-9_-]+ at ${ctx}.fields[${i}]`

View file

@ -926,7 +926,7 @@ export default class TagRenderingConfig {
* Might give undefined if setting to unknown is not possible
*/
public removeToSetUnknown(partOfLayer: LayerConfig, currentTags: Record<string, string>): string[] | undefined {
if(!partOfLayer?.source || !currentTags){
if (!partOfLayer?.source || !currentTags) {
return
}
const toDelete = new Set<string>()
@ -1001,12 +1001,17 @@ export class TagRenderingConfigUtils {
// The original mappings get "priorityIf" set
const oldMappingsCloned =
clone.mappings?.map(
(m) =>
<Mapping>{
(m) => {
const mapping = {
...m,
addExtraTags: [new Tag("nobrand", "")],
priorityIf: m.priorityIf ?? TagUtils.Tag("id~*"),
},
}
if (m.if.usedKeys().indexOf("nobrand") < 0) {
// Erase 'nobrand=yes', unless this option explicitly sets it
mapping["addExtraTags"] = [new Tag("nobrand", "")]
}
return <Mapping>mapping
},
) ?? []
clone.mappings = [...oldMappingsCloned, ...extraMappings]
return clone

View file

@ -2,7 +2,11 @@ import LayoutConfig from "./ThemeConfig/LayoutConfig"
import { SpecialVisualizationState } from "../UI/SpecialVisualization"
import { Changes } from "../Logic/Osm/Changes"
import { Store, UIEventSource } from "../Logic/UIEventSource"
import { FeatureSource, IndexedFeatureSource, WritableFeatureSource } from "../Logic/FeatureSource/FeatureSource"
import {
FeatureSource,
IndexedFeatureSource,
WritableFeatureSource
} from "../Logic/FeatureSource/FeatureSource"
import { OsmConnection } from "../Logic/Osm/OsmConnection"
import { ExportableMap, MapProperties } from "./MapProperties"
import LayerState from "../Logic/State/LayerState"
@ -46,7 +50,9 @@ import BackgroundLayerResetter from "../Logic/Actors/BackgroundLayerResetter"
import SaveFeatureSourceToLocalStorage from "../Logic/FeatureSource/Actors/SaveFeatureSourceToLocalStorage"
import BBoxFeatureSource from "../Logic/FeatureSource/Sources/TouchesBboxFeatureSource"
import ThemeViewStateHashActor from "../Logic/Web/ThemeViewStateHashActor"
import NoElementsInViewDetector, { FeatureViewState } from "../Logic/Actors/NoElementsInViewDetector"
import NoElementsInViewDetector, {
FeatureViewState
} from "../Logic/Actors/NoElementsInViewDetector"
import FilteredLayer from "./FilteredLayer"
import { PreferredRasterLayerSelector } from "../Logic/Actors/PreferredRasterLayerSelector"
import { ImageUploadManager } from "../Logic/ImageProviders/ImageUploadManager"
@ -150,6 +156,10 @@ export default class ThemeViewState implements SpecialVisualizationState {
public readonly toCacheSavers: ReadonlyMap<string, SaveFeatureSourceToLocalStorage>
public readonly nearbyImageSearcher: CombinedFetcher
/**
* Geocoded images that should be shown on the main map; probably only the currently hovered image
*/
public readonly geocodedImages: UIEventSource<Feature[]> = new UIEventSource<Feature[]>([ ])
public readonly searchState: SearchState
@ -773,6 +783,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
gps_location: this.geolocation.currentUserLocation,
gps_location_history: this.geolocation.historicalUserLocations,
gps_track: this.geolocation.historicalUserLocationsTrack,
geocoded_image: new StaticFeatureSource(this.geocodedImages),
selected_element: new StaticFeatureSource(
this.selectedElement.map((f) => (f === undefined ? empty : [f]))
),
@ -898,6 +909,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
this.selectedElement.addCallback((selected) => {
if (selected === undefined) {
this.focusOnMap()
this.geocodedImages.set([])
} else {
this.lastClickObject.clear()
}
@ -934,6 +946,9 @@ export default class ThemeViewState implements SpecialVisualizationState {
this.userRelatedState.recentlyVisitedSearch.add(r)
})
this.userRelatedState.showScale.addCallbackAndRun(showScale => {
this.mapProperties.showScale.set(showScale)
})
new ThemeViewStateHashActor(this)
new MetaTagging(this)
new TitleHandler(this.selectedElement, this.featureProperties, this)