Skip to content

Commit

Permalink
Any -> Sendable in GeoJsonWritable (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
trasch authored Feb 20, 2025
1 parent a84053b commit 09127c8
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 22 deletions.
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import PackageDescription
let swiftSettings: [SwiftSetting] = [
.enableExperimentalFeature("StrictConcurrency"), // 5.10
.enableUpcomingFeature("StrictConcurrency"), // 6.0
.enableUpcomingFeature("InferSendableFromCaptures"), // Silences a Sendable warning
]

let package = Package(
Expand Down
8 changes: 4 additions & 4 deletions Sources/GISTools/GeoJson/Feature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public struct Feature:
}
}

public var asJson: Any {
public var asJson: Sendable {
switch self {
case .double(let double): double
case .int(let int): int
Expand Down Expand Up @@ -148,13 +148,13 @@ public struct Feature:
}
}

public var asJson: [String: Any] {
var result: [String: Any] = [
public var asJson: [String: Sendable] {
var result: [String: Sendable] = [
"type": GeoJsonType.feature.rawValue,
"properties": properties,
"geometry": geometry.asJson
]
if let id = id {
if let id {
result["id"] = id.asJson
}
if let boundingBox = boundingBox {
Expand Down
4 changes: 2 additions & 2 deletions Sources/GISTools/GeoJson/FeatureCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public struct FeatureCollection:
}
}

public var asJson: [String: Any] {
var result: [String: Any] = [
public var asJson: [String: Sendable] {
var result: [String: Sendable] = [
"type": GeoJsonType.featureCollection.rawValue,
"features": features.map { $0.asJson }
]
Expand Down
4 changes: 2 additions & 2 deletions Sources/GISTools/GeoJson/GeoJsonConvertible.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public protocol GeoJsonWritable {
/// Return the GeoJson object as a Swift dictionary.
///
/// - important: Always projected to EPSG:4326, unless the receiver has no SRID.
var asJson: [String: Any] { get }
var asJson: [String: Sendable] { get }

}

Expand Down Expand Up @@ -99,7 +99,7 @@ extension Sequence where Self.Iterator.Element: GeoJsonWritable {
/// Returns all elements as an array of JSON objects
///
/// - important: Always projected to EPSG:4326, unless the coordinate has no SRID.
public var asJson: [[String: Any]] {
public var asJson: [[String: Sendable]] {
return self.map({ $0.asJson })
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/GISTools/GeoJson/GeometryCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public struct GeometryCollection: GeoJsonGeometry {
}
}

public var asJson: [String: Any] {
var result: [String: Any] = [
public var asJson: [String: Sendable] {
var result: [String: Sendable] = [
"type": GeoJsonType.geometryCollection.rawValue,
"geometries": geometries.map { $0.asJson }
]
Expand Down
4 changes: 2 additions & 2 deletions Sources/GISTools/GeoJson/LineString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public struct LineString:
}
}

public var asJson: [String: Any] {
var result: [String: Any] = [
public var asJson: [String: Sendable] {
var result: [String: Sendable] = [
"type": GeoJsonType.lineString.rawValue,
"coordinates": coordinates.map { $0.asJson }
]
Expand Down
4 changes: 2 additions & 2 deletions Sources/GISTools/GeoJson/MultiLineString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ public struct MultiLineString:
}
}

public var asJson: [String: Any] {
var result: [String: Any] = [
public var asJson: [String: Sendable] {
var result: [String: Sendable] = [
"type": GeoJsonType.multiLineString.rawValue,
"coordinates": coordinates.map { $0.map { $0.asJson } }
]
Expand Down
4 changes: 2 additions & 2 deletions Sources/GISTools/GeoJson/MultiPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public struct MultiPoint:
}
}

public var asJson: [String: Any] {
var result: [String: Any] = [
public var asJson: [String: Sendable] {
var result: [String: Sendable] = [
"type": GeoJsonType.multiPoint.rawValue,
"coordinates": coordinates.map { $0.asJson }
]
Expand Down
4 changes: 2 additions & 2 deletions Sources/GISTools/GeoJson/MultiPolygon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public struct MultiPolygon:
}
}

public var asJson: [String: Any] {
var result: [String: Any] = [
public var asJson: [String: Sendable] {
var result: [String: Sendable] = [
"type": GeoJsonType.multiPolygon.rawValue,
"coordinates": coordinates.map { $0.map { $0.map { $0.asJson } } }
]
Expand Down
4 changes: 2 additions & 2 deletions Sources/GISTools/GeoJson/Point.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public struct Point: PointGeometry {
}
}

public var asJson: [String: Any] {
var result: [String: Any] = [
public var asJson: [String: Sendable] {
var result: [String: Sendable] = [
"type": GeoJsonType.point.rawValue,
"coordinates": coordinate.asJson
]
Expand Down
4 changes: 2 additions & 2 deletions Sources/GISTools/GeoJson/Polygon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ public struct Polygon:
}
}

public var asJson: [String: Any] {
var result: [String: Any] = [
public var asJson: [String: Sendable] {
var result: [String: Sendable] = [
"type": GeoJsonType.polygon.rawValue,
"coordinates": coordinates.map { $0.map { $0.asJson } }
]
Expand Down

0 comments on commit 09127c8

Please sign in to comment.