Turf-swift
Warning: The Turf-swift API is experimental and will change. It is published to be able to get feedback from the community. Please use with caution and open issues for any problems you see or missing features that should be added.
A spatial analysis library written in Swift for native iOS and macOS applications, ported from Turf.js.
Installation
Although there has not yet been a beta release of this library yet, you can still experiment with it in your application by using CocoaPods to install it. Edit your Podfile to include:
pod 'Turf-swift', '~> 0.0.4'
Alternatively, you can clone this repo and drag and drop Turf.swift and CoreLocation.swift into your project in Xcode.
Available functionality
This work-in-progress port of Turf.js contains the following functionality:
Turf.js | Turf-swift |
---|---|
turf-along | Polyline.coordinateFromStart(distance:) |
turf-destination | CLLocationCoordinate2D.coordinate(at:facing:) RadianCoordinate2D.coordinate(at:facing:) |
turf-distance | CLLocationCoordinate2D.distance(to:) RadianCoordinate2D.distance(to:) |
turf-helpers#lineString | Polyline(_:) |
turf-helpers#degrees2radians | CLLocationDegrees.toRadians() |
turf-helpers#radians2degrees | CLLocationDegrees.toDegrees() |
turf-line-distance | Polyline.distance(from:to:) |
turf-line-intersect | Turf.intersection(_:_:) |
turf-line-slice | Polyline.sliced(from:to:) |
turf-line-slice-along | Polyline.trimmed(from:distance:) |
turf-point-on-line | Polyline.closestCoordinate(to:) |
— | CLLocationCoordinate2D.direction(to:) RadianCoordinate2D.direction(to:) |
— | CLLocationDirection.differenceBetween(_:) |
— | CLLocationDirection.wrap(min:max:) |