forked from MapComplete/MapComplete
		
	Fix: don't show maxstay=30 days in velopark, this is actually 'unknown'
				
					
				
			This commit is contained in:
		
							parent
							
								
									f1106ad4a8
								
							
						
					
					
						commit
						d2237cf26c
					
				
					 2 changed files with 14 additions and 7 deletions
				
			
		| 
						 | 
					@ -371,6 +371,10 @@ export default class LinkedDataLoader {
 | 
				
			||||||
            const match = maxstay.match(/P([0-9]+)D/)
 | 
					            const match = maxstay.match(/P([0-9]+)D/)
 | 
				
			||||||
            if (match) {
 | 
					            if (match) {
 | 
				
			||||||
                const days = Number(match[1])
 | 
					                const days = Number(match[1])
 | 
				
			||||||
 | 
					                if(days === 30){
 | 
				
			||||||
 | 
					                    // 30 is the default which is set if velopark didn't know the actual value
 | 
				
			||||||
 | 
					                    return undefined
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                if (days === 1) {
 | 
					                if (days === 1) {
 | 
				
			||||||
                    return "1 day"
 | 
					                    return "1 day"
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +17,7 @@ export default class VeloparkLoader {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static readonly coder = new CountryCoder(
 | 
					    private static readonly coder = new CountryCoder(
 | 
				
			||||||
        Constants.countryCoderEndpoint,
 | 
					        Constants.countryCoderEndpoint,
 | 
				
			||||||
        Utils.downloadJson
 | 
					        Utils.downloadJson,
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static convert(veloparkData: VeloparkData): Feature {
 | 
					    public static convert(veloparkData: VeloparkData): Feature {
 | 
				
			||||||
| 
						 | 
					@ -46,14 +46,14 @@ export default class VeloparkLoader {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (veloparkData.contactPoint?.email) {
 | 
					        if (veloparkData.contactPoint?.email) {
 | 
				
			||||||
            properties["operator:email"] = VeloparkLoader.emailReformatting.reformat(
 | 
					            properties["operator:email"] = VeloparkLoader.emailReformatting.reformat(
 | 
				
			||||||
                veloparkData.contactPoint?.email
 | 
					                veloparkData.contactPoint?.email,
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (veloparkData.contactPoint?.telephone) {
 | 
					        if (veloparkData.contactPoint?.telephone) {
 | 
				
			||||||
            properties["operator:phone"] = VeloparkLoader.phoneValidator.reformat(
 | 
					            properties["operator:phone"] = VeloparkLoader.phoneValidator.reformat(
 | 
				
			||||||
                veloparkData.contactPoint?.telephone,
 | 
					                veloparkData.contactPoint?.telephone,
 | 
				
			||||||
                () => "be"
 | 
					                () => "be",
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,10 +78,13 @@ export default class VeloparkLoader {
 | 
				
			||||||
            ) {
 | 
					            ) {
 | 
				
			||||||
                const duration = g.maximumParkingDuration.substring(
 | 
					                const duration = g.maximumParkingDuration.substring(
 | 
				
			||||||
                    1,
 | 
					                    1,
 | 
				
			||||||
                    g.maximumParkingDuration.length - 1
 | 
					                    g.maximumParkingDuration.length - 1,
 | 
				
			||||||
                )
 | 
					                )
 | 
				
			||||||
 | 
					                if (duration !== "30") {
 | 
				
			||||||
 | 
					                    // We don't set maxstay if it is 30, they are the default value that velopark chose for "unknown"
 | 
				
			||||||
                    properties.maxstay = duration + " days"
 | 
					                    properties.maxstay = duration + " days"
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            properties.access = g.publicAccess ?? "yes" ? "yes" : "no"
 | 
					            properties.access = g.publicAccess ?? "yes" ? "yes" : "no"
 | 
				
			||||||
            const prefix = "http://schema.org/"
 | 
					            const prefix = "http://schema.org/"
 | 
				
			||||||
            if (g.openingHoursSpecification) {
 | 
					            if (g.openingHoursSpecification) {
 | 
				
			||||||
| 
						 | 
					@ -94,11 +97,11 @@ export default class VeloparkLoader {
 | 
				
			||||||
                            const startHour = spec.opens
 | 
					                            const startHour = spec.opens
 | 
				
			||||||
                            const endHour = spec.closes === "23:59" ? "24:00" : spec.closes
 | 
					                            const endHour = spec.closes === "23:59" ? "24:00" : spec.closes
 | 
				
			||||||
                            const merged = OH.MergeTimes(
 | 
					                            const merged = OH.MergeTimes(
 | 
				
			||||||
                                OH.ParseRule(dayOfWeek + " " + startHour + "-" + endHour)
 | 
					                                OH.ParseRule(dayOfWeek + " " + startHour + "-" + endHour),
 | 
				
			||||||
                            )
 | 
					                            )
 | 
				
			||||||
                            return OH.ToString(merged)
 | 
					                            return OH.ToString(merged)
 | 
				
			||||||
                        })
 | 
					                        })
 | 
				
			||||||
                        .join("; ")
 | 
					                        .join("; "),
 | 
				
			||||||
                )
 | 
					                )
 | 
				
			||||||
                properties.opening_hours = oh
 | 
					                properties.opening_hours = oh
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue