diff --git a/TCAT.xcodeproj/project.pbxproj b/TCAT.xcodeproj/project.pbxproj index daff45a3..7871ee40 100644 --- a/TCAT.xcodeproj/project.pbxproj +++ b/TCAT.xcodeproj/project.pbxproj @@ -1004,7 +1004,7 @@ INFOPLIST_FILE = TCAT/Supporting/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Ithaca Transit"; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.travel"; - IPHONEOS_DEPLOYMENT_TARGET = 18.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1101,7 +1101,7 @@ INFOPLIST_FILE = TCAT/Supporting/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Ithaca Transit"; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.travel"; - IPHONEOS_DEPLOYMENT_TARGET = 18.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1200,7 +1200,7 @@ INFOPLIST_FILE = TCAT/Supporting/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Ithaca Transit"; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.travel"; - IPHONEOS_DEPLOYMENT_TARGET = 18.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/TCAT/Controllers/RouteDetail+ContentViewController.swift b/TCAT/Controllers/RouteDetail+ContentViewController.swift index a14cdc4e..5263061c 100755 --- a/TCAT/Controllers/RouteDetail+ContentViewController.swift +++ b/TCAT/Controllers/RouteDetail+ContentViewController.swift @@ -455,7 +455,38 @@ class RouteDetailContentViewController: UIViewController { } }() } - + + /// Helper function to create individual walking circles + func createWalkPathCircle() -> UIImage { + let fillColor = UIColor(white: 0.82, alpha: 1.0) + let borderColor = UIColor(white: 0.57, alpha: 1.0) + let diameter: CGFloat = 70.0 + let borderWidth: CGFloat = 13.0 + + let renderer = UIGraphicsImageRenderer(size: CGSize(width: diameter, height: diameter)) + return renderer.image { context in + context.cgContext.setFillColor(borderColor.cgColor) + context.cgContext.setStrokeColor(borderColor.cgColor) + context.cgContext.setLineWidth(borderWidth) + context.cgContext.addEllipse(in: CGRect(x: borderWidth / 2, y: borderWidth / 2, width: diameter - borderWidth, height: diameter - borderWidth)) + context.cgContext.drawPath(using: .fillStroke) + + context.cgContext.setFillColor(fillColor.cgColor) + context.cgContext.addEllipse(in: CGRect(x: borderWidth, y: borderWidth, width: diameter - 2 * borderWidth, height: diameter - 2 * borderWidth)) + context.cgContext.fillPath() + } + } + + /// Configure polylines for each walking segment + func configurePolyline(for path: GMSPath) { + let walkPathCircle = createWalkPathCircle() + let polyline = GMSPolyline(path: path) + let stampStyle = GMSSpriteStyle(image: walkPathCircle) + polyline.strokeWidth = 7 + polyline.spans = [GMSStyleSpan(style: GMSStrokeStyle.transparentStroke(withStamp: stampStyle))] + polyline.map = mapView + } + /// Draw all waypoints initially for all paths in [Path] or [[CLLocationCoordinate2D]], plus fill bounds private func drawMapRoute() { var pathCount = 0 @@ -473,9 +504,7 @@ class RouteDetailContentViewController: UIViewController { // Helper function to map final location marker func mapLocationMarker() -> UIImage? { let targetSize = CGSize(width: 18, height: 30) - guard let originalImage = UIImage(named: "locationMarker") else { - return nil - } + guard let originalImage = UIImage(named: "locationMarker") else { return nil } UIGraphicsBeginImageContextWithOptions(targetSize, false, 0.0) originalImage.draw(in: CGRect(origin: .zero, size: targetSize)) @@ -484,27 +513,6 @@ class RouteDetailContentViewController: UIViewController { return resizedImage } - // Helper function to create individual walking circles - func createWalkPathCircle() -> UIImage { - let fillColor = UIColor(white: 0.82, alpha: 1.0) - let borderColor = UIColor(white: 0.57, alpha: 1.0) - let diameter: CGFloat = 70.0 - let borderWidth: CGFloat = 13.0 - - let renderer = UIGraphicsImageRenderer(size: CGSize(width: diameter, height: diameter)) - return renderer.image { context in - context.cgContext.setFillColor(borderColor.cgColor) - context.cgContext.setStrokeColor(borderColor.cgColor) - context.cgContext.setLineWidth(borderWidth) - context.cgContext.addEllipse(in: CGRect(x: borderWidth / 2, y: borderWidth / 2, width: diameter - borderWidth, height: diameter - borderWidth)) - context.cgContext.drawPath(using: .fillStroke) - - context.cgContext.setFillColor(fillColor.cgColor) - context.cgContext.addEllipse(in: CGRect(x: borderWidth, y: borderWidth, width: diameter - 2 * borderWidth, height: diameter - 2 * borderWidth)) - context.cgContext.fillPath() - } - } - for path in paths { path.traveledPolyline.map = mapView path.map = mapView @@ -544,7 +552,7 @@ class RouteDetailContentViewController: UIViewController { } func mapRouteSegment(_ segment: [GMSCircle], to path: GMSMutablePath, addMarker: Bool = false) { - for (index, waypoint) in segment.enumerated() { + segment.enumerated().forEach { index, waypoint in let coordinates = CLLocation(latitude: waypoint.position.latitude, longitude: waypoint.position.longitude) path.addLatitude(coordinates.coordinate.latitude, longitude: coordinates.coordinate.longitude) if addMarker && index == segment.count - 1 { @@ -564,18 +572,10 @@ class RouteDetailContentViewController: UIViewController { if !finalRouteSegment.isEmpty { mapRouteSegment(finalRouteSegment, to: finalWalkSegment, addMarker: true) } - - // Configure polylines for each walking segment - func configurePolyline(for path: GMSPath) { - let walkPathCircle = createWalkPathCircle() - let polyline = GMSPolyline(path: path) - let stampStyle = GMSSpriteStyle(image: walkPathCircle) - polyline.strokeWidth = 9 - polyline.spans = [GMSStyleSpan(style: GMSStrokeStyle.transparentStroke(withStamp: stampStyle))] - polyline.map = mapView - } + configurePolyline(for: firstWalkSegment) configurePolyline(for: finalWalkSegment) + } /// Adjusts the size of endpoint bus stop circles based on zoom level diff --git a/TCAT/Models/WalkPath.swift b/TCAT/Models/WalkPath.swift index d9f496e2..0c851eb5 100644 --- a/TCAT/Models/WalkPath.swift +++ b/TCAT/Models/WalkPath.swift @@ -51,9 +51,7 @@ class WalkPath: Path { let circleLocation = CLLocation(latitude: circleCoordinate.latitude, longitude: circleCoordinate.longitude) let previousCircleLocation = CLLocation(latitude: previousCircle.coordinate.latitude, longitude: previousCircle.coordinate.longitude) - if circleLocation.distance(from: previousCircleLocation) < intervalDistanceIncrement { - continue - } + if circleLocation.distance(from: previousCircleLocation) < intervalDistanceIncrement { continue } } circles.append((coordinate: circleCoordinate, radius: 5.0))