forked from MapComplete/MapComplete
		
	Velopark: load some more data fields
This commit is contained in:
		
							parent
							
								
									5130a2b73a
								
							
						
					
					
						commit
						c46e9da511
					
				
					 1 changed files with 13 additions and 8 deletions
				
			
		| 
						 | 
					@ -643,9 +643,7 @@ export default class LinkedDataLoader {
 | 
				
			||||||
            allPartialResults.push(r)
 | 
					            allPartialResults.push(r)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const results = this.mergeResults(...allPartialResults)
 | 
					        return this.mergeResults(...allPartialResults)
 | 
				
			||||||
 | 
					 | 
				
			||||||
        return results
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static veloparkCache : Record<string, Feature[]> = {}
 | 
					    private static veloparkCache : Record<string, Feature[]> = {}
 | 
				
			||||||
| 
						 | 
					@ -655,9 +653,10 @@ export default class LinkedDataLoader {
 | 
				
			||||||
     * The id will be saved as `ref:velopark`
 | 
					     * The id will be saved as `ref:velopark`
 | 
				
			||||||
     * @param url
 | 
					     * @param url
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static async fetchVeloparkEntry(url: string): Promise<Feature[]> {
 | 
					    public static async fetchVeloparkEntry(url: string, includeExtras: boolean = false): Promise<Feature[]> {
 | 
				
			||||||
        if(this.veloparkCache[url]){
 | 
					        const cacheKey = includeExtras+url
 | 
				
			||||||
            return this.veloparkCache[url]
 | 
					        if(this.veloparkCache[cacheKey]){
 | 
				
			||||||
 | 
					            return this.veloparkCache[cacheKey]
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        const withProxyUrl = Constants.linkedDataProxy.replace("{url}", encodeURIComponent(url))
 | 
					        const withProxyUrl = Constants.linkedDataProxy.replace("{url}", encodeURIComponent(url))
 | 
				
			||||||
        const optionalPaths: Record<string, string | Record<string, string>> = {
 | 
					        const optionalPaths: Record<string, string | Record<string, string>> = {
 | 
				
			||||||
| 
						 | 
					@ -674,6 +673,12 @@ export default class LinkedDataLoader {
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            "schema:dateModified": "_last_edit_timestamp",
 | 
					            "schema:dateModified": "_last_edit_timestamp",
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        if(includeExtras){
 | 
				
			||||||
 | 
					            optionalPaths["schema:address"] = {
 | 
				
			||||||
 | 
					                "schema:streetAddress":"addr"
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            optionalPaths["schema:description"] = "description"
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const graphOptionalPaths = {
 | 
					        const graphOptionalPaths = {
 | 
				
			||||||
            a: "type",
 | 
					            a: "type",
 | 
				
			||||||
| 
						 | 
					@ -692,7 +697,7 @@ export default class LinkedDataLoader {
 | 
				
			||||||
            "schema:priceSpecification": {
 | 
					            "schema:priceSpecification": {
 | 
				
			||||||
                "mv:freeOfCharge": "fee",
 | 
					                "mv:freeOfCharge": "fee",
 | 
				
			||||||
                "schema:price": "charge",
 | 
					                "schema:price": "charge",
 | 
				
			||||||
            },
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const extra = [
 | 
					        const extra = [
 | 
				
			||||||
| 
						 | 
					@ -714,7 +719,7 @@ export default class LinkedDataLoader {
 | 
				
			||||||
            p["ref:velopark"] = [section]
 | 
					            p["ref:velopark"] = [section]
 | 
				
			||||||
            patched.push(LinkedDataLoader.asGeojson(p))
 | 
					            patched.push(LinkedDataLoader.asGeojson(p))
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        this.veloparkCache[url] = patched
 | 
					        this.veloparkCache[cacheKey] = patched
 | 
				
			||||||
        return patched
 | 
					        return patched
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue