Merge branch 'develop' into RobinLinde-patch-1
This commit is contained in:
commit
7215702896
23 changed files with 672 additions and 277 deletions
|
@ -64,7 +64,8 @@
|
|||
"iconSize": "40,40",
|
||||
"location": [
|
||||
"point",
|
||||
"centroid"
|
||||
"projected_centerpoint",
|
||||
"polygon_centroid"
|
||||
],
|
||||
"anchor": "bottom",
|
||||
"marker": [
|
||||
|
|
|
@ -204,6 +204,35 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "dogicon",
|
||||
"labels": [
|
||||
"defaults",
|
||||
"in_favourite"
|
||||
],
|
||||
"mappings": [
|
||||
{
|
||||
"if": "dog=no",
|
||||
"#": "ignore-image-in-then",
|
||||
"then": "<img textmode='🐕 ⃠' alt='no_dogs' src='./assets/layers/questions/no_dogs.svg'>"
|
||||
},
|
||||
{
|
||||
"if": "dog=leashed",
|
||||
"#": "ignore-image-in-then",
|
||||
"then": "<img textmode='🐕' alt='dogs are allowed but leashed' src='./assets/layers/questions/dogs_leashed.svg'>"
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"or": [
|
||||
"dog=yes",
|
||||
"dog=unleashed"
|
||||
]
|
||||
},
|
||||
"#": "ignore-image-in-then",
|
||||
"then": "<img textmode='🐕' alt='dogs are allowed' src='./assets/layers/questions/dogs_allowed.svg'>"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "sharelink",
|
||||
"labels": [
|
||||
|
@ -263,35 +292,6 @@
|
|||
],
|
||||
"condition": "id~(node|way|relation)/[0-9]*"
|
||||
},
|
||||
{
|
||||
"id": "dogicon",
|
||||
"labels": [
|
||||
"defaults",
|
||||
"in_favourite"
|
||||
],
|
||||
"mappings": [
|
||||
{
|
||||
"if": "dog=no",
|
||||
"#": "ignore-image-in-then",
|
||||
"then": "<img textmode='🐕 ⃠' alt='no_dogs' src='./assets/layers/questions/no_dogs.svg'>"
|
||||
},
|
||||
{
|
||||
"if": "dog=leashed",
|
||||
"#": "ignore-image-in-then",
|
||||
"then": "<img textmode='🐕' alt='dogs are allowed but leashed' src='./assets/layers/questions/dogs_leashed.svg'>"
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"or": [
|
||||
"dog=yes",
|
||||
"dog=unleashed"
|
||||
]
|
||||
},
|
||||
"#": "ignore-image-in-then",
|
||||
"then": "<img textmode='🐕' alt='dogs are allowed' src='./assets/layers/questions/dogs_allowed.svg'>"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "rating",
|
||||
"icon": {
|
||||
|
|
|
@ -548,6 +548,115 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": "toilets:position!=urinal",
|
||||
"id": "gender_segregated",
|
||||
"question": {
|
||||
"en": "Are these toilets gender-segregated?",
|
||||
"nl": "Zijn deze toiletten gescheiden op basis van geslacht?"
|
||||
},
|
||||
"questionHint": {
|
||||
"en": "Are there separate stalls or separate areas for men and women and are they signposted as such?",
|
||||
"nl": "Is er een aparte ruimte voor mannen en vrouwen en zijn deze ruimtes ook expliciet aangegeven?"
|
||||
},
|
||||
"mappings": [
|
||||
{
|
||||
"if": "gender_segregated=yes",
|
||||
"then": {
|
||||
"en": "There is a separate, signposted area for men and women",
|
||||
"nl": "Er zijn aparte ruimtes of toiletten voor mannen en vrouwen"
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": "gender_segregated=no",
|
||||
"then": {
|
||||
"en": "There is no separate, signposted area for men and women",
|
||||
"nl": "Mannen en vrouwen gebruiken dezelfde ruimtes en toiletten"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "menstrual_products",
|
||||
"question": {
|
||||
"en": "Are free, menstrual products distributed here?",
|
||||
"nl": "Zijn er gratis menstruatieproducten beschikbaar?"
|
||||
},
|
||||
"questionHint": {
|
||||
"en": "This is only about menstrual products that are free of charge. If e.g. a vending machine is available which charges for menstrual products, ignore it for this question.",
|
||||
"nl": "Dit gaat enkel over menstruatieproducten die gratis geschikbaar zijn. Indien er bv. een verkoopautomaat met menstruatieproducten is, negeer deze dan"
|
||||
},
|
||||
"mappings": [
|
||||
{
|
||||
"if": "toilets:menstrual_products=yes",
|
||||
"then": {
|
||||
"en": "Free menstrual products are available to all visitors of these toilets",
|
||||
"nl": "Er zijn gratis menstruatieprocten beschikbaar voor alle bezoekers van deze toiletten"
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": "toilets:menstrual_products=limited",
|
||||
"then": {
|
||||
"en": "Free menstrual products are available to some visitors of these toilets",
|
||||
"nl": "De gratis menstruatieproducten zijn enkel beschikbaar in een deel van de toiletten"
|
||||
},
|
||||
"hideInAnswer": "gender_segregated=yes"
|
||||
},
|
||||
{
|
||||
"if": "toilets:menstrual_products=no",
|
||||
"alsoShowIf": "toilets:menstrual_products=",
|
||||
"then": {
|
||||
"en": "No free menstrual products are available here",
|
||||
"nl": "Er zijn geen gratis menstruatieproducten beschikbaar"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "menstrual_products_location",
|
||||
"question": {
|
||||
"en": "Where are the free menstrual products located?",
|
||||
"nl": "Waar bevinden de gratis menstruatieproducten zich?"
|
||||
},
|
||||
"condition": {
|
||||
"or": [
|
||||
"toilets:menstrual_products=limited",
|
||||
"toilets:menstrual_products:location~*"
|
||||
]
|
||||
},
|
||||
"render": {
|
||||
"en": "The menstrual products are located in {toilets:menstrual_products:location}",
|
||||
"nl": "De menstruatieproducten bevinden zich in {toilets:menstrual_products:location}"
|
||||
},
|
||||
"freeform": {
|
||||
"key": "toilets:menstrual_products:location",
|
||||
"inline": true
|
||||
},
|
||||
"mappings": [
|
||||
{
|
||||
"then": {
|
||||
"en": "The free, menstrual products are located in the toilet for women",
|
||||
"nl": "De gratis menstruatieproducten bevinden zich in het vrouwentoilet"
|
||||
},
|
||||
"if": "toilets:menstrual_products:location=female_toilet",
|
||||
"alsoShowIf": "toilets:menstrual_products:location="
|
||||
},
|
||||
{
|
||||
"then": {
|
||||
"en": "The free, menstrual products are located in the toilet for men",
|
||||
"nl": "De gratis menstruatieproducten bevinden zich in het mannentoilet"
|
||||
},
|
||||
"if": "toilets:menstrual_products:location=male_toilet"
|
||||
},
|
||||
{
|
||||
"if": "toilets:menstrual_products:location=wheelchair_toilet",
|
||||
"then": {
|
||||
"en": "The free, menstrual products are located in the toilet for wheelchair users",
|
||||
"nl": "De gratis menstruatieproducten bevinden zich in het rolstoeltoegankelijke toilet"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "toilets-changing-table",
|
||||
"labels": [
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
"en": "<p><a href='https://velopark.be' target='_blank'>Velopark.be</a> is a website collecting data about bicycle parkings in a semi-crowdsourced way. However, only 'authorized' instances are allowed to make changes there, in practice the operator of the bicycle parking such as SNCB, de Lijn or the municipality. They have now decided to synchronize their dataset with OpenStreetMap, and this MapComplete-instance is set up to help link and import their data into OpenStreetMap.</p> How to use: <ul><li>A velopark-icon on the map (yellow with bicycle silhouette) represents a bicycle known by Velopark but not yet known by OpenStreetMap</li><li>Blue pins are bicycle parkings known by OpenStreetMap</li><li>Light blue pins are bicycle parkings known by OpenStreetMap with a reference to Velopark.be (<span class='literal-code'>ref-velopark=*</span>)</li><li>Click a velopark item, you can either link it with a nearby OSM-bicycle parking or create a new bicycle parking. Note that the geometry of Velopark is often incorrect and can be a few up till 100 meters away from the actual bicycle parking. Use aerial imagery, linked images and streetview to determine the correct location</li><li>Once linked, you can compare the Velopark- and OSM-attributes and apply correct attributes</li><li>If Velopark has an image, you can also link the image</li></ul> That's it! Thanks for helping to import this!",
|
||||
"nl": "<p><a href='https://velopark.be' target='_blank'>Velopark.be</a> is een website die data verzamelt over fietsenstallingen in een semi-crowdsource manier. Hierbij kunnen enkel geautorizeerde gebruikers data bijdragen, in de praktijk de uitbaters van de fietsenstallingen zoals de bevoegde gemeentebesturen, de NMBS of de Lijn. Velopark.be heeft nu beslist om hun data met OpenStreetMap te synchronizeren. Deze website is de tool om van Velopark.be naar OpenStreetMap te gaan en hun data te importeren.</p> Hoe te gebruiken? <ul><li>Een velopark-logo op de kaart (geel met een fietssilhouette) duidt een fietsenstalling aan die gekend is in Velopark maar nog niet gekend (of gelinkt) is aan een fietsenstalling in OpenStreetMap</li><li>Een blauwe pin duidt een fietsenstalling aan die gekend is in OpenStreetMap</li><li>Een licht-blauwe pin duidt een fietsenstalling aan uit OpenStreetMap die een link heeft naar Velopark.be (<span class='literal-code'>ref-velopark=*</span>)</li><li>Als je op een velopark-item klikt op, kan je deze linken met een fietsenstalling in de buurt (<25m) of een nieuwe fietstalling aan OpenStreetMap toevoegen. Let op: de geometrie van Velopark is zelden correct en wijkt makkelijk 10 meter of meer af van de echte locatie - in uitzonderlijke gevallen zelfs tot meer dan 100 meter. Gebruik de meest recente luchtfoto's, de gelinkte foto's en mapillary om de correcte locatie te bepalen</li><li>Eens gelinkt, kan je de Velopark- en OSM-attributen vergelijken en de correcte attributen toepassen in OpenStreetMap</li><li>Indien velopark een foto heeft, kan je die ook nog linken</li></ul> Dat is het! Bedankt om mee te helpen!"
|
||||
},
|
||||
"descriptionTail": {
|
||||
"*": "<h3>Maintainer tools</h3><ul><li><a class='link-underline' href='https://maproulette.org/api/v2/challenge/view/43282' download='Velopark_sync_2024-01-15.geojson'>Download the first sync results</a></li></ul>"
|
||||
},
|
||||
"hideFromOverview": true,
|
||||
"icon": "./assets/themes/velopark/velopark.svg",
|
||||
"mustHaveLanguage": [
|
||||
|
@ -30,6 +33,7 @@
|
|||
"startLon": 3.71025,
|
||||
"startZoom": 18,
|
||||
"defaultBackgroundId": "photo",
|
||||
"enableNoteImports": false,
|
||||
"layers": [
|
||||
{
|
||||
"id": "velopark_maproulette",
|
||||
|
@ -94,6 +98,14 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "login",
|
||||
"render": {
|
||||
"special": {
|
||||
"type": "login_button"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "closest_parkings",
|
||||
"render": {
|
||||
|
@ -137,7 +149,7 @@
|
|||
"type": "maproulette_set_status",
|
||||
"message": {
|
||||
"en": "Mark this item as linked manually. Use this if you did apply the reference via copy-paste or via another editor",
|
||||
"nl": "Markeer als gelinkt. Gebruik deze optie indien je de ID plakte in een fietsenstalling of via een andere editor toevoegdemap"
|
||||
"nl": "Markeer als gelinkt. Gebruik deze optie indien je de ID plakte in een fietsenstalling of via een andere editor toevoegd"
|
||||
},
|
||||
"status": 1
|
||||
}
|
||||
|
@ -150,10 +162,15 @@
|
|||
"type": "maproulette_set_status",
|
||||
"message": {
|
||||
"en": "Mark this item as incorrect or too hard to solve (duplicate, does not exist anymore, contradictory data, not placeable from aerial imagery)",
|
||||
"nl": "Markeer dit object als incorrect of te moeillijk (duplicaat, incorrect of tegenstrijdige data, niet eenduidig te plaatsen adhv luchtfoto's, ...)"
|
||||
"nl": "Markeer dit object als incorrecte velopark data of te moeillijk (duplicaat, incorrect of tegenstrijdige data, niet eenduidig te plaatsen adhv luchtfoto's, ...)"
|
||||
},
|
||||
"image": "invalid",
|
||||
"status": 6
|
||||
"status": 6,
|
||||
"ask_feedback": {
|
||||
"en": "Is this point incorrect or is it difficult to solve? Please provide some feedback below",
|
||||
"nl": "Is dit punt foutief of te moeilijk? Gelieve wat feedback te geven"
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -248,7 +265,7 @@
|
|||
{
|
||||
"marker": [
|
||||
{
|
||||
"color": "#0088ff"
|
||||
"color": "#2cf200"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -671,6 +671,7 @@
|
|||
"reviewPlaceholder": "Describe your experience…",
|
||||
"reviewing_as": "Reviewing as {nickname}",
|
||||
"reviewing_as_anonymous": "Reviewing as anonymous",
|
||||
"reviews_bug": "Expected more reviews? Some reviews are not displayed due to a bug.",
|
||||
"save": "Save review",
|
||||
"saved": "Review saved. Thanks for sharing!",
|
||||
"saving_review": "Saving…",
|
||||
|
@ -678,7 +679,9 @@
|
|||
"title_singular": "One review",
|
||||
"too_long": "At most {max} characters are allowed. Your review has {amount} characters.",
|
||||
"tos": "If you create a review, you agree to <a href='https://mangrove.reviews/terms' target='_blank'>the TOS and privacy policy of Mangrove.reviews</a>",
|
||||
"write_a_comment": "Leave a review…"
|
||||
"write_a_comment": "Leave a review…",
|
||||
"your_reviews": "Your previous reviews",
|
||||
"your_reviews_empty": "We couldn't find any of your previous reviews"
|
||||
},
|
||||
"split": {
|
||||
"cancel": "Cancel",
|
||||
|
|
72
scripts/velopark/compare.ts
Normal file
72
scripts/velopark/compare.ts
Normal file
|
@ -0,0 +1,72 @@
|
|||
import Script from "../Script"
|
||||
import fs from "fs"
|
||||
import { Feature, FeatureCollection } from "geojson"
|
||||
import { GeoOperations } from "../../src/Logic/GeoOperations"
|
||||
import * as os from "os"
|
||||
// vite-node scripts/velopark/compare.ts -- scripts/velopark/velopark_all_2024-02-14T12\:18\:41.772Z.geojson ~/Projecten/OSM/Fietsberaad/2024-02-02\ Fietsenstallingen_OSM_met_velopark_ref.geojson
|
||||
class Compare extends Script {
|
||||
|
||||
compare(veloId: string, osmParking: Feature, veloParking: Feature): {distance: number, ref: string, osmid: string, diffs: {
|
||||
osm: string, velopark: string, key: string
|
||||
}[] }{
|
||||
const osmCenterpoint = GeoOperations.centerpointCoordinates(osmParking)
|
||||
const veloparkCenterpoint = GeoOperations.centerpointCoordinates(veloParking)
|
||||
const distance = Math.round(GeoOperations.distanceBetween(osmCenterpoint, veloparkCenterpoint))
|
||||
const diffs: { osm: string, velopark: string, key: string}[] = []
|
||||
|
||||
const allKeys = new Set<string>(Object.keys(osmParking.properties).concat(Object.keys(veloParking.properties)))
|
||||
for (const key of allKeys) {
|
||||
if(osmParking.properties[key] === veloParking.properties[key]){
|
||||
continue
|
||||
}
|
||||
if(Number(osmParking.properties[key]) === veloParking.properties[key]){
|
||||
continue
|
||||
}
|
||||
if(veloParking.properties[key] === undefined){
|
||||
continue
|
||||
}
|
||||
diffs.push({
|
||||
key,
|
||||
osm: osmParking.properties[key],
|
||||
velopark: veloParking.properties[key]
|
||||
})
|
||||
}
|
||||
return {
|
||||
ref: veloId,
|
||||
osmid: osmParking.properties["@id"],
|
||||
distance, diffs
|
||||
}
|
||||
}
|
||||
async main(args: string[]): Promise<void> {
|
||||
let [velopark, osm, key] = args
|
||||
key ??= "ref:velopark"
|
||||
const veloparkData: FeatureCollection = JSON.parse(fs.readFileSync(velopark, "utf-8"))
|
||||
const osmData : FeatureCollection = JSON.parse(fs.readFileSync(osm, "utf-8"))
|
||||
|
||||
const veloparkById : Record<string, Feature> = {}
|
||||
for (const parking of veloparkData.features) {
|
||||
veloparkById[parking.properties[key]] = parking
|
||||
}
|
||||
|
||||
const diffs = []
|
||||
for (const parking of osmData.features) {
|
||||
const veloId = parking.properties[key]
|
||||
const veloparking = veloparkById[veloId]
|
||||
if(veloparking === undefined){
|
||||
console.error("No velopark entry found for", veloId)
|
||||
continue
|
||||
}
|
||||
diffs.push(this.compare(veloId, parking, veloparking))
|
||||
}
|
||||
|
||||
fs.writeFileSync("report_diff.json",JSON.stringify(diffs))
|
||||
|
||||
|
||||
}
|
||||
constructor() {
|
||||
super("Compares a velopark geojson with OSM geojson. Usage: `compare velopark.geojson osm.geojson [key-to-compare-on]`. If key-to-compare-on is not given, `ref:velopark` will be used")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new Compare().run()
|
|
@ -15,6 +15,20 @@ class VeloParkToGeojson extends Script {
|
|||
)
|
||||
}
|
||||
|
||||
exportTo(filename: string, features){
|
||||
fs.writeFileSync(
|
||||
filename+"_" + new Date().toISOString() + ".geojson",
|
||||
JSON.stringify(
|
||||
{
|
||||
type: "FeatureCollection",
|
||||
features,
|
||||
},
|
||||
null,
|
||||
" "
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
async main(args: string[]): Promise<void> {
|
||||
console.log("Downloading velopark data")
|
||||
// Download data for NIS-code 1000. 1000 means: all of belgium
|
||||
|
@ -38,12 +52,15 @@ class VeloParkToGeojson extends Script {
|
|||
)
|
||||
console.log("OpenStreetMap contains", seenIds.size, "bicycle parkings with a velopark ref")
|
||||
const allVelopark = data.map((f) => VeloparkLoader.convert(f))
|
||||
this.exportTo("velopark_all", allVelopark)
|
||||
|
||||
const features = allVelopark.filter((f) => !seenIds.has(f.properties["ref:velopark"]))
|
||||
|
||||
const allProperties = new Set<string>()
|
||||
for (const feature of features) {
|
||||
Object.keys(feature.properties).forEach((k) => allProperties.add(k))
|
||||
}
|
||||
this.exportTo("velopark_noncynced",features)
|
||||
allProperties.delete("ref:velopark")
|
||||
for (const feature of features) {
|
||||
allProperties.forEach((k) => {
|
||||
|
@ -51,17 +68,7 @@ class VeloParkToGeojson extends Script {
|
|||
})
|
||||
}
|
||||
|
||||
fs.writeFileSync(
|
||||
"velopark_id_only_export_" + new Date().toISOString() + ".geojson",
|
||||
JSON.stringify(
|
||||
{
|
||||
type: "FeatureCollection",
|
||||
features,
|
||||
},
|
||||
null,
|
||||
" "
|
||||
)
|
||||
)
|
||||
this.exportTo("velopark_nonsynced_id_only", features)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ export class GeoOperations {
|
|||
const intersection = GeoOperations.calculateIntersection(
|
||||
feature,
|
||||
otherFeature,
|
||||
featureBBox
|
||||
featureBBox,
|
||||
)
|
||||
if (intersection === null) {
|
||||
continue
|
||||
|
@ -195,7 +195,7 @@ export class GeoOperations {
|
|||
console.error(
|
||||
"Could not correctly calculate the overlap of ",
|
||||
feature,
|
||||
": unsupported type"
|
||||
": unsupported type",
|
||||
)
|
||||
return result
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ export class GeoOperations {
|
|||
*/
|
||||
public static inside(
|
||||
pointCoordinate: [number, number] | Feature<Point>,
|
||||
feature: Feature
|
||||
feature: Feature,
|
||||
): boolean {
|
||||
// ray-casting algorithm based on
|
||||
// http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
|
||||
|
@ -302,7 +302,7 @@ export class GeoOperations {
|
|||
*/
|
||||
public static nearestPoint(
|
||||
way: Feature<LineString>,
|
||||
point: [number, number]
|
||||
point: [number, number],
|
||||
): Feature<
|
||||
Point,
|
||||
{
|
||||
|
@ -324,11 +324,11 @@ export class GeoOperations {
|
|||
public static forceLineString(way: Feature<LineString | Polygon>): Feature<LineString>
|
||||
|
||||
public static forceLineString(
|
||||
way: Feature<MultiLineString | MultiPolygon>
|
||||
way: Feature<MultiLineString | MultiPolygon>,
|
||||
): Feature<MultiLineString>
|
||||
|
||||
public static forceLineString(
|
||||
way: Feature<LineString | MultiLineString | Polygon | MultiPolygon>
|
||||
way: Feature<LineString | MultiLineString | Polygon | MultiPolygon>,
|
||||
): Feature<LineString | MultiLineString> {
|
||||
if (way.geometry.type === "Polygon") {
|
||||
way = { ...way }
|
||||
|
@ -352,8 +352,8 @@ export class GeoOperations {
|
|||
const headerValuesOrdered: string[] = []
|
||||
|
||||
function addH(key: string) {
|
||||
if(options?.ignoreTags){
|
||||
if(key.match(options.ignoreTags)){
|
||||
if (options?.ignoreTags) {
|
||||
if (key.match(options.ignoreTags)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -455,7 +455,7 @@ export class GeoOperations {
|
|||
*/
|
||||
public static LineIntersections(
|
||||
feature: Feature<LineString | MultiLineString | Polygon | MultiPolygon>,
|
||||
otherFeature: Feature<LineString | MultiLineString | Polygon | MultiPolygon>
|
||||
otherFeature: Feature<LineString | MultiLineString | Polygon | MultiPolygon>,
|
||||
): [number, number][] {
|
||||
return turf
|
||||
.lineIntersect(feature, otherFeature)
|
||||
|
@ -492,7 +492,7 @@ export class GeoOperations {
|
|||
locations:
|
||||
| Feature<LineString>
|
||||
| Feature<Point, { date?: string; altitude?: number | string }>[],
|
||||
title?: string
|
||||
title?: string,
|
||||
) {
|
||||
title = title?.trim()
|
||||
if (title === undefined || title === "") {
|
||||
|
@ -513,7 +513,7 @@ export class GeoOperations {
|
|||
type: "Point",
|
||||
coordinates: p,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
for (const l of locationsWithMeta) {
|
||||
|
@ -528,7 +528,7 @@ export class GeoOperations {
|
|||
trackPoints.push(trkpt)
|
||||
}
|
||||
const header =
|
||||
'<gpx version="1.1" creator="mapcomplete.org" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">'
|
||||
"<gpx version=\"1.1\" creator=\"mapcomplete.org\" xmlns=\"http://www.topografix.com/GPX/1/1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">"
|
||||
return (
|
||||
header +
|
||||
"\n<name>" +
|
||||
|
@ -546,7 +546,7 @@ export class GeoOperations {
|
|||
*/
|
||||
public static toGpxPoints(
|
||||
locations: Feature<Point, { date?: string; altitude?: number | string }>[],
|
||||
title?: string
|
||||
title?: string,
|
||||
) {
|
||||
title = title?.trim()
|
||||
if (title === undefined || title === "") {
|
||||
|
@ -567,7 +567,7 @@ export class GeoOperations {
|
|||
trackPoints.push(trkpt)
|
||||
}
|
||||
const header =
|
||||
'<gpx version="1.1" creator="mapcomplete.org" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">'
|
||||
"<gpx version=\"1.1\" creator=\"mapcomplete.org\" xmlns=\"http://www.topografix.com/GPX/1/1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">"
|
||||
return (
|
||||
header +
|
||||
"\n<name>" +
|
||||
|
@ -655,7 +655,7 @@ export class GeoOperations {
|
|||
},
|
||||
},
|
||||
distanceMeter,
|
||||
{ units: "meters" }
|
||||
{ units: "meters" },
|
||||
).geometry.coordinates
|
||||
}
|
||||
|
||||
|
@ -690,7 +690,7 @@ export class GeoOperations {
|
|||
*/
|
||||
static completelyWithin(
|
||||
feature: Feature<Geometry, any>,
|
||||
possiblyEnclosingFeature: Feature<Polygon | MultiPolygon, any>
|
||||
possiblyEnclosingFeature: Feature<Polygon | MultiPolygon, any>,
|
||||
): boolean {
|
||||
return booleanWithin(feature, possiblyEnclosingFeature)
|
||||
}
|
||||
|
@ -746,7 +746,7 @@ export class GeoOperations {
|
|||
*/
|
||||
public static featureToCoordinateWithRenderingType(
|
||||
feature: Feature,
|
||||
location: "point" | "centroid" | "start" | "end" | "projected_centerpoint" | string
|
||||
location: "point" | "centroid" | "start" | "end" | "projected_centerpoint" | "polygon_centerpoint" | string,
|
||||
): [number, number] | undefined {
|
||||
switch (location) {
|
||||
case "point":
|
||||
|
@ -759,6 +759,11 @@ export class GeoOperations {
|
|||
return undefined
|
||||
}
|
||||
return GeoOperations.centerpointCoordinates(feature)
|
||||
case "polygon_centerpoint":
|
||||
if (feature.geometry.type === "Polygon") {
|
||||
return GeoOperations.centerpointCoordinates(feature)
|
||||
}
|
||||
return undefined
|
||||
case "projected_centerpoint":
|
||||
if (
|
||||
feature.geometry.type === "LineString" ||
|
||||
|
@ -767,7 +772,7 @@ export class GeoOperations {
|
|||
const centerpoint = GeoOperations.centerpointCoordinates(feature)
|
||||
const projected = GeoOperations.nearestPoint(
|
||||
<Feature<LineString>>feature,
|
||||
centerpoint
|
||||
centerpoint,
|
||||
)
|
||||
return <[number, number]>projected.geometry.coordinates
|
||||
}
|
||||
|
@ -944,7 +949,7 @@ export class GeoOperations {
|
|||
* GeoOperations.bearingToHuman(46) // => "NE"
|
||||
*/
|
||||
public static bearingToHuman(
|
||||
bearing: number
|
||||
bearing: number,
|
||||
): "N" | "NE" | "E" | "SE" | "S" | "SW" | "W" | "NW" {
|
||||
while (bearing < 0) {
|
||||
bearing += 360
|
||||
|
@ -970,7 +975,7 @@ export class GeoOperations {
|
|||
*
|
||||
*/
|
||||
public static bearingToHumanRelative(
|
||||
bearing: number
|
||||
bearing: number,
|
||||
):
|
||||
| "straight"
|
||||
| "slight_right"
|
||||
|
@ -995,12 +1000,12 @@ export class GeoOperations {
|
|||
private static pointInPolygonCoordinates(
|
||||
x: number,
|
||||
y: number,
|
||||
coordinates: [number, number][][]
|
||||
coordinates: [number, number][][],
|
||||
): boolean {
|
||||
const inside = GeoOperations.pointWithinRing(
|
||||
x,
|
||||
y,
|
||||
/*This is the outer ring of the polygon */ coordinates[0]
|
||||
/*This is the outer ring of the polygon */ coordinates[0],
|
||||
)
|
||||
if (!inside) {
|
||||
return false
|
||||
|
@ -1009,7 +1014,7 @@ export class GeoOperations {
|
|||
const inHole = GeoOperations.pointWithinRing(
|
||||
x,
|
||||
y,
|
||||
coordinates[i] /* These are inner rings, aka holes*/
|
||||
coordinates[i], /* These are inner rings, aka holes*/
|
||||
)
|
||||
if (inHole) {
|
||||
return false
|
||||
|
@ -1047,7 +1052,7 @@ export class GeoOperations {
|
|||
feature,
|
||||
otherFeature,
|
||||
featureBBox: BBox,
|
||||
otherFeatureBBox?: BBox
|
||||
otherFeatureBBox?: BBox,
|
||||
): number {
|
||||
if (feature.geometry.type === "LineString") {
|
||||
otherFeatureBBox = otherFeatureBBox ?? BBox.get(otherFeature)
|
||||
|
@ -1096,7 +1101,7 @@ export class GeoOperations {
|
|||
let intersection = turf.lineSlice(
|
||||
turf.point(intersectionPointsArray[0]),
|
||||
turf.point(intersectionPointsArray[1]),
|
||||
feature
|
||||
feature,
|
||||
)
|
||||
|
||||
if (intersection == null) {
|
||||
|
@ -1117,7 +1122,7 @@ export class GeoOperations {
|
|||
otherFeature,
|
||||
feature,
|
||||
otherFeatureBBox,
|
||||
featureBBox
|
||||
featureBBox,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1137,7 +1142,7 @@ export class GeoOperations {
|
|||
console.log("Applying fallback intersection...")
|
||||
const intersection = turf.intersect(
|
||||
turf.truncate(feature),
|
||||
turf.truncate(otherFeature)
|
||||
turf.truncate(otherFeature),
|
||||
)
|
||||
if (intersection == null) {
|
||||
return null
|
||||
|
|
|
@ -73,7 +73,6 @@ export default class UserRelatedState {
|
|||
|
||||
constructor(
|
||||
osmConnection: OsmConnection,
|
||||
availableLanguages?: string[],
|
||||
layout?: LayoutConfig,
|
||||
featureSwitches?: FeatureSwitchState,
|
||||
mapProperties?: MapProperties
|
||||
|
@ -365,6 +364,11 @@ export default class UserRelatedState {
|
|||
[translationMode]
|
||||
)
|
||||
|
||||
this.mangroveIdentity.getKeyId().addCallbackAndRun(kid => {
|
||||
amendedPrefs.data["mangrove_kid"] = kid
|
||||
amendedPrefs.ping()
|
||||
})
|
||||
|
||||
const usersettingMetaTagging = new ThemeMetaTagging()
|
||||
osmConnection.userDetails.addCallback((userDetails) => {
|
||||
for (const k in userDetails) {
|
||||
|
|
|
@ -306,7 +306,8 @@ export abstract class Store<T> implements Readable<T> {
|
|||
|
||||
export class ImmutableStore<T> extends Store<T> {
|
||||
public readonly data: T
|
||||
|
||||
static FALSE = new ImmutableStore<boolean>(false)
|
||||
static TRUE = new ImmutableStore<boolean>(true)
|
||||
constructor(data: T) {
|
||||
super()
|
||||
this.data = data
|
||||
|
|
|
@ -5,10 +5,12 @@ import { Feature, Position } from "geojson"
|
|||
import { GeoOperations } from "../GeoOperations"
|
||||
|
||||
export class MangroveIdentity {
|
||||
public readonly keypair: Store<CryptoKeyPair>
|
||||
public readonly key_id: Store<string>
|
||||
private readonly keypair: Store<CryptoKeyPair>
|
||||
private readonly mangroveIdentity: UIEventSource<string>
|
||||
private readonly key_id: Store<string>
|
||||
|
||||
constructor(mangroveIdentity: UIEventSource<string>) {
|
||||
this.mangroveIdentity = mangroveIdentity
|
||||
const key_id = new UIEventSource<string>(undefined)
|
||||
this.key_id = key_id
|
||||
const keypairEventSource = new UIEventSource<CryptoKeyPair>(undefined)
|
||||
|
@ -23,13 +25,7 @@ export class MangroveIdentity {
|
|||
key_id.setData(pem)
|
||||
})
|
||||
|
||||
try {
|
||||
if (!Utils.runningFromConsole && (mangroveIdentity.data ?? "") === "") {
|
||||
MangroveIdentity.CreateIdentity(mangroveIdentity).then((_) => {})
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Could not create identity: ", e)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,8 +40,61 @@ export class MangroveIdentity {
|
|||
// Identity has been loaded via osmPreferences by now - we don't overwrite
|
||||
return
|
||||
}
|
||||
console.log("Creating a new Mangrove identity!")
|
||||
identity.setData(JSON.stringify(jwk))
|
||||
}
|
||||
|
||||
/**
|
||||
* Only called to create a review.
|
||||
*/
|
||||
async getKeypair(): Promise<CryptoKeyPair> {
|
||||
if(this.keypair.data ?? "" === ""){
|
||||
// We want to create a review, but it seems like no key has been setup at this moment
|
||||
// We create the key
|
||||
try {
|
||||
if (!Utils.runningFromConsole && (this.mangroveIdentity.data ?? "") === "") {
|
||||
await MangroveIdentity.CreateIdentity(this.mangroveIdentity)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Could not create identity: ", e)
|
||||
}
|
||||
}
|
||||
return this.keypair.data
|
||||
}
|
||||
|
||||
getKeyId(): Store<string> {
|
||||
return this.key_id
|
||||
}
|
||||
|
||||
private allReviewsById : UIEventSource<(Review & {kid: string, signature: string})[]>= undefined
|
||||
|
||||
|
||||
/**
|
||||
* Gets all reviews that are made for the current identity.
|
||||
*/
|
||||
public getAllReviews(): Store<(Review & {kid: string, signature: string})[]>{
|
||||
if(this.allReviewsById !== undefined){
|
||||
return this.allReviewsById
|
||||
}
|
||||
this.allReviewsById = new UIEventSource( [])
|
||||
this.key_id.map(pem => {
|
||||
if(pem === undefined){
|
||||
return []
|
||||
}
|
||||
MangroveReviews.getReviews({
|
||||
kid: pem
|
||||
}).then(allReviews => {
|
||||
this.allReviewsById.setData(allReviews.reviews.map(r => ({
|
||||
...r, ...r.payload
|
||||
})))
|
||||
})
|
||||
})
|
||||
return this.allReviewsById
|
||||
}
|
||||
|
||||
addReview(review: Review & {kid, signature}) {
|
||||
this.allReviewsById?.setData(this.allReviewsById?.data?.concat([review]))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -176,25 +225,29 @@ export default class FeatureReviews {
|
|||
* The given review is uploaded to mangrove.reviews and added to the list of known reviews
|
||||
*/
|
||||
public async createReview(review: Omit<Review, "sub">): Promise<void> {
|
||||
if(review.opinion.length > FeatureReviews .REVIEW_OPINION_MAX_LENGTH){
|
||||
if(review.opinion !== undefined && review.opinion.length > FeatureReviews .REVIEW_OPINION_MAX_LENGTH){
|
||||
throw "Opinion too long, should be at most "+FeatureReviews.REVIEW_OPINION_MAX_LENGTH+" characters long"
|
||||
}
|
||||
const r: Review = {
|
||||
sub: this.subjectUri.data,
|
||||
...review,
|
||||
}
|
||||
const keypair: CryptoKeyPair = this._identity.keypair.data
|
||||
const keypair: CryptoKeyPair = await this._identity.getKeypair()
|
||||
const jwt = await MangroveReviews.signReview(keypair, r)
|
||||
const kid = await MangroveReviews.publicToPem(keypair.publicKey)
|
||||
await MangroveReviews.submitReview(jwt)
|
||||
this._reviews.data.push({
|
||||
const reviewWithKid = {
|
||||
...r,
|
||||
kid,
|
||||
signature: jwt,
|
||||
madeByLoggedInUser: new ImmutableStore(true),
|
||||
})
|
||||
this._reviews.ping()
|
||||
}
|
||||
this._reviews.data.push( reviewWithKid)
|
||||
this._reviews.ping()
|
||||
this._identity.addReview(reviewWithKid)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds given reviews to the 'reviews'-UI-eventsource
|
||||
|
@ -235,7 +288,7 @@ export default class FeatureReviews {
|
|||
...review,
|
||||
kid: reviewData.kid,
|
||||
signature: reviewData.signature,
|
||||
madeByLoggedInUser: this._identity.key_id.map((user_key_id) => {
|
||||
madeByLoggedInUser: this._identity.getKeyId().map((user_key_id) => {
|
||||
return reviewData.kid === user_key_id
|
||||
}),
|
||||
})
|
||||
|
|
|
@ -28,9 +28,9 @@ export default interface PointRenderingConfigJson {
|
|||
/**
|
||||
* question: At what location should this icon be shown?
|
||||
* multianswer: true
|
||||
* suggestions: return [{if: "value=point",then: "Show an icon for point (node) objects"},{if: "value=centroid",then: "Show an icon for line or polygon (way) objects at their centroid location"}, {if: "value=start",then: "Show an icon for line (way) objects at the start"},{if: "value=end",then: "Show an icon for line (way) object at the end"},{if: "value=projected_centerpoint",then: "Show an icon for line (way) object near the centroid location, but moved onto the line"}]
|
||||
* suggestions: return [{if: "value=point",then: "Show an icon for point (node) objects"},{if: "value=centroid",then: "Show an icon for line or polygon (way) objects at their centroid location"}, {if: "value=start",then: "Show an icon for line (way) objects at the start"},{if: "value=end",then: "Show an icon for line (way) object at the end"},{if: "value=projected_centerpoint",then: "Show an icon for line (way) object near the centroid location, but moved onto the line. Does not show an item on polygons"}, ,{if: "value=polygon_centroid",then: "Show an icon at a polygon centroid (but not if it is a way)"}]
|
||||
*/
|
||||
location: ("point" | "centroid" | "start" | "end" | "projected_centerpoint" | string)[]
|
||||
location: ("point" | "centroid" | "start" | "end" | "projected_centerpoint" | "polygon_centroid" | string)[]
|
||||
|
||||
/**
|
||||
* The marker for an element.
|
||||
|
|
|
@ -38,9 +38,10 @@ export default class PointRenderingConfig extends WithContextLoader {
|
|||
"start",
|
||||
"end",
|
||||
"projected_centerpoint",
|
||||
"polygon_centroid"
|
||||
])
|
||||
public readonly location: Set<
|
||||
"point" | "centroid" | "start" | "end" | "projected_centerpoint" | string
|
||||
"point" | "centroid" | "start" | "end" | "projected_centerpoint" | "polygon_centroid" | string
|
||||
>
|
||||
|
||||
public readonly marker: IconConfig[]
|
||||
|
|
|
@ -171,7 +171,6 @@ export default class ThemeViewState implements SpecialVisualizationState {
|
|||
})
|
||||
this.userRelatedState = new UserRelatedState(
|
||||
this.osmConnection,
|
||||
layout?.language,
|
||||
layout,
|
||||
this.featureSwitches,
|
||||
this.mapProperties
|
||||
|
|
|
@ -77,6 +77,9 @@ export class Orientation {
|
|||
}
|
||||
|
||||
private update(event: DeviceOrientationEvent) {
|
||||
if(event.alpha === null || event.beta === null || event.gamma === null){
|
||||
return
|
||||
}
|
||||
this.gotMeasurement.setData(true)
|
||||
// IF the phone is lying flat, then:
|
||||
// alpha is the compass direction (but not absolute)
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
center()
|
||||
}
|
||||
|
||||
const titleIconBlacklist = ["osmlink", "sharelink", "favourite_title_icon"]
|
||||
let titleIconBlacklist = ["osmlink", "sharelink", "favourite_title_icon"]
|
||||
</script>
|
||||
|
||||
{#if favLayer !== undefined}
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
|
||||
<div class="flex flex-col" on:keypress={(e) => console.log("Got keypress", e)}>
|
||||
<Tr t={Translations.t.favouritePoi.intro.Subs({ length: $favourites?.length ?? 0 })} />
|
||||
<Tr t={Translations.t.favouritePoi.priintroPrivacyvacy} />
|
||||
<Tr t={Translations.t.favouritePoi.introPrivacy} />
|
||||
|
||||
{#each $favourites as feature (feature.properties.id)}
|
||||
<FavouriteSummary {feature} {state} />
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
import Translations from "../i18n/Translations"
|
||||
import Icon from "../Map/Icon.svelte"
|
||||
import Maproulette from "../../Logic/Maproulette"
|
||||
import LoginToggle from "../Base/LoginToggle.svelte"
|
||||
|
||||
/**
|
||||
* A UI-element to change the status of a maproulette-task
|
||||
|
@ -18,8 +19,11 @@
|
|||
export let statusToSet: string
|
||||
export let maproulette_id_key: string
|
||||
|
||||
export let askFeedback: string = ""
|
||||
|
||||
let applying = false
|
||||
let failed = false
|
||||
let feedback: string = ""
|
||||
|
||||
/** Current status of the task*/
|
||||
let status: Store<number> = tags
|
||||
|
@ -36,6 +40,7 @@
|
|||
try {
|
||||
await Maproulette.singleton.closeTask(Number(maproulette_id), Number(statusToSet), {
|
||||
tags: `MapComplete MapComplete:${state.layout.id}`,
|
||||
comment: feedback
|
||||
})
|
||||
tags.data["mr_taskStatus"] = Maproulette.STATUS_MEANING[Number(statusToSet)]
|
||||
tags.data.status = statusToSet
|
||||
|
@ -47,17 +52,31 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
{#if failed}
|
||||
<LoginToggle ignoreLoading={true} {state}>
|
||||
{#if failed}
|
||||
<div class="alert">ERROR - could not close the MapRoulette task</div>
|
||||
{:else if applying}
|
||||
{:else if applying}
|
||||
<Loading>
|
||||
<Tr t={Translations.t.general.loading} />
|
||||
</Loading>
|
||||
{:else if $status === Maproulette.STATUS_OPEN}
|
||||
{:else if $status === Maproulette.STATUS_OPEN}
|
||||
{#if askFeedback !== "" && askFeedback !== undefined}
|
||||
<div class="flex flex-col p-1 gap-y-1 interactive border border-gray-500 border-dashed">
|
||||
<h3>{askFeedback}</h3>
|
||||
<textarea bind:value={feedback}></textarea>
|
||||
<button class="no-image-background w-full p-4 m-0" class:disabled={feedback===""} on:click={() => apply()}>
|
||||
<Icon clss="w-8 h-8 mr-2 shrink-0" icon={image} />
|
||||
{message}
|
||||
</button>
|
||||
{feedback}
|
||||
</div>
|
||||
{:else}
|
||||
<button class="no-image-background w-full p-4 m-0" on:click={() => apply()}>
|
||||
<Icon clss="w-8 h-8 mr-2 shrink-0" icon={image} />
|
||||
{message}
|
||||
</button>
|
||||
{:else}
|
||||
{/if}
|
||||
{:else}
|
||||
{message_closed}
|
||||
{/if}
|
||||
{/if}
|
||||
</LoginToggle>
|
||||
|
|
|
@ -35,9 +35,9 @@
|
|||
|
||||
let _state: "ask" | "saving" | "done" = "ask"
|
||||
|
||||
const connection = state.osmConnection
|
||||
let connection = state.osmConnection
|
||||
|
||||
const hasError: Store<undefined | "too_long"> = opinion.mapD(op => {
|
||||
let hasError: Store<undefined | "too_long"> = opinion.mapD(op => {
|
||||
const tooLong = op.length > FeatureReviews.REVIEW_OPINION_MAX_LENGTH
|
||||
if (tooLong) {
|
||||
return "too_long"
|
||||
|
@ -45,6 +45,8 @@
|
|||
return undefined
|
||||
})
|
||||
|
||||
let uploadFailed: string = undefined
|
||||
|
||||
async function save() {
|
||||
if (hasError.data) {
|
||||
return
|
||||
|
@ -63,13 +65,24 @@
|
|||
console.log("Testing - not actually saving review", review)
|
||||
await Utils.waitFor(1000)
|
||||
} else {
|
||||
try {
|
||||
|
||||
await reviews.createReview(review)
|
||||
} catch (e) {
|
||||
console.error("Could not create review due to", e)
|
||||
uploadFailed = "" + e
|
||||
}
|
||||
}
|
||||
_state = "done"
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if _state === "done"}
|
||||
{#if uploadFailed}
|
||||
<div class="alert flex">
|
||||
<ExclamationTriangle class="w-6 h-6" />
|
||||
<Tr t={Translations.t.general.error}/>
|
||||
{uploadFailed}
|
||||
</div>
|
||||
{:else if _state === "done"}
|
||||
<Tr cls="thanks w-full" t={t.saved} />
|
||||
{:else if _state === "saving"}
|
||||
<Loading>
|
||||
|
@ -109,8 +122,9 @@
|
|||
/>
|
||||
{#if $hasError === "too_long"}
|
||||
<div class="alert flex items-center px-2">
|
||||
<ExclamationTriangle class="w-12 h-12"/>
|
||||
<Tr t={t.too_long.Subs({max: FeatureReviews.REVIEW_OPINION_MAX_LENGTH, amount: $opinion?.length ?? 0})}> </Tr>
|
||||
<ExclamationTriangle class="w-12 h-12" />
|
||||
<Tr
|
||||
t={t.too_long.Subs({max: FeatureReviews.REVIEW_OPINION_MAX_LENGTH, amount: $opinion?.length ?? 0})}></Tr>
|
||||
</div>
|
||||
{/if}
|
||||
</label>
|
||||
|
|
40
src/UI/Reviews/ReviewsOverview.svelte
Normal file
40
src/UI/Reviews/ReviewsOverview.svelte
Normal file
|
@ -0,0 +1,40 @@
|
|||
<script lang="ts">
|
||||
import type { SpecialVisualizationState } from "../SpecialVisualization"
|
||||
import Translations from "../i18n/Translations"
|
||||
import Tr from "../Base/Tr.svelte"
|
||||
import LoginToggle from "../Base/LoginToggle.svelte"
|
||||
import LoginButton from "../Base/LoginButton.svelte"
|
||||
import SingleReview from "./SingleReview.svelte"
|
||||
import Mangrove_logo from "../../assets/svg/Mangrove_logo.svelte"
|
||||
|
||||
/**
|
||||
* A panel showing all the reviews by the logged-in user
|
||||
*/
|
||||
export let state: SpecialVisualizationState
|
||||
let reviews = state.userRelatedState.mangroveIdentity.getAllReviews()
|
||||
const t = Translations.t.reviews
|
||||
</script>
|
||||
|
||||
<LoginToggle {state}>
|
||||
<div slot="not-logged-in">
|
||||
<LoginButton osmConnection={state.osmConnection}>
|
||||
<Tr t={Translations.t.favouritePoi.loginToSeeList} />
|
||||
</LoginButton>
|
||||
</div>
|
||||
|
||||
|
||||
{#if $reviews?.length > 0}
|
||||
<div class="flex flex-col" on:keypress={(e) => console.log("Got keypress", e)}>
|
||||
{#each $reviews as review (review.sub)}
|
||||
<SingleReview {review} showSub={true} {state} />
|
||||
{/each}
|
||||
</div>
|
||||
{:else}
|
||||
<Tr t={t.your_reviews_empty} />
|
||||
{/if}
|
||||
<a class="link-underline" href="https://github.com/pietervdvn/MapComplete/issues/1782" target="_blank" rel="noopener noreferrer"><Tr t={t.reviews_bug}/></a>
|
||||
<div class="flex justify-end">
|
||||
<Mangrove_logo class="h-12 w-12 shrink-0 p-1" />
|
||||
<Tr cls="text-sm subtle" t={t.attribution} />
|
||||
</div>
|
||||
</LoginToggle>
|
|
@ -1,22 +1,43 @@
|
|||
<script lang="ts">
|
||||
import { Review } from "mangrove-reviews-typescript"
|
||||
import { Store } from "../../Logic/UIEventSource"
|
||||
import { ImmutableStore, Store } from "../../Logic/UIEventSource"
|
||||
import StarsBar from "./StarsBar.svelte"
|
||||
import Translations from "../i18n/Translations"
|
||||
import Tr from "../Base/Tr.svelte"
|
||||
import { ariaLabel } from "../../Utils/ariaLabel"
|
||||
import type { SpecialVisualizationState } from "../SpecialVisualization"
|
||||
|
||||
export let review: Review & { kid: string; signature: string; madeByLoggedInUser: Store<boolean> }
|
||||
export let state: SpecialVisualizationState = undefined
|
||||
export let review: Review & { kid: string; signature: string; madeByLoggedInUser?: Store<boolean> }
|
||||
let name = review.metadata.nickname
|
||||
name ??= ((review.metadata.given_name ?? "") + " " + (review.metadata.family_name ?? "")).trim()
|
||||
let d = new Date()
|
||||
d.setTime(review.iat * 1000)
|
||||
let date = d.toDateString()
|
||||
let byLoggedInUser = review.madeByLoggedInUser
|
||||
let byLoggedInUser = review.madeByLoggedInUser ?? ImmutableStore.FALSE
|
||||
|
||||
export let showSub = false
|
||||
let subUrl = new URL(review.sub)
|
||||
let [lat, lon] = subUrl.pathname.split(",").map(l => Number(l))
|
||||
let sub = subUrl.searchParams.get("q")
|
||||
|
||||
function selectFeature(){
|
||||
console.log("Selecting and zooming to", {lon, lat})
|
||||
state?.mapProperties?.location?.setData({lon, lat})
|
||||
state?.mapProperties?.zoom?.setData(Math.max(16, state?.mapProperties?.zoom?.data))
|
||||
|
||||
state?.guistate?.closeAll()
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div class={"low-interaction rounded-lg p-1 px-2 " + ($byLoggedInUser ? "border-interactive" : "")}>
|
||||
<div class="flex items-center justify-between">
|
||||
<div class={"low-interaction rounded-lg p-1 px-2 flex flex-col" + ($byLoggedInUser ? "border-interactive" : "")}>
|
||||
{#if showSub}
|
||||
<button class="link" on:click={() => selectFeature()}>
|
||||
<h3>{sub}</h3>
|
||||
</button>
|
||||
{/if}
|
||||
<div class="flex items-center justify-between w-full">
|
||||
<div
|
||||
tabindex="0"
|
||||
use:ariaLabel={Translations.t.reviews.rated.Subs({
|
||||
|
|
|
@ -3,11 +3,7 @@ import { FixedUiElement } from "./Base/FixedUiElement"
|
|||
import BaseUIElement from "./BaseUIElement"
|
||||
import Title from "./Base/Title"
|
||||
import Table from "./Base/Table"
|
||||
import {
|
||||
RenderingSpecification,
|
||||
SpecialVisualization,
|
||||
SpecialVisualizationState,
|
||||
} from "./SpecialVisualization"
|
||||
import { RenderingSpecification, SpecialVisualization, SpecialVisualizationState } from "./SpecialVisualization"
|
||||
import { HistogramViz } from "./Popup/HistogramViz"
|
||||
import { MinimapViz } from "./Popup/MinimapViz"
|
||||
import { ShareLinkViz } from "./Popup/ShareLinkViz"
|
||||
|
@ -90,6 +86,8 @@ import Qr from "../Utils/Qr"
|
|||
import ComparisonTool from "./Comparison/ComparisonTool.svelte"
|
||||
import SpecialTranslation from "./Popup/TagRendering/SpecialTranslation.svelte"
|
||||
import SpecialVisualisationUtils from "./SpecialVisualisationUtils"
|
||||
import LoginButton from "./Base/LoginButton.svelte"
|
||||
import Toggle from "./Input/Toggle"
|
||||
|
||||
class NearbyImageVis implements SpecialVisualization {
|
||||
// Class must be in SpecialVisualisations due to weird cyclical import that breaks the tests
|
||||
|
@ -116,7 +114,7 @@ class NearbyImageVis implements SpecialVisualization {
|
|||
tags: UIEventSource<Record<string, string>>,
|
||||
args: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
): BaseUIElement {
|
||||
const isOpen = args[0] === "open"
|
||||
const readonly = args[1] === "readonly"
|
||||
|
@ -183,7 +181,7 @@ class StealViz implements SpecialVisualization {
|
|||
selectedElement: otherFeature,
|
||||
state,
|
||||
layer,
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
if (elements.length === 1) {
|
||||
|
@ -191,8 +189,8 @@ class StealViz implements SpecialVisualization {
|
|||
}
|
||||
return new Combine(elements).SetClass("flex flex-col")
|
||||
},
|
||||
[state.indexedFeatures.featuresById]
|
||||
)
|
||||
[state.indexedFeatures.featuresById],
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -231,7 +229,7 @@ export class QuestionViz implements SpecialVisualization {
|
|||
tags: UIEventSource<Record<string, string>>,
|
||||
args: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
): BaseUIElement {
|
||||
const labels = args[0]
|
||||
?.split(";")
|
||||
|
@ -274,7 +272,7 @@ export default class SpecialVisualizations {
|
|||
defaultArg = "_empty string_"
|
||||
}
|
||||
return [arg.name, defaultArg, arg.doc]
|
||||
})
|
||||
}),
|
||||
)
|
||||
: undefined,
|
||||
new Title("Example usage of " + viz.funcName, 4),
|
||||
|
@ -284,20 +282,21 @@ export default class SpecialVisualizations {
|
|||
viz.funcName +
|
||||
"(" +
|
||||
viz.args.map((arg) => arg.defaultValue).join(",") +
|
||||
")}`"
|
||||
")}`",
|
||||
).SetClass("literal-code"),
|
||||
])
|
||||
}
|
||||
|
||||
public static constructSpecification(
|
||||
template: string,
|
||||
extraMappings: SpecialVisualization[] = []
|
||||
extraMappings: SpecialVisualization[] = [],
|
||||
): RenderingSpecification[] {
|
||||
return SpecialVisualisationUtils.constructSpecification(template, extraMappings)
|
||||
}
|
||||
|
||||
public static HelpMessage() {
|
||||
const helpTexts = SpecialVisualizations.specialVisualizations.map((viz) =>
|
||||
SpecialVisualizations.DocumentationFor(viz)
|
||||
SpecialVisualizations.DocumentationFor(viz),
|
||||
)
|
||||
|
||||
return new Combine([
|
||||
|
@ -331,10 +330,10 @@ export default class SpecialVisualizations {
|
|||
},
|
||||
},
|
||||
null,
|
||||
" "
|
||||
)
|
||||
" ",
|
||||
),
|
||||
).SetClass("code"),
|
||||
'In other words: use `{ "before": ..., "after": ..., "special": {"type": ..., "argname": ...argvalue...}`. The args are in the `special` block; an argvalue can be a string, a translation or another value. (Refer to class `RewriteSpecial` in case of problems)',
|
||||
"In other words: use `{ \"before\": ..., \"after\": ..., \"special\": {\"type\": ..., \"argname\": ...argvalue...}`. The args are in the `special` block; an argvalue can be a string, a translation or another value. (Refer to class `RewriteSpecial` in case of problems)",
|
||||
]).SetClass("flex flex-col"),
|
||||
...helpTexts,
|
||||
]).SetClass("flex flex-col")
|
||||
|
@ -343,7 +342,7 @@ export default class SpecialVisualizations {
|
|||
// noinspection JSUnusedGlobalSymbols
|
||||
public static renderExampleOfSpecial(
|
||||
state: SpecialVisualizationState,
|
||||
s: SpecialVisualization
|
||||
s: SpecialVisualization,
|
||||
): BaseUIElement {
|
||||
const examples =
|
||||
s.structuredExamples === undefined
|
||||
|
@ -354,7 +353,7 @@ export default class SpecialVisualizations {
|
|||
new UIEventSource<Record<string, string>>(e.feature.properties),
|
||||
e.args,
|
||||
e.feature,
|
||||
undefined
|
||||
undefined,
|
||||
)
|
||||
})
|
||||
return new Combine([new Title(s.funcName), s.docs, ...examples])
|
||||
|
@ -396,7 +395,7 @@ export default class SpecialVisualizations {
|
|||
assignTo: state.userRelatedState.language,
|
||||
availableLanguages: state.layout.language,
|
||||
preferredLanguages: state.osmConnection.userDetails.map(
|
||||
(ud) => ud.languages
|
||||
(ud) => ud.languages,
|
||||
),
|
||||
})
|
||||
},
|
||||
|
@ -421,7 +420,7 @@ export default class SpecialVisualizations {
|
|||
|
||||
constr(
|
||||
state: SpecialVisualizationState,
|
||||
tagSource: UIEventSource<Record<string, string>>
|
||||
tagSource: UIEventSource<Record<string, string>>,
|
||||
): BaseUIElement {
|
||||
return new VariableUiElement(
|
||||
tagSource
|
||||
|
@ -431,7 +430,7 @@ export default class SpecialVisualizations {
|
|||
return new SplitRoadWizard(<WayId>id, state)
|
||||
}
|
||||
return undefined
|
||||
})
|
||||
}),
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -445,7 +444,7 @@ export default class SpecialVisualizations {
|
|||
tagSource: UIEventSource<Record<string, string>>,
|
||||
argument: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
): BaseUIElement {
|
||||
if (feature.geometry.type !== "Point") {
|
||||
return undefined
|
||||
|
@ -468,7 +467,7 @@ export default class SpecialVisualizations {
|
|||
tagSource: UIEventSource<Record<string, string>>,
|
||||
argument: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
): BaseUIElement {
|
||||
if (!layer.deletion) {
|
||||
return undefined
|
||||
|
@ -496,7 +495,7 @@ export default class SpecialVisualizations {
|
|||
state: SpecialVisualizationState,
|
||||
tagSource: UIEventSource<Record<string, string>>,
|
||||
argument: string[],
|
||||
feature: Feature
|
||||
feature: Feature,
|
||||
): BaseUIElement {
|
||||
const [lon, lat] = GeoOperations.centerpointCoordinates(feature)
|
||||
return new SvelteUIElement(CreateNewNote, {
|
||||
|
@ -560,7 +559,7 @@ export default class SpecialVisualizations {
|
|||
.map((tags) => tags[args[0]])
|
||||
.map((wikidata) => {
|
||||
wikidata = Utils.NoEmpty(
|
||||
wikidata?.split(";")?.map((wd) => wd.trim()) ?? []
|
||||
wikidata?.split(";")?.map((wd) => wd.trim()) ?? [],
|
||||
)[0]
|
||||
const entry = Wikidata.LoadWikidataEntry(wikidata)
|
||||
return new VariableUiElement(
|
||||
|
@ -570,9 +569,9 @@ export default class SpecialVisualizations {
|
|||
}
|
||||
const response = <WikidataResponse>e["success"]
|
||||
return Translation.fromMap(response.labels)
|
||||
})
|
||||
}),
|
||||
)
|
||||
})
|
||||
}),
|
||||
),
|
||||
},
|
||||
new MapillaryLinkVis(),
|
||||
|
@ -586,7 +585,7 @@ export default class SpecialVisualizations {
|
|||
tags: UIEventSource<Record<string, string>>,
|
||||
_,
|
||||
__,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
) => new SvelteUIElement(AllTagsPanel, { tags, layer }),
|
||||
},
|
||||
{
|
||||
|
@ -608,7 +607,7 @@ export default class SpecialVisualizations {
|
|||
return new ImageCarousel(
|
||||
AllImageProviders.LoadImagesFor(tags, imagePrefixes),
|
||||
tags,
|
||||
state
|
||||
state,
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -664,7 +663,7 @@ export default class SpecialVisualizations {
|
|||
{
|
||||
nameKey: nameKey,
|
||||
fallbackName,
|
||||
}
|
||||
},
|
||||
)
|
||||
return new SvelteUIElement(StarsBarIcon, {
|
||||
score: reviews.average,
|
||||
|
@ -697,7 +696,7 @@ export default class SpecialVisualizations {
|
|||
{
|
||||
nameKey: nameKey,
|
||||
fallbackName,
|
||||
}
|
||||
},
|
||||
)
|
||||
return new SvelteUIElement(ReviewForm, { reviews, state, tags, feature, layer })
|
||||
},
|
||||
|
@ -729,7 +728,7 @@ export default class SpecialVisualizations {
|
|||
{
|
||||
nameKey: nameKey,
|
||||
fallbackName,
|
||||
}
|
||||
},
|
||||
)
|
||||
return new SvelteUIElement(AllReviews, { reviews, state, tags, feature, layer })
|
||||
},
|
||||
|
@ -787,7 +786,7 @@ export default class SpecialVisualizations {
|
|||
tags: UIEventSource<Record<string, string>>,
|
||||
args: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
): SvelteUIElement {
|
||||
const keyToUse = args[0]
|
||||
const prefix = args[1]
|
||||
|
@ -824,17 +823,17 @@ export default class SpecialVisualizations {
|
|||
return undefined
|
||||
}
|
||||
const allUnits: Unit[] = [].concat(
|
||||
...(state?.layout?.layers?.map((lyr) => lyr.units) ?? [])
|
||||
...(state?.layout?.layers?.map((lyr) => lyr.units) ?? []),
|
||||
)
|
||||
const unit = allUnits.filter((unit) =>
|
||||
unit.isApplicableToKey(key)
|
||||
unit.isApplicableToKey(key),
|
||||
)[0]
|
||||
if (unit === undefined) {
|
||||
return value
|
||||
}
|
||||
const getCountry = () => tagSource.data._country
|
||||
return unit.asHumanLongValue(value, getCountry)
|
||||
})
|
||||
}),
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -851,7 +850,7 @@ export default class SpecialVisualizations {
|
|||
new Combine([
|
||||
t.downloadFeatureAsGeojson.SetClass("font-bold text-lg"),
|
||||
t.downloadGeoJsonHelper.SetClass("subtle"),
|
||||
]).SetClass("flex flex-col")
|
||||
]).SetClass("flex flex-col"),
|
||||
)
|
||||
.onClick(() => {
|
||||
console.log("Exporting as Geojson")
|
||||
|
@ -864,7 +863,7 @@ export default class SpecialVisualizations {
|
|||
title + "_mapcomplete_export.geojson",
|
||||
{
|
||||
mimetype: "application/vnd.geo+json",
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
.SetClass("w-full")
|
||||
|
@ -900,7 +899,7 @@ export default class SpecialVisualizations {
|
|||
constr: (state) => {
|
||||
return new SubtleButton(
|
||||
Svg.delete_icon_svg().SetStyle("height: 1.5rem"),
|
||||
Translations.t.general.removeLocationHistory
|
||||
Translations.t.general.removeLocationHistory,
|
||||
).onClick(() => {
|
||||
state.historicalUserLocations.features.setData([])
|
||||
state.selectedElement.setData(undefined)
|
||||
|
@ -938,10 +937,10 @@ export default class SpecialVisualizations {
|
|||
.filter((c) => c.text !== "")
|
||||
.map(
|
||||
(c, i) =>
|
||||
new NoteCommentElement(c, state, i, comments.length)
|
||||
)
|
||||
new NoteCommentElement(c, state, i, comments.length),
|
||||
),
|
||||
).SetClass("flex flex-col")
|
||||
})
|
||||
}),
|
||||
),
|
||||
},
|
||||
{
|
||||
|
@ -975,7 +974,7 @@ export default class SpecialVisualizations {
|
|||
tagsSource: UIEventSource<Record<string, string>>,
|
||||
_: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
) =>
|
||||
new VariableUiElement(
|
||||
tagsSource.map((tags) => {
|
||||
|
@ -993,7 +992,7 @@ export default class SpecialVisualizations {
|
|||
feature,
|
||||
layer,
|
||||
}).SetClass("px-1")
|
||||
})
|
||||
}),
|
||||
),
|
||||
},
|
||||
{
|
||||
|
@ -1009,8 +1008,8 @@ export default class SpecialVisualizations {
|
|||
let challenge = Stores.FromPromise(
|
||||
Utils.downloadJsonCached(
|
||||
`${Maproulette.defaultEndpoint}/challenge/${parentId}`,
|
||||
24 * 60 * 60 * 1000
|
||||
)
|
||||
24 * 60 * 60 * 1000,
|
||||
),
|
||||
)
|
||||
|
||||
return new VariableUiElement(
|
||||
|
@ -1035,7 +1034,7 @@ export default class SpecialVisualizations {
|
|||
} else {
|
||||
return [title, new List(listItems)]
|
||||
}
|
||||
})
|
||||
}),
|
||||
)
|
||||
},
|
||||
docs: "Fetches the metadata of MapRoulette campaign that this task is part of and shows those details (namely `title`, `description` and `instruction`).\n\nThis reads the property `mr_challengeId` to detect the parent campaign.",
|
||||
|
@ -1049,15 +1048,15 @@ export default class SpecialVisualizations {
|
|||
"\n" +
|
||||
"```json\n" +
|
||||
"{\n" +
|
||||
' "id": "mark_duplicate",\n' +
|
||||
' "render": {\n' +
|
||||
' "special": {\n' +
|
||||
' "type": "maproulette_set_status",\n' +
|
||||
' "message": {\n' +
|
||||
' "en": "Mark as not found or false positive"\n' +
|
||||
" \"id\": \"mark_duplicate\",\n" +
|
||||
" \"render\": {\n" +
|
||||
" \"special\": {\n" +
|
||||
" \"type\": \"maproulette_set_status\",\n" +
|
||||
" \"message\": {\n" +
|
||||
" \"en\": \"Mark as not found or false positive\"\n" +
|
||||
" },\n" +
|
||||
' "status": "2",\n' +
|
||||
' "image": "close"\n' +
|
||||
" \"status\": \"2\",\n" +
|
||||
" \"image\": \"close\"\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"}\n" +
|
||||
|
@ -1086,10 +1085,15 @@ export default class SpecialVisualizations {
|
|||
doc: "The property name containing the maproulette id",
|
||||
defaultValue: "mr_taskId",
|
||||
},
|
||||
{
|
||||
name: "ask_feedback",
|
||||
doc: "If not an empty string, this will be used as question to ask some additional feedback. A text field will be added",
|
||||
defaultValue: ""
|
||||
}
|
||||
],
|
||||
|
||||
constr: (state, tagsSource, args) => {
|
||||
let [message, image, message_closed, statusToSet, maproulette_id_key] = args
|
||||
let [message, image, message_closed, statusToSet, maproulette_id_key, askFeedback] = args
|
||||
if (image === "") {
|
||||
image = "confirm"
|
||||
}
|
||||
|
@ -1105,6 +1109,7 @@ export default class SpecialVisualizations {
|
|||
message_closed,
|
||||
statusToSet,
|
||||
maproulette_id_key,
|
||||
askFeedback
|
||||
})
|
||||
},
|
||||
},
|
||||
|
@ -1124,8 +1129,8 @@ export default class SpecialVisualizations {
|
|||
const fsBboxed = new BBoxFeatureSourceForLayer(fs, bbox)
|
||||
return new StatisticsPanel(fsBboxed)
|
||||
},
|
||||
[state.mapProperties.bounds]
|
||||
)
|
||||
[state.mapProperties.bounds],
|
||||
),
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -1191,7 +1196,7 @@ export default class SpecialVisualizations {
|
|||
constr(
|
||||
state: SpecialVisualizationState,
|
||||
tagSource: UIEventSource<Record<string, string>>,
|
||||
args: string[]
|
||||
args: string[],
|
||||
): BaseUIElement {
|
||||
let [text, href, classnames, download, ariaLabel] = args
|
||||
if (download === "") {
|
||||
|
@ -1203,13 +1208,13 @@ export default class SpecialVisualizations {
|
|||
(tags) =>
|
||||
new SvelteUIElement(Link, {
|
||||
text: Utils.SubstituteKeys(text, tags),
|
||||
href: Utils.SubstituteKeys(href, tags).replaceAll(/ /g, '%20') /* Chromium based browsers eat the spaces */,
|
||||
href: Utils.SubstituteKeys(href, tags).replaceAll(/ /g, "%20") /* Chromium based browsers eat the spaces */,
|
||||
classnames,
|
||||
download: Utils.SubstituteKeys(download, tags),
|
||||
ariaLabel: Utils.SubstituteKeys(ariaLabel, tags),
|
||||
newTab,
|
||||
})
|
||||
)
|
||||
}),
|
||||
),
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -1231,7 +1236,7 @@ export default class SpecialVisualizations {
|
|||
},
|
||||
},
|
||||
null,
|
||||
" "
|
||||
" ",
|
||||
) +
|
||||
"\n```",
|
||||
args: [
|
||||
|
@ -1255,7 +1260,7 @@ export default class SpecialVisualizations {
|
|||
featureTags: UIEventSource<Record<string, string>>,
|
||||
args: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
) {
|
||||
const [key, tr, classesRaw] = args
|
||||
let classes = classesRaw ?? ""
|
||||
|
@ -1280,7 +1285,7 @@ export default class SpecialVisualizations {
|
|||
elements.push(subsTr)
|
||||
}
|
||||
return elements
|
||||
})
|
||||
}),
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -1300,7 +1305,7 @@ export default class SpecialVisualizations {
|
|||
tagSource: UIEventSource<Record<string, string>>,
|
||||
argument: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
): BaseUIElement {
|
||||
return new VariableUiElement(
|
||||
tagSource.map((tags) => {
|
||||
|
@ -1312,7 +1317,7 @@ export default class SpecialVisualizations {
|
|||
console.error("Cannot create a translation for", v, "due to", e)
|
||||
return JSON.stringify(v)
|
||||
}
|
||||
})
|
||||
}),
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -1332,7 +1337,7 @@ export default class SpecialVisualizations {
|
|||
tagSource: UIEventSource<Record<string, string>>,
|
||||
argument: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
): BaseUIElement {
|
||||
const key = argument[0]
|
||||
const validator = new FediverseValidator()
|
||||
|
@ -1342,7 +1347,7 @@ export default class SpecialVisualizations {
|
|||
.map((fediAccount) => {
|
||||
fediAccount = validator.reformat(fediAccount)
|
||||
const [_, username, host] = fediAccount.match(
|
||||
FediverseValidator.usernameAtServer
|
||||
FediverseValidator.usernameAtServer,
|
||||
)
|
||||
|
||||
const normalLink = new SvelteUIElement(Link, {
|
||||
|
@ -1357,7 +1362,7 @@ export default class SpecialVisualizations {
|
|||
]
|
||||
console.log(
|
||||
"LoggedinContributorMastodon",
|
||||
loggedInContributorMastodon
|
||||
loggedInContributorMastodon,
|
||||
)
|
||||
if (!loggedInContributorMastodon) {
|
||||
return normalLink
|
||||
|
@ -1373,7 +1378,7 @@ export default class SpecialVisualizations {
|
|||
newTab: true,
|
||||
}).SetClass("button"),
|
||||
])
|
||||
})
|
||||
}),
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -1393,7 +1398,7 @@ export default class SpecialVisualizations {
|
|||
tagSource: UIEventSource<Record<string, string>>,
|
||||
args: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
): BaseUIElement {
|
||||
return new FixedUiElement("{" + args[0] + "}")
|
||||
},
|
||||
|
@ -1414,7 +1419,7 @@ export default class SpecialVisualizations {
|
|||
tagSource: UIEventSource<Record<string, string>>,
|
||||
argument: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
): BaseUIElement {
|
||||
const key = argument[0] ?? "value"
|
||||
return new VariableUiElement(
|
||||
|
@ -1434,10 +1439,10 @@ export default class SpecialVisualizations {
|
|||
"Could not parse this tag: " +
|
||||
JSON.stringify(value) +
|
||||
" due to " +
|
||||
e
|
||||
e,
|
||||
).SetClass("alert")
|
||||
}
|
||||
})
|
||||
}),
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -1458,7 +1463,7 @@ export default class SpecialVisualizations {
|
|||
tagSource: UIEventSource<Record<string, string>>,
|
||||
argument: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
): BaseUIElement {
|
||||
const giggityUrl = argument[0]
|
||||
return new SvelteUIElement(Giggity, { tags: tagSource, state, giggityUrl })
|
||||
|
@ -1474,12 +1479,12 @@ export default class SpecialVisualizations {
|
|||
_: UIEventSource<Record<string, string>>,
|
||||
argument: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
): BaseUIElement {
|
||||
const tags = (<ThemeViewState>(
|
||||
state
|
||||
)).geolocation.currentUserLocation.features.map(
|
||||
(features) => features[0]?.properties
|
||||
(features) => features[0]?.properties,
|
||||
)
|
||||
return new Combine([
|
||||
new SvelteUIElement(OrientationDebugPanel, {}),
|
||||
|
@ -1501,7 +1506,7 @@ export default class SpecialVisualizations {
|
|||
tagSource: UIEventSource<Record<string, string>>,
|
||||
argument: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
): BaseUIElement {
|
||||
return new SvelteUIElement(MarkAsFavourite, {
|
||||
tags: tagSource,
|
||||
|
@ -1521,7 +1526,7 @@ export default class SpecialVisualizations {
|
|||
tagSource: UIEventSource<Record<string, string>>,
|
||||
argument: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
): BaseUIElement {
|
||||
return new SvelteUIElement(MarkAsFavouriteMini, {
|
||||
tags: tagSource,
|
||||
|
@ -1541,7 +1546,7 @@ export default class SpecialVisualizations {
|
|||
tagSource: UIEventSource<Record<string, string>>,
|
||||
argument: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
): BaseUIElement {
|
||||
return new SvelteUIElement(DirectionIndicator, { state, feature })
|
||||
},
|
||||
|
@ -1556,7 +1561,7 @@ export default class SpecialVisualizations {
|
|||
tagSource: UIEventSource<Record<string, string>>,
|
||||
argument: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
): BaseUIElement {
|
||||
return new VariableUiElement(
|
||||
tagSource
|
||||
|
@ -1578,9 +1583,9 @@ export default class SpecialVisualizations {
|
|||
`${window.location.protocol}//${window.location.host}${window.location.pathname}?${layout}lat=${lat}&lon=${lon}&z=15` +
|
||||
`#${id}`
|
||||
return new Img(new Qr(url).toImageElement(75)).SetStyle(
|
||||
"width: 75px"
|
||||
"width: 75px",
|
||||
)
|
||||
})
|
||||
}),
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -1600,7 +1605,7 @@ export default class SpecialVisualizations {
|
|||
tagSource: UIEventSource<Record<string, string>>,
|
||||
args: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
): BaseUIElement {
|
||||
const key = args[0] === "" ? "_direction:centerpoint" : args[0]
|
||||
return new VariableUiElement(
|
||||
|
@ -1611,11 +1616,11 @@ export default class SpecialVisualizations {
|
|||
})
|
||||
.mapD((value) => {
|
||||
const dir = GeoOperations.bearingToHuman(
|
||||
GeoOperations.parseBearing(value)
|
||||
GeoOperations.parseBearing(value),
|
||||
)
|
||||
console.log("Human dir", dir)
|
||||
return Translations.t.general.visualFeedback.directionsAbsolute[dir]
|
||||
})
|
||||
}),
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -1650,7 +1655,7 @@ export default class SpecialVisualizations {
|
|||
tagSource: UIEventSource<Record<string, string>>,
|
||||
args: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig
|
||||
layer: LayerConfig,
|
||||
): BaseUIElement {
|
||||
const url = args[0]
|
||||
const postprocessVelopark = args[2] === "velopark"
|
||||
|
@ -1666,6 +1671,17 @@ export default class SpecialVisualizations {
|
|||
})
|
||||
},
|
||||
},
|
||||
{
|
||||
funcName: "login_button",
|
||||
args: [
|
||||
],
|
||||
docs: "Show a login button",
|
||||
needsUrls: [],
|
||||
constr(state: SpecialVisualizationState, tagSource: UIEventSource<Record<string, string>>, args: string[], feature: Feature, layer: LayerConfig): BaseUIElement {
|
||||
return new Toggle(undefined,
|
||||
new SvelteUIElement(LoginButton), state.osmConnection.isLoggedIn)
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
specialVisualizations.push(new AutoApplyButton(specialVisualizations))
|
||||
|
@ -1677,7 +1693,7 @@ export default class SpecialVisualizations {
|
|||
throw (
|
||||
"Invalid special visualisation found: funcName is undefined for " +
|
||||
invalid.map((sp) => sp.i).join(", ") +
|
||||
'. Did you perhaps type \n funcName: "funcname" // type declaration uses COLON\ninstead of:\n funcName = "funcName" // value definition uses EQUAL'
|
||||
". Did you perhaps type \n funcName: \"funcname\" // type declaration uses COLON\ninstead of:\n funcName = \"funcName\" // value definition uses EQUAL"
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
import FilterPanel from "./BigComponents/FilterPanel.svelte"
|
||||
import PrivacyPolicy from "./BigComponents/PrivacyPolicy.svelte"
|
||||
import { BBox } from "../Logic/BBox"
|
||||
import ReviewsOverview from "./Reviews/ReviewsOverview.svelte"
|
||||
|
||||
export let state: ThemeViewState
|
||||
let layout = state.layout
|
||||
|
@ -264,12 +265,15 @@
|
|||
{#if state.lastClickObject.hasPresets || state.lastClickObject.hasNoteLayer}
|
||||
<button
|
||||
class="pointer-events-auto w-fit"
|
||||
class:disabled={$currentZoom < Constants.minZoomLevelToAddNewPoint}
|
||||
on:click={() => {
|
||||
state.openNewDialog()
|
||||
}}
|
||||
on:keydown={forwardEventToMap}
|
||||
>
|
||||
{#if state.lastClickObject.hasPresets}
|
||||
{#if $currentZoom < Constants.minZoomLevelToAddNewPoint}
|
||||
<Tr t={Translations.t.general.add.zoomInFurther}/>
|
||||
{:else if state.lastClickObject.hasPresets}
|
||||
<Tr t={Translations.t.general.add.title} />
|
||||
{:else}
|
||||
<Tr t={Translations.t.notes.addAComment} />
|
||||
|
@ -355,14 +359,16 @@
|
|||
|
||||
<LoginToggle ignoreLoading={true} {state}>
|
||||
{#if ($showCrosshair === "yes" && $currentZoom >= 17) || $showCrosshair === "always" || $visualFeedback}
|
||||
<!-- Don't use h-full: h-full does _not_ include the area under the URL-bar, which offsets the crosshair a bit -->
|
||||
<div
|
||||
class="pointer-events-none absolute top-0 left-0 flex h-full w-full items-center justify-center"
|
||||
class="pointer-events-none absolute top-0 left-0 flex w-full items-center justify-center"
|
||||
style="height: 100vh"
|
||||
>
|
||||
<Cross class="h-4 w-4" />
|
||||
</div>
|
||||
{/if}
|
||||
<!-- Add in an empty container to remove error messages if login fails -->
|
||||
<svelte:fragment slot="error" />
|
||||
<!-- Add in an empty container to remove errors -->
|
||||
</LoginToggle>
|
||||
|
||||
<If condition={state.previewedImage.map((i) => i !== undefined)}>
|
||||
|
@ -588,6 +594,10 @@
|
|||
<Tr t={Translations.t.favouritePoi.title} />
|
||||
</h3>
|
||||
<Favourites {state} />
|
||||
<h3>
|
||||
<Tr t={Translations.t.reviews.your_reviews} />
|
||||
</h3>
|
||||
<ReviewsOverview {state}/>
|
||||
</div>
|
||||
</TabbedGroup>
|
||||
</FloatOver>
|
||||
|
|
Loading…
Reference in a new issue