目录
目录README.md

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 GeoJSONKit-Turf
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.

关于
844.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号