RLMGeospatialPoint
Objective-C
@interface RLMGeospatialPoint : NSObject
Swift
class RLMGeospatialPoint : NSObject, @unchecked Sendable
A class that represents the coordinates of a point formed by a latitude and a longitude value.
- Latitude ranges between -90 and 90 degrees, inclusive.
- Longitude ranges between -180 and 180 degrees, inclusive.
- Altitude cannot have negative values.
Values outside this ranges will return nil when trying to create a RLMGeospatialPoint
.
Note
There is no dedicated type to store Geospatial points, instead points should be stored as GeoJson-shaped embedded object, as explained below. Geospatial queries (geoWithin
) can only be executed
in such a type of objects and will throw otherwise.
Persisting geo points in Realm is currently done using duck-typing, which means that any model class with a specific shape can be queried as though it contained a geographical location. The recommended approach is using an embedded object.
Warning
This structure cannot be persisted and can only be used to build other geospatial shapes
such as (RLMGeospatialBox
, RLMGeospatialPolygon
and RLMGeospatialCircle
).
Warning
Altitude is not used in any of the query calculations.
-
Latitude in degrees.
Declaration
Objective-C
@property (readonly) double latitude;
Swift
var latitude: Double { get }
-
Longitude in degrees.
Declaration
Objective-C
@property (readonly) double longitude;
Swift
var longitude: Double { get }
-
Altitude distance.
Declaration
Objective-C
@property (readonly) double altitude;
Swift
var altitude: Double { get }
-
Initialize a
RLMGeospatialPoint
, with the specific values for latitude and longitude.Returns
nil
if the values of latitude and longitude are not within the ranges specified.Declaration
Objective-C
- (nullable instancetype)initWithLatitude:(double)latitude longitude:(double)longitude;
Swift
init?(latitude: Double, longitude: Double)
Parameters
latitude
Latitude in degrees. Ranges between -90 and 90 degrees, inclusive.
longitude
Longitude in degrees. Ranges between -180 and 180 degrees, inclusive.
-
Initialize a
RLMGeospatialPoint
, with the specific values for latitude and longitude.Returns
nil
if the values of latitude and longitude are not within the ranges specified.Declaration
Objective-C
- (nullable instancetype)initWithLatitude:(double)latitude longitude:(double)longitude altitude:(double)altitude;
Swift
init?(latitude: Double, longitude: Double, altitude: Double)
Parameters
latitude
Latitude in degrees. Ranges between -90 and 90 degrees, inclusive.
longitude
Longitude in degrees. Ranges between -180 and 180 degrees, inclusive.
altitude
Altitude. Distance cannot have negative values
Warning
Altitude is not used in any of the query calculations.