Skip to content
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Example/ForeFlightKMLDemo/KML/KMLGenerator.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Foundation
import GeodesySpherical
import CoreLocation
import ForeFlightKML

Expand Down
1 change: 0 additions & 1 deletion Example/ForeFlightKMLDemo/Map/MapViewRepresentable.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import SwiftUI
import MapKit
import CoreLocation
import GeodesySpherical
import ForeFlightKML

struct MapViewRepresentable: UIViewRepresentable {
Expand Down
11 changes: 6 additions & 5 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ let package = Package(
)
],
dependencies: [
.package(url: "https://github.com/florianreinhart/Geodesy", .upToNextMajor(from: "0.2.2")),
.package(url: "https://github.com/Haelix-Code/Vincenty", .upToNextMinor(from: "0.0.1")),
.package(url: "https://github.com/weichsel/ZIPFoundation.git", from: "0.9.0")
],
targets: [
.target(
name: "ForeFlightKML",
dependencies: [
.product(name: "Geodesy", package: "Geodesy"),
.product(name: "Vincenty", package: "Vincenty"),
.product(name: "ZIPFoundation", package: "ZIPFoundation")
],
resources: [
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ See `/Tests/UserMapShapeTests/UserMapShapesSampleFullTest.swift`

```swift
import ForeFlightKML
import GeodesySpherical

let builder = ForeFlightKMLBuilder(documentName: "Airport with ATZ")

Expand Down Expand Up @@ -126,7 +125,7 @@ Full public API surface is visible in the package sources.

## Notes, conventions and gotchas

- **Coordinates order**: KML requires `longitude,latitude[,altitude]`. The public API accepts `Coordinate(latitude:..., longitude:...)` (from `Geodesy`) and the framework emits coordinates in the KML `lon,lat[,alt]` order.
- **Coordinates order**: KML requires `longitude,latitude[,altitude]`. The public API accepts `Coordinate(latitude:..., longitude:...)` (a typealias for [Vincenty](https://github.com/Haelix-Code/Vincenty)'s `GeodeticCoordinate`) and the framework emits coordinates in the KML `lon,lat[,alt]` order.
- **Units**: Distances (e.g. `LineCircle.radius`) are in **meters**.
- **Angles/bearings**: bearings (for arc & circle generation) are interpreted in degrees (0..360). The bearing convention is clockwise from north.
- **Altitude**: When you provide altitudes, the `AltitudeMode` is emitted (defaults to `.absolute` in most geometries).
Expand Down
2 changes: 1 addition & 1 deletion Sources/ForeFlightKML/CoreElements/LineString.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GeodesySpherical
import Vincenty

/// A line string connecting multiple coordinates in order.
/// Used for routes, boundaries, or any connected line geometry.
Expand Down
2 changes: 1 addition & 1 deletion Sources/ForeFlightKML/CoreElements/LinearRing.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GeodesySpherical
import Vincenty

/// Defines a closed line string, typically the outer boundary of a Polygon.
/// Optionally, a LinearRing can also be used as the inner boundary of a Polygon to create holes in the Polygon.
Expand Down
2 changes: 1 addition & 1 deletion Sources/ForeFlightKML/CoreElements/Point.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GeodesySpherical
import Vincenty

/// A geographic point in 3D space that can be displayed as a marker in ForeFlight.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/ForeFlightKML/ForeFlightKML+Convenience.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import GeodesySpherical
import Vincenty

extension ForeFlightKMLBuilder {

Expand Down
2 changes: 1 addition & 1 deletion Sources/ForeFlightKML/ForeFlightKML.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import GeodesySpherical
import Vincenty

/// A Builder for composing a KML Document (styles + placemarks).
/// Use this to create KML documents compatible with ForeFlight's User Map Shapes feature.
Expand Down
2 changes: 1 addition & 1 deletion Sources/ForeFlightKML/Geometry/Circle/LineCircle.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import GeodesySpherical
import Vincenty

/// A circular line geometry approximated with multiple line segments.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/ForeFlightKML/Geometry/Circle/PolygonCircle.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GeodesySpherical
import Vincenty

/// A circular polygon geometry approximated with multiple line segments.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/ForeFlightKML/Geometry/Segment/LineSector.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GeodesySpherical
import Vincenty

/// An arc or sector geometry (like a pie slice) defined by center, radius, and angular extents.
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GeodesySpherical
import Vincenty

public struct PolygonAnnularSector: KMLElement, AltitudeSupport {
let polygon: Polygon
Expand Down
2 changes: 1 addition & 1 deletion Sources/ForeFlightKML/Geometry/Segment/PolygonSector.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GeodesySpherical
import Vincenty

public struct PolygonSector: KMLElement, AltitudeSupport {
let polygon: Polygon
Expand Down
2 changes: 1 addition & 1 deletion Sources/ForeFlightKML/Geometry/Shared/CircleGeometry.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GeodesySpherical
import Vincenty

internal enum CircleGeometry {

Expand Down
2 changes: 1 addition & 1 deletion Sources/ForeFlightKML/Geometry/Shared/Line.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GeodesySpherical
import Vincenty

/// A simple line connecting multiple coordinates in sequence.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/ForeFlightKML/Geometry/Shared/SectorGeometry.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import GeodesySpherical
import Vincenty

internal enum SectorGeometry {
static func generateSectorPoints(
Expand Down
2 changes: 1 addition & 1 deletion Sources/ForeFlightKML/Models/CoordinateContainer.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GeodesySpherical
import Vincenty

/// Protocol for KML elements that contain coordinate arrays and support altitude/tessellation.
/// Used by LineString, LinearRing, and similar coordinate-based geometries.
Expand Down
2 changes: 1 addition & 1 deletion Sources/ForeFlightKML/Models/Placemark.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GeodesySpherical
import Vincenty

/// Represents a Feature Placemark that combines geometry with styling and metadata.
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation
import GeodesySpherical
// Re-exported so `Coordinate` is fully usable with just `import ForeFlightKML`.
@_exported import Vincenty

// KML uses 3D geographic coordinates: longitude, latitude and altitude, in that order.
// The longitude and latitude components are in decimal degrees
Expand Down Expand Up @@ -39,7 +40,21 @@ internal func formatCoordinate(_ value: Double, precision: Int) -> String {
return String(formatted[formatted.startIndex..<end])
}

extension GeodesySpherical.Coordinate {
/// A WGS-84 latitude/longitude in decimal degrees.
public typealias Coordinate = GeodeticCoordinate

extension Coordinate {
/// The point `distance` metres from here along a WGS-84 geodesic, setting off on `bearing`
/// degrees from north (Vincenty direct solution).
///
/// Non-finite input yields a NaN coordinate rather than trapping.
internal func destination(with distance: Double, bearing: Double) -> Coordinate {
guard let solution = try? Ellipsoid.wgs84.direct(from: self, distance: distance, initialBearing: bearing) else {
return Coordinate(latitude: .nan, longitude: .nan)
}
return solution.destination
}

/// Format coordinate as KML `longitude,latitude` string with given precision.
/// Trailing zeros are trimmed (e.g. `2.0` not `2.00000000`).
public func kmlString(precision: Int = 8) -> String {
Expand Down Expand Up @@ -68,7 +83,7 @@ internal struct Coordinate3D: Hashable {
public let altitude: Double?

public init(
latitude: GeodesySpherical.Degrees, longitude: GeodesySpherical.Degrees,
latitude: Double, longitude: Double,
altitude: Double? = nil
) {
self.coordinate = Coordinate(latitude: latitude, longitude: longitude)
Expand All @@ -80,8 +95,8 @@ internal struct Coordinate3D: Hashable {
self.altitude = altitude
}

public var latitude: GeodesySpherical.Degrees { coordinate.latitude }
public var longitude: GeodesySpherical.Degrees { coordinate.longitude }
public var latitude: Double { coordinate.latitude }
public var longitude: Double { coordinate.longitude }

public func kmlString(precision: Int = kDefaultCoordinatePrecision) -> String {
let lon = formatCoordinate(self.longitude, precision: precision)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import XCTest
import GeodesySpherical
@testable import ForeFlightKML

final class ForeFlightKMLBuildTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import XCTest
@testable import ForeFlightKML
import GeodesySpherical
import ZIPFoundation

final class KMZPackagingTests: XCTestCase {
Expand Down
1 change: 0 additions & 1 deletion Tests/ForeFlightKMLTests/Builder/ForeFlightKMLTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import GeodesySpherical
import Foundation
import XCTest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import GeodesySpherical
import XCTest

@testable import ForeFlightKML
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import GeodesySpherical
import XCTest

@testable import ForeFlightKML
Expand Down
1 change: 0 additions & 1 deletion Tests/ForeFlightKMLTests/CoreElementTests/PointTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import GeodesySpherical
import XCTest

@testable import ForeFlightKML
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import GeodesySpherical
import XCTest

@testable import ForeFlightKML
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import GeodesySpherical
import XCTest

@testable import ForeFlightKML
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import GeodesySpherical
import XCTest

@testable import ForeFlightKML
Expand Down
1 change: 0 additions & 1 deletion Tests/ForeFlightKMLTests/GeometryTests/LineTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import GeodesySpherical
import XCTest

@testable import ForeFlightKML
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import GeodesySpherical
import XCTest

@testable import ForeFlightKML
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import GeodesySpherical
import XCTest

@testable import ForeFlightKML
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import GeodesySpherical
import XCTest

@testable import ForeFlightKML
Expand Down
1 change: 0 additions & 1 deletion Tests/ForeFlightKMLTests/ModelTests/AltitudeTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import GeodesySpherical
import XCTest

@testable import ForeFlightKML
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import GeodesySpherical
import XCTest

@testable import ForeFlightKML
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import GeodesySpherical
import XCTest

@testable import ForeFlightKML
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import XCTest
import GeodesySpherical
@testable import ForeFlightKML

final class PointStylesTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import XCTest
@testable import ForeFlightKML
import GeodesySpherical

final class LabelOnlyTests: XCTestCase {

Expand Down
1 change: 0 additions & 1 deletion Tests/ForeFlightKMLTests/StyleTests/SubStyleTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import GeodesySpherical
import XCTest

@testable import ForeFlightKML
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import XCTest
import GeodesySpherical
@testable import ForeFlightKML

final class CoordinateFormattingTests: XCTestCase {
Expand Down
1 change: 0 additions & 1 deletion Tests/ForeFlightKMLTests/Utils/TestHelpers.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import XCTest
import GeodesySpherical
@testable import ForeFlightKML

class XMLTestHelper {
Expand Down
1 change: 0 additions & 1 deletion Tests/UserMapShapeTests/UserMapShapesSampleFullTest.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import GeodesySpherical
import XCTest

@testable import ForeFlightKML
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import GeodesySpherical
import XCTest

@testable import ForeFlightKML
Expand Down
Loading