Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPM support #30

Merged
merged 3 commits into from
Jan 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Turf",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "Turf",
targets: ["Turf"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "Turf",
dependencies: []),
.testTarget(
name: "TurfTests",
dependencies: ["Turf"]),
]
)
13 changes: 10 additions & 3 deletions Turf/CoreLocation.swift → Sources/Turf/CoreLocation.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import Foundation
#if os(Linux)
public struct CLLocationCoordinate2D {
let latitude: Double
let longitude: Double
}
public typealias CLLocationDirection = Double
public typealias CLLocationDistance = Double
public typealias CLLocationDegrees = Double
#else
import CoreLocation

#if os(OSX)
let CLLocationDistanceMax: CLLocationDistance = .greatestFiniteMagnitude
#endif

extension CLLocationDirection {
Expand Down
File renamed without changes.
File renamed without changes.
9 changes: 6 additions & 3 deletions Turf/Turf.swift → Sources/Turf/Turf.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if !os(Linux)
import CoreLocation
#endif

public typealias LocationRadians = Double
public typealias RadianDistance = Double
Expand Down Expand Up @@ -274,13 +277,13 @@ public struct Polyline {
let intersectionPoint = Turf.intersection((perpendicularPoint1, perpendicularPoint2), segment)
let intersectionDistance: CLLocationDistance? = intersectionPoint != nil ? coordinate.distance(to: intersectionPoint!) : nil

if distances.0 < closestCoordinate?.distance ?? CLLocationDistanceMax {
if distances.0 < closestCoordinate?.distance ?? .greatestFiniteMagnitude {
closestCoordinate = IndexedCoordinate(coordinate: segment.0, index: index, distance: distances.0)
}
if distances.1 < closestCoordinate?.distance ?? CLLocationDistanceMax {
if distances.1 < closestCoordinate?.distance ?? .greatestFiniteMagnitude {
closestCoordinate = IndexedCoordinate(coordinate: segment.1, index: index+1, distance: distances.1)
}
if intersectionDistance != nil && intersectionDistance! < closestCoordinate?.distance ?? CLLocationDistanceMax {
if intersectionDistance != nil && intersectionDistance! < closestCoordinate?.distance ?? .greatestFiniteMagnitude {
closestCoordinate = IndexedCoordinate(coordinate: intersectionPoint!, index: (distances.0 < distances.1 ? index : index+1), distance: intersectionDistance!)
}
}
Expand Down
6 changes: 6 additions & 0 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import XCTest
@testable import Turf

XCTMain([
testCase(TurfTests.allTests)
])
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Turf.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Pod::Spec.new do |s|

# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #

s.source_files = "Turf/**/*"
s.source_files = "Sources/**/*"

# ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #

Expand Down
156 changes: 88 additions & 68 deletions Turf.xcodeproj/project.pbxproj

Large diffs are not rendered by default.