PFPolygon

Objective-C

@interface PFPolygon : NSObject <NSCopying, NSCoding>

Swift

class PFPolygon : NSObject, NSCopying, NSCoding

PFPolygon may be used to embed a latitude / longitude points as the value for a key in a PFObject. It could be used to perform queries in a geospatial manner using PFQuery..

Creating a Polygon

  • Creates a new PFPolygon object for the given CLLocation, set to the location’s coordinates.

    Declaration

    Objective-C

    + (nonnull instancetype)polygonWithCoordinates:(nonnull NSArray *)coordinates;

    Swift

    convenience init(coordinates: [Any])

    Parameters

    coordinates

    Array of CLLocation, PFGeoPoint or (lat,lng)

    Return Value

    Returns a new PFPolygon at specified location.

  • Test if this polygon contains a point

    Declaration

    Objective-C

    - (BOOL)containsPoint:(nonnull PFGeoPoint *)point;

    Swift

    func contains(_ point: PFGeoPoint) -> Bool

    Parameters

    point

    PFGeoPoint to test

    Return Value

    Returns a boolean.

Controlling Position

  • Array of PFGeoPoints or CLLocations

    Declaration

    Objective-C

    @property (nonatomic, strong) NSArray *_Nonnull coordinates;

    Swift

    var coordinates: [Any] { get set }