that’s basically what I added to the PR I’m adding. but in CLLocationCoordinate2D. Maybe I might as well add toCLLocation like you did in my PR.
I like the toGeoPoint() as well. but how would do that if I’m working on the ParseGeoPoint side? is that possible?
// MARK: Convenience
extension ParseGeoPoint {
/**
Creates a new `CLLocation` instance for the given `ParseGeoPoint`, set to the location's coordinates.
- parameter geopoint: Instance of `ParseGeoPoint`, with set latitude and longitude.
- returns: Returns a `CLLocation`
*/
public func toCLLocation() -> CLLocation {
return CLLocation(latitude: latitude, longitude: longitude)
}
/**
Creates a new `CLLocationCoordinate2D` instance for the given `ParseGeoPoint`, set to the location's coordinates.
- parameter geopoint: Instance of `ParseGeoPoint`, with set latitude and longitude.
- returns: Returns a `CLLocationCoordinate2D`
*/
public func toCLLocationCoordinate2D() -> CLLocationCoordinate2D {
return CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
}
}
This is basically what I’m adding to the PR which I’ll submit soon. It’s my first PR so if you guys see any mistakes I need to fix, let me know.
func testToCLLocation() throws {
let point = try ParseGeoPoint(latitude: 10, longitude: 20)
let location = point.toCLLocation()
XCTAssertEqual(point.latitude, location.coordinate.latitude)
XCTAssertEqual(point.longitude, location.coordinate.longitude)
}
func testToCLLocationCoordinate2D() throws {
let point = try ParseGeoPoint(latitude: 10, longitude: 20)
let location = point.toCLLocationCoordinate2D()
XCTAssertEqual(point.latitude, location.latitude)
XCTAssertEqual(point.longitude, location.longitude)
}
And my Tests that pass.