Skip to content

Instantly share code, notes, and snippets.

View dylanmaryk's full-sized avatar

Dylan Maryk dylanmaryk

View GitHub Profile
List<PatternItem> pattern = Arrays.asList(new Dot(), new Gap(20));
PolylineOptions options = new PolylineOptions().pattern(pattern);
map.addPolyline(options);
let strokeStyles = [GMSStrokeStyle.solidColor(.black), GMSStrokeStyle.solidColor(.clear)]
let strokeLengths = [NSNumber(value: 10), NSNumber(value: 10)]
if let path = polyline.path {
polyline.spans = GMSStyleSpans(path, strokeStyles, strokeLengths, .rhumb)
}
polyline.map = mapView
func mapView(_ mapView: GMSMapView, didChange position: GMSCameraPosition) {
set(polyline: polyline, on: mapView)
}
private let polyline = GMSPolyline(path: GMSPath(fromEncodedPath: "{dq_IowzpAzkAbhF"))
override func viewDidLoad() {
super.viewDidLoad()
mapView.delegate = self
set(polyline: polyline, on: mapView)
}
for coordinateIndex in 0 ..< path.count() - 1 {
let startCoordinate = path.coordinate(at: coordinateIndex)
let endCoordinate = path.coordinate(at: coordinateIndex + 1)
let startLocation = CLLocation(latitude: startCoordinate.latitude, longitude: startCoordinate.longitude)
let endLocation = CLLocation(latitude: endCoordinate.latitude, longitude: endCoordinate.longitude)
let pathDistance = endLocation.distance(from: startLocation)
let intervalLatIncrement = (endLocation.coordinate.latitude - startLocation.coordinate.latitude) / pathDistance
let intervalLngIncrement = (endLocation.coordinate.longitude - startLocation.coordinate.longitude) / pathDistance
for intervalDistance in 0 ..< Int(pathDistance) {
let intervalLat = startLocation.coordinate.latitude + (intervalLatIncrement * Double(intervalDistance))
if let previousCircle = previousCircle {
let circleLocation = CLLocation(latitude: circleCoordinate.latitude,
longitude: circleCoordinate.longitude)
let previousCircleLocation = CLLocation(latitude: previousCircle.position.latitude,
longitude: previousCircle.position.longitude)
if mapView.projection.points(forMeters: circleLocation.distance(from: previousCircleLocation),
at: mapView.camera.target) < intervalDistanceIncrement {
continue
}
}
guard let path = polyline.path else {
return
}
mapView.clear()
let intervalDistanceIncrement: CGFloat = 10
let circleRadiusScale = 1 / mapView.projection.points(forMeters: 1, at: mapView.camera.target)
var previousCircle: GMSCircle?
for coordinateIndex in 0 ..< path.count() - 1 {
let startCoordinate = path.coordinate(at: coordinateIndex)
let endCoordinate = path.coordinate(at: coordinateIndex + 1)
describe("route to result card header component view model mapper test") {
context("when the route is a walking route") {
let route = Route.mockWalkingRoute
let departureDate = (route.segments?.first?.stops?.first?.scheduledDate)!
context("when the route is in less than 15 minutes") {
let currentDate = calendar.date(byAdding: .minute, value: -14, to: departureDate)!
let model = mapper.resultCardHeaderComponentViewModel(for: route, currentDate: currentDate)
it("returns a route type string for walking") {
expect(model.routeType).to(equal("Walk"))
}
view = MockPlannerMapView()
stub(view) { stub in
when(stub.setPolygons(with: any())).thenDoNothing()
when(stub.changeHintViewToOrigin()).thenDoNothing()
when(stub.makeTimeBubbleVisible()).thenDoNothing()
when(stub.makeTimeBubbleInvisible()).thenDoNothing()
when(stub.expandTimeBubble(withSearchModeText: anyString(),
andDateText: anyString(),
animated: any(Bool.self)))
.thenDoNothing()
verify(view).expandTimeBubble(withSearchModeText: "Arrive: ",
andDateText: "Wed, 00:00",
animated: true)