Swiftpack.co - nighthawk/ASPolygonKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by nighthawk.
nighthawk/ASPolygonKit 0.5.1
A little Swift toolkit for working with polygons
⭐️ 1
🕓 28 weeks ago
iOS macOS
.package(url: "https://github.com/nighthawk/ASPolygonKit.git", from: "0.5.1")

ASPolygonKit

CI

Functionality:

  • Polygon union

ASPolygonKit is tested and confirmed working on on iOS, macOS and Linux. It might work on other platforms, too.

Installation

Swift Package Manager

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

.package(name: "ASPolygonKit", url: "https://github.com/nighthawk/aspolygonkit.git", from: "0.4.0"),

Usage

import ASPolygonKit in any Swift file in your module.

Example, usage merging a GeoJSON polygon from GeoJSONKit:

import GeoJSONKit
import ASPolygonKit

extension GeoJSON.Polygon {
  public static func union(_ polygons: [GeoJSON.Polygon]) throws -> [GeoJSON.Polygon] {
    try ASPolygonKit.Polygon.union(polygons.map(ASPolygonKit.Polygon.init))
      .map { polygon in
        .init(exterior: .init(positions: polygon.points.map { .init(latitude: $0.lat, longitude: $0.lng) }))
      }
  }
}

private extension ASPolygonKit.Polygon {
  init(_ geojson: GeoJSON.Polygon) {
    self.init(points: geojson.exterior.positions.map { .init(latitude: $0.latitude, longitude: $0.longitude) })
  }
}

Author

[email protected]

License

ASPolygonKit is available under the MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 1
Last commit: 28 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

0.5.0
1 year ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics