BoundingBox

public struct BoundingBox : Codable, Hashable

Bounding box is an area defined by two longitudes and two latitudes, where: Latitude is a decimal number between -90.0 and 90.0. Longitude is a decimal number between -180.0 and 180.0.

  • The most south and west coordinate in bounding box

    Declaration

    Swift

    public var southWest: CLLocationCoordinate2D { get set }
  • The most north and east coordinate in bounding box

    Declaration

    Swift

    public var northEast: CLLocationCoordinate2D { get set }
  • Build BoundingBox with array of coordinates

    Constructor would search for the minimal and maximum latitude and longitude.

    Declaration

    Swift

    public init?(from coordinates: [CLLocationCoordinate2D]?)

    Parameters

    coordinates

    Collection of coordinates. Recommended minimum is 4 coordinates and meaningful maximum.

  • Build BoundingBox based on south-west (bottom-left) and north-east (top-right) coordinates

    Declaration

    Swift

    public init(_ southWest: CLLocationCoordinate2D, _ northEast: CLLocationCoordinate2D)

    Parameters

    southWest

    The most south-west coordinate in bounding box

    northEast

    The most north-east coordinate in bounding box

  • Returns a Boolean value indicating whether the BoundingBox contains the coordinate.

    Declaration

    Swift

    public func contains(_ coordinate: CLLocationCoordinate2D, ignoreBoundary: Bool = true) -> Bool

    Parameters

    coordinate

    The coordinate to find in the bounding box.

    ignoreBoundary

    true if coordinate on the boundary is suitable

    Return Value

    true if coordinates was found