GeoJSONKitTurf

0.1.4

A fork of turf-swift based on GeoJSONKit
maparoni/GeoJSONKit-Turf

What's New

0.1.4

2022-10-21T02:22:08Z
  • Bug fix for creating bounding boxes that span the anti-meridian
  • Performance improvement for trimmed(from:,to:) from upstream

Full Changelog: 0.1.3...0.1.4

GeoJSONKit+Turf

Swift

This package provides various geospatial extensions for GeoJSONKit. It is a fork of turf-swift, which is ported from Turf.js.

Requirements

GeoJSONKitTurf requires Xcode 12.x and supports the following minimum deployment targets:

  • iOS 10.0 and above
  • macOS 10.12 (Sierra) and above
  • tvOS 10.0 and above
  • watchOS 3.0 and above

It's also compatible with Linux (and possibly other platforms), as long as you have Swift 5.3 (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.1.0")

Then use:

import GeoJSONKitTurf

Available functionality

This is a partial port of Turf.js, which adds the following functionality to GeoJSONKit's GeoJSON:

Turf.js Turf-swift
turf-along GeoJSON.LineString.coordinateFromStart(distance:)
turf-area GeoJSON.Polygon.area
turf-bearing GeoJSON.Position.direction(to:)
RadianCoordinate2D.direction(to:)
turf-bezier-spline GeoJSON.LineString.bezier(resolution:sharpness:)
turf-boolean-point-in-polygon GeoJSON.Polygon.contains(_:ignoreBoundary:)
turf-center GeoJSON.Geometry.center()
turf-center-of-mass GeoJSON.Geometry.centerOfMass()
turf-centroid GeoJSON.Geometry.centroid()
turf-circle GeoJSON.Polygon(center:radius:vertices:)
turf-convex GeoJSON.convexHull()
Collection<GeoJSON.Position>.convexHull()
turf-destination GeoJSON.Position.coordinate(at:facing:)
RadianCoordinate2D.coordinate(at:facing:)
turf-distance GeoJSON.Position.distance(to:)
RadianCoordinate2D.distance(to:)
turf-helpers#degreesToRadians GeoJSON.Degrees.toRadians()
turf-helpers#radiansToDegrees GeoJSON.DegreesRadians.toDegrees()
turf-helpers#convertLength
turf-helpers#convertArea
Measurement.converted(to:)
turf-length GeoJSON.LineString.distance(from:to:)
turf-line-intersect GeoJSON.LineString.intersection(with:)
turf-line-slice GeoJSON.LineString.sliced(from:to:)
turf-line-slice-along GeoJSON.LineString.trimmed(from:distance:)
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:)
GeoJSON.Polygon.nearestPoint(to:)
turf-polygon-smooth GeoJSON.Polygon.smooth(iterations:)
turf-union Not provided, but see ASPolygonKit
turf-simplify GeoJSON.simplify(options:)
GeoJSON.Direction.difference(from:)
GeoJSON.Direction.wrap(min:max:)

CLI

Comes with a mini-CLI geokitten with these commands:

  • geokitten simplify $input to simplify a GeoJSON

Installation

Via SPM

First clone or download the repository, then run this:

swift build -c release
sudo cp .build/release/geokitten /usr/local/bin/geokitten
Via Mint
mint install maparoni/GeoJSONKit-Turf@main

If you get a permissions error, check this Mint issue.

Description

  • Swift Tools 5.3.0
View More Packages from this Author

Dependencies

Last updated: Fri Nov 25 2022 02:41:02 GMT-0500 (GMT-05:00)