-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAPSIOS-1581: Geofence integration (#2319)
- Loading branch information
1 parent
e661d2a
commit 2cef5b1
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
Sources/MapboxMaps/Foundation/Extensions/Geofencing/Geofencing+Turf.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
@_spi(Experimental) @_spi(Internal) import MapboxCommon | ||
|
||
@_spi(Experimental) | ||
extension GeofenceState { | ||
/// Create `GeofenceState` | ||
@_spi(Experimental) | ||
public init(feature: Turf.Feature, timestamp: Date?) { | ||
self.init(_feature: MapboxCommon.Feature(feature), timestamp: timestamp) | ||
} | ||
|
||
/// The feature linked to this state | ||
@_spi(Experimental) | ||
public var feature: Turf.Feature { Turf.Feature(_feature) } | ||
} | ||
|
||
@_spi(Experimental) | ||
extension GeofencingEvent { | ||
/// Create `GeofenceEvent` | ||
@_spi(Experimental) | ||
public init(feature: Turf.Feature, timestamp: Date) { | ||
self.init(_feature: MapboxCommon.Feature(feature), timestamp: timestamp) | ||
} | ||
|
||
/// The feature linked to this event | ||
@_spi(Experimental) | ||
public var feature: Turf.Feature { Turf.Feature(_feature) } | ||
} | ||
|
||
@_spi(Experimental) | ||
extension GeofencingService { | ||
/// Adds a feature to be monitored for geofencing activities. | ||
/// You can add extra properties (see GeofencingPropertiesKeys) to the Feature to configure how geofencing engine behaves per each specific feature. | ||
/// If a feature with the same ID already exist it will be overwritten and its state reset | ||
@_spi(Experimental) | ||
public func addFeature(feature: Turf.Feature, callback: @escaping (Result<String, GeofencingError>) -> Void) { | ||
self.addFeature(feature: MapboxCommon.Feature(feature)) { result in | ||
callback(result) | ||
} | ||
} | ||
} |