Skip to content

Commit

Permalink
Documented more public symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Oct 2, 2021
1 parent 422cfa2 commit eeab0ae
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
14 changes: 14 additions & 0 deletions Sources/Turf/Feature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,24 @@ import CoreLocation
A [Feature object](https://datatracker.ietf.org/doc/html/rfc7946#section-3.2) represents a spatially bounded thing.
*/
public struct Feature: Equatable {
/**
A string or number that commonly identifies the feature in the context of a data set.

Turf does not guarantee that the feature is unique; however, a data set may make such a guarantee.
*/
public var identifier: FeatureIdentifier?

/// Arbitrary, JSON-compatible attributes to associate with the feature.
public var properties: JSONObject?

/// The geometry at which the feature is located.
public var geometry: Geometry?

/**
Initializes a feature located at the given geometry.

- parameter geometry: The geometry at which the feature is located.
*/
public init(geometry: Geometry?) {
self.geometry = geometry
}
Expand Down
8 changes: 7 additions & 1 deletion Sources/Turf/FeatureCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ import Foundation
A [FeatureCollection object](https://datatracker.ietf.org/doc/html/rfc7946#section-3.3) is a collection of Feature objects.
*/
public struct FeatureCollection: Equatable {
public var features: Array<Feature> = []
/// The features that the collection contains.
public var features: [Feature] = []

/**
Initializes a feature collection containing the given features.

- parameter features: The features that the collection contains.
*/
public init(features: [Feature]) {
self.features = features
}
Expand Down
14 changes: 7 additions & 7 deletions Sources/Turf/Geometries/MultiPolygon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ public struct MultiPolygon: Equatable {
/// The positions at which the multipolygon is located. Each nested array corresponds to one polygon.
public var coordinates: [[[LocationCoordinate2D]]]

/// The polygon geometries that conceptually form the multipolygon.
public var polygons: [Polygon] {
return coordinates.map { (coordinates) -> Polygon in
return Polygon(coordinates)
}
}

/**
Initializes a multipolygon defined by the given positions.

Expand Down Expand Up @@ -56,13 +63,6 @@ extension MultiPolygon: Codable {
}

extension MultiPolygon {

public var polygons: [Polygon] {
return coordinates.map { (coordinates) -> Polygon in
return Polygon(coordinates)
}
}

/**
* Determines if the given coordinate falls within any of the polygons.
* The optional parameter `ignoreBoundary` will result in the method returning true if the given coordinate
Expand Down
20 changes: 18 additions & 2 deletions Sources/Turf/RadianCoordinate2D.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,38 @@ import Foundation
import CoreLocation
#endif

/// A latitude or longitude measured in radians, as opposed to `LocationDegrees`, which is measured in degrees of arc.
public typealias LocationRadians = Double

/// A difference in latitude or longitude measured in radians, as opposed to `CLLocationDegrees`, which is used by some libraries to represent a similar distance measured in degrees of arc.
public typealias RadianDistance = Double

/**
A `RadianCoordinate2D` is a coordinate represented in radians as opposed to
`LocationCoordinate2D` which is represented in latitude and longitude.
A coordinate pair measured in radians, as opposed to `LocationCoordinate2D`, which is measured in degrees of arc.
*/
public struct RadianCoordinate2D {
/// The latitude measured in radians.
private(set) var latitude: LocationRadians

/// The longitude measured in radians.
private(set) var longitude: LocationRadians

/**
Initializes a coordinate pair located at the given latitude and longitude.

- parameter latitude: The latitude measured in radians.
- parameter longitude: The longitude measured in radians.
*/
public init(latitude: LocationRadians, longitude: LocationRadians) {
self.latitude = latitude
self.longitude = longitude
}

/**
Initializes a coordinate pair measured in radians that is coincident to the given coordinate pair measured in degrees of arc.

- parameter degreeCoordinate: A coordinate pair measured in degrees of arc.
*/
public init(_ degreeCoordinate: LocationCoordinate2D) {
latitude = degreeCoordinate.latitude.toRadians()
longitude = degreeCoordinate.longitude.toRadians()
Expand Down

0 comments on commit eeab0ae

Please sign in to comment.