Merge pull request #1 from salishseasoftware/spi Updates for swift package index
Merge pull request #1 from salishseasoftware/spi
Updates for swift package index
This package provides some Formatters that convert between coordinates and their textual representations.
Please see the documentation for more detailed usage instructions.
This is the primary formatter for converting coordinates. It utilizes additional formatters for specific formats.
LocationCoordinateFormatter provides a variety of configuration options for customizing both the string output and parsing coordinates from strings.
import LocationFormatter let coordinate = CLLocationCoordinate2D(latitude: 48.11638, longitude: -122.77527) let formatter = LocationCoordinateFormatter() // Decimal Degrees (DD) formatter.format = .decimalDegrees formatter.string(from: coordinate) // "48.11638° N, 122.74231° W" // Degrees Decimal Minutes (DDM) formatter.format = .degreesDecimalMinutes formatter.string(from: coordinate) // "48° 06.983' N, 122° 46.516' W" // Degrees Minutes Seconds (DMS) formatter.format = .degreesMinutesSeconds formatter.string(from: coordinate) // "48° 6' 59" N, 122° 46' 31" W" // Universal Trans Mercator (UTM) formatter.format = .utm formatter.string(from: coordinate) // "10U 516726m E 5329260m N"
import LocationFormatter let formatter = LocationCoordinateFormatter() // Decimal Degrees (DD) formatter.format = .decimalDegrees try formatter.coordinate(from: "48.11638° N, 122.74231° W") // (48.11638, -122.77527) // Degrees Decimal Minutes (DDM) formatter.format = .degreesDecimalMinutes try formatter.coordinate(from: "48° 06.983' N, 122° 46.516' W") // (48.11638, -122.77527) // Degrees Minutes Seconds (DMS) formatter.format = .degreesMinutesSeconds try formatter.coordinate(from: "48° 6' 59\" N, 122° 46' 31\" W") // (48.11638, -122.77527) // Universal Trans Mercator (UTM) formatter.format = .utm try formatter.coordinate(from: "10U 516726m E 5329260m N") // (48.11638, -122.77527)
Extends String with a convenience function to parse a coordinate from a string using all supported format.
String
import Location "48.11638 °N, 122.74231° W".coordinate() // (48.11638, -122.77527) "48° 06.983' N, 122° 46.516' W".coordinate() // (48.11638, -122.77527) "48° 6' 59\" N, 122° 46' 31\" W".coordinate() // (48.11638, -122.77527) "10U 516726m E 5329260m N".coordinate() // (48.11638, -122.77527)
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
LocationFormatter
This package provides some Formatters that convert between coordinates and their textual representations.
Usage
Please see the documentation for more detailed usage instructions.
LocationCoordinateFormatter
This is the primary formatter for converting coordinates. It utilizes additional formatters for specific formats.
LocationCoordinateFormatter provides a variety of configuration options for customizing both the string output and parsing coordinates from strings.
Converting coordinates to strings
Converting strings to coordinates
Extensions
String+Location
Extends
String
with a convenience function to parse a coordinate from a string using all supported format.Dependencies
UTMConversion
Swift-DocC Plugin