Skip to content

Commit

Permalink
Addressed Richie's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
angelinaa-chen authored and rs929 committed Nov 6, 2024
1 parent 9aa6ce9 commit 790634e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 42 deletions.
6 changes: 3 additions & 3 deletions TCAT.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
72 changes: 36 additions & 36 deletions TCAT/Controllers/RouteDetail+ContentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions TCAT/Models/WalkPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 790634e

Please sign in to comment.