RLMGeospatialPolygon

Objective-C

@interface RLMGeospatialPolygon : NSObject <RLMGeospatial>

Swift

class RLMGeospatialPolygon : NSObject, RLMGeospatial, @unchecked Sendable

A class that represents a polygon, that can be used in a geospatial geoWithinquery.

A RLMGeospatialPolygon describes a shape conformed of and outer Polygon, called outerRing, and 0 or more inner Polygons, called holes, which represents an unlimited number of internal holes inside the outer Polygon. A Polygon describes a shape conformed by at least three segments, where the last and the first RLMGeospatialPoint must be the same to indicate a closed polygon (meaning you need at least 4 points to define a polygon). Inner holes in a RLMGeospatialPolygon must be entirely inside the outer ring

A hole has the following restrictions:

  • Holes may not cross, i.e. the boundary of a hole may not intersect both the interior and the exterior of any other hole.
  • Holes may not share edges, i.e. if a hole contains and edge AB, the no other hole may contain it.
  • Holes may share vertices, however no vertex may appear twice in a single hole.
  • No hole may be empty.
  • Only one nesting is allowed.

Warning

This class cannot be persisted and can only be use within a geospatial geoWithin query.

  • The polygon’s external (outer) ring.

    Declaration

    Objective-C

    @property (strong, readonly) NSArray<RLMGeospatialPoint *> *_Nonnull outerRing;

    Swift

    var outerRing: [RLMGeospatialPoint] { get }
  • The holes (if any) in the polygon.

    Declaration

    Objective-C

    @property (strong, readonly, nullable) NSArray<NSArray<RLMGeospatialPoint *> *> *holes;

    Swift

    var holes: [[RLMGeospatialPoint]]? { get }
  • Initialize a RLMGeospatialPolygon, with its outer rings and holes (if any).

    Returns nil if the RLMGeospatialPoints representing a polygon (outer ring or holes), don’t have at least 4 points. Returns nil if the first and the last RLMGeospatialPoint in a polygon are not the same.

    Declaration

    Objective-C

    - (nullable instancetype)initWithOuterRing:
        (nonnull NSArray<RLMGeospatialPoint *> *)outerRing;

    Swift

    init?(outerRing: [RLMGeospatialPoint])

    Parameters

    outerRing

    The polygon’s external (outer) ring.

  • Initialize a RLMGeospatialPolygon, with its outer rings and holes (if any).

    Returns nil if the RLMGeospatialPoints representing a polygon (outer ring or holes), don’t have at least 4 points. Returns nil if the first and the last RLMGeospatialPoint in a polygon are not the same.

    Declaration

    Objective-C

    - (nullable instancetype)
        initWithOuterRing:(nonnull NSArray<RLMGeospatialPoint *> *)outerRing
                    holes:
                        (nullable NSArray<NSArray<RLMGeospatialPoint *> *> *)holes;

    Swift

    init?(outerRing: [RLMGeospatialPoint], holes: [[RLMGeospatialPoint]]?)

    Parameters

    outerRing

    The polygon’s external (outer) ring.

    holes

    The holes (if any) in the polygon.