Welcome to SwiftGeographicLib, a Swift wrapper for geodesic routines from Charles Karney's GeographicLib. This library provides a clean and efficient way to perform geodesic calculations in your Swift applications. Whether you're developing for iOS with SwiftUI or UIKit, this library simplifies complex geographic computations.
- Geodesic Calculations: Easily compute distances and angles between geographic points.
- Swift Compatibility: Built entirely in Swift, making it easy to integrate into your projects.
- High Precision: Uses proven algorithms to ensure accuracy in geodesic computations.
- Lightweight: Minimal dependencies, keeping your app lean and efficient.
- Comprehensive Documentation: Detailed guides and examples to help you get started.
To get started with SwiftGeographicLib, you can download the latest release from our Releases section. Follow the instructions provided in the release notes to execute the package in your project.
If you prefer using CocoaPods, add the following line to your Podfile
:
pod 'SwiftGeographicLib'
Then run:
pod install
To integrate using Swift Package Manager, add the following dependency in your Package.swift
file:
dependencies: [
.package(url: "https://github.com/MartinMira24/SwiftGeographicLib.git", from: "1.0.0")
]
Once you have installed SwiftGeographicLib, you can start using it in your Swift projects. Here’s a simple example to demonstrate its functionality.
import SwiftGeographicLib
To calculate the distance between two geographic points, use the following code:
let pointA = GeographicPoint(latitude: 34.0522, longitude: -118.2437) // Los Angeles
let pointB = GeographicPoint(latitude: 40.7128, longitude: -74.0060) // New York
let distance = Geodesic.distance(from: pointA, to: pointB)
print("Distance: \(distance) meters")
Here are a few more examples of how to use SwiftGeographicLib in your projects.
let point1 = GeographicPoint(latitude: 51.5074, longitude: -0.1278) // London
let point2 = GeographicPoint(latitude: 48.8566, longitude: 2.3522) // Paris
let distance = Geodesic.distance(from: point1, to: point2)
print("Distance from London to Paris: \(distance) meters")
let angle = Geodesic.angle(from: point1, to: point2)
print("Angle from London to Paris: \(angle) degrees")
We welcome contributions to SwiftGeographicLib! If you have suggestions, improvements, or bug fixes, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or fix.
- Make your changes.
- Submit a pull request.
Your contributions help improve the library for everyone!
SwiftGeographicLib is licensed under the MIT License. See the LICENSE file for details.
For any questions or support, please feel free to reach out. You can also check our Releases section for the latest updates and versions.
Thank you for choosing SwiftGeographicLib! We hope this library makes your geodesic calculations straightforward and efficient. Happy coding!