| 
									
										
										
										
											2020-07-13 17:16:12 +02:00
										 |  |  | import {LayerDefinition} from "../LayerDefinition"; | 
					
						
							| 
									
										
										
										
											2020-07-29 18:35:46 +02:00
										 |  |  | import {And, Tag, TagsFilter, Or, Not} from "../../Logic/TagsFilter"; | 
					
						
							| 
									
										
										
										
											2020-07-16 15:29:50 +02:00
										 |  |  | import BikeStationChain from "../Questions/bike/StationChain"; | 
					
						
							|  |  |  | import BikeStationPumpTools from "../Questions/bike/StationPumpTools"; | 
					
						
							|  |  |  | import BikeStationStand from "../Questions/bike/StationStand"; | 
					
						
							|  |  |  | import PumpManual from "../Questions/bike/PumpManual"; | 
					
						
							|  |  |  | import BikeStationOperator from "../Questions/bike/StationOperator"; | 
					
						
							|  |  |  | import BikeStationBrand from "../Questions/bike/StationBrand"; | 
					
						
							| 
									
										
										
										
											2020-07-16 09:54:32 +02:00
										 |  |  | import FixedText from "../Questions/FixedText"; | 
					
						
							| 
									
										
										
										
											2020-07-16 15:29:50 +02:00
										 |  |  | import PumpManometer from "../Questions/bike/PumpManometer"; | 
					
						
							| 
									
										
										
										
											2020-07-16 09:54:32 +02:00
										 |  |  | import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload"; | 
					
						
							| 
									
										
										
										
											2020-07-16 15:56:10 +02:00
										 |  |  | import PumpOperational from "../Questions/bike/PumpOperational"; | 
					
						
							| 
									
										
										
										
											2020-07-16 15:32:32 +02:00
										 |  |  | import PumpValves from "../Questions/bike/PumpValves"; | 
					
						
							| 
									
										
										
										
											2020-07-20 23:43:42 +02:00
										 |  |  | import Translations from "../../UI/i18n/Translations"; | 
					
						
							| 
									
										
										
										
											2020-07-29 13:16:21 +02:00
										 |  |  | import { TagRenderingOptions } from "../TagRendering"; | 
					
						
							| 
									
										
										
										
											2020-07-16 14:21:06 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-16 15:29:50 +02:00
										 |  |  | export default class BikeStations extends LayerDefinition { | 
					
						
							| 
									
										
										
										
											2020-07-29 18:35:46 +02:00
										 |  |  |     private readonly repairStation = new Tag("amenity", "bicycle_repair_station"); | 
					
						
							| 
									
										
										
										
											2020-07-16 16:08:51 +02:00
										 |  |  |     private readonly pump = new Tag("service:bicycle:pump", "yes"); | 
					
						
							| 
									
										
										
										
											2020-07-29 18:35:46 +02:00
										 |  |  |     private readonly nopump = new Tag("service:bicycle:pump", "no"); | 
					
						
							| 
									
										
										
										
											2020-07-16 16:08:51 +02:00
										 |  |  |     private readonly pumpOperationalAny = new Tag("service:bicycle:pump:operational_status", "yes"); | 
					
						
							| 
									
										
										
										
											2020-07-17 12:00:52 +02:00
										 |  |  |     private readonly pumpOperationalOk = new Or([new Tag("service:bicycle:pump:operational_status", "yes"), new Tag("service:bicycle:pump:operational_status", "operational"), new Tag("service:bicycle:pump:operational_status", "ok"), new Tag("service:bicycle:pump:operational_status", "")]); | 
					
						
							| 
									
										
										
										
											2020-07-16 16:08:51 +02:00
										 |  |  |     private readonly tools = new Tag("service:bicycle:tools", "yes"); | 
					
						
							| 
									
										
										
										
											2020-07-29 18:35:46 +02:00
										 |  |  |     private readonly notools = new Tag("service:bicycle:tools", "no"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-29 13:16:21 +02:00
										 |  |  |     private readonly to = Translations.t.cyclofix.station | 
					
						
							| 
									
										
										
										
											2020-07-16 14:21:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-13 17:16:12 +02:00
										 |  |  |     constructor() { | 
					
						
							|  |  |  |         super(); | 
					
						
							| 
									
										
										
										
											2020-07-21 23:31:41 +02:00
										 |  |  |         this.name = Translations.t.cyclofix.station.name; | 
					
						
							| 
									
										
										
										
											2020-07-22 18:01:16 +02:00
										 |  |  |         this.icon = "./assets/bike/repair_station_pump.svg"; | 
					
						
							| 
									
										
										
										
											2020-07-13 17:16:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-29 18:35:46 +02:00
										 |  |  |         const tr = Translations.t.cyclofix.station | 
					
						
							|  |  |  |         this.overpassFilter = this.repairStation; | 
					
						
							|  |  |  |         this.presets = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 title: tr.titlePump, | 
					
						
							|  |  |  |                 description: tr.services.pump, | 
					
						
							|  |  |  |                 icon: "/assets/bike/pump.svg", | 
					
						
							|  |  |  |                 tags: [this.repairStation, this.pump, this.notools] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 title: tr.titleRepair, | 
					
						
							|  |  |  |                 description: tr.services.tools, | 
					
						
							|  |  |  |                 icon: "/assets/bike/repair_station.svg", | 
					
						
							|  |  |  |                 tags: [this.repairStation, this.tools, this.nopump] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 title: tr.titlePumpAndRepair, | 
					
						
							|  |  |  |                 description: tr.services.both, | 
					
						
							|  |  |  |                 icon: "/assets/bike/repair_station_pump.svg", | 
					
						
							|  |  |  |                 tags: [this.repairStation, this.tools, this.nopump] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ] | 
					
						
							| 
									
										
										
										
											2020-07-13 17:16:12 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         this.maxAllowedOverlapPercentage = 10; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         this.minzoom = 13; | 
					
						
							|  |  |  |         this.style = this.generateStyleFunction(); | 
					
						
							| 
									
										
										
										
											2020-07-29 13:16:21 +02:00
										 |  |  |         this.title = new TagRenderingOptions({ | 
					
						
							|  |  |  |             mappings: [ | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     k: new And([this.pump, this.tools]), | 
					
						
							|  |  |  |                     txt: this.to.titlePumpAndRepair | 
					
						
							|  |  |  |                 }, | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     k: new And([this.pump]), | 
					
						
							|  |  |  |                     txt: this.to.titlePump | 
					
						
							|  |  |  |                 }, | 
					
						
							|  |  |  |                 {k: null, txt: this.to.titleRepair}, | 
					
						
							|  |  |  |             ] | 
					
						
							|  |  |  |         }) | 
					
						
							| 
									
										
										
										
											2020-07-22 00:50:30 +02:00
										 |  |  |         this.wayHandling = LayerDefinition.WAYHANDLING_CENTER_AND_WAY | 
					
						
							| 
									
										
										
										
											2020-07-16 09:54:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-13 17:16:12 +02:00
										 |  |  |         this.elementsToShow = [ | 
					
						
							| 
									
										
										
										
											2020-07-16 09:54:32 +02:00
										 |  |  |             new ImageCarouselWithUploadConstructor(), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-13 17:16:12 +02:00
										 |  |  |             new BikeStationPumpTools(), | 
					
						
							| 
									
										
										
										
											2020-07-16 14:21:06 +02:00
										 |  |  |             new BikeStationChain().OnlyShowIf(this.tools), | 
					
						
							|  |  |  |             new BikeStationStand().OnlyShowIf(this.tools), | 
					
						
							| 
									
										
										
										
											2020-07-16 09:54:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-16 14:21:06 +02:00
										 |  |  |             new PumpManual().OnlyShowIf(this.pump), | 
					
						
							| 
									
										
										
										
											2020-07-16 15:29:50 +02:00
										 |  |  |             new PumpManometer().OnlyShowIf(this.pump), | 
					
						
							| 
									
										
										
										
											2020-07-16 15:32:32 +02:00
										 |  |  |             new PumpValves().OnlyShowIf(this.pump), | 
					
						
							| 
									
										
										
										
											2020-07-16 15:56:10 +02:00
										 |  |  |             new PumpOperational().OnlyShowIf(this.pump), | 
					
						
							| 
									
										
										
										
											2020-07-16 09:54:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-20 23:43:42 +02:00
										 |  |  |             // new BikeStationOperator(),
 | 
					
						
							| 
									
										
										
										
											2020-07-16 15:29:50 +02:00
										 |  |  |             // new BikeStationBrand()   DISABLED
 | 
					
						
							| 
									
										
										
										
											2020-07-13 17:16:12 +02:00
										 |  |  |         ]; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private generateStyleFunction() { | 
					
						
							|  |  |  |         const self = this; | 
					
						
							|  |  |  |         return function (properties: any) { | 
					
						
							| 
									
										
										
										
											2020-07-16 15:56:10 +02:00
										 |  |  |             const hasPump = self.pump.matchesProperties(properties) | 
					
						
							| 
									
										
										
										
											2020-07-17 12:00:52 +02:00
										 |  |  |             const isOperational = self.pumpOperationalOk.matchesProperties(properties) | 
					
						
							| 
									
										
										
										
											2020-07-16 15:56:10 +02:00
										 |  |  |             const hasTools = self.tools.matchesProperties(properties) | 
					
						
							| 
									
										
										
										
											2020-07-22 00:18:07 +02:00
										 |  |  |             let iconName = "repair_station.svg"; | 
					
						
							|  |  |  |             if (hasTools && hasPump && isOperational) { | 
					
						
							|  |  |  |                 iconName = "repair_station_pump.svg" | 
					
						
							| 
									
										
										
										
											2020-07-29 13:16:21 +02:00
										 |  |  |             } else if(hasTools) { | 
					
						
							| 
									
										
										
										
											2020-07-20 17:30:02 +02:00
										 |  |  |                     iconName = "repair_station.svg" | 
					
						
							| 
									
										
										
										
											2020-07-29 13:16:21 +02:00
										 |  |  |             } else if(hasPump) { | 
					
						
							| 
									
										
										
										
											2020-07-22 00:18:07 +02:00
										 |  |  |                 if (isOperational) { | 
					
						
							|  |  |  |                     iconName = "pump.svg" | 
					
						
							| 
									
										
										
										
											2020-07-20 17:30:02 +02:00
										 |  |  |                 } else { | 
					
						
							| 
									
										
										
										
											2020-07-26 02:01:34 +02:00
										 |  |  |                     iconName = "broken_pump_2.svg" | 
					
						
							| 
									
										
										
										
											2020-07-20 17:30:02 +02:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2020-07-16 15:56:10 +02:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2020-07-22 00:18:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-16 15:56:10 +02:00
										 |  |  |             const iconUrl = `./assets/bike/${iconName}` | 
					
						
							| 
									
										
										
										
											2020-07-13 17:16:12 +02:00
										 |  |  |             return { | 
					
						
							|  |  |  |                 color: "#00bb00", | 
					
						
							| 
									
										
										
										
											2020-07-26 02:01:34 +02:00
										 |  |  |                 icon: { | 
					
						
							| 
									
										
										
										
											2020-07-13 17:16:12 +02:00
										 |  |  |                     iconUrl: iconUrl, | 
					
						
							| 
									
										
										
										
											2020-07-20 16:16:22 +02:00
										 |  |  |                     iconSize: [50, 50], | 
					
						
							| 
									
										
										
										
											2020-07-24 18:19:37 +02:00
										 |  |  |                     iconAnchor: [25, 50] | 
					
						
							| 
									
										
										
										
											2020-07-26 02:01:34 +02:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2020-07-13 17:16:12 +02:00
										 |  |  |             }; | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-07-16 15:29:50 +02:00
										 |  |  | } |