Skip to content

Releases: mapbox/turf-swift

v2.2.0

21 Jan 20:33
Compare
Choose a tag to compare

Changes since v2.1.0:

  • The Feature, FeatureCollection, GeometryCollection, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, and Polygon structs now conform to the ForeignMemberContainer protocol. Foreign members (unrecognized properties outside of properties) are stored in the ForeignMemberContainer.foreignMembers property and round-tripped to JSON. (#175)
  • Ring now conforms to the Codable protocol. (#175)

Documentation is available online or within Xcode.

v2.1.0

11 Nov 13:23
132aaf7
Compare
Choose a tag to compare

Changes since v2.0.0:

  • Added LineString.trimmed(from:to:) method that returns a sliced LineString based on the starting and stopping distances.
  • Added Linestring.intersection(with:) method that returns all the intersections of the LineString with another one.

Documentation is available online or within Xcode.

v2.0.0

06 Oct 01:57
Compare
Choose a tag to compare

Changes since v1.2.0:

Packaging

  • ⚠️ Turf requires Xcode 12.0 or above to build from source. (#152)
  • ⚠️ When installing this library using Carthage, Carthage builds it with library evolution enabled. (#134)
  • Turf is now 100% documented. A full API reference is available online. (#162)

Geometry

  • ⚠️ Replaced the Linux-specific definitions of CLLocationCoordinate2D, CLLocationDirection, CLLocationDistance, and CLLocationDegrees with LocationCoordinate2D, LocationDirection, LocationDistance, and LocationDegrees, respectively. On Apple platforms, the new types remain type aliases, so you can continue to use the familiar CL-prefixed Core Location types unless you are writing cross-platform code that supports Linux. (#132)

  • ⚠️ Combined the GeoJSON class and GeoJSON protocol into a unified GeoJSONObject enumeration. Use JSONDecoder instead of the GeoJSON.parse(_:) or GeoJSON.parse<T: GeoJSONObject>(_:from:) method. (#154)

    v1.x
    if let feature = try GeoJSON.parse(data)?.decodedFeature,
       case let .lineString(lineString) = feature.geometry {  }
    v2.0.0
    if case let .feature(feature) = try JSONDecoder().decode(GeoJSONObject.self, from: data),
       case let .lineString(lineString) = feature.geometry {  }
  • ⚠️ Removed the FeatureCollection.identifier and FeatureCollection.properties properties with no replacement. These properties had been represented in GeoJSON by foreign members, which are not yet implemented. If you had been relying on the identifier or properties foreign members of FeatureCollection objects, move the data to each individual feature in the collection. (#154)

    v1.x
    let uuid = UUID().description
    featureCollection.identifier = .string(uuid)
    v2.0.0
    let uuid = UUID().description
    for feature in featureCollection.features {
        $0.identifier = .string(uuid)
    }
  • ⚠️ The Feature.properties property is now a JSONObject? (in other words, [String: JSONValue?]?). JSONObject is type-checked at compile time instead of runtime, but you can initialize it using a literal or full-width conversion from Any?. Code that builds a JSON object using literals will have to be modified to either specify a JSONValue case for each value or call the JSONObject(rawValue:) initializer. (#154)

    v1.x
    feature.properties = [
        "name": "Wapakoneta",
        "population": 9_957,
        "favorite": isFavorite,
    ]
    
    let isBigCity = (feature.properties?["population"] as? Double).flatMap { $0 > 10_000 }
    v2.0.0
    feature.properties = [
        "name": "Wapakoneta",
        "population": 9_957,
        "favorite": .boolean(isFavorite),
    ]
    
    var isBigCity: Bool?
    if case let .number(population) = feature.properties?["population"] {
        isBigCity = population > 10_000
    }
  • ⚠️ The Feature.geometry property is now optional. (#154)

  • ⚠️ Removed the Geometry.type property. Use pattern matching (case let) instead. (#154)

    v1.x
    if geometry.type == .Point {  }
    v2.0.0
    if case .point = geometry {  }
  • ⚠️ Removed the Geometry.value property. This type erasure is unnecessary and can potentially become a source of bugs. Use pattern matching instead. (#154)

    v1.x
    if let point = geometry.value as? Point {  }
    v2.0.0
    if case let .point(point) = geometry {  }
  • ⚠️ Removed the Number enumeration in favor of a Double-typed FeatureIdentifier.number(_:) case. JSON doesn’t distinguish between integers and double-precision floating point numbers. Any distinction in the type system or encoded JSON is purely cosmetic. (#154)

    v1.x
    let randomNumber = Int.random(in: 0...255)
    feature.identifier = .number(.int(randomNumber))
    
    if let number = feature.identifier?.value as? Int {
        print("You rolled a \(number)!")
    }
    v2.0.0
    let randomNumber = Int.random(in: 0...255)
    feature.identifier = .number(Double(randomNumber))
    
    if let .number(number) = feature.identifier {
        print("You rolled a \(Int(number))!")
    }
  • ⚠️ Renamed the BoundingBox(_:_:) initializer to BoundingBox(southWest:northEast:). (#132)

  • Feature and FeatureCollection now conform to the Equatable protocol. (#154)

  • Each geometric type, such as Point, now conforms to the Codable and Equatable protocols. (#154)

  • BoundingBox and FeatureIdentifier now conform to the Hashable protocol. (#154, #159)

Trigonometry

  • ⚠️ The RadianCoordinate2D.direction(to:) method now returns a Measurement<UnitAngle> instead of a RadianDirection, and the RadianCoordinate2D.coordinate(at:facing:) method now accepts a Measurement<UnitAngle> instance instead of a RadianDirection. The LocationCoordinate2D.coordinate(at:facing:) method can now accept a Measurement<UnitAngle> instance instead of a LocationDirection instance. (#143)
  • Added the Polygon.smooth(iterations:) method for polygon smoothing. (#137)
  • Added the Polygon.simplify(tolerance:highestQuality) method in both non-mutating and mutating forms. (#138)
  • Added the LineString.bezier(resolution:sharpness:) method for calculating a Bézier curve. (#140)
  • Added the Polygon.center, Polygon.centroid, and Polygon.centerOfMass properties. (#148)

Documentation is available online or within Xcode.

v2.0.0-rc.2

29 Sep 06:28
Compare
Choose a tag to compare
v2.0.0-rc.2 Pre-release
Pre-release

Changes since v2.0.0-rc.1:

Packaging

  • ⚠️ Turf requires Xcode 12.0 or above to build from source. (#152)

Geometry

  • ⚠️ Replaced the GeoJSON class and GeoJSON protocol with a unified GeoJSONObject enumeration. Use JSONDecoder instead of the GeoJSON.parse(_:) or GeoJSON.parse<T: GeoJSONObject>(_:from:) method. (#154)

    v2.0.0-rc.1
    if let feature = try GeoJSON.parse(data)?.decodedFeature,
       case let .lineString(lineString) = feature.geometry {  }
    v2.0.0-rc.2
    if case let .feature(feature) = try JSONDecoder().decode(GeoJSONObject.self, from: data),
       case let .lineString(lineString) = feature.geometry {  }
  • ⚠️ Removed the FeatureCollection.identifier and FeatureCollection.properties properties with no replacement. These properties had been represented in GeoJSON by foreign members, which are not yet implemented. If you had been relying on the identifier or properties foreign members of FeatureCollection objects, move the data to each individual feature in the collection. (#154)

    v2.0.0-rc.1
    let uuid = UUID().description
    featureCollection.identifier = .string(uuid)
    v2.0.0-rc.2
    let uuid = UUID().description
    for feature in featureCollection.features {
        $0.identifier = .string(uuid)
    }
  • ⚠️ The Feature.properties property is now a JSONObject? (in other words, [String: JSONValue?]?). JSONObject is type-checked at compile time instead of runtime, but you can initialize it using a literal or full-width conversion from Any?. Code that builds a JSON object using literals will have to be modified to either specify a JSONValue case for each value or call the JSONObject(rawValue:) initializer. (#154)

    v2.0.0-rc.1
    feature.properties = [
        "name": "Wapakoneta",
        "population": 9_957,
        "favorite": isFavorite,
    ]
    
    let isBigCity = (feature.properties?["population"] as? Double).flatMap { $0 > 10_000 }
    v2.0.0-rc.2
    feature.properties = [
        "name": "Wapakoneta",
        "population": 9_957,
        "favorite": .boolean(isFavorite),
    ]
    
    var isBigCity: Bool?
    if case let .number(population) = feature.properties?["population"] {
        isBigCity = population > 10_000
    }
  • ⚠️ The Feature.geometry property is now optional. (#154)

  • ⚠️ Removed the Geometry.type property. Use pattern matching (case let) instead. (#154)

    v2.0.0-rc.1
    if geometry.type == .Point {  }
    v2.0.0-rc.2
    if case .point = geometry {  }
  • ⚠️ Removed the Geometry.value property. This type erasure is unnecessary and can potentially become a source of bugs. Use pattern matching instead. (#154)

    v2.0.0-rc.1
    if let point = geometry.value as? Point {  }
    v2.0.0-rc.2
    if case let .point(point) = geometry {  }
  • ⚠️ Removed the Number enumeration in favor of a Double-typed FeatureIdentifier.number(_:) case. JSON doesn’t distinguish between integers and double-precision floating point numbers. Any distinction in the type system or encoded JSON is purely cosmetic. (#154)

    v2.0.0-rc.1
    let randomNumber = Int.random(in: 0...255)
    feature.identifier = .number(.int(randomNumber))
    
    if let number = feature.identifier?.value as? Int {
        print("You rolled a \(number)!")
    }
    v2.0.0-rc.2
    let randomNumber = Int.random(in: 0...255)
    feature.identifier = .number(Double(randomNumber))
    
    if let .number(number) = feature.identifier {
        print("You rolled a \(Int(number))!")
    }
  • Feature and FeatureCollection now conform to the Equatable protocol. (#154)

  • Each geometric type, such as Point, now conforms to the Codable and Equatable protocols. (#154)

  • BoundingBox now conforms to the Hashable protocol. (#154)

Trigonometry

  • Fixed an issue where the LineString.simplify(tolerance:highestQuality:) method returned a highest-quality result even if the highestQuality parameter was set to false. (#152)
  • Fixed an issue where the Polygon.simplify(tolerance:highestQuality:) method incorrectly applied the tolerance. (#152)
  • Fixed an issue where the Polygon.simplify(tolerance:highestQuality:) method failed to simplify the polygon at all if any of the linear rings was a triangle. (#152)

v2.0.0-rc.1

05 Aug 08:53
555458b
Compare
Choose a tag to compare
v2.0.0-rc.1 Pre-release
Pre-release

Changes since v2.0.0-beta.1:

  • Made bezier feature on LineString public. (#140)
  • Added Polygon.centroid() and Polygon.centerOfMass() methods. (#148)

v2.0.0-beta.1

28 May 17:56
e460a11
Compare
Choose a tag to compare
v2.0.0-beta.1 Pre-release
Pre-release

Changes since v2.0.0-alpha.3:

  • Added Polygon.smooth(iterations:) for polygon smoothing. (#137)
  • Added Polygon.simplify(tolerance:highestQuality) method in both non-mutating and mutating options. (#138)
  • Changed direction type in RadianCoordinate2D.direction(to:) and RadianCoordinate2D.coordinate(at:facing:) to Measurement<UnitAngle>. (#143)
  • Added LocationCoordinate2D.coordinate(at:facing:) with Measurement<UnitAngle> as direction type. (#143)

v2.0.0-alpha.3

22 Feb 22:25
Compare
Choose a tag to compare
v2.0.0-alpha.3 Pre-release
Pre-release

Changes since v2.0.0-alpha.2:

Packaging

  • Restored support for tvOS, watchOS, and Linux.
  • This library once is once again distributed as source code.
  • When installing this library using Carthage, Carthage builds it with library evolution enabled. (#134)

Other changes

  • Replaced the Linux-specific definitions of CLLocationCoordinate2D, CLLocationDirection, CLLocationDistance, and CLLocationDegrees with LocationCoordinate2D, LocationDirection, LocationDistance, and LocationDegrees, respectively. On Apple platforms, the new types remain type aliases, so you can continue to use the familiar CL-prefixed Core Location types unless you are writing cross-platform code that supports Linux. (#132)
  • Renamed BoundingBox(_:_:) to BoundingBox(southWest:northEast:). (#132)

v2.0.0-alpha.2

09 Feb 22:15
Compare
Choose a tag to compare
v2.0.0-alpha.2 Pre-release
Pre-release

v1.2.0

22 Jan 23:23
Compare
Choose a tag to compare

Changes since v1.1.0:

  • Application extensions can now link to Turf. (#126)
  • Added the Polygon(center:radius:vertices:) initializer for creating a regular polygon that approximates a circle. (#123)
  • Added the LineString.simplified(tolerance:highestQuality:) and LineString.simplify(tolerance:highestQuality:) methods that apply Ramer–Douglas–Peucker simplification. (#124)

v2.0.0-alpha.1

19 Jan 20:06
Compare
Choose a tag to compare
v2.0.0-alpha.1 Pre-release
Pre-release

This release is a wrapper that will serve v1.1.0 of Turf-Swift as a binary. This consumption is needed so that Swift Package Manager can use Turf Swift as a dynamic dependency.