forked from MapComplete/MapComplete
		
	Fix: generating layeroverview; performance: do not try to download ratings if no ratings element is present
This commit is contained in:
		
							parent
							
								
									c13d80f062
								
							
						
					
					
						commit
						fc62d41e1b
					
				
					 12 changed files with 67 additions and 15 deletions
				
			
		| 
						 | 
					@ -189,9 +189,6 @@
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      "id": "rating",
 | 
					      "id": "rating",
 | 
				
			||||||
      "labels": [
 | 
					 | 
				
			||||||
        "defaults"
 | 
					 | 
				
			||||||
      ],
 | 
					 | 
				
			||||||
      "icon": {
 | 
					      "icon": {
 | 
				
			||||||
        "class": "w-20 mx-1 flex items-center"
 | 
					        "class": "w-20 mx-1 flex items-center"
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -604,7 +604,7 @@
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "marker": [
 | 
					            "marker": [
 | 
				
			||||||
              {
 | 
					              {
 | 
				
			||||||
                "icon": "statistics:black"
 | 
					                "icon": "./assets/svg/statistics.svg"
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "iconSize": "30,30",
 | 
					            "iconSize": "30,30",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -294,7 +294,7 @@
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "marker": [
 | 
					            "marker": [
 | 
				
			||||||
              {
 | 
					              {
 | 
				
			||||||
                "icon": "statistics:black"
 | 
					                "icon": "./assets/svg/statistics.svg"
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "iconSize": "30,30",
 | 
					            "iconSize": "30,30",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -467,7 +467,7 @@
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "marker": [
 | 
					            "marker": [
 | 
				
			||||||
              {
 | 
					              {
 | 
				
			||||||
                "icon": "statistics"
 | 
					                "icon": "./assets/svg/statistics.svg"
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
            ]
 | 
					            ]
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  "name": "mapcomplete",
 | 
					  "name": "mapcomplete",
 | 
				
			||||||
  "version": "0.34.9",
 | 
					  "version": "0.35.0",
 | 
				
			||||||
  "repository": "https://github.com/pietervdvn/MapComplete",
 | 
					  "repository": "https://github.com/pietervdvn/MapComplete",
 | 
				
			||||||
  "description": "A small website to edit OSM easily",
 | 
					  "description": "A small website to edit OSM easily",
 | 
				
			||||||
  "bugs": "https://github.com/pietervdvn/MapComplete/issues",
 | 
					  "bugs": "https://github.com/pietervdvn/MapComplete/issues",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -123,6 +123,14 @@ export default class Constants {
 | 
				
			||||||
        "teardrop",
 | 
					        "teardrop",
 | 
				
			||||||
        "triangle",
 | 
					        "triangle",
 | 
				
			||||||
        "crosshair",
 | 
					        "crosshair",
 | 
				
			||||||
 | 
					        "brick_wall_square",
 | 
				
			||||||
 | 
					        "brick_wall_round",
 | 
				
			||||||
 | 
					        "gps_arrow",
 | 
				
			||||||
 | 
					        "checkmark",
 | 
				
			||||||
 | 
					        "help",
 | 
				
			||||||
 | 
					        "clock",
 | 
				
			||||||
 | 
					        "invalid",
 | 
				
			||||||
 | 
					        "close",
 | 
				
			||||||
    ] as const
 | 
					    ] as const
 | 
				
			||||||
    public static readonly defaultPinIcons: string[] = <any>Constants._defaultPinIcons
 | 
					    public static readonly defaultPinIcons: string[] = <any>Constants._defaultPinIcons
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1193,6 +1193,32 @@ class ExpandMarkerRenderings extends DesugaringStep<IconConfigJson> {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export class AddRatingBadge extends DesugaringStep<LayerConfigJson> {
 | 
				
			||||||
 | 
					    constructor() {
 | 
				
			||||||
 | 
					        super(
 | 
				
			||||||
 | 
					            "Adds the 'rating'-element if a reviews-element is used in the tagRenderings",
 | 
				
			||||||
 | 
					            ["titleIcons"],
 | 
				
			||||||
 | 
					            "AddRatingBadge"
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    convert(json: LayerConfigJson, context: ConversionContext): LayerConfigJson {
 | 
				
			||||||
 | 
					        if (!json.tagRenderings) {
 | 
				
			||||||
 | 
					            return json
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const specialVis: RenderingSpecification[] = ValidationUtils.getAllSpecialVisualisations(
 | 
				
			||||||
 | 
					            <QuestionableTagRenderingConfigJson[]>json.tagRenderings
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const calledFuncs = new Set<string>(specialVis.map((rs) => rs["func"]))
 | 
				
			||||||
 | 
					        if (calledFuncs.has("list_reviews")) {
 | 
				
			||||||
 | 
					            ;(<(string | TagRenderingConfigJson)[]>json.titleIcons).push("ratings")
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return json
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class PrepareLayer extends Fuse<LayerConfigJson> {
 | 
					export class PrepareLayer extends Fuse<LayerConfigJson> {
 | 
				
			||||||
    constructor(state: DesugaringContext) {
 | 
					    constructor(state: DesugaringContext) {
 | 
				
			||||||
        super(
 | 
					        super(
 | 
				
			||||||
| 
						 | 
					@ -1223,6 +1249,7 @@ export class PrepareLayer extends Fuse<LayerConfigJson> {
 | 
				
			||||||
                (layer) =>
 | 
					                (layer) =>
 | 
				
			||||||
                    new Concat(new ExpandTagRendering(state, layer, { noHardcodedStrings: true }))
 | 
					                    new Concat(new ExpandTagRendering(state, layer, { noHardcodedStrings: true }))
 | 
				
			||||||
            ),
 | 
					            ),
 | 
				
			||||||
 | 
					            new AddRatingBadge(),
 | 
				
			||||||
            new ExpandFilter(state)
 | 
					            new ExpandFilter(state)
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -110,7 +110,7 @@ export class DoesImageExist extends DesugaringStep<string> {
 | 
				
			||||||
                )
 | 
					                )
 | 
				
			||||||
            } else if (!this.doesPathExist(image)) {
 | 
					            } else if (!this.doesPathExist(image)) {
 | 
				
			||||||
                context.err(
 | 
					                context.err(
 | 
				
			||||||
                    `Image with path ${image} does not exist; it is used in ${context}.\n     Check for typo's and missing directories in the path.`
 | 
					                    `Image with path ${image} does not exist.\n     Check for typo's and missing directories in the path.`
 | 
				
			||||||
                )
 | 
					                )
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                context.err(
 | 
					                context.err(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,12 @@ export default class ValidationUtils {
 | 
				
			||||||
        renderingConfigs: (TagRenderingConfigJson | QuestionableTagRenderingConfigJson)[]
 | 
					        renderingConfigs: (TagRenderingConfigJson | QuestionableTagRenderingConfigJson)[]
 | 
				
			||||||
    ): RenderingSpecification[] {
 | 
					    ): RenderingSpecification[] {
 | 
				
			||||||
        const visualisations: RenderingSpecification[] = []
 | 
					        const visualisations: RenderingSpecification[] = []
 | 
				
			||||||
 | 
					        if (!Array.isArray(renderingConfigs)) {
 | 
				
			||||||
 | 
					            throw (
 | 
				
			||||||
 | 
					                "Could not inspect renderingConfigs, not an array: " +
 | 
				
			||||||
 | 
					                JSON.stringify(renderingConfigs)
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        for (const renderConfig of renderingConfigs) {
 | 
					        for (const renderConfig of renderingConfigs) {
 | 
				
			||||||
            visualisations.push(...ValidationUtils.getSpecialVisualisationsWithArgs(renderConfig))
 | 
					            visualisations.push(...ValidationUtils.getSpecialVisualisationsWithArgs(renderConfig))
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,6 +19,9 @@
 | 
				
			||||||
  import Teardrop from "../../assets/svg/Teardrop.svelte"
 | 
					  import Teardrop from "../../assets/svg/Teardrop.svelte"
 | 
				
			||||||
  import Teardrop_with_hole_green from "../../assets/svg/Teardrop_with_hole_green.svelte"
 | 
					  import Teardrop_with_hole_green from "../../assets/svg/Teardrop_with_hole_green.svelte"
 | 
				
			||||||
  import Triangle from "../../assets/svg/Triangle.svelte"
 | 
					  import Triangle from "../../assets/svg/Triangle.svelte"
 | 
				
			||||||
 | 
					  import Brick_wall_square from "../../assets/svg/Brick_wall_square.svelte";
 | 
				
			||||||
 | 
					  import Brick_wall_round from "../../assets/svg/Brick_wall_round.svelte";
 | 
				
			||||||
 | 
					  import Gps_arrow from "../../assets/svg/Gps_arrow.svelte";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Renders a single icon.
 | 
					   * Renders a single icon.
 | 
				
			||||||
| 
						 | 
					@ -72,6 +75,22 @@
 | 
				
			||||||
      <Teardrop_with_hole_green {color} />
 | 
					      <Teardrop_with_hole_green {color} />
 | 
				
			||||||
    {:else if icon === "triangle"}
 | 
					    {:else if icon === "triangle"}
 | 
				
			||||||
      <Triangle {color} />
 | 
					      <Triangle {color} />
 | 
				
			||||||
 | 
					    {:else if icon === "brick_wall_square"}
 | 
				
			||||||
 | 
					      <Brick_wall_square {color} />
 | 
				
			||||||
 | 
					    {:else if icon === "brick_wall_round"}
 | 
				
			||||||
 | 
					      <Brick_wall_round {color} />
 | 
				
			||||||
 | 
					    {:else if icon === "gps_arrow"}
 | 
				
			||||||
 | 
					      <Gps_arrow {color} />
 | 
				
			||||||
 | 
					    {:else if icon === "checkmark"}
 | 
				
			||||||
 | 
					      <Checkmark {color} />
 | 
				
			||||||
 | 
					    {:else if icon === "help"}
 | 
				
			||||||
 | 
					      <Help {color} />
 | 
				
			||||||
 | 
					    {:else if icon === "clock"}
 | 
				
			||||||
 | 
					      <Clock {color} />
 | 
				
			||||||
 | 
					    {:else if icon === "close"}
 | 
				
			||||||
 | 
					      <Close {color} />
 | 
				
			||||||
 | 
					    {:else if icon === "invalid"}
 | 
				
			||||||
 | 
					      <Invalid {color} />
 | 
				
			||||||
    {:else}
 | 
					    {:else}
 | 
				
			||||||
      <img class="h-full w-full" src={icon} />
 | 
					      <img class="h-full w-full" src={icon} />
 | 
				
			||||||
    {/if}
 | 
					    {/if}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,7 +78,6 @@ export default class Locale {
 | 
				
			||||||
            Locale.showLinkToWeblate.setData(Locale.showLinkToWeblate.data || tr)
 | 
					            Locale.showLinkToWeblate.setData(Locale.showLinkToWeblate.data || tr)
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        console.log("Initial language:", source, source.data)
 | 
					 | 
				
			||||||
        return source
 | 
					        return source
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -999,7 +999,7 @@ class SvgToPdfPage {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface PdfTemplateInfo {
 | 
					export interface PdfTemplateInfo {
 | 
				
			||||||
    pages: string[]
 | 
					    pages: string[]
 | 
				
			||||||
    description: string | Translation
 | 
					    description?: string | Translation
 | 
				
			||||||
    format: "a3" | "a4" | "a2"
 | 
					    format: "a3" | "a4" | "a2"
 | 
				
			||||||
    orientation: "portrait" | "landscape"
 | 
					    orientation: "portrait" | "landscape"
 | 
				
			||||||
    isPublic: boolean
 | 
					    isPublic: boolean
 | 
				
			||||||
| 
						 | 
					@ -1043,22 +1043,18 @@ export class SvgToPdf {
 | 
				
			||||||
            format: "a4",
 | 
					            format: "a4",
 | 
				
			||||||
            orientation: "landscape",
 | 
					            orientation: "landscape",
 | 
				
			||||||
            pages: ["./assets/templates/CurrentMapWithHeaderA4.svg"],
 | 
					            pages: ["./assets/templates/CurrentMapWithHeaderA4.svg"],
 | 
				
			||||||
            description: Translations.t.general.download.pdf.current_view_a4,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            isPublic: true,
 | 
					            isPublic: true,
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        current_view_a3_landscape: {
 | 
					        current_view_a3_landscape: {
 | 
				
			||||||
            format: "a3",
 | 
					            format: "a3",
 | 
				
			||||||
            orientation: "landscape",
 | 
					            orientation: "landscape",
 | 
				
			||||||
            pages: ["./assets/templates/CurrentMapWithHeader_A3_Landscape.svg"],
 | 
					            pages: ["./assets/templates/CurrentMapWithHeader_A3_Landscape.svg"],
 | 
				
			||||||
            description: Translations.t.general.download.pdf.current_view_a3,
 | 
					 | 
				
			||||||
            isPublic: true,
 | 
					            isPublic: true,
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        current_view_a3_portrait: {
 | 
					        current_view_a3_portrait: {
 | 
				
			||||||
            format: "a3",
 | 
					            format: "a3",
 | 
				
			||||||
            orientation: "portrait",
 | 
					            orientation: "portrait",
 | 
				
			||||||
            pages: ["./assets/templates/CurrentMapWithHeader_A3_Portrait.svg"],
 | 
					            pages: ["./assets/templates/CurrentMapWithHeader_A3_Portrait.svg"],
 | 
				
			||||||
            description: Translations.t.general.download.pdf.current_view_a3,
 | 
					 | 
				
			||||||
            isPublic: true,
 | 
					            isPublic: true,
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue