Merge branch 'develop' into feature/360-view

This commit is contained in:
Pieter Vander Vennet 2025-03-29 00:50:32 +01:00
commit fa9e61c2b5
230 changed files with 45510 additions and 33214 deletions

View file

@ -14,7 +14,6 @@ import {
} from "geojson"
import { Tiles } from "../Models/TileRange"
import { Utils } from "../Utils"
;("use strict")
export class GeoOperations {

View file

@ -65,6 +65,16 @@ interface OsmUserInfo {
}
}
interface UserBlock {
id: number
created_at: string
updated_at: string
ends_at: string
needs_view: boolean
user: { uid: number; user: string }
creator: { uid: number; user: string }
}
export default interface UserDetails {
name: string
uid: number
@ -78,6 +88,7 @@ export default interface UserDetails {
tracesCount: number
description?: string
languages: string[]
active_blocks: number
}
export type OsmServiceState = "online" | "readonly" | "offline" | "unknown" | "unreachable"
@ -309,6 +320,7 @@ export class OsmConnection {
account_created: user.account_created,
tracesCount: user.traces?.count ?? 0,
unreadMessages: user.messages.received?.unread ?? 0,
active_blocks: user.blocks.received.active ?? 0,
}
this.userDetails.set(userdetails)
this.loadingStatus.setData("logged-in")
@ -559,6 +571,14 @@ export class OsmConnection {
})
}
/**
* Have you been banned by the DWG?
*/
public async getUserBlocks(): Promise<UserBlock[]> {
const raw = await this.interact("/user/blocks/active.json")
return JSON.parse(raw)["user_blocks"]
}
/**
* To be called by land.html
*/

View file

@ -497,7 +497,10 @@ export default class SimpleMetaTaggers {
continue
}
const value = feature.properties[key]
const denom: [string, Denomination] = unit.findDenomination(value, () => feature.properties["_country"])
const denom: [string, Denomination] = unit.findDenomination(
value,
() => feature.properties["_country"]
)
if (denom === undefined) {
// no valid value found
break
@ -515,7 +518,12 @@ export default class SimpleMetaTaggers {
if (canonical === value) {
break
}
console.log("Rewritten ", key, ` from '${value}' into '${canonical}' due to denomination`, denomination)
console.log(
"Rewritten ",
key,
` from '${value}' into '${canonical}' due to denomination`,
denomination
)
if (canonical === undefined && !unit.eraseInvalid) {
break
}

View file

@ -61,7 +61,7 @@ export default class SearchState {
return new ImmutableStore(true)
}
return Stores.concat(suggestions).map((suggestions) =>
suggestions.some(list => list === undefined)
suggestions.some((list) => list === undefined)
)
})
this.suggestions = suggestionsList.bindD((suggestions) =>
@ -101,7 +101,7 @@ export default class SearchState {
this.showSearchDrawer = new UIEventSource(false)
this.searchIsFocused.addCallbackAndRunD(sugg => {
this.searchIsFocused.addCallbackAndRunD((sugg) => {
if (sugg) {
this.showSearchDrawer.set(true)
}
@ -192,7 +192,7 @@ export default class SearchState {
state.mapProperties.bounds.set(
new BBox([
[lon0, lat0],
[lon1, lat1]
[lon1, lat1],
]).pad(0.01)
)
} else {

View file

@ -1,14 +1,42 @@
import { Utils } from "../../Utils"
/** This code is autogenerated - do not edit. Edit ./assets/layers/usersettings/usersettings.json instead */
export class ThemeMetaTagging {
public static readonly themeName = "usersettings"
public static readonly themeName = "usersettings"
public metaTaggging_for_usersettings(feat: {properties: Record<string, string>}) {
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_md', () => feat.properties._description.match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/)?.at(1) )
Utils.AddLazyProperty(feat.properties, '_d', () => feat.properties._description?.replace(/&lt;/g,'<')?.replace(/&gt;/g,'>') ?? '' )
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_a', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.href.match(/mastodon|en.osm.town/) !== null)[0]?.href }) (feat) )
Utils.AddLazyProperty(feat.properties, '_mastodon_link', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.getAttribute("rel")?.indexOf('me') >= 0)[0]?.href})(feat) )
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate', () => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a )
feat.properties['__current_backgroun'] = 'initial_value'
}
}
public metaTaggging_for_usersettings(feat: { properties: Record<string, string> }) {
Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_md", () =>
feat.properties._description
.match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/)
?.at(1)
)
Utils.AddLazyProperty(
feat.properties,
"_d",
() => feat.properties._description?.replace(/&lt;/g, "<")?.replace(/&gt;/g, ">") ?? ""
)
Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_a", () =>
((feat) => {
const e = document.createElement("div")
e.innerHTML = feat.properties._d
return Array.from(e.getElementsByTagName("a")).filter(
(a) => a.href.match(/mastodon|en.osm.town/) !== null
)[0]?.href
})(feat)
)
Utils.AddLazyProperty(feat.properties, "_mastodon_link", () =>
((feat) => {
const e = document.createElement("div")
e.innerHTML = feat.properties._d
return Array.from(e.getElementsByTagName("a")).filter(
(a) => a.getAttribute("rel")?.indexOf("me") >= 0
)[0]?.href
})(feat)
)
Utils.AddLazyProperty(
feat.properties,
"_mastodon_candidate",
() => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a
)
feat.properties["__current_backgroun"] = "initial_value"
}
}

