forked from MapComplete/MapComplete
		
	More improvements to loading linked data (esp. velopark)
This commit is contained in:
		
							parent
							
								
									1bc45c1c0c
								
							
						
					
					
						commit
						4a65ab69f8
					
				
					 1 changed files with 30 additions and 24 deletions
				
			
		| 
						 | 
				
			
			@ -295,10 +295,16 @@ export default class LinkedDataLoader {
 | 
			
		|||
 | 
			
		||||
    private static patchVeloparkProperties(input: Record<string, Set<string>>): Record<string, string[]> {
 | 
			
		||||
        const output: Record<string, string[]> = {}
 | 
			
		||||
        console.log("Input for patchVelopark:", input)
 | 
			
		||||
        for (const k in input) {
 | 
			
		||||
            output[k] = Array.from(input[k])
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (output["type"][0] === "https://data.velopark.be/openvelopark/terms#BicycleLocker") {
 | 
			
		||||
            output["bicycle_parking"] = ["lockers"]
 | 
			
		||||
        }
 | 
			
		||||
        delete output["type"]
 | 
			
		||||
 | 
			
		||||
        function on(key: string, applyF: (s: string) => string) {
 | 
			
		||||
            if (!output[key]) {
 | 
			
		||||
                return
 | 
			
		||||
| 
						 | 
				
			
			@ -341,6 +347,10 @@ export default class LinkedDataLoader {
 | 
			
		|||
        for (const attribute in LinkedDataLoader.formatters) {
 | 
			
		||||
            on(attribute, p => LinkedDataLoader.formatters[attribute].reformat(p))
 | 
			
		||||
        }
 | 
			
		||||
        rename("phone", "operator:phone")
 | 
			
		||||
        rename("email", "operator:email")
 | 
			
		||||
        rename("website", "operator:website")
 | 
			
		||||
 | 
			
		||||
        on("charge", (p => {
 | 
			
		||||
            if (Number(p) === 0) {
 | 
			
		||||
                output["fee"] = ["no"]
 | 
			
		||||
| 
						 | 
				
			
			@ -379,10 +389,10 @@ export default class LinkedDataLoader {
 | 
			
		|||
        on("access", audience => {
 | 
			
		||||
 | 
			
		||||
            if (["brede publiek", "iedereen", "bezoekers", "iedereen - vooral bezoekers gemeentehuis of bibliotheek."].indexOf(audience.toLowerCase()) >= 0) {
 | 
			
		||||
                return "public"
 | 
			
		||||
                return "yes"
 | 
			
		||||
            }
 | 
			
		||||
            if (audience.toLowerCase().startsWith("bezoekers")) {
 | 
			
		||||
                return "public"
 | 
			
		||||
                return "yes"
 | 
			
		||||
            }
 | 
			
		||||
            if (["abonnees"].indexOf(audience.toLowerCase()) >= 0) {
 | 
			
		||||
                return "members"
 | 
			
		||||
| 
						 | 
				
			
			@ -400,8 +410,8 @@ export default class LinkedDataLoader {
 | 
			
		|||
                return "customers"
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            console.warn("Suspicious 'access'-tag:", audience, "for", input["ref:velopark"]," assuming public")
 | 
			
		||||
            return "public"
 | 
			
		||||
            console.warn("Suspicious 'access'-tag:", audience, "for", input["ref:velopark"], " assuming yes")
 | 
			
		||||
            return "yes"
 | 
			
		||||
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -458,8 +468,8 @@ export default class LinkedDataLoader {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    private static async fetchVeloparkGraphProperty<T extends string>(url: string, property: string, subExpr?: string):
 | 
			
		||||
        Promise<SparqlResult<T, "section">> {
 | 
			
		||||
        const results = await new TypedSparql().typedSparql<T, "g">(
 | 
			
		||||
        Promise<SparqlResult<T, "g">> {
 | 
			
		||||
        return await new TypedSparql().typedSparql<T, "g">(
 | 
			
		||||
            {
 | 
			
		||||
                schema: "http://schema.org/",
 | 
			
		||||
                mv: "http://schema.mobivoc.org/",
 | 
			
		||||
| 
						 | 
				
			
			@ -476,7 +486,6 @@ export default class LinkedDataLoader {
 | 
			
		|||
                "?section a ?type"
 | 
			
		||||
            )
 | 
			
		||||
        )
 | 
			
		||||
        return results
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			@ -594,11 +603,12 @@ export default class LinkedDataLoader {
 | 
			
		|||
            "schema:contactPoint": {
 | 
			
		||||
                "schema:email": "email",
 | 
			
		||||
                "schema:telephone": "phone"
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            },
 | 
			
		||||
            "schema:dateModified":"_last_edit_timestamp"
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const graphOptionalPaths = {
 | 
			
		||||
            "a": "type",
 | 
			
		||||
            "vp:covered": "covered",
 | 
			
		||||
            "vp:maximumParkingDuration": "maxstay",
 | 
			
		||||
            "mv:totalCapacity": "capacity",
 | 
			
		||||
| 
						 | 
				
			
			@ -614,11 +624,7 @@ export default class LinkedDataLoader {
 | 
			
		|||
            "schema:priceSpecification": {
 | 
			
		||||
                "mv:freeOfCharge": "fee",
 | 
			
		||||
                "schema:price": "charge"
 | 
			
		||||
            },
 | 
			
		||||
            "schema:amenityFeature": {
 | 
			
		||||
                "a": "fixme_nearby_amenity"
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const extra = [
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue