Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
cbaker6 committed Jun 13, 2023
1 parent 82df592 commit 5e8e03b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Sources/ParseSwift/Types/ParsePolygon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public struct ParsePolygon: ParseTypeable, Hashable {
private let __type: String = "Polygon" // swiftlint:disable:this identifier_name
public let coordinates: [ParseGeoPoint]
var flipEncodingCoordinates = false
var isSwappingCoordinates = false

enum CodingKeys: String, CodingKey {
case __type // swiftlint:disable:this identifier_name
Expand Down Expand Up @@ -109,7 +109,7 @@ extension ParsePolygon {
try container.encode(__type, forKey: .__type)
var nestedUnkeyedContainer = container.nestedUnkeyedContainer(forKey: .coordinates)
try coordinates.forEach {
guard flipEncodingCoordinates else {
guard isSwappingCoordinates else {
try nestedUnkeyedContainer.encode([$0.latitude, $0.longitude])
return
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseSwift/Types/QueryConstraint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ public func withinPolygon(key: String, points: [ParseGeoPoint]) -> QueryConstrai
*/
public func geoPoint(_ key: String, within polygon: ParsePolygon) -> QueryConstraint {
var polygon = polygon
polygon.flipEncodingCoordinates = true
polygon.isSwappingCoordinates = true

Check warning on line 624 in Sources/ParseSwift/Types/QueryConstraint.swift

View check run for this annotation

Codecov / codecov/patch

Sources/ParseSwift/Types/QueryConstraint.swift#L622-L624

Added lines #L622 - L624 were not covered by tests
let dictionary = [QueryConstraint.Comparator.polygon.rawValue: polygon]
return .init(key: key, value: dictionary, comparator: .geoWithin)
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/ParseSwiftTests/ParsePolygonTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class ParsePolygonTests: XCTestCase {

func testDecode() throws {
var polygon = try ParsePolygon(points)
polygon.flipEncodingCoordinates = false
polygon.isSwappingCoordinates = false
let encoded = try ParseCoding.jsonEncoder().encode(polygon)
let decoded = try ParseCoding.jsonDecoder().decode(ParsePolygon.self, from: encoded)
XCTAssertEqual(decoded, polygon)
Expand Down

0 comments on commit 5e8e03b

Please sign in to comment.