forked from MapComplete/MapComplete
		
	Performance: load NSI when needed, should decrease bundle size
This commit is contained in:
		
							parent
							
								
									4fcdd8ba5a
								
							
						
					
					
						commit
						a79557c87c
					
				
					 7 changed files with 122 additions and 76 deletions
				
			
		| 
						 | 
				
			
			@ -1,17 +1,13 @@
 | 
			
		|||
import { DesugaringStep } from "./Conversion"
 | 
			
		||||
import { TagRenderingConfigJson } from "../Json/TagRenderingConfigJson"
 | 
			
		||||
import { LayerConfigJson } from "../Json/LayerConfigJson"
 | 
			
		||||
import {
 | 
			
		||||
    MappingConfigJson,
 | 
			
		||||
    QuestionableTagRenderingConfigJson,
 | 
			
		||||
} from "../Json/QuestionableTagRenderingConfigJson"
 | 
			
		||||
import { MappingConfigJson, QuestionableTagRenderingConfigJson } from "../Json/QuestionableTagRenderingConfigJson"
 | 
			
		||||
import { ConversionContext } from "./ConversionContext"
 | 
			
		||||
import { Translation } from "../../../UI/i18n/Translation"
 | 
			
		||||
import NameSuggestionIndex from "../../../Logic/Web/NameSuggestionIndex"
 | 
			
		||||
import { TagUtils } from "../../../Logic/Tags/TagUtils"
 | 
			
		||||
import { Tag } from "../../../Logic/Tags/Tag"
 | 
			
		||||
import Validators from "../../../UI/InputElement/Validators"
 | 
			
		||||
import { CheckTranslation } from "./Validation"
 | 
			
		||||
import NameSuggestionIndex from "../../../Logic/Web/NameSuggestionIndex"
 | 
			
		||||
 | 
			
		||||
export class MiscTagRenderingChecks extends DesugaringStep<TagRenderingConfigJson> {
 | 
			
		||||
    private readonly _layerConfig: LayerConfigJson
 | 
			
		||||
| 
						 | 
				
			
			@ -197,11 +193,11 @@ export class MiscTagRenderingChecks extends DesugaringStep<TagRenderingConfigJso
 | 
			
		|||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (
 | 
			
		||||
                this._layerConfig?.source?.osmTags &&
 | 
			
		||||
                NameSuggestionIndex.supportedTypes().indexOf(json.freeform.key) >= 0
 | 
			
		||||
                this._layerConfig?.source?.["osmTags"] &&
 | 
			
		||||
                NameSuggestionIndex.supportedTypes.indexOf(<any> json.freeform.key) >= 0
 | 
			
		||||
            ) {
 | 
			
		||||
                const tags = TagUtils.TagD(this._layerConfig?.source?.osmTags)?.usedTags()
 | 
			
		||||
                const suggestions = NameSuggestionIndex.getSuggestionsFor(json.freeform.key, tags)
 | 
			
		||||
                const tags = TagUtils.TagD(this._layerConfig?.source?.["osmTags"])?.usedTags()
 | 
			
		||||
               /* const suggestions = nameSuggestionIndexBundled.getSuggestionsFor(json.freeform.key, tags)
 | 
			
		||||
                if (suggestions === undefined) {
 | 
			
		||||
                    context
 | 
			
		||||
                        .enters("freeform", "type")
 | 
			
		||||
| 
						 | 
				
			
			@ -209,8 +205,8 @@ export class MiscTagRenderingChecks extends DesugaringStep<TagRenderingConfigJso
 | 
			
		|||
                            "No entry found in the 'Name Suggestion Index'. None of the 'osmSource'-tags match an entry in the NSI.\n\tOsmSource-tags are " +
 | 
			
		||||
                                tags.map((t) => new Tag(t.key, t.value).asHumanString()).join(" ; ")
 | 
			
		||||
                        )
 | 
			
		||||
                }
 | 
			
		||||
            } else if (json.freeform.type === "nsi") {
 | 
			
		||||
                }*/
 | 
			
		||||
            } else if (json.freeform["type"] === "nsi") {
 | 
			
		||||
                context
 | 
			
		||||
                    .enters("freeform", "type")
 | 
			
		||||
                    .warn(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -999,7 +999,7 @@ export class TagRenderingConfigUtils {
 | 
			
		|||
        tags: UIEventSource<Record<string, string>>,
 | 
			
		||||
        feature?: Feature
 | 
			
		||||
    ): Store<TagRenderingConfig> {
 | 
			
		||||
        const isNSI = NameSuggestionIndex.supportedTypes().indexOf(config.freeform?.key) >= 0
 | 
			
		||||
        const isNSI = NameSuggestionIndex.supportedTypes.indexOf(<any> config.freeform?.key) >= 0
 | 
			
		||||
        if (!isNSI) {
 | 
			
		||||
            return new ImmutableStore(config)
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -1019,8 +1019,8 @@ export class TagRenderingConfigUtils {
 | 
			
		|||
                )
 | 
			
		||||
            )
 | 
			
		||||
        })
 | 
			
		||||
        return extraMappings.map((extraMappings) => {
 | 
			
		||||
            if (!extraMappings || extraMappings.length == 0) {
 | 
			
		||||
        return extraMappings.mapD((extraMappings) => {
 | 
			
		||||
            if (extraMappings.length == 0) {
 | 
			
		||||
                return config
 | 
			
		||||
            }
 | 
			
		||||
            const clone: TagRenderingConfig = Object.create(config)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue