All Projects → mapbox → Turf Swift

mapbox / Turf Swift

Licence: isc
A Swift language port of Turf.js.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Turf Swift

Turf
A modular geospatial engine written in JavaScript
Stars: ✭ 6,659 (+5313.82%)
Mutual labels:  algorithm, gis, computational-geometry
topo
A Geometry library for Elixir that calculates spatial relationships between two geometries
Stars: ✭ 125 (+1.63%)
Mutual labels:  geospatial, gis, computational-geometry
Geotiff.io
Static website for viewing and analyzing GeoTIFF's in the browser
Stars: ✭ 53 (-56.91%)
Mutual labels:  gis, geospatial
Geotools
Official GeoTools repository
Stars: ✭ 1,109 (+801.63%)
Mutual labels:  gis, geospatial
Pyearth
🌐 A lightweight 3D visualization of the earth in 150 lines of Qt/OpenGL
Stars: ✭ 78 (-36.59%)
Mutual labels:  gis, geospatial
Urbansprawl
Open framework for calculating spatial urban sprawl indices and performing disaggregated population estimates using open data
Stars: ✭ 48 (-60.98%)
Mutual labels:  gis, geospatial
3d Tiles
Specification for streaming massive heterogeneous 3D geospatial datasets 🌎
Stars: ✭ 1,054 (+756.91%)
Mutual labels:  gis, geospatial
Simplification
Very fast LineString simplification using RDP or Visvalingam-Whyatt and a Rust binary
Stars: ✭ 78 (-36.59%)
Mutual labels:  geospatial, computational-geometry
Polysnap
A work in progress polygon operations library with integer snap-rounding
Stars: ✭ 14 (-88.62%)
Mutual labels:  algorithm, computational-geometry
Arctern
Stars: ✭ 94 (-23.58%)
Mutual labels:  gis, geospatial
Geocube
Tool to convert geopandas vector data into rasterized xarray data.
Stars: ✭ 87 (-29.27%)
Mutual labels:  gis, geospatial
Earcut
The fastest and smallest JavaScript polygon triangulation library for your WebGL apps
Stars: ✭ 1,359 (+1004.88%)
Mutual labels:  algorithm, computational-geometry
Flatbush
A very fast static spatial index for 2D points and rectangles in JavaScript
Stars: ✭ 1,031 (+738.21%)
Mutual labels:  algorithm, computational-geometry
Shapefile.jl
Parsing .shp files in Julia
Stars: ✭ 40 (-67.48%)
Mutual labels:  gis, geospatial
Geoblacklight
Discovery platform for GIS data.
Stars: ✭ 116 (-5.69%)
Mutual labels:  gis, geospatial
Geemap
A Python package for interactive mapping with Google Earth Engine, ipyleaflet, and folium
Stars: ✭ 959 (+679.67%)
Mutual labels:  gis, geospatial
Geoscript Js
A JavaScript Implementation of GeoScript
Stars: ✭ 72 (-41.46%)
Mutual labels:  gis, geospatial
Proj4js
JavaScript library to transform coordinates from one coordinate system to another, including datum transformations
Stars: ✭ 1,365 (+1009.76%)
Mutual labels:  gis, geospatial
Rlur
Shiny dashboard for Land Use Regression modelling
Stars: ✭ 8 (-93.5%)
Mutual labels:  gis, geospatial
Cesium
An open-source JavaScript library for world-class 3D globes and maps 🌎
Stars: ✭ 8,095 (+6481.3%)
Mutual labels:  gis, geospatial

Turf for Swift

📱iOS     🖥💻macOS     📺tvOS     ⌚️watchOS     Linux     codecov Carthage compatible     CocoaPods     SPM compatible    

A spatial analysis library written in Swift for native iOS, macOS, tvOS, watchOS, and Linux applications, ported from Turf.js.

Requirements

Turf requires Xcode 9.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

Alternatively, you can incorporate Turf into a command line tool without Xcode on any platform that Swift supports, including Linux.

If your project is written in Objective-C, you’ll need to write a compatibility layer between turf-swift and your Objective-C code. If your project is written in Objective-C++, you may be able to use spatial-algorithms as an alternative to Turf.

Installation

Although a stable release of this library is not yet available, prereleases are available for installation using any of the popular Swift dependency managers.

CocoaPods

To install Turf using CocoaPods:

  1. Specify the following dependency in your Podfile:
    pod 'Turf', '~> 1.2'
    
  2. Run pod repo update if you haven’t lately.
  3. Run pod install and open the resulting Xcode workspace.
  4. Add import Turf to any Swift file in your application target.

Carthage

To install Turf using Carthage:

  1. Add the following dependency to your Cartfile:
    github "mapbox/turf-swift" ~> 1.2
    
  2. Run carthage bootstrap.
  3. Follow the rest of Carthage’s integration instructions. Your application target’s Embedded Frameworks should include Turf.framework.
  4. Add import Turf to any Swift file in your application target.

Swift Package Manager

To install Turf using the Swift Package Manager, add the following package to the dependencies in your Package.swift file:

.package(url: "https://github.com/mapbox/turf-swift.git", from: "1.2.0")

Then import Turf in any Swift file in your module.

Available functionality

This work-in-progress port of Turf.js contains the following functionality:

Turf.js Turf-swift
turf-along LineString.coordinateFromStart(distance:)
turf-area Polygon.area
turf-bearing CLLocationCoordinate2D.direction(to:)
LocationCoordinate2D.direction(to:) on Linux
RadianCoordinate2D.direction(to:)
turf-bezier-spline LineString.bezier(resolution:sharpness:)
turf-boolean-point-in-polygon Polygon.contains(_:ignoreBoundary:)
turf-circle Polygon(center:radius:vertices:)
turf-destination CLLocationCoordinate2D.coordinate(at:facing:)
LocationCoordinate2D.coordinate(at:facing:) on Linux
RadianCoordinate2D.coordinate(at:facing:)
turf-distance CLLocationCoordinate2D.distance(to:)
LocationCoordinate2D.distance(to:) on Linux
RadianCoordinate2D.distance(to:)
turf-helpers#polygon Polygon(_:)
turf-helpers#lineString LineString(_:)
turf-helpers#degreesToRadians CLLocationDegrees.toRadians()
LocationDegrees.toRadians() on Linux
turf-helpers#radiansToDegrees CLLocationDegrees.toDegrees()
LocationDegrees.toDegrees() on Linux
turf-helpers#convertLength
turf-helpers#convertArea
Measurement.converted(to:)
turf-length LineString.distance(from:to:)
turf-line-intersect intersection(_:_:)
turf-line-slice LineString.sliced(from:to:)
turf-line-slice-along LineString.trimmed(from:distance:)
turf-midpoint mid(_:_:)
turf-nearest-point-on-line LineString.closestCoordinate(to:)
turf-polygon-to-line LineString(_:)
MultiLineString(_:)
FeatureCollection(_:)
turf-simplify LineString.simplified(tolerance:highestQuality:)
turf-polygon-smooth Polygon.smooth(iterations:)
turf-simplify Polygon.simplified(tolerance:highestQuality:)
CLLocationDirection.difference(from:)
LocationDirection.difference(from:) on Linux
CLLocationDirection.wrap(min:max:)
LocationDirection.wrap(min:max:) on Linux

GeoJSON

turf-swift also contains an experimental GeoJSON encoder/decoder with support for Codable.

// Decode unknown GeoJSON type
let geojson = try! GeoJSON.parse(data)

// Decode known GeoJSON type
let geojson = try! GeoJSON.parse(FeatureCollection.self, from: data)

// Initialize a PointFeature and encode as GeoJSON
let coordinate = CLLocationCoordinate2D(latitude: 0, longitude: 1)
let point = Point(coordinate)
let pointFeature = Feature(geometry: .point(point))
let data = try! JSONEncoder().encode(pointFeature)
let json = String(data: data, encoding: .utf8)
print(json)

/*
{
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [
      1,
      0
    ]
  }
}
*/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].