Skip to content

Commit b0263de

Browse files
committed
Change GeoPoint to ParseGeoPoint
1 parent db391a4 commit b0263de

File tree

6 files changed

+78
-78
lines changed

6 files changed

+78
-78
lines changed

ParseSwift.playground/Pages/7 - GeoPoint.xcplaygroundpage/Contents.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct GameScore: ParseObject {
1414
var createdAt: Date?
1515
var updatedAt: Date?
1616
var ACL: ParseACL?
17-
var location: GeoPoint?
17+
var location: ParseGeoPoint?
1818
//: Your own properties
1919
var score: Int
2020

@@ -26,7 +26,7 @@ struct GameScore: ParseObject {
2626

2727
//: Define initial GameScore
2828
var score = GameScore(score: 10)
29-
score.location = GeoPoint(latitude: 40.0, longitude: -30.0)
29+
score.location = ParseGeoPoint(latitude: 40.0, longitude: -30.0)
3030

3131
/*: Save asynchronously (preferred way) - performs work on background
3232
queue and returns to designated on designated callbackQueue.
@@ -55,8 +55,8 @@ score.save { result in
5555

5656
}
5757

58-
//: Now we will show how to query based on the GeoPoint
59-
let pointToFind = GeoPoint(latitude: 40.0, longitude: -30.0)
58+
//: Now we will show how to query based on the ParseGeoPoint
59+
let pointToFind = ParseGeoPoint(latitude: 40.0, longitude: -30.0)
6060
var constraints = [QueryConstraint]()
6161
constraints.append(near(key: "location", geoPoint: pointToFind))
6262

@@ -114,7 +114,7 @@ query2.find { results in
114114
}
115115
}
116116

117-
//: If you want to query for scores > 50 and don't have a GeoPoint
117+
//: If you want to query for scores > 50 and don't have a ParseGeoPoint
118118
var query3 = GameScore.query("score" > 50, doesNotExist(key: "location"))
119119
query3.find { results in
120120
switch results {
@@ -132,8 +132,8 @@ query3.find { results in
132132
}
133133
}
134134

135-
//: If you want to query for scores > 50 and have a GeoPoint
136-
var query4 = GameScore.query("score" > 10, exists(key: "location"))
135+
//: If you want to query for scores > 9 and have a ParseGeoPoint
136+
var query4 = GameScore.query("score" > 9, exists(key: "location"))
137137
query4.find { results in
138138
switch results {
139139
case .success(let scores):

ParseSwift.xcodeproj/project.pbxproj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@
123123
F97B45E724D9C6F200F4A88B /* Query.swift in Sources */ = {isa = PBXBuildFile; fileRef = F97B45BB24D9C6F200F4A88B /* Query.swift */; };
124124
F97B45E824D9C6F200F4A88B /* Query.swift in Sources */ = {isa = PBXBuildFile; fileRef = F97B45BB24D9C6F200F4A88B /* Query.swift */; };
125125
F97B45E924D9C6F200F4A88B /* Query.swift in Sources */ = {isa = PBXBuildFile; fileRef = F97B45BB24D9C6F200F4A88B /* Query.swift */; };
126-
F97B45EA24D9C6F200F4A88B /* GeoPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = F97B45BC24D9C6F200F4A88B /* GeoPoint.swift */; };
127-
F97B45EB24D9C6F200F4A88B /* GeoPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = F97B45BC24D9C6F200F4A88B /* GeoPoint.swift */; };
128-
F97B45EC24D9C6F200F4A88B /* GeoPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = F97B45BC24D9C6F200F4A88B /* GeoPoint.swift */; };
129-
F97B45ED24D9C6F200F4A88B /* GeoPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = F97B45BC24D9C6F200F4A88B /* GeoPoint.swift */; };
126+
F97B45EA24D9C6F200F4A88B /* ParseGeoPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = F97B45BC24D9C6F200F4A88B /* ParseGeoPoint.swift */; };
127+
F97B45EB24D9C6F200F4A88B /* ParseGeoPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = F97B45BC24D9C6F200F4A88B /* ParseGeoPoint.swift */; };
128+
F97B45EC24D9C6F200F4A88B /* ParseGeoPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = F97B45BC24D9C6F200F4A88B /* ParseGeoPoint.swift */; };
129+
F97B45ED24D9C6F200F4A88B /* ParseGeoPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = F97B45BC24D9C6F200F4A88B /* ParseGeoPoint.swift */; };
130130
F97B45EE24D9C6F200F4A88B /* BaseParseUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = F97B45BD24D9C6F200F4A88B /* BaseParseUser.swift */; };
131131
F97B45EF24D9C6F200F4A88B /* BaseParseUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = F97B45BD24D9C6F200F4A88B /* BaseParseUser.swift */; };
132132
F97B45F024D9C6F200F4A88B /* BaseParseUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = F97B45BD24D9C6F200F4A88B /* BaseParseUser.swift */; };
@@ -339,7 +339,7 @@
339339
F97B45B824D9C6F200F4A88B /* AnyCodable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnyCodable.swift; sourceTree = "<group>"; };
340340
F97B45B924D9C6F200F4A88B /* AnyEncodable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnyEncodable.swift; sourceTree = "<group>"; };
341341
F97B45BB24D9C6F200F4A88B /* Query.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Query.swift; sourceTree = "<group>"; };
342-
F97B45BC24D9C6F200F4A88B /* GeoPoint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeoPoint.swift; sourceTree = "<group>"; };
342+
F97B45BC24D9C6F200F4A88B /* ParseGeoPoint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParseGeoPoint.swift; sourceTree = "<group>"; };
343343
F97B45BD24D9C6F200F4A88B /* BaseParseUser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseParseUser.swift; sourceTree = "<group>"; };
344344
F97B45BE24D9C6F200F4A88B /* Pointer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Pointer.swift; sourceTree = "<group>"; };
345345
F97B45BF24D9C6F200F4A88B /* ParseError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParseError.swift; sourceTree = "<group>"; };
@@ -672,7 +672,7 @@
672672
children = (
673673
F97B45C024D9C6F200F4A88B /* ParseACL.swift */,
674674
F97B45C124D9C6F200F4A88B /* File.swift */,
675-
F97B45BC24D9C6F200F4A88B /* GeoPoint.swift */,
675+
F97B45BC24D9C6F200F4A88B /* ParseGeoPoint.swift */,
676676
F97B45BF24D9C6F200F4A88B /* ParseError.swift */,
677677
F97B45BE24D9C6F200F4A88B /* Pointer.swift */,
678678
F97B45BB24D9C6F200F4A88B /* Query.swift */,
@@ -1147,7 +1147,7 @@
11471147
F97B466424D9C88600F4A88B /* SecureStorage.swift in Sources */,
11481148
F97B462F24D9C74400F4A88B /* BatchUtils.swift in Sources */,
11491149
4A82B7F61F254CCE0063D731 /* Parse.swift in Sources */,
1150-
F97B45EA24D9C6F200F4A88B /* GeoPoint.swift in Sources */,
1150+
F97B45EA24D9C6F200F4A88B /* ParseGeoPoint.swift in Sources */,
11511151
F97B460224D9C6F200F4A88B /* NoBody.swift in Sources */,
11521152
F97B45F624D9C6F200F4A88B /* ParseError.swift in Sources */,
11531153
F97B463324D9C74400F4A88B /* URLSession+extensions.swift in Sources */,
@@ -1218,7 +1218,7 @@
12181218
F97B466524D9C88600F4A88B /* SecureStorage.swift in Sources */,
12191219
F97B463024D9C74400F4A88B /* BatchUtils.swift in Sources */,
12201220
4AFDA72A1F26DAE1002AE4FC /* Parse.swift in Sources */,
1221-
F97B45EB24D9C6F200F4A88B /* GeoPoint.swift in Sources */,
1221+
F97B45EB24D9C6F200F4A88B /* ParseGeoPoint.swift in Sources */,
12221222
F97B460324D9C6F200F4A88B /* NoBody.swift in Sources */,
12231223
F97B45F724D9C6F200F4A88B /* ParseError.swift in Sources */,
12241224
F97B463424D9C74400F4A88B /* URLSession+extensions.swift in Sources */,
@@ -1309,7 +1309,7 @@
13091309
F97B465124D9C78C00F4A88B /* AddOperation.swift in Sources */,
13101310
F97B461124D9C6F200F4A88B /* ParseObject.swift in Sources */,
13111311
F97B460D24D9C6F200F4A88B /* Fetchable.swift in Sources */,
1312-
F97B45ED24D9C6F200F4A88B /* GeoPoint.swift in Sources */,
1312+
F97B45ED24D9C6F200F4A88B /* ParseGeoPoint.swift in Sources */,
13131313
F97B45F524D9C6F200F4A88B /* Pointer.swift in Sources */,
13141314
F97B460924D9C6F200F4A88B /* ParseUser.swift in Sources */,
13151315
F97B463A24D9C74400F4A88B /* Responses.swift in Sources */,
@@ -1357,7 +1357,7 @@
13571357
F97B465024D9C78B00F4A88B /* AddOperation.swift in Sources */,
13581358
F97B461024D9C6F200F4A88B /* ParseObject.swift in Sources */,
13591359
F97B460C24D9C6F200F4A88B /* Fetchable.swift in Sources */,
1360-
F97B45EC24D9C6F200F4A88B /* GeoPoint.swift in Sources */,
1360+
F97B45EC24D9C6F200F4A88B /* ParseGeoPoint.swift in Sources */,
13611361
F97B45F424D9C6F200F4A88B /* Pointer.swift in Sources */,
13621362
F97B460824D9C6F200F4A88B /* ParseUser.swift in Sources */,
13631363
F97B463924D9C74400F4A88B /* Responses.swift in Sources */,

Sources/ParseSwift/Parse Types/GeoPoint.swift renamed to Sources/ParseSwift/Parse Types/ParseGeoPoint.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import CoreLocation
44
#endif
55

66
/**
7-
`GeoPoint` is used to embed a latitude / longitude point as the value for a key in a `ParseObject`.
7+
`ParseGeoPoint` is used to embed a latitude / longitude point as the value for a key in a `ParseObject`.
88
It could be used to perform queries in a geospatial manner using `ParseQuery.-whereKey:nearGeoPoint:`.
9-
Currently, instances of `ParseObject` may only have one key associated with a `GeoPoint` type.
9+
Currently, instances of `ParseObject` may only have one key associated with a `ParseGeoPoint` type.
1010
*/
11-
public struct GeoPoint: Codable, Hashable, Equatable {
11+
public struct ParseGeoPoint: Codable, Hashable, Equatable {
1212
private let __type: String = "GeoPoint" // swiftlint:disable:this identifier_name
1313
static let earthRadiusMiles = 3958.8
1414
static let earthRadiusKilometers = 6371.0
@@ -49,15 +49,15 @@ public struct GeoPoint: Codable, Hashable, Equatable {
4949
private var _longitude: Double
5050

5151
/**
52-
Create a `GeoPoint` instance. Latitude and longitude are set to `0.0`.
52+
Create a `ParseGeoPoint` instance. Latitude and longitude are set to `0.0`.
5353
*/
5454
public init() {
5555
_latitude = 0.0
5656
_longitude = 0.0
5757
}
5858

5959
/**
60-
Create a new `GeoPoint` instance with the specified latitude and longitude.
60+
Create a new `ParseGeoPoint` instance with the specified latitude and longitude.
6161
- parameter latitude: Latitude of point in degrees.
6262
- parameter longitude: Longitude of point in degrees.
6363
*/
@@ -72,7 +72,7 @@ public struct GeoPoint: Codable, Hashable, Equatable {
7272

7373
#if canImport(CoreLocation)
7474
/**
75-
Creates a new `GeoPoint` instance for the given `CLLocation`, set to the location's coordinates.
75+
Creates a new `ParseGeoPoint` instance for the given `CLLocation`, set to the location's coordinates.
7676
- parameter location: Instance of `CLLocation`, with set latitude and longitude.
7777
*/
7878
public init(location: CLLocation) {
@@ -84,10 +84,10 @@ public struct GeoPoint: Codable, Hashable, Equatable {
8484
/**
8585
Get distance in radians from this point to specified point.
8686

87-
- parameter point: `GeoPoint` that represents the location of other point.
87+
- parameter point: `ParseGeoPoint` that represents the location of other point.
8888
- returns: Distance in radians between the receiver and `point`.
8989
*/
90-
public func distanceInRadians(_ point: GeoPoint) -> Double {
90+
public func distanceInRadians(_ point: ParseGeoPoint) -> Double {
9191
let d2r: Double = .pi / 180.0 // radian conversion factor
9292
let lat1rad = self.latitude * d2r
9393
let long1rad = self.longitude * d2r
@@ -107,24 +107,24 @@ public struct GeoPoint: Codable, Hashable, Equatable {
107107
/**
108108
Get distance in miles from this point to specified point.
109109

110-
- parameter point: `GeoPoint` that represents the location of other point.
110+
- parameter point: `ParseGeoPoint` that represents the location of other point.
111111
- returns: Distance in miles between the receiver and `point`.
112112
*/
113-
public func distanceInMiles(_ point: GeoPoint) -> Double {
113+
public func distanceInMiles(_ point: ParseGeoPoint) -> Double {
114114
return distanceInRadians(point) * Self.earthRadiusMiles
115115
}
116116

117117
/**
118118
Get distance in kilometers from this point to specified point.
119-
- parameter point: `GeoPoint` that represents the location of other point.
119+
- parameter point: `ParseGeoPoint` that represents the location of other point.
120120
- returns: Distance in kilometers between the receiver and `point`.
121121
*/
122-
public func distanceInKilometers(_ point: GeoPoint) -> Double {
122+
public func distanceInKilometers(_ point: ParseGeoPoint) -> Double {
123123
return distanceInRadians(point) * Self.earthRadiusKilometers
124124
}
125125
}
126126

127-
extension GeoPoint {
127+
extension ParseGeoPoint {
128128
public init(from decoder: Decoder) throws {
129129
let values = try decoder.container(keyedBy: CodingKeys.self)
130130
_longitude = try values.decode(Double.self, forKey: .longitude)
@@ -139,7 +139,7 @@ extension GeoPoint {
139139
}
140140
}
141141

142-
extension GeoPoint: CustomDebugStringConvertible {
142+
extension ParseGeoPoint: CustomDebugStringConvertible {
143143
public var debugDescription: String {
144144
guard let descriptionData = try? JSONEncoder().encode(self),
145145
let descriptionString = String(data: descriptionData, encoding: .utf8) else {

Sources/ParseSwift/Parse Types/Query.swift

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -237,68 +237,68 @@ public func containsAll <T>(key: String, array: [T]) -> QueryConstraint where T:
237237
}
238238

239239
/**
240-
Add a constraint to the query that requires a particular key's coordinates (specified via `GeoPoint`)
240+
Add a constraint to the query that requires a particular key's coordinates (specified via `ParseGeoPoint`)
241241
be near a reference point. Distance is calculated based on angular distance on a sphere. Results will be sorted
242242
by distance from reference point.
243243
- parameter key: The key to be constrained.
244-
- parameter geoPoint: The reference point represented as a `GeoPoint`.
244+
- parameter geoPoint: The reference point represented as a `ParseGeoPoint`.
245245
- returns: The same instance of `QueryConstraint` as the receiver.
246246
*/
247-
public func near(key: String, geoPoint: GeoPoint) -> QueryConstraint {
247+
public func near(key: String, geoPoint: ParseGeoPoint) -> QueryConstraint {
248248
return QueryConstraint(key: key, value: geoPoint, comparator: .nearSphere)
249249
}
250250

251251
/**
252-
Add a constraint to the query that requires a particular key's coordinates (specified via `GeoPoint`) be near
252+
Add a constraint to the query that requires a particular key's coordinates (specified via `ParseGeoPoint`) be near
253253
a reference point and within the maximum distance specified (in radians). Distance is calculated based on
254254
angular distance on a sphere. Results will be sorted by distance (nearest to farthest) from the reference point.
255255
- parameter key: The key to be constrained.
256-
- parameter geoPoint: The reference point as a `GeoPoint`.
256+
- parameter geoPoint: The reference point as a `ParseGeoPoint`.
257257
- parameter distance: Maximum distance in radians.
258258
- returns: The same instance of `QueryConstraint` as the receiver.
259259
*/
260-
public func withinRadians(key: String, geoPoint: GeoPoint, distance: Double) -> [QueryConstraint] {
260+
public func withinRadians(key: String, geoPoint: ParseGeoPoint, distance: Double) -> [QueryConstraint] {
261261
var constraints = [QueryConstraint(key: key, value: geoPoint, comparator: .nearSphere)]
262262
constraints.append(.init(key: key, value: distance, comparator: .maxDistance))
263263
return constraints
264264
}
265265

266266
/**
267-
Add a constraint to the query that requires a particular key's coordinates (specified via `GeoPoint`)
267+
Add a constraint to the query that requires a particular key's coordinates (specified via `ParseGeoPoint`)
268268
be near a reference point and within the maximum distance specified (in miles). Distance is calculated based
269269
on a spherical coordinate system. Results will be sorted by distance (nearest to farthest) from the reference point.
270270
- parameter key: The key to be constrained.
271-
- parameter geoPoint: The reference point represented as a `GeoPoint`.
271+
- parameter geoPoint: The reference point represented as a `ParseGeoPoint`.
272272
- parameter distance: Maximum distance in miles.
273273
- returns: The same instance of `QueryConstraint` as the receiver.
274274
*/
275-
public func withinMiles(key: String, geoPoint: GeoPoint, distance: Double) -> [QueryConstraint] {
276-
return withinRadians(key: key, geoPoint: geoPoint, distance: (distance / GeoPoint.earthRadiusMiles))
275+
public func withinMiles(key: String, geoPoint: ParseGeoPoint, distance: Double) -> [QueryConstraint] {
276+
return withinRadians(key: key, geoPoint: geoPoint, distance: (distance / ParseGeoPoint.earthRadiusMiles))
277277
}
278278

279279
/**
280-
Add a constraint to the query that requires a particular key's coordinates (specified via `GeoPoint`)
280+
Add a constraint to the query that requires a particular key's coordinates (specified via `ParseGeoPoint`)
281281
be near a reference point and within the maximum distance specified (in kilometers). Distance is calculated based
282282
on a spherical coordinate system. Results will be sorted by distance (nearest to farthest) from the reference point.
283283
- parameter key: The key to be constrained.
284-
- parameter geoPoint: The reference point represented as a `GeoPoint`.
284+
- parameter geoPoint: The reference point represented as a `ParseGeoPoint`.
285285
- parameter distance: Maximum distance in kilometers.
286286
- returns: The same instance of `QueryConstraint` as the receiver.
287287
*/
288-
public func withinKilometers(key: String, geoPoint: GeoPoint, distance: Double) -> [QueryConstraint] {
289-
return withinRadians(key: key, geoPoint: geoPoint, distance: (distance / GeoPoint.earthRadiusKilometers))
288+
public func withinKilometers(key: String, geoPoint: ParseGeoPoint, distance: Double) -> [QueryConstraint] {
289+
return withinRadians(key: key, geoPoint: geoPoint, distance: (distance / ParseGeoPoint.earthRadiusKilometers))
290290
}
291291

292292
/**
293-
Add a constraint to the query that requires a particular key's coordinates (specified via `GeoPoint`) be
293+
Add a constraint to the query that requires a particular key's coordinates (specified via `ParseGeoPoint`) be
294294
contained within a given rectangular geographic bounding box.
295295
- parameter key: The key to be constrained.
296296
- parameter fromSouthWest: The lower-left inclusive corner of the box.
297297
- parameter toNortheast: The upper-right inclusive corner of the box.
298298
- returns: The same instance of `QueryConstraint` as the receiver.
299299
*/
300-
public func withinGeoBox(key: String, fromSouthWest southwest: GeoPoint,
301-
toNortheast northeast: GeoPoint) -> QueryConstraint {
300+
public func withinGeoBox(key: String, fromSouthWest southwest: ParseGeoPoint,
301+
toNortheast northeast: ParseGeoPoint) -> QueryConstraint {
302302
let array = [southwest, northeast]
303303
let dictionary = [QueryConstraint.Comparator.box.rawValue: array]
304304
return .init(key: key, value: dictionary, comparator: .within)
@@ -313,25 +313,25 @@ public func withinGeoBox(key: String, fromSouthWest southwest: GeoPoint,
313313
Polygon must have at least 3 points.
314314

315315
- parameter key: The key to be constrained.
316-
- parameter points: The polygon points as an Array of `GeoPoint`'s.
316+
- parameter points: The polygon points as an Array of `ParseGeoPoint`'s.
317317
- returns: The same instance of `QueryConstraint` as the receiver.
318318
*/
319-
public func withinPolygon(key: String, points: [GeoPoint]) -> QueryConstraint {
319+
public func withinPolygon(key: String, points: [ParseGeoPoint]) -> QueryConstraint {
320320
let dictionary = [QueryConstraint.Comparator.polygon.rawValue: points]
321321
return .init(key: key, value: dictionary, comparator: .geoWithin)
322322
}
323323

324324
/**
325325
Add a constraint to the query that requires a particular key's
326-
coordinates that contains a `GeoPoint`
326+
coordinates that contains a `ParseGeoPoint`
327327
(Requires [email protected])
328328

329329
- parameter key: The key to be constrained.
330-
- parameter point: The point the polygon contains `GeoPoint`.
330+
- parameter point: The point the polygon contains `ParseGeoPoint`.
331331

332332
- returns: The same instance of `QueryConstraint` as the receiver.
333333
*/
334-
public func polygonContains(key: String, point: GeoPoint) -> QueryConstraint {
334+
public func polygonContains(key: String, point: ParseGeoPoint) -> QueryConstraint {
335335
let dictionary = [QueryConstraint.Comparator.point.rawValue: point]
336336
return .init(key: key, value: dictionary, comparator: .geoIntersects)
337337
}

0 commit comments

Comments
 (0)