| 
									
										
										
										
											2023-06-09 16:13:35 +02:00
										 |  |  | import fs from "fs" | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  | import { OH } from "../../UI/OpeningHours/OpeningHours" | 
					
						
							| 
									
										
										
										
											2023-06-09 16:13:35 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  | const cashpunten = JSON.parse( | 
					
						
							|  |  |  |     fs.readFileSync("/home/pietervdvn/Downloads/cash_punten.json", "utf8") | 
					
						
							|  |  |  | ).data | 
					
						
							| 
									
										
										
										
											2023-06-09 16:13:35 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | const features: any[] = [] | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  | const weekdays = ["MO", "TU", "WE", "TH", "FR", "SA", "SU"] | 
					
						
							| 
									
										
										
										
											2023-06-09 16:13:35 +02:00
										 |  |  | for (const atm of cashpunten) { | 
					
						
							|  |  |  |     const properties = { | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |         amenity: "atm", | 
					
						
							| 
									
										
										
										
											2023-06-09 16:13:35 +02:00
										 |  |  |         "addr:street": atm.adr_street, | 
					
						
							|  |  |  |         "addr:housenumber": atm.adr_street_number, | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |         phone: <string>atm.phone_number, | 
					
						
							|  |  |  |         operator: "Batopin", | 
					
						
							| 
									
										
										
										
											2023-06-09 16:13:35 +02:00
										 |  |  |         network: "CASH", | 
					
						
							|  |  |  |         fee: "no", | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |         speech_output: "yes", | 
					
						
							|  |  |  |         brand: "CASH", | 
					
						
							| 
									
										
										
										
											2023-06-09 16:13:35 +02:00
										 |  |  |         website: "https://batopin.be", | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |         source: "https://batopin.be", | 
					
						
							| 
									
										
										
										
											2023-06-09 16:13:35 +02:00
										 |  |  |         "brand:wikidata": "Q112875867", | 
					
						
							|  |  |  |         "operator:wikidata": "Q97142699", | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |         "currency:EUR": "yes", | 
					
						
							| 
									
										
										
										
											2023-06-09 16:13:35 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     features.push({ | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |         geometry: { type: "Point", coordinates: [atm.adr_longitude, atm.adr_latitude] }, | 
					
						
							| 
									
										
										
										
											2023-06-09 16:13:35 +02:00
										 |  |  |         properties: { | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |             tags: properties, | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2023-06-09 16:13:35 +02:00
										 |  |  |     }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     switch (atm.accessibility) { | 
					
						
							|  |  |  |         case "Green": | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |             properties["wheelchair"] = "yes" | 
					
						
							|  |  |  |             break | 
					
						
							| 
									
										
										
										
											2023-06-09 16:13:35 +02:00
										 |  |  |         case "Orange": | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |             properties["wheelchair"] = "limited" | 
					
						
							|  |  |  |             break | 
					
						
							| 
									
										
										
										
											2023-06-09 16:13:35 +02:00
										 |  |  |         case "Red": | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |             properties["wheelchair"] = "no" | 
					
						
							|  |  |  |             break | 
					
						
							| 
									
										
										
										
											2023-06-09 16:13:35 +02:00
										 |  |  |         default: | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |             break | 
					
						
							| 
									
										
										
										
											2023-06-09 16:13:35 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     delete atm.accessibility | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (atm.deposit_cash) { | 
					
						
							|  |  |  |         properties["cash_in"] = atm.deposit_cash === "1" ? "yes" : "no" | 
					
						
							|  |  |  |         delete atm.deposit_cash | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |     if (!weekdays.some((wd) => atm.regular_hours[wd] !== "00:00-00:00")) { | 
					
						
							| 
									
										
										
										
											2023-06-09 16:13:35 +02:00
										 |  |  |         properties["opening_hours"] = "24/7" | 
					
						
							|  |  |  |         delete atm.regular_hours | 
					
						
							|  |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |         const rules = weekdays | 
					
						
							|  |  |  |             .filter((wd) => atm.regular_hours[wd] !== undefined) | 
					
						
							|  |  |  |             .map((wd) => wd[0] + wd.toLowerCase()[1] + " " + atm.regular_hours[wd]) | 
					
						
							|  |  |  |             .join(";") | 
					
						
							| 
									
										
										
										
											2023-06-09 16:13:35 +02:00
										 |  |  |         properties["opening_hours"] = OH.ToString(OH.MergeTimes(OH.Parse(rules))) | 
					
						
							|  |  |  |         delete atm.regular_hours | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     delete atm.special_hours // Only one data point has this
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     delete atm.location_language | 
					
						
							|  |  |  |     delete atm.location_name | 
					
						
							|  |  |  |     delete atm.shop_code | 
					
						
							|  |  |  |     delete atm.id | 
					
						
							|  |  |  |     delete atm.adr_longitude | 
					
						
							|  |  |  |     delete atm.adr_latitude | 
					
						
							|  |  |  |     delete atm.adr_street_number | 
					
						
							|  |  |  |     delete atm.adr_street | 
					
						
							|  |  |  |     delete atm.adr_zipcode | 
					
						
							|  |  |  |     delete atm.adr_city | 
					
						
							|  |  |  |     delete atm.adr_country | 
					
						
							|  |  |  |     delete atm.phone_number | 
					
						
							|  |  |  |     if (Object.keys(atm).length == 0) { | 
					
						
							|  |  |  |         continue | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     console.log(atm, properties) | 
					
						
							|  |  |  |     break | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  | fs.writeFileSync("atms.geojson", JSON.stringify({ type: "FeatureCollection", features })) |