Skip to content

Commit

Permalink
Added CLLocationCoordinate2D locationIsInside
Browse files Browse the repository at this point in the history
  • Loading branch information
ddaddy committed Dec 24, 2020
1 parent 787789a commit b77744f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions DJSwiftHelpers.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
621B3C2D255D467000A5E77F /* UIWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 620F6A4F250BC1E400B10032 /* UIWindow.swift */; };
621B3C2E255D467000A5E77F /* UIViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 620F6A4B250BBCD700B10032 /* UIViewController.swift */; };
621B3C2F255D467000A5E77F /* UIImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 620F6A49250BBC4B00B10032 /* UIImage.swift */; };
625380722594BCE900C58B2F /* CLLocationCoordinate2D.swift in Sources */ = {isa = PBXBuildFile; fileRef = 625380712594BCE900C58B2F /* CLLocationCoordinate2D.swift */; };
625380762594BDDD00C58B2F /* CLLocationCoordinate2D.swift in Sources */ = {isa = PBXBuildFile; fileRef = 625380712594BCE900C58B2F /* CLLocationCoordinate2D.swift */; };
6253807A2594BDDD00C58B2F /* CLLocationCoordinate2D.swift in Sources */ = {isa = PBXBuildFile; fileRef = 625380712594BCE900C58B2F /* CLLocationCoordinate2D.swift */; };
627631A7255D512F005C09B1 /* DJSwiftHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 627631A6255D512F005C09B1 /* DJSwiftHelpers.swift */; };
62D6CDE9255BFCCB00ABD216 /* Decodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62D6CDE8255BFCCB00ABD216 /* Decodable.swift */; };
62D6CDEC255BFDA900ABD216 /* Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62D6CDEB255BFDA900ABD216 /* Date.swift */; };
Expand Down Expand Up @@ -72,6 +75,7 @@
620F6A4D250BBCE900B10032 /* UserDefaults.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserDefaults.swift; sourceTree = "<group>"; };
620F6A4F250BC1E400B10032 /* UIWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIWindow.swift; sourceTree = "<group>"; };
621B3C35255D467000A5E77F /* DJSwiftHelpers_Extension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DJSwiftHelpers_Extension.framework; sourceTree = BUILT_PRODUCTS_DIR; };
625380712594BCE900C58B2F /* CLLocationCoordinate2D.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CLLocationCoordinate2D.swift; sourceTree = "<group>"; };
627631A6255D512F005C09B1 /* DJSwiftHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DJSwiftHelpers.swift; sourceTree = "<group>"; };
62D6CDE8255BFCCB00ABD216 /* Decodable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Decodable.swift; sourceTree = "<group>"; };
62D6CDEB255BFDA900ABD216 /* Date.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Date.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -138,6 +142,7 @@
isa = PBXGroup;
children = (
620F6A32250BB78100B10032 /* Array.swift */,
625380712594BCE900C58B2F /* CLLocationCoordinate2D.swift */,
62D6CDEB255BFDA900ABD216 /* Date.swift */,
627631A6255D512F005C09B1 /* DJSwiftHelpers.swift */,
620F6A34250BB78200B10032 /* String.swift */,
Expand Down Expand Up @@ -320,6 +325,7 @@
620F6A3B250BB78200B10032 /* UIColor.swift in Sources */,
62D6CDEF255BFFA300ABD216 /* URLResponse.swift in Sources */,
62D6CDEC255BFDA900ABD216 /* Date.swift in Sources */,
625380722594BCE900C58B2F /* CLLocationCoordinate2D.swift in Sources */,
62D6CDF5255C01F400ABD216 /* UILabel.swift in Sources */,
62D6CDE9255BFCCB00ABD216 /* Decodable.swift in Sources */,
620F6A50250BC1E400B10032 /* UIWindow.swift in Sources */,
Expand All @@ -344,6 +350,7 @@
621B3C28255D467000A5E77F /* UIColor.swift in Sources */,
621B3C29255D467000A5E77F /* URLResponse.swift in Sources */,
621B3C2A255D467000A5E77F /* Date.swift in Sources */,
625380762594BDDD00C58B2F /* CLLocationCoordinate2D.swift in Sources */,
621B3C2B255D467000A5E77F /* UILabel.swift in Sources */,
621B3C2C255D467000A5E77F /* Decodable.swift in Sources */,
621B3C2D255D467000A5E77F /* UIWindow.swift in Sources */,
Expand All @@ -360,6 +367,7 @@
62DF507D256E9A8D00C88FF7 /* DJSwiftHelpers.swift in Sources */,
62DF50AD256E9AA800C88FF7 /* URLSession.swift in Sources */,
62DF5089256E9A9400C88FF7 /* UIColor.swift in Sources */,
6253807A2594BDDD00C58B2F /* CLLocationCoordinate2D.swift in Sources */,
62DF50B1256E9AAA00C88FF7 /* UserDefaults.swift in Sources */,
62DF5078256E9A8900C88FF7 /* Array.swift in Sources */,
62DF5081256E9A9000C88FF7 /* String.swift in Sources */,
Expand Down
19 changes: 19 additions & 0 deletions DJSwiftHelpers/Helpers/CLLocationCoordinate2D.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// CLLocationCoordinate2D.swift
// DJSwiftHelpers
//
// Created by Darren Jones on 24/12/2020.
// Copyright © 2020 Dappological Ltd. All rights reserved.
//

import Foundation
import CoreLocation

public
extension CLLocationCoordinate2D {

func locationIsInside(minLat:Double, maxLat:Double, minLong:Double, maxLong:Double) -> Bool {

return self.latitude >= minLat && self.latitude <= maxLat && self.longitude >= minLong && self.longitude <= maxLong
}
}
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ Example:
.uniques(by: \.surname)
```

### CLLocationCoordinate2D
Determine if a location is within a bounding rect

```swift
locationIsInside(minLat:Double, maxLat:Double, minLong:Double, maxLong:Double) -> Bool
```

### Date
Adds additional seconds or minutes to a `Date`

Expand Down

0 comments on commit b77744f

Please sign in to comment.