View file

@ -29,6 +29,9 @@ export class And extends TagsFilter {
and: ReadonlyArray<FlatTag | (Or & OptimizedTag)>
): TagsFilterClosed & OptimizedTag
public static construct(and: ReadonlyArray<TagsFilter>): TagsFilter {
if (and === undefined) {
return undefined
}
if (and.length === 1) {
return and[0]
}

View file

@ -29,7 +29,6 @@ export class TagTypes {
return <any>and.and
}
static safeOr(or: Or & OptimizedTag): ((FlatTag | (And & OptimizedTag)) & OptimizedTag)[] {
return <any>or.or
}

View file

@ -21,7 +21,7 @@ export class TagUtils {
["<=", (a, b) => a <= b],
[">=", (a, b) => a >= b],
["<", (a, b) => a < b],
[">", (a, b) => a > b]
[">", (a, b) => a > b],
]
public static modeDocumentation: Record<
string,
@ -48,7 +48,7 @@ export class TagUtils {
"### Removing a key\n" +
"\n" +
"If a key should be deleted in the OpenStreetMap-database, specify `key=` as well. This can be used e.g. to remove a\n" +
"fixme or value from another mapping if another field is filled out."
"fixme or value from another mapping if another field is filled out.",
},
"!=": {
name: "strict not equals",
@ -62,7 +62,7 @@ export class TagUtils {
"### If key is present\n" +
"\n" +
"This implies that, to check if a key is present, `key!=` can be used. This will only match if the key is present and not\n" +
"empty."
"empty.",
},
"~": {
name: "Value matches regex",
@ -73,12 +73,12 @@ export class TagUtils {
"The regex is put within braces as to prevent runaway values.\n" +
"\nUse `key~*` to indicate that any value is allowed. This is effectively the check that the attribute is present (defined _and_ not empty)." +
"\n" +
"Regexes will match the newline character with `.` too - the `s`-flag is enabled by default."
"Regexes will match the newline character with `.` too - the `s`-flag is enabled by default.",
},
"~i~": {
name: "Value matches case-invariant regex",
overpassSupport: true,
docs: "A tag can also be tested against a regex with `key~i~regex`, where the case of the value will be ignored. The regex is still matched against the _entire_ value"
docs: "A tag can also be tested against a regex with `key~i~regex`, where the case of the value will be ignored. The regex is still matched against the _entire_ value",
},
"!~": {
name: "Value should _not_ match regex",
@ -87,27 +87,27 @@ export class TagUtils {
"A tag can also be tested against a regex with `key!~regex`. This filter will match if the value does *not* match the regex. " +
"\n If the\n" +
"value is allowed to appear anywhere as substring, use `key~.*regex.*`.\n" +
"The regex is put within braces as to prevent runaway values.\n"
"The regex is put within braces as to prevent runaway values.\n",
},
"!~i~": {
name: "Value does *not* match case-invariant regex",
overpassSupport: true,
docs: "A tag can also be tested against a regex with `key~i~regex`, where the case of the value will be ignored. The regex is still matched against the _entire_ value. This filter returns true if the value does *not* match"
docs: "A tag can also be tested against a regex with `key~i~regex`, where the case of the value will be ignored. The regex is still matched against the _entire_ value. This filter returns true if the value does *not* match",
},
"~~": {
name: "Key and value should match given regex",
overpassSupport: true,
docs: "Both the `key` and `value` part of this specification are interpreted as regexes, both the key and value musth completely match their respective regexes"
docs: "Both the `key` and `value` part of this specification are interpreted as regexes, both the key and value musth completely match their respective regexes",
},
"~i~~": {
name: "Key and value should match a given regex; value is case-invariant",
overpassSupport: true,
docs: "Similar to ~~, except that the value is case-invariant"
docs: "Similar to ~~, except that the value is case-invariant",
},
"!~i~~": {
name: "Key and value should match a given regex; value is case-invariant",
overpassSupport: true,
docs: "Similar to !~~, except that the value is case-invariant"
docs: "Similar to !~~, except that the value is case-invariant",
},
":=": {
name: "Substitute `... {some_key} ...` and match `key`",
@ -133,24 +133,24 @@ export class TagUtils {
"\n" +
"```json\n" +
"{\n" +
" \"mappings\": [\n" +
' "mappings": [\n' +
" {\n" +
" \"if\":\"key:={some_other_key}\",\n" +
" \"then\": \"...\",\n" +
" \"hideInAnswer\": \"some_other_key=\"\n" +
' "if":"key:={some_other_key}",\n' +
' "then": "...",\n' +
' "hideInAnswer": "some_other_key="\n' +
" }\n" +
" ]\n" +
"}\n" +
"```\n" +
"\n" +
"One can use `key!:=prefix-{other_key}-postfix` as well, to match if `key` is _not_ the same\n" +
"as `prefix-{other_key}-postfix` (with `other_key` substituted by the value)"
"as `prefix-{other_key}-postfix` (with `other_key` substituted by the value)",
},
"!:=": {
name: "Substitute `{some_key}` should not match `key`",
overpassSupport: false,
docs: "See `:=`, except that this filter is inverted"
}
docs: "See `:=`, except that this filter is inverted",
},
}
private static keyCounts: { keys: any; tags: any } = key_counts
public static readonly numberAndDateComparisonDocs =
@ -175,10 +175,10 @@ export class TagUtils {
"\n" +
"```json\n" +
"{\n" +
" \"osmTags\": {\n" +
" \"or\": [\n" +
" \"amenity=school\",\n" +
" \"amenity=kindergarten\"\n" +
' "osmTags": {\n' +
' "or": [\n' +
' "amenity=school",\n' +
' "amenity=kindergarten"\n' +
" ]\n" +
" }\n" +
"}\n" +
@ -194,7 +194,7 @@ export class TagUtils {
"If the schema-files note a type [`TagConfigJson`](https://github.com/pietervdvn/MapComplete/blob/develop/src/Models/ThemeConfig/Json/TagConfigJson.ts), you can use one of these values.\n" +
"\n" +
"In some cases, not every type of tags-filter can be used. For example, _rendering_ an option with a regex is\n" +
"fine (`\"if\": \"brand~[Bb]randname\", \"then\":\" The brand is Brandname\"`); but this regex can not be used to write a value\n" +
'fine (`"if": "brand~[Bb]randname", "then":" The brand is Brandname"`); but this regex can not be used to write a value\n' +
"into the database. The theme loader will however refuse to work with such inconsistencies and notify you of this while\n" +
"you are building your theme.\n" +
"\n" +
@ -205,18 +205,18 @@ export class TagUtils {
"\n" +
"```json\n" +
"{\n" +
" \"and\": [\n" +
" \"key=value\",\n" +
' "and": [\n' +
' "key=value",\n' +
" {\n" +
" \"or\": [\n" +
" \"other_key=value\",\n" +
" \"other_key=some_other_value\"\n" +
' "or": [\n' +
' "other_key=value",\n' +
' "other_key=some_other_value"\n' +
" ]\n" +
" },\n" +
" \"key_which_should_be_missing=\",\n" +
" \"key_which_should_have_a_value~*\",\n" +
" \"key~.*some_regex_a*_b+_[a-z]?\",\n" +
" \"height<1\"\n" +
' "key_which_should_be_missing=",\n' +
' "key_which_should_have_a_value~*",\n' +
' "key~.*some_regex_a*_b+_[a-z]?",\n' +
' "height<1"\n' +
" ]\n" +
"}\n" +
"```\n" +
@ -986,10 +986,10 @@ export class TagUtils {
return ["", "## `" + mode + "` " + doc.name, "", doc.docs, "", ""].join("\n")
}),
"## " +
TagUtils.comparators.map((comparator) => "`" + comparator[0] + "`").join(" ") +
" Logical comparators",
TagUtils.comparators.map((comparator) => "`" + comparator[0] + "`").join(" ") +
" Logical comparators",
TagUtils.numberAndDateComparisonDocs,
TagUtils.logicalOperator
TagUtils.logicalOperator,
].join("\n")
}