maparoni/geojsonkit-turf
This package provides various geospatial extensions for [GeoJSONKit](https://github.com/maparoni/geojsonkit). It is a fork of [turf-swift](https://github.com/mapbox/turf-swift.git), which itself is a partial Swift-port of [Turf.js](https://github.com/Turfjs/turf/).
Requirements
GeoJSONKitTurf requires Xcode 14.x and supports the following minimum deployment targets:
- iOS 15 and above
- macOS 12 and above
- tvOS 15 and above
- visionOS 1.0 and above
- watchOS 8.0 and above
It's also compatible with Linux (and possibly other platforms), as long as you have Swift 5.7 (or above) installed.
Installation
Swift Package Manager
To install GeoJSONKitTurf using the Swift Package Manager, add the following package to the dependencies in your Package.swift file:
.package(name: "GeoJSONKitTurf", url: "https://github.com/maparoni/geojsonkit-turf", from: "0.3.0")Then use:
import GeoJSONKitTurfAvailable functionality
This is a partial port of Turf.js, which adds the following functionality to GeoJSONKit's GeoJSON:
Turf.js | GeoJSONKit-Turf ----|---- turf-along | GeoJSON.LineString.coordinateFromStart(distance:) turf-area | GeoJSON.Polygon.area turf-bbox-clip | GeoJSON.LineString.clipped(to:)<br/>GeoJSON.Polygon.clipped(to:) turf-bearing | GeoJSON.Position.direction(to:)<br/> RadianCoordinate2D.direction(to:) turf-bezier-spline | GeoJSON.LineString.bezier(resolution:sharpness:) turf-boolean-point-in-polygon | GeoJSON.Polygon.contains(:) turf-center | GeoJSON.Geometry.center() | turf-center-of-mass | GeoJSON.Geometry.centerOfMass() | turf-centroid | GeoJSON.Geometry.centroid() | turf-circle | GeoJSON.Polygon(center:radius:) | turf-convex | GeoJSON.convexHull()<br/>Collection<GeoJSON.Position>.convexHull() | turf-destination | GeoJSON.Position.coordinate(at:facing:)<br/> RadianCoordinate2D.coordinate(at:facing:) turf-distance | GeoJSON.Position.distance(to:)<br/>RadianCoordinate2D.distance(to:) turf-helpers#degreesToRadians | GeoJSON.Degrees.toRadians() turf-helpers#radiansToDegrees | GeoJSON.DegreesRadians.toDegrees() turf-helpers#convertLength<br/>turf-helpers#convertArea | Measurement.converted(to:) turf-length | GeoJSON.LineString.distance(from:to:) turf-line-chunk | GeoJSON.LineString.chunked(length:)<br/>GeoJSON.Polygon.LinearRing.chunked(length:) | turf-line-intersect | GeoJSON.LineString.intersection(with:) turf-line-slice | GeoJSON.LineString.sliced(from:to:) turf-line-slice-along | GeoJSON.LineString.trimmed(from:distance:)<br/>GeoJSON.LineString.trimmed(from:to:) turf-midpoint | mid(:_:) turf-nearest-point-on-line | GeoJSON.LineString.closestCoordinate(to:) turf-point-on-feature | GeoJSON.Geometry.nearestPoint(to:)<br/>GeoJSON.Polygon.nearestPoint(to:) turf-polygon-smooth | GeoJSON.Polygon.smooth(iterations:) turf-union | Not provided, but see ASPolygonKit turf-simplify | GeoJSON.simplify(options:)
Additionally, it adds the following features, which do not have a direct equivalent in turf.js:
GeoJSON.Direction.difference(from:)GeoJSON.Direction.wrap(min:max:)GeoJSON.LineString.frechetDistance(to:): Determines the Fréchet distance between two line strings, which is a measure of their similarity.GeoJSON.GeometryObject(splittingWhenCrossingAntiMeridian:): Breaks up a LineString or Polygon into two when crossing the anti-meridian.
CLI
Comes with a mini-CLI geokitten with these commands:
geokitten simplify $inputto simplify a GeoJSON
Installation
<details> <summary>Via SPM</summary>
First clone or download the repository, then run this:
swift build -c release
sudo cp .build/release/geokitten /usr/local/bin/geokitten</details>
<details> <summary>Via <a href="https://github.com/yonaskolb/Mint">Mint</a></summary>
mint install maparoni/GeoJSONKit-Turf@mainIf you get a permissions error, check this Mint issue.
</details>
Package Metadata
Repository: maparoni/geojsonkit-turf
Default branch: main
README: README.md