Skip to content

Instantly share code, notes, and snippets.

@pimnijman
pimnijman / CLLocation.swift
Last active February 14, 2019 13:20
A CLLocation extension that adds a method to calculate the shortest distance between a location and an imaginary line between two other locations.
extension CLLocation {
/// Returns the shortest distance (measured in meters) from the current object's location to the imaginary line running between the two specified locations.
///
/// - Parameters:
/// - start: The first location that makes up the imaginary line.
/// - end: The second location that makes up the imaginary line.
/// - Returns: The shortest distance (in meters) between the current object's location and the imaginary line.
func distanceToLine(from start: CLLocation, to end: CLLocation) -> CLLocationDistance {
let s0lat = degreesToRadians(coordinate.latitude)
@pimnijman
pimnijman / ReactiveExtensionsCosmos.swift
Created October 7, 2019 12:28
ReactiveExtension to create a bidirectional binding with a CosmosView rating control
//
// ReactiveExtensionsCosmos.swift
// Route.nl
//
// Created by Pim Nijman on 07/09/2019.
// Copyright © 2019 Falk. All rights reserved.
//
import Bond
import ReactiveKit