Skip to content

Commit

Permalink
A feature can have no geometry
Browse files Browse the repository at this point in the history
The GeoJSON specification allows a Feature object to have no geometry at all.
  • Loading branch information
1ec5 committed Sep 28, 2021
1 parent 51c1981 commit 3e30f46
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Sources/Turf/Feature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import CoreLocation
public struct Feature {
public var identifier: FeatureIdentifier?
public var properties: JSONObject?
public var geometry: Geometry
public var geometry: Geometry?

public init(geometry: Geometry) {
public init(geometry: Geometry?) {
self.geometry = geometry
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/TurfTests/PointTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class PointTests: XCTestCase {
}

var encodedData: Data?
XCTAssertNoThrow(encodedData = try JSONEncoder().encode(GeoJSONObject.geometry(feature.geometry)))
XCTAssertNoThrow(encodedData = try JSONEncoder().encode(GeoJSONObject.geometry(XCTUnwrap(feature.geometry))))
XCTAssertNotNil(encodedData)

var decoded: GeoJSONObject?
Expand Down

0 comments on commit 3e30f46

Please sign in to comment.