ConcaveHull 1.3.0

ConcaveHull 1.3.0

测试已测试
语言语言 SwiftSwift
许可证 NOASSERTION
发布最新发布2019年1月
SPM支持 SPM

Sany Maamari 维护。



  • 作者:
  • SanyM

ConcaveHull - 一个通过点集构建凹多边形边界的 Swift 库

CI Status Version License Platform

用法

let points = [[162, 332], [182, 299], [141, 292], [158, 264], ... ];
let h = Hull(concavity: 50)
let hull = h.hull(points, nil)

参数

public func hull(_ pointSet: [Any], _ concavity: Double?, _ format: [String]?) -> [Any] {

  • 1st param - array of coordinates in format: [Any], [Any] can be [[Int]], [[Double]], [[String: Int]], [[String: Double]];
  • 2nd param - concavity. 1 - thin shape. Infinity - convex hull. By default 20;
  • 3rd param - the format of the array of coordinates For example: ["lng", "lat"] if you have ["lng": x, "lat": y] points. If your are using [[Int]] or [[Double]], the value can be nil

工作原理

这个逐步指南基于GitHub 上的原始代码https://github.com/AndriiHeonia/hull。让我们一步一步看看调用 hull() 函数时会发生什么。

  1. Hull.js 可以接收你的形状的源点
  2. 构建凸包
  3. 之后,边框会向内弯曲(根据`concavity`参数)。例如
    `concavity = 80`
    `concavity = 40`
    `concavity = 20`
## 安装

ConcaveHull 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod "ConcaveHull"