@@ -770,34 +770,56 @@ public class Query : NSObject, NSCopying {
770770 }
771771 // NOTE: Objective-C bridge moved away to `_objc_Query`
772772
773- /// Control the radius associated with a `aroundLatLng` or `aroundLatLngViaIP` query. Defined in meters.
774- /// If not set, the radius is computed automatically using the density of the area, you can retrieve the computed
773+ /// Applicable values for the `aroundRadius` parameter.
774+ public enum AroundRadius : Equatable {
775+ /// Specify an explicit value (in meters).
776+ case explicit( UInt )
777+
778+ /// Compute the geo distance without filtering in a geo area.
779+ /// This option will be faster than specifying a big integer.
780+ case all
781+
782+ // NOTE: Associated values disable automatic conformance to `Equatable`, so we have to implement it ourselves.
783+ static public func == ( lhs: AroundRadius , rhs: AroundRadius ) -> Bool {
784+ switch ( lhs, rhs) {
785+ case ( let . explicit( lhsValue) , let . explicit( rhsValue) ) : return lhsValue == rhsValue
786+ case ( . all, . all) : return true
787+ default : return false
788+ }
789+ }
790+ }
791+
792+ /// Control the radius associated with a `aroundLatLng` or `aroundLatLngViaIP` query.
793+ /// If not set, the radius is computed automatically using the density of the area. You can retrieve the computed
775794 /// radius in the `automaticRadius` attribute of the answer. You can also specify a minimum value for the automatic
776- /// radius by using the `minimumAroundRadius` query parameter. You can specify `aroundRadiusAll ` if you want to
777- /// compute the geo distance without filtering in a geo area, this option will be faster than specifying a big
778- /// integer.
795+ /// radius by using the `minimumAroundRadius` query parameter. You can specify `.all ` if you want to
796+ /// compute the geo distance without filtering in a geo area ( this option will be faster than specifying a big
797+ /// integer) .
779798 ///
780- public var aroundRadius : UInt ? {
799+ public var aroundRadius : AroundRadius ? {
781800 get {
782801 if let stringValue = self [ " aroundRadius " ] {
783802 if stringValue == " all " {
784- return Query . aroundRadiusAll
785- } else {
786- return Query . parseUInt ( stringValue )
803+ return . all
804+ } else if let value = Query . parseUInt ( stringValue ) {
805+ return . explicit ( value )
787806 }
788- } else {
789- return nil
790807 }
808+ return nil
791809 }
792810 set {
793- self [ " aroundRadius " ] = newValue == Query . aroundRadiusAll ? " all " : Query . buildUInt ( newValue)
811+ if let newValue = newValue {
812+ switch newValue {
813+ case let . explicit( value) : self [ " aroundRadius " ] = Query . buildUInt ( value)
814+ case . all: self [ " aroundRadius " ] = " all "
815+ }
816+ } else {
817+ self [ " aroundRadius " ] = nil
818+ }
794819 }
795820 }
796821 // NOTE: Objective-C bridge moved away to `_objc_Query`
797822
798- /// Special value for `aroundRadius` to compute the geo distance without filtering.
799- public static let aroundRadiusAll : UInt = UInt . max
800-
801823 /// Control the precision of a `aroundLatLng` query. In meter. For example if you set `aroundPrecision=100`, two
802824 /// objects that are in the range 0-99m will be considered as identical in the ranking for the .variable geo
803825 /// ranking parameter (same for 100-199, 200-299, … ranges).
@@ -1235,10 +1257,31 @@ public class _objc_Query: Query {
12351257 set { self . aroundLatLngViaIP = newValue? . boolValue }
12361258 }
12371259
1260+ /// Special value for `aroundRadius` to compute the geo distance without filtering.
1261+ @objc public static let aroundRadiusAll : NSNumber = NSNumber ( value: UInt . max)
1262+
12381263 @objc ( aroundRadius)
12391264 public var _aroundRadius : NSNumber ? {
1240- get { return Query . toNumber ( self . aroundRadius) }
1241- set { self . aroundRadius = newValue? . uintValue }
1265+ get {
1266+ if let aroundRadius = aroundRadius {
1267+ switch aroundRadius {
1268+ case let . explicit( value) : return NSNumber ( value: value)
1269+ case . all: return _objc_Query. aroundRadiusAll
1270+ }
1271+ }
1272+ return nil
1273+ }
1274+ set {
1275+ if let newValue = newValue {
1276+ if newValue == _objc_Query. aroundRadiusAll {
1277+ self . aroundRadius = . all
1278+ } else {
1279+ self . aroundRadius = . explicit( newValue. uintValue)
1280+ }
1281+ } else {
1282+ self . aroundRadius = nil
1283+ }
1284+ }
12421285 }
12431286
12441287 @objc ( aroundPrecision)
0 commit comments