Skip to content

Commit

Permalink
Merge pull request #34 from Outdooractive/geojson_projection
Browse files Browse the repository at this point in the history
#33: Adds support for projections
  • Loading branch information
trasch authored Jul 21, 2023
2 parents 8e4e122 + 9204d6e commit fd47ec0
Show file tree
Hide file tree
Showing 74 changed files with 2,518 additions and 1,631 deletions.
503 changes: 275 additions & 228 deletions README.md

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions Sources/GISTools/Extensions/ArrayExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,11 @@ extension Array {

/// Returns the array's elements pairwise, with every element only once in the result.
/// For arrays with uneven length, the last element will be skipped.
///
/// ```
/// let a = [1, 2, 3, 4, 5]
/// a.distinctPairs() -> [(1, 2), (3, 4)]
/// ```
func distinctPairs() -> [(first: Element, second: Element)] {
guard !isEmpty else { return [] }

Expand All @@ -133,8 +136,11 @@ extension Array {
}

/// Returns the array's elements pairwise, where each pair overlaps the previous pair.
///
/// ```
/// let a = [1, 2, 3, 4, 5]
/// a.overlappingPairs() -> [(1, 2), (2, 3), (3, 4), (4, 5)]
/// ```
func overlappingPairs() -> [(first: Element, second: Element)] {
guard !isEmpty else { return [] }

Expand Down Expand Up @@ -169,4 +175,9 @@ extension Array {
return self
}

/// A Boolean value indicating whether the collection is not empty.
var isNotEmpty: Bool {
!isEmpty
}

}
1 change: 1 addition & 0 deletions Sources/GISTools/Extensions/DataExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extension Data {
.compactMap { UInt8($0, radix: 16) }

guard hex.count / bytes.count == 2 else { return nil }

self.init(bytes)
}

Expand Down
5 changes: 3 additions & 2 deletions Sources/GISTools/GISTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import CoreLocation
#endif

// MARK: GISTool

/// Some constants used in this library.
public enum GISTool {

Expand All @@ -16,6 +14,9 @@ public enum GISTool {
/// Length of the equator, in meters.
public static let earthCircumference: CLLocationDistance = 40_075_016.6855785

/// Mercator projection origin shift.
public static let originShift = 2.0 * Double.pi * GISTool.equatorialRadius / 2.0 // 20037508.342789244

/// The accuracy for testing what is equal.
public static let equalityDelta: Double = 1e-10

Expand Down
Loading

0 comments on commit fd47ec0

Please sign in to comment